Filtering by Job Cost Centre Name on Invoice or Job Query
Posted: Tue Nov 25, 2025 11:27 am
We have working code which downloads all jobs and invoices between a certain issue date. If invoices run first, then they are piped into the Jobs request as a comma separated list to download the same jobs only. This query is working.
I'm trying to filter either the Invoice or Job query to download on the SimPro Cost Center Name, but the API says there is no filtering on subquery fields. As a result, we are downloading all of the records in the time period and then filtering with the results. It would be much quicker to be able to filter on the job cost center name directly on the Jobs or Invoices query.
$request->query()->merge([
'Jobs.ID' => "in($idsCsv)",
'columns' => 'ID,CustomFields,InternalID,Type,Customer,RecurringInvoice,DateIssued,Period,PaymentTermID,PaymentTerms,ProgressClaimNumber,IsFinalClaim,Stage,PerItem,OrderNo,LatePaymentFee,CISDeductionRate,AccountingCategory,Status,AutoAdjustStatus,Description,Notes,Total,Retainage,RetainageRebate,IsPaid,DatePaid,Currency,DateCreated,DateModified,CostCenters',
'display' => 'all',
]);
$items = Simpro::paginate($request)
->setPerPageLimit($this->max_page_size)
->collect()->all(); // gather all pages for this job
Is there a way to filter on the Invoices or Jobs object by Cost Center Name so we can only get the records required, instead of downloading everything in the time period and then filtering.
I'm trying to filter either the Invoice or Job query to download on the SimPro Cost Center Name, but the API says there is no filtering on subquery fields. As a result, we are downloading all of the records in the time period and then filtering with the results. It would be much quicker to be able to filter on the job cost center name directly on the Jobs or Invoices query.
$request->query()->merge([
'Jobs.ID' => "in($idsCsv)",
'columns' => 'ID,CustomFields,InternalID,Type,Customer,RecurringInvoice,DateIssued,Period,PaymentTermID,PaymentTerms,ProgressClaimNumber,IsFinalClaim,Stage,PerItem,OrderNo,LatePaymentFee,CISDeductionRate,AccountingCategory,Status,AutoAdjustStatus,Description,Notes,Total,Retainage,RetainageRebate,IsPaid,DatePaid,Currency,DateCreated,DateModified,CostCenters',
'display' => 'all',
]);
$items = Simpro::paginate($request)
->setPerPageLimit($this->max_page_size)
->collect()->all(); // gather all pages for this job
Is there a way to filter on the Invoices or Jobs object by Cost Center Name so we can only get the records required, instead of downloading everything in the time period and then filtering.