Loop Through Date Range to Create Quickbooks Invoices


I’m looking for ideas on how to accomplish the following:
1. I have a Salesforce custom object called “Reservation”. The Reservation object is related to the Lead object. The Reservation object has a Date field and Rate field. A Lead record will have many (typically 60-120) Reservation records, for example May 15, 2024 - July 10th, 2024. 

  1. I want to use Zapier to create a Quickbooks invoice for each month in the range of reservation records. Each invoice month would have a line item for each date of reservation record. In the above example, an invoice for May would be created with a line item from May 15th - May 31st. Then a new invoice would be created for June for the entire month. The last invoice would be created for July but line items would only be for July 1st - July 9th. 

Currently, my Zap can get all reservation records from the lead, create an invoice in quickbooks with line item pricing for every date retrieved from the reservation records. 

Any guidance on how I could achieve the above outcome? Some ideas I had were loop function and potentially needing to use Javascript code to work with the dates. 

2 replies

Userlevel 7
Badge +11

Hi @falconpartners, welcome to the Community! 😁

I’m not sure you’d need to use Looping by Zapier for this as the Create Invoice action supports line items. If you use a Code action to process the dates and generate a list of the relevant reservations for that specific month (output as line items) then you those could be supplied to the Create Invoice action without the need for any loops. 

I can’t provide the necessary code but we a handy AI feature available that can help to generate the code for you. You can learn more about this here: Generate a Code step using AI (Beta)

Hope that helps to get you pointed in the right direction. If I’ve misunderstood or you run into any trouble on that do let us know!

Userlevel 3
Badge +3

Hi @falconpartners Yes I think adding a code block in the middle would get it work for sure. You can be pretty specific as how you want to group the line items, and then sending that back to QBO.