Reputation: 319
I want to create a monthly late fee invoice based on due date data from other invoices. For instance - late fee = £10 will be stored in a field based on due date calculation. So:
Company 1 - 5 invoices, 3 were paid late. Total fee invoice - £30 Company 2 - 3 invoices, 2 were paid late. Total fee invoice - £20 Company 3 - 7 invoices, 5 were paid late. Total fee invoice - £50
If I create a scheduled script that loops though all the invoices created in a month how would we say invoice company 1 £30, company 2 £20 and company 3 £50?
I need a way of grouping invoices that belong to a particular customer but as I am not passing any customer ID for example, how could I total up invoices for a particular customer?
Upvotes: 0
Views: 681
Reputation: 8847
You can build a Saved Search in the UI to group Invoices by Customer and sum the Totals or whatever field(s) you wish summarized. You can then invoke your Saved Search directly in your Scheduled Script, or export your Saved Search to raw SuiteScript using this handy Chrome Extension.
You shouldn't need to pass in any specific Customer ID; you'll just be doing a search of all relevant invoices and iterating over the Customer groups that result.
If you're not sure exactly how to group or sum in the UI, just leave a comment, and I will update my answer accordingly.
Upvotes: 2