Skip to content

Commit

Permalink
FINERACT-2148: Add 'Accelerate maturity' charge-off behaviour option.…
Browse files Browse the repository at this point in the history
… Fix loan balance
  • Loading branch information
leksinomi committed Dec 20, 2024
1 parent c5dde93 commit d249b1b
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1206,12 +1206,10 @@ private void handleAccelerateMaturityChargeOff(LoanTransaction loanTransaction,
Loan loan = loanTransaction.getLoan();
LoanRepaymentScheduleInstallment currentInstallment = loan.getRelatedRepaymentScheduleInstallment(transactionDate);

if (!installments.isEmpty()) {
if (!installments.isEmpty() && transactionDate.isBefore(loan.getMaturityDate())) {
if (loan.isInterestRecalculationEnabled()) {
final BigDecimal newInterest = emiCalculator.getPeriodInterestTillDate(progressiveTransactionCtx.getModel(),
currentInstallment.getDueDate(), transactionDate).getAmount();
final BigDecimal interestRemoved = currentInstallment.getInterestCharged().subtract(newInterest);
currentInstallment.updatePrincipal(MathUtil.nullToZero(currentInstallment.getPrincipal()).add(interestRemoved));
currentInstallment.updateInterestCharged(newInterest);
} else {
final BigDecimal totalInterest = currentInstallment.getInterestOutstanding(progressiveTransactionCtx.getCurrency())
Expand All @@ -1223,8 +1221,6 @@ private void handleAccelerateMaturityChargeOff(LoanTransaction loanTransaction,
.divide(BigDecimal.valueOf(totalDaysInPeriod), MoneyHelper.getMathContext())
.multiply(BigDecimal.valueOf(daysTillChargeOff));

final BigDecimal interestRemoved = totalInterest.subtract(interestTillChargeOff);
currentInstallment.updatePrincipal(MathUtil.nullToZero(currentInstallment.getPrincipal()).add(interestRemoved));
currentInstallment.updateInterestCharged(interestTillChargeOff);
}

Expand Down

0 comments on commit d249b1b

Please sign in to comment.