Credit Notes
Xero provides a clean way of working with Xero credit notes.
To work with credit notes, first call ->creditNotes() followed by a method.
Xero::creditNotes();
To list credit notes, call the creditNotes()->get() method.
Xero docs for listing credid notes - https://developer.xero.com/documentation/api/accounting/creditnotes
Filtering Credit Notes
You can filter credit notes using the filter
method:
The filter can be chained to the get method, or you can use the filter method directly.
$query = Xero::creditNotes();
if ($searchTerm) {
$query->filter('searchTerm', $searchTerm);
}
if ($status) {
$query->filter('where', 'Status=="'.$status.'"');
}
$query->filter('order', 'Date DESC')
->get();
View credit note
To view a single credit note, a find method can be called passing in the id
Xero::creditNotes()->find(string $id);
Create Credit Note
To create a credit note, call a store method passing in an array of data:
See https://developer.xero.com/documentation/api/accounting/creditnotes/#post-creditnotes for the array contents specifications
Xero::creditNotes()->store($data);
Update Credit Note
To update a credit note, 2 params are required the Id and an array of data to be updated:
See https://developer.xero.com/documentation/api/accounting/creditnotes/#put-creditnotes for details on the fields that can be updated.
Xero::creditNotes()->update($invoiceId, $data);