=== CatCode Accounting Sync with Xero for WooCommerce ===
Contributors: catcodestudio
Tags: xero, accounting, invoices, vat, gst
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sends WooCommerce orders to Xero as sales invoices, with contacts, VAT and GST mapping, automatic retries and no duplicates.

== Description ==

Every order in your shop has to end up in your accounts. This plugin sends it to Xero when the order reaches a status you choose, and keeps trying when the connection is down.

Xero is a third-party product. This is an independent integration, not affiliated with or endorsed by Xero.

= What it does =

* Creates a sales invoice in Xero for each order, with products, shipping and fees, approved or as a draft.
* Finds or creates the contact: by customer reference (Contact Code in Xero), then by e-mail address. Company name, tax number, billing address and phone come along. A second customer with the same name gets the e-mail address added to the name, because Xero keeps contact names unique.
* VAT and GST: a WooCommerce rate goes to the Xero tax rate of the same percentage when Xero has exactly one, or to the one you choose. Where Xero has several (the zero rates, for example), the order stops with a message instead of landing in the wrong box of your return.
* Lines go to Xero tax inclusive, with the tax WooCommerce charged, so the total in Xero is the total of the order. A total that does not match stops the order with both amounts.
* Revenue accounts for products, shipping and fees, read from your chart of accounts.
* Invoice number: the next number in Xero with the order reference in Reference, or the order reference as the invoice number.
* Works through a queue. Network and server errors are retried automatically for up to about two days. When Xero says the limit of calls is reached, the queue waits by itself. Problems that need your attention stop with a clear message on the order and in the queue.
* No duplicates. A document exists once per reference in the queue, every creating request carries an idempotency key, and before creating anything the plugin looks the order reference up in Xero, so a lost answer or a second status change does not create a second invoice.
* A box on the order with a link to the invoice in Xero, a bulk action on the orders list, and "Send again" in the queue.
* Works with High-Performance Order Storage and classic order storage.
* English.

== Installation ==

1. Install and activate the plugin. WooCommerce has to be active.
2. In WooCommerce > Accounting Sync, copy the redirect URI shown on the Connection tab.
3. At developer.xero.com open My Apps and click "New app". Choose "Web app", enter your shop address as the company URL and the copied address as the redirect URI. Open Configuration, copy the client ID and generate a client secret.
4. Back in the shop, enter the client ID and the client secret, save, then click "Connect to Xero" and choose your organisation.
5. Open the Mapping tab: choose the revenue accounts and check the tax rates.

A Custom Connection (a paid Xero subscription for one organisation) works too: choose it on the Connection tab and enter its client ID and secret.

== Frequently Asked Questions ==

= Why my own Xero app? =

A Xero app you create yourself is free to use with your own organisation, and your data goes straight from your shop to Xero, through no server of ours. An uncertified Xero app allows 1000 calls a day per organisation; an order takes three to five, a payment two.

= What happens to orders that existed before I installed the plugin? =

Nothing, until you send them: select them in the orders list and choose "Send to the bookkeeping".

= Which address is on the invoice? =

Xero prints the postal address of the contact. The plugin fills it in when it creates the contact; a later change of address in the shop does not change the contact in Xero.

= Does the plugin change prices or the checkout? =

No. It adds nothing to the shop front.

= Is this tax advice? =

No. You stay responsible for your bookkeeping and your VAT or GST return. Check the mapping with your accountant.

= An order stopped with a tax message. What now? =

Choose the tax rate on the Mapping tab and click "Send again". The invoice is created once.

= The connection ended. =

Xero ends a connection that was not used for 60 days, or that was disconnected in Xero. The plugin refreshes it once a week by itself; if it ends anyway, click "Connect to Xero" again. Orders wait in the queue and "Send all stopped documents again" sends them.

== External services ==

This plugin connects to Xero to create contacts and sales invoices in your own Xero organisation. It only does so after you add the client ID and the client secret of your Xero app and connect.

* login.xero.com: you sign in there and choose the organisation when you click "Connect to Xero".
* identity.xero.com: the plugin gets and refreshes its access tokens there, and revokes them when you disconnect. It sends the client ID, the client secret and the token.
* api.xero.com: when an order reaches a status you chose, or when you send it by hand, these data go to Xero: the customer's name, company, address, e-mail address, phone number and tax number, and the order's reference, date, lines, amounts, tax and the link to the order in your shop's admin. The settings screens also read your organisation's name, tax rates and chart of accounts.

Xero [terms of use](https://www.xero.com/legal/terms/) and [privacy notice](https://www.xero.com/legal/privacy/).

== Changelog ==

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.0.0 =
First release.
