FINERACT-2389: Reprocess Interest Refund txn amount if no txn was changed

This commit is contained in:
Jose Alberto Hernandez
2026-01-13 10:05:19 +01:00
committed by Adam Saghy
parent 0026aaf1a6
commit 6df78f64c0
4 changed files with 76 additions and 24 deletions
@@ -568,12 +568,10 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
.filter(LoanTransaction::isNotReversed).map(AbstractPersistableCustom::getId).toList();
final List<LoanTransaction> modifiedTransactions = new ArrayList<>(progCtx.getAlreadyProcessedTransactions().stream()
.filter(LoanTransaction::isNotReversed).filter(tr -> tr.getId() == null).toList());
if (!modifiedTransactions.isEmpty()) {
final Money interestAfterRefund = interestRefundService.totalInterestByTransactions(this, loan.getId(), targetDate,
modifiedTransactions, unmodifiedTransactionIds);
final Money newAmount = interestBeforeRefund.minus(progCtx.getSumOfInterestRefundAmount()).minus(interestAfterRefund);
loanTransaction.updateAmount(newAmount.getAmount());
}
final Money interestAfterRefund = interestRefundService.totalInterestByTransactions(this, loan.getId(), targetDate,
modifiedTransactions, unmodifiedTransactionIds);
final Money newAmount = interestBeforeRefund.minus(progCtx.getSumOfInterestRefundAmount()).minus(interestAfterRefund);
loanTransaction.updateAmount(newAmount.getAmount());
progCtx.setSumOfInterestRefundAmount(progCtx.getSumOfInterestRefundAmount().add(loanTransaction.getAmount()));
}
}