Invoices
Xero provides a clean way of working with Xero invoices.
To work with invoices first call ->invocies() followed by a method.
Xero::invoices();
List Invoices
To list invoices call the invoices()->get() method.
Xero docs for listing invoices - https://developer.xero.com/documentation/api/invoices#get
The optional parameters are $page and $where. $page defaults to 1 which means being back on the first page, for additional pages enter higher page numbers until there are no pages left to return. The API does not offer a count to determine how many pages there are.
Xero::invoices()->get(int $page = 1, string $where = null);
$where allows for filter options to be passed, the most common filters have been optimised to ensure performance across organisations of all sizes. We recommend you restrict your filtering to the following optimised parameters.
Filter by status:
Xero::contacts()->get(1, 'Status="AUTHORISED"');
Filter by contact id:
Xero::contacts()->get(1, 'Contact.ContactID=guid("96988e67-ecf9-466d-bfbf-0afa1725a649")')
Filter by contact number
Xero::contacts()->get(1, 'Contact.ContactNumber="ID001"')
Filter by reference
Xero::contacts()->get(1, 'Reference="INV-0001"')
Filter by date
Xero::contacts()->get(1, 'Date=DateTime(2020, 01, 01)')
Filter by type
Xero::contacts()->get(1, 'Type="ACCREC"')
View Invoice
To view a single invoice a find method can be called passing in the invoice id
Xero::invoices()->find(string $invoiceId);
View Online Invoice
For invoices created that have a status of either Submitted, Authorised, or Paid an online invoice can be seen by calling onlineUrl passing in the invoiceId
Xero::invoices()->onlineUrl($invoiceId);
Create Invoice
To create a invoice call a store method passing in an array of invoice data:
See https://developer.xero.com/documentation/api/invoices#post for the array contents specifications
Xero::invoices()->store($data);
Update Invoice
To update an invoice 2 params are required the invoice Id and an array of data to be updated:
See https://developer.xero.com/documentation/api/invoices#post for details on the fields that can be updated.
Xero::invoices()->update($invoiceId, $data);