# Xero Accounting Sync

Invoices, contacts and payments flow to Xero automatically - and payments flow back.

Once connected, TowConnect keeps your books in step with **Xero** without double entry: sending an invoice creates it in Xero, marking it paid records the payment there, and a payment recorded in Xero marks the invoice paid here. Syncing runs in the background about every **5 minutes**.

## Connecting

1. Go to **Settings → Connect → Xero** and click **Connect Xero**
2. Sign in to Xero and choose the organisation to link
3. Back on the card, set your two account codes (below) and **Save**

## The two account codes

- **Sales account code** - the revenue account invoice lines post to, from your Xero chart of accounts (Xero → Accounting → Chart of accounts). Xero's default Sales account is `200`.
- **Payment account code** - the account payments are recorded against, usually your bank account (Xero default `090`). It must have **Enable payments** ticked in Xero.

## What syncs, and when

- **Send an invoice** → the client is created/updated as a Xero contact (business clients carry their ABN and payment terms; walk-in jobs use the job contact) and the invoice is created as **Awaiting Payment**, GST set from your tax settings, with any PO / order reference.
- **Mark an invoice paid** → the payment is recorded on the Xero invoice against your payment account.
- **Record a payment in Xero** → once the invoice is fully paid there, it flips to paid in TowConnect automatically and the admin bell tells you.

Every invoice shows a sync chip: **Xero pending** (queued, next background run picks it up), **Xero ✓** (synced), or **Xero failed** with a **Retry** button.

> The sync never emails or texts your clients - it only moves accounting records. Client-facing email happens only when *you* send an invoice.

> Partial payments in Xero are reflected only once the invoice is **fully paid** there. Invoices already sent before you connected are not back-filled - only invoices sent while connected sync across.

## If a sync fails

- The invoice shows a **Xero failed** chip - the most common causes are a wrong account code or an archived Xero contact
- Fix the cause (e.g. correct the code on **Settings → Connect → Xero**), then hit **Retry** on the invoice
- After repeated failures, admins get a notification - the sync keeps retrying with backoff in the meantime
- If the card shows **Needs reconnect**, one click re-authorises - nothing else to fix

## Disconnecting

**Settings → Connect → Xero → Disconnect** stops new syncing and revokes TowConnect's access with Xero. Already-synced invoices stay in Xero untouched, and your sync history is kept.
