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.
Filtering by Job Cost Centre Name on Invoice or Job Query
Forum rules
- Check the documentation first. Before posting questions, please check the documentation to ensure it doesn't already cover what you need.
- No spam. All automated messages, advertisements, and links to competitor websites will be deleted immediately.
- Post in relevant sub-forums only. Messages posted in the wrong topic area will be removed and placed in the correct sub-forum by moderators.
- Respect other users. No flaming or abusing fellow forum members. Users who continue to post inflammatory, abusive comments will be deleted from the forum after two warnings are issued by moderators.
- Harassment. No threats or harassment of other users will be tolerated. Any instance of threatening or harassing behavior is grounds for deletion from the forums.
- Adult content. No profanity or pornography is allowed. Posts containing adult material will be deleted.
- Bandwidth. All images and signatures must be 500 x 500 pixels or smaller. Posts containing over-sized images and signatures will be removed.
- Illegal content. No re-posting of copyrighted materials or other illegal content is allowed. Any posts containing illegal content or copyrighted materials will be deleted.
-
SimproAPITeam
- Posts: 831
- Joined: Wed May 01, 2024 2:31 am
Re: Filtering by Job Cost Centre Name on Invoice or Job Query
Hi devappau,
We don't support searching for names in this instance but you should be able to search on cost center id's.
If you are looking for jobs related to specific invoiced cost centers you can query the jobs endpoint like this with the list of cost center id's
If you want to retrieve jobs related to a specific cost centre type use the id to retrieve them like this:
I hope this can improve your workflow.
Regards
We don't support searching for names in this instance but you should be able to search on cost center id's.
If you are looking for jobs related to specific invoiced cost centers you can query the jobs endpoint like this with the list of cost center id's
Code: Select all
/jobs/?Sections.CostCenters.ID=in(6347,10277)If you want to retrieve jobs related to a specific cost centre type use the id to retrieve them like this:
Code: Select all
/jobs/?Sections.CostCenters.CostCenter=35Regards
Simpro API Team | Simpro Software Group
DEVELOPER CENTER