FINERACT-1968 Waive loan charges with advanced payment allocations

This commit is contained in:
Peter Bagrij
2023-11-30 10:38:52 +01:00
committed by Adam Saghy
parent 35171c0823
commit 9129fb89a3
4 changed files with 273 additions and 9 deletions
@@ -157,6 +157,7 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
handleRepayment(loanTransaction, currency, installments, charges);
case CHARGE_OFF -> handleChargeOff(loanTransaction, currency, installments);
case CHARGE_PAYMENT -> handleChargePayment(loanTransaction, currency, installments, charges);
case WAIVE_CHARGES -> log.debug("WAIVE_CHARGES transaction will not be processed.");
// TODO: Cover rest of the transaction types
default -> {
log.warn("Unhandled transaction processing for transaction type: {}", loanTransaction.getTypeOf());
@@ -224,7 +225,9 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
ChangedTransactionDetail changedTransactionDetail) {
if (loanTransaction.getId() == null) {
processLatestTransaction(loanTransaction, currency, installments, charges, Money.zero(currency));
loanTransaction.adjustInterestComponent(currency);
if (loanTransaction.isInterestWaiver()) {
loanTransaction.adjustInterestComponent(currency);
}
} else {
/*
* For existing transactions, check if the re-payment breakup (principal, interest, fees, penalties) has
@@ -235,7 +238,9 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
// Reset derived component of new loan transaction and
// re-process transaction
processLatestTransaction(newLoanTransaction, currency, installments, charges, Money.zero(currency));
newLoanTransaction.adjustInterestComponent(currency);
if (loanTransaction.isInterestWaiver()) {
newLoanTransaction.adjustInterestComponent(currency);
}
/*
* Check if the transaction amounts have changed. If so, reverse the original transaction and update
* changedTransactionDetail accordingly