Class : SalesInvoicePostService
Function : PostSalesInvoices
Input : List<Sales_Invoice__c>
Output : void
Please follow the below steps to post multiple invoices.
- Prepare the list collection ‘List<Sales_Invoice__c>’ to supply as an input for the above function. For this, you can execute a SOQL command to fetch all the sales invoices which should be posted or you can use the output of the function ‘CreateSalesinvoices’ as explained above in the document.
- Do not execute this inside batch processing, since this function will take care of the batch processing internally.
/* Post invoices */
List<Sales_Invoice__c> lstInvoices = [Select id from Sales_Invoice__c where Status__c = 'Draft' order by createddate desc limit 20];
SalesInvoicePostService objInvoiceHandler = new SalesInvoicePostService();