=== Demfilz Sync for Xero ===
Contributors: demfilz
Tags: woocommerce, xero, accounting, invoices, inventory
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.2
Stable tag: 1.2.0
Requires Plugins: woocommerce
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send WooCommerce orders, customers and stock to Xero via the official Xero Accounting API. Free manual sync; Pro adds automation.

== Description ==

Demfilz Sync for Xero connects your WooCommerce store to your Xero organisation so you stop re-keying sales. It posts orders as Xero invoices (or quotes), matches or creates the contact, and can read stock-on-hand back from Xero.

**Free features**

* One-click OAuth 2.0 connection to your Xero organisation
* Push a WooCommerce order to Xero as an invoice or quote with a button on the order screen
* Create or match the contact in Xero automatically
* Map a default income account and GST tax rates
* Pull current stock-on-hand from Xero for a product (button on the product screen)
* Sync log of every attempt

**Pro features (A$19.95/month)**

* Automatic order sync when an order reaches a chosen status
* Bulk / historical order backfill
* Scheduled inventory sync across all products
* Refunds / credit notes to Xero
* Per-product / per-tax-class tax mapping
* Auto-retry of failed syncs with email alerts
* Multiple stores / organisations
* Supplier purchases: when the Demfilz Auto Order plugin emails a supplier a purchase order, post a matching bill (at cost) to Xero

Pro is delivered as a separate add-on plugin after subscribing at https://demfilz.com/woo-to-xero

== External services ==

This plugin connects to external services. It sends data only when you explicitly connect and sync.

1. **Xero API** (https://login.xero.com, https://identity.xero.com and https://api.xero.com)
   * Purpose: authenticate (OAuth 2.0) and read/write your accounting data.
   * Data sent: your store's order details (customer name, billing address, email, phone, line items, totals, tax), product SKUs, and your Xero developer-app credentials/tokens.
   * When: when you connect, push an order, or pull stock.
   * Terms: https://www.xero.com/au/legal/terms — Privacy: https://www.xero.com/au/legal/privacy

== Installation ==

1. Install and activate the plugin (WooCommerce must be active).
2. Go to **WooCommerce → Xero Sync**.
3. Create a "Web app" in the Xero developer portal and paste the Client ID and Client Secret, adding the redirect URI shown on the Connection tab.
4. Click **Save & Connect to Xero**, approve access, then choose your organisation.
5. Set your default income account and tax rates on the Mapping tab.
6. Open any order and click **Sync to Xero**.

== Frequently Asked Questions ==

= Does it post orders as invoices or quotes? =
Either. Choose how to post orders on the Mapping tab, and pick the invoice status (Draft, Submitted or Authorised).

= Is the free version time-limited? =
No. Manual order, contact and stock sync are free forever. Pro adds automation and scale.

= Where is my data stored? =
OAuth tokens are stored encrypted in your WordPress database. Order data is only sent to Xero when you sync.

== Screenshots ==

1. The Connection tab — connect to your Xero organisation with OAuth 2.0 and pick the organisation.
2. Mapping — post orders as an invoice or quote and pick your income account and GST tax rates.
3. The Xero Sync box on an order, with the one-click Sync to Xero button.
4. The sync log of every push.

== Changelog ==

= 1.2.0 =
* Compliance: the free plugin no longer contains any premium or licensing code. All Pro gating, licence handling and supplier-bill sync now live entirely in the separate Pro add-on.
* The free plugin exposes small, generic Xero API helpers (get/post) that the Pro add-on builds on; no Pro-only endpoints ship in the free plugin.
* No functional change for free users.

= 1.1.0 =
* Pro: post a Xero bill (at cost) when the Demfilz Auto Order plugin emails a supplier purchase order.
* Added Xero supplier, bill (ACCPAY) and expense-account API support (used by Pro).
* Fix: "Save & Connect to Xero" now correctly redirects to the Xero consent screen.
* Pro subscriptions are now validated through the Demfilz billing service, and "Get Pro" links to live checkout.

= 1.0.0 =
* Initial release: OAuth 2.0 connection, manual order push (invoice or quote), contact sync, manual stock pull, mapping, logs, Pro licence framework.
