How settle multiple invoices or credits with finalized invoices or credits at once?
← Billing & Invoice Management FAQ ← Accounting Support FAQ
You can offset non-related invoices and credits of an account via settlements. Usually, JustOn settles multiple open invoices or credits automatically with new draft invoices or credits when executing a batch finalization. Your business may, however, need to settle invoices or credits with open invoices or credits – which, by default, users do manually for individual invoices or credits.
So how to settle multiple invoices or credits with finalized invoices or credits at once?
To this end, you execute the following command in the Execute Anonymous Apex tool of the Developer Console, applying your particular search criteria in an SOQL WHERE clause.
List<ONB2__Invoice__c> invoices = [SELECT Id FROM ONB2__Invoice__c WHERE <invoice condition>];
Set<Id> invoiceIds = new Map<Id, ONB2__Invoice__c>(invoices).keySet();
new ONB2.ChainRunner()
.execute(
new ONB2.ChainFactory()
.getForBatchNames(new List<String>{'SettleInvoicesBatchHelper'})
.setParameters(
new Map<String, Object>{
'settleOpen' => true,
'invoiceIds' => invoiceIds
}
)
);
Example use cases and WHERE clauses
WHERE Clause | Use Case |
---|---|
WHERE ONB2__InvoiceRun__c = '<id>' |
Retrieves invoices of a particular invoice run (specified by its ID). |
WHERE ONB2__Date__c = '<date>' |
Retrieves invoices of a particular date. |
WHERE ONB2__Class__c = 'Credit' |
Retrieves all credits. |
Your use case may require different conditions. Make sure to adjust the WHERE clause according to your needs.