# Quickbooks

IXO Commerce sends [Sales Orders](https://bookstack.iconography.co.uk/books/sales-orders "Sales Orders"), payments and refunds to QuickBooks. Two schedulers handle this: the update scheduler and the update payments scheduler.

## How it works

### Sales Orders

1. A Sales Order can be edited freely in IXO Commerce until it is [Completed](https://bookstack.iconography.co.uk/books/sales-orders/page/order-status "Order Status").
2. Once the order has been [despatched](https://bookstack.iconography.co.uk/books/packing/page/packing-and-despatching-a-sales-order-packing-screen "Packing and Despatching a Sales Order"), it is sent to QuickBooks as an invoice. Cancelled and returned lines are left off.
3. Payments on the order are then sent to QuickBooks and recorded against the invoice.

### Changes after completion

Once a Sales Order is [Completed](https://bookstack.iconography.co.uk/books/sales-orders/page/order-status "Order Status"), its invoice in QuickBooks is not changed. Any [discount](https://bookstack.iconography.co.uk/books/sales-orders/page/apply-discounts "Apply Discounts") or [return](https://bookstack.iconography.co.uk/books/returns-aka-rmas "Returns (aka RMAs)") added after this point is raised in QuickBooks as a credit note, with the refund payment recorded against that credit note.

#### Example 1: full return

A customer buys a Women's Hat for £40. The order is despatched and Completed, so a £40 invoice and a £40 payment are sent to QuickBooks. A week later the hat is returned and refunded. The original invoice stays at £40, and a £40 credit note is created in QuickBooks with a £40 refund payment against it.

#### Example 2: partial refund with mixed VAT

A customer buys two items in one order, paying £55 by card:

<table border="1" id="bkmrk-item-nominal-code-va" style="border-collapse: collapse; width: 100%;"><thead><tr><td>Item</td><td>Nominal Code</td><td>VAT Rate</td><td>Net</td><td>VAT</td><td>Gross</td></tr></thead><tbody><tr><td>Women's Hat - Red</td><td>nom123</td><td>Standard (20%)</td><td>£33.33</td><td>£6.67</td><td>£40.00</td></tr><tr><td>Children's Gloves - Blue</td><td>nom456</td><td>Zero rated</td><td>£15.00</td><td>£0.00</td><td>£15.00</td></tr><tr><td>**Total**</td><td> </td><td> </td><td>**£48.33**</td><td>**£6.67**</td><td>**£55.00**</td></tr></tbody></table>

The order is despatched and Completed, so a £55 invoice with these two lines and a £55 payment are sent to QuickBooks.

The customer then returns the gloves, and is given a £5 discount on the hat because of a mark on the brim. £20 is refunded to their card. The original £55 invoice is not changed. Instead, a £20 credit note is created in QuickBooks, with each line keeping the VAT Rate and Nominal Code of the line it came from:

<table border="1" id="bkmrk-credit-note-line-nom" style="border-collapse: collapse; width: 100%;"><thead><tr><td>Credit note line</td><td>Nominal Code</td><td>VAT Rate</td><td>Net</td><td>VAT</td><td>Gross</td></tr></thead><tbody><tr><td>Children's Gloves - Blue (return)</td><td>nom456</td><td>Zero rated</td><td>£15.00</td><td>£0.00</td><td>£15.00</td></tr><tr><td>Women's Hat - Red (discount)</td><td>nom123</td><td>Standard (20%)</td><td>£4.17</td><td>£0.83</td><td>£5.00</td></tr><tr><td>**Total**</td><td> </td><td> </td><td>**£19.17**</td><td>**£0.83**</td><td>**£20.00**</td></tr></tbody></table>

A £20 refund payment is recorded against the credit note. In QuickBooks, net sales for the order are £29.16 (£48.33 less £19.17), with £5.84 of VAT due (£6.67 less £0.83).

### Account payments

A sale paid [on account](https://bookstack.iconography.co.uk/books/general/page/pay-on-account "Pay on Account") is sent to QuickBooks as an invoice with no payment against it. This leaves a balance outstanding on the [Customer](https://bookstack.iconography.co.uk/books/customers "Customers")'s account in QuickBooks.

<p class="callout warning">When the Customer pays off their account balance in IXO Commerce, that payment is not sent to QuickBooks. It must also be recorded manually against the invoice in QuickBooks.</p>

<p class="callout info">[Account payments](https://bookstack.iconography.co.uk/books/payment-reports/page/account-payments "Account Payments") and account refunds are never sent by the integration. Only non-account payments and refunds are passed to QuickBooks.</p>

## Product Catalogue

No product catalogue is maintained in QuickBooks.

QuickBooks takes nominal codes from its own product listings, so IXO Commerce can't send them directly. Instead, if a [Nominal Code](https://bookstack.iconography.co.uk/books/categories/page/inventory "Inventory") is set against a [Variant](https://bookstack.iconography.co.uk/books/categories/page/variants "Variants") in IXO Commerce, it is sent to QuickBooks as the SKU code. If a Product with that SKU exists in QuickBooks, the line is matched to it. If not, a new Product is created in QuickBooks.

<p class="callout info">The Client should set up a Product in QuickBooks for each Nominal Code used in IXO Commerce.</p>

#### Example

<table border="1" id="bkmrk-field-value-sku-code" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 50%;"></col><col style="width: 50%;"></col></colgroup><thead><tr><td>Field</td><td>Value</td></tr></thead><tbody><tr><td>SKU Code</td><td>*nom123*

</td></tr><tr><td>Product Name</td><td>*nom123 - General Sales*

</td></tr><tr><td>VAT Rate</td><td>*Standard*

</td></tr></tbody></table>

When an item is sold, it is sent with its own description, e.g. 'Women's Hat - Red', against the relevant Nominal Code. This allows sales to be reported by nominal code in QuickBooks.

<p class="callout warning">QuickBooks will not hold product level sales data. Product level sales reports must be run in IXO Commerce, e.g. [Sold Items](https://bookstack.iconography.co.uk/books/sales-reports/page/sold-items "Sold Items").</p>

## Update scheduler

Calls the following functions, in this order.

### getItems

Gets the [default cost price](https://bookstack.iconography.co.uk/books/general/page/cost-prices "Cost Prices") of all items in QuickBooks.

### sendOrdersToQuickbooks

- Gets all Sales Orders from IXO that haven't already been [acknowledged](https://bookstack.iconography.co.uk/books/integrations/page/sales-order-acknowledged "Sales Order 'Acknowledged'"), including only orders that have been despatched.
- Creates the [Customer](https://bookstack.iconography.co.uk/books/customers "Customers") as a contact in QuickBooks if they don't already exist.
- Makes sure all sold Products exist in QuickBooks, and adds any that don't.
- Leaves out cancelled and returned lines.
- Posts the invoice to QuickBooks.

## Update payments scheduler

Calls the following functions, in this order.

### sendOrderPaymentsToQuickbooks

- Gets a list of invoices awaiting payment from QuickBooks.
- Matches [unacknowledged](https://bookstack.iconography.co.uk/books/integrations/page/sales-order-acknowledged "Sales Order 'Acknowledged'") non-account payments in IXO to each invoice by Sales Order ID.
- Creates each payment in QuickBooks individually, as long as it fits within the amount outstanding on the invoice.

### sendOrderRefundPaymentsToQuickbooks

- Gets all [unacknowledged](https://bookstack.iconography.co.uk/books/integrations/page/sales-order-acknowledged "Sales Order 'Acknowledged'") non-account refund payments on IXO orders whose QuickBooks invoice is paid.
- Creates a credit note in QuickBooks and adds the refund payment to it.