FINERACT-2221: Add immediate charge accrual post maturity for progressive loans

This commit is contained in:
Oleksii Novikov
2025-04-23 10:58:23 +02:00
committed by Adam Saghy
parent 241906e042
commit 3687391148
5 changed files with 61 additions and 7 deletions
@@ -1114,16 +1114,20 @@ public class LoanChargeWritePlatformServiceImpl implements LoanChargeWritePlatfo
// we want to apply charge transactions only for those loans charges that are applied when a loan is active and
// the loan product uses Upfront Accruals, or only when the loan are closed too,
if ((loan.getStatus().isActive() && loan.isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct())
|| loan.getStatus().isOverpaid() || loan.getStatus().isClosedObligationsMet()
|| (configurationDomainService.isImmediateChargeAccrualPostMaturityEnabled()
&& DateUtils.getBusinessLocalDate().isAfter(loan.getMaturityDate()))) {
|| loan.getStatus().isOverpaid() || loan.getStatus().isClosedObligationsMet()) {
final LoanTransaction applyLoanChargeTransaction = loan.handleChargeAppliedTransaction(loanCharge, null);
if (applyLoanChargeTransaction != null) {
this.loanTransactionRepository.saveAndFlush(applyLoanChargeTransaction);
businessEventNotifierService
.notifyPostBusinessEvent(new LoanAccrualTransactionCreatedBusinessEvent(applyLoanChargeTransaction));
}
} else if (configurationDomainService.isImmediateChargeAccrualPostMaturityEnabled()
&& DateUtils.getBusinessLocalDate().isAfter(loan.getMaturityDate())) {
final LoanTransaction loanTransaction = loan.createChargeAppliedTransaction(loanCharge, null);
this.loanTransactionRepository.saveAndFlush(loanTransaction);
businessEventNotifierService.notifyPostBusinessEvent(new LoanAccrualTransactionCreatedBusinessEvent(loanTransaction));
}
return DateUtils.isBeforeBusinessDate(loanCharge.getDueLocalDate());
}