ChangeInstallmentsChain
The ChangeInstallmentsChain is called when users manually create or modify installments on invoices.
Batch Chain Name | Batch Chain Alias | Apex Classes |
---|---|---|
ChangeInstallmentsChain | CHANGEINSTALLMENTS | BatchCancelEntriesHelper CreateInstallmentsBatchHelper BatchCreateEntriesHelper BatchSettleChangedInstallmentsHelper GetPaymentLinksBatchHelper |
The batch chain involves Apex classes for batch helpers. The helper classes include additional logic to determine which batches are actually required. Most of them include optimization logic, which skips batches that are not needed under the given conditions.
Chain Item | Generated Batch | Description | Notes |
---|---|---|---|
BatchCancelEntriesHelper | BatchCancelEntries | Cancel existing entry records related to the invoice | The behavior differs depending on the use case. When called for changing installments, the entries related fo the invoice are canceled. When called from the FinalizeInvoiceChain to finalize a cancelation invoice, the the entries related to the canceled invoice are canceled. |
CreateInstallmentsBatchHelper | BatchCreateInstallments | Creates installments | The behavior differs depending on the use case. When called for changing installments, existing installments are deleted and new installments are created. When called from the FinalizeInvoiceChain or the InvoiceRunChain, new installments are created only if there are no existing installments. Any existing installments are kept. |
BatchCreateEntriesHelper | BatchCreateEntriesHelper | Creates entries for JustOn Cash Management integration | |
BatchSettleChangedInstallmentsHelper | BatchSettleChangedInstallments | Calls the settlement API of JustOn Cash Management, resulting in the assignment of the same payments that were used for the canceled entries. | |
GetPaymentLinksBatchHelper | BatchGetEntryPaymentLinks | Updates payment page links for all related entries | |
BatchGetInvoicePaymentLinks | Updates payment page link for an installment invoice |
The ChangeInstallmentsChain will not update invoice PDF files.
Depending on whether JustOn Billing & Invoice Management integrates with JustOn Cash Management or not, the execution scope differs:
When using JustOn Billing & Invoice Management with JustOn Cash Management integration, changing installments involves multiple steps:
-
Cancels the related entry records applying the cancellation reason
Changed Installment Plan
.Any defined credit balance strategy for the business entity will be ignored in this case.
-
Deletes existing and creates new installment records (
ONB2__Payment__c
records of the typeInstallment
) - Creates new entry records for the new installments
- Settles the new entry records using the payments that were used to settle the canceled entry records
- Updates the payment page links for the new installments and the InvoiceEmailQueueChain
Example: Modifying installments with existing payments in JustOn Cash Management
Assume there is an invoice with a grand total of 1200 and 4 installments. After collecting two payments of 300 each, there are the following records:
Installment | Amount | Entry | Payment | Entry Item | Assigned Amount | Payment Balance |
---|---|---|---|---|---|---|
I1 | 300 | E1 | P1 | P1, E1 | -300 | -300 |
I2 | 300 | E2 | P2 | P2, E2 | -300 | -300 |
I3 | E3 | |||||
I4 | E4 |
Changing the payment plan to 6 installments will result in:
Installment | Amount | Entry | Payment | Entry Item | Assigned Amount | Payment Balance |
---|---|---|---|---|---|---|
I5 | 200 | E5 | P1 | P1, E5 | -200 | -200 |
I6 | 200 | E6 | P1 | P1, E6 | -100 | -100 |
P2 | P2, E6 | -100 | -100 | |||
I7 | 200 | E7 | P2 | P2, E7 | -200 | -200 |
I8 | E8 | |||||
I9 | E9 | |||||
I10 | E10 |
When using JustOn Billing & Invoice Management without the JustOn Cash Management integration, only the chain item CreateInstallmentsBatchHelper is executed. With an existing installment configuration, the batch class BatchCreateInstallments, consequently, deletes any existing and creates new installment records (ONB2__Payment__c
records of the type Installment
).