Search code examples
phpapiquickbooksinvoice

Check customer has new invoices


I am trying to find a flag to determine whether a QuickBooks Customer has new invoices. I am syncing the invoices, and next time when I try to sync I want to check whether there are any new Invoices OR updated once.

There is a syncToken in Customer record but it only shows the updates for the Customer object.

Is there a way to check for the updated Invoices OR New onces, other than syncing all?


Solution

  • I figure it out after @Naveen's Answer.

    Basically the syncToken is good to use when we deal with single record at a time. We can keep syncToken in our database and check it against QuickBooks next time.

    But when it comes to bulk record fetching its good to use LastUpdatedTime.

    To filter invoices what I did was query QuickBooks as below,

    $InvoiceService = new QuickBooks_IPP_Service_Invoice();
    $invoices = $InvoiceService->query($Context, $realm, "SELECT * FROM Invoice where MetaData.LastUpdatedTime > <date>";  
    

    Note: <date> should be in long date format. Ex: 2004-02-12T15:19:21+00:00. We can get this date format by date('c', mySql date);

    Cheers..!!! Thanks again @Naveen for your tip