# Xero

The scheduler calls the following functions, in this order:

**getItems**  
Gets default cost price of all items in Xero

**getOrdersForXero**  
Get all orders from IXO that haven't been acknowledged already, excluding draft, abandoned, cancelled or quotes.  
Creates the customer as a contact in Xero if it doesn't already exist.  
Ensures all sold products exist in Xero. Adds them if not.  
Posts an invoice to Xero as "draft" status

**getReturnsForXero**  
Gets all returned items that haven't been acknowledged already.  
Ensure the customer exists in Xero. Adds one if not.  
Creates Credit Note in Xero as "draft" status

**getPurchaseOrdersForXero**  
Gets all submitted purchase orders that haven't been acknowledged.  
Ensures supplier exists as a contact. Adds one if not.  
Ensures all products exist as items in Xero.  
Creates a Purchase Order in Xero.

<p class="callout info">Purchase Order lines will inherit the IXO Commerce Nominal Code as the Xero Account Code</p>

**getUnpaidInvoices**  
Gets a list of unpaid invoices from Xero.  
Compares payments in IXO against the Sales Order ID.  
Creates a payment in Xero if one exists.

**getUnpaidCreditNotes**  
Gets a list of unpaid credit notes from Xero.  
Compares refunds in IXO against the Sales Order ID.  
Creates a payment in Xero if one exists.

### Configs

All Sales Order invoices can either be created as draft invoices, or as authorised.

There is a config that will change this. If created as draft invoices, they can be automatically updates to 'authorised' once all non cancelled lines on a Sales Order are marked as completed.