I'm trying to filter invoices and bills by Tracking Option in the Xero API to show costs to a project where the project is set in a Tracking Category/Option on the Bill or Invoice.
This value appears in the returned object:
["tracking"]=>
array(1) {
[0]=>
object(XeroAPI\XeroPHP\Models\Accounting\LineItemTracking)#18755 (1) {
["container":protected]=>
array(4) {
["tracking_category_id"]=>
string(36) "8a29ae32-c0f1-43b4-a4aa-09293ad182be"
["tracking_option_id"]=>
NULL
["name"]=>
string(7) "Project"
["option"]=>
string(4) "2455"
}
}
}
I've tried to use LineItems
LineItemTracking
and many other guesses in the Where:
$where = "Type=="ACCPAY"&&tracking_category_option=="' . $projectNo . '";
But I can't get anything to work.
Does anyone know how to achieve filtering on the tracking categories or options or can think of a workaround?
When you make a GET invoices call you will always receive a summary response. You would need to use pagination or a status filter to get a detailed response which includes the tracking option details.
As far as I am aware it is not possible to filter by tracking option in the API as the tracking option is inside a tracking table inside a line item table inside the invoice, but someone else in this forum may have a suggestion. Otherwise you would need to get all the invoices and filter the results outside of the API.