FINERACT-2124: Fix final income accrual calculation with multiple fee charges

This commit is contained in:
mariiaKraievska
2025-08-05 13:46:22 +02:00
committed by Adam Saghy
parent 68f20c29e9
commit 0daf42ec33
6 changed files with 328 additions and 3 deletions
@@ -620,7 +620,15 @@ public class LoanAccrualsProcessingServiceImpl implements LoanAccrualsProcessing
final Money unrecognizedWaived = MathUtil
.toMoney(loanTransactionRepository.findChargeUnrecognizedWaivedAmount(loanCharge, tillDate), currency);
final Money transactionWaived = MathUtil.minusToZero(waived, unrecognizedWaived);
final Money transactionAccrued = MathUtil.toMoney(loanTransactionRepository.findChargeAccrualAmount(loanCharge), currency);
// For installment fees, use installment-specific accrual amount
final Money transactionAccrued;
if (installmentFee && installmentChargeId != null) {
transactionAccrued = MathUtil.toMoney(
loanTransactionRepository.findChargeAccrualAmountByInstallment(loanCharge, dueInstallment.getInstallmentNumber()),
currency);
} else {
transactionAccrued = MathUtil.toMoney(loanTransactionRepository.findChargeAccrualAmount(loanCharge), currency);
}
chargeData.setTransactionAccrued(transactionAccrued);
chargeData.setChargeAccrued(MathUtil.minusToZero(transactionAccrued, transactionWaived));