FINERACT-2421: added e2e test for verifying reprocess Interest Refund txn amount if no txn was changed
This commit is contained in:
committed by
Adam Saghy
parent
6df78f64c0
commit
3e197e367b
+10
-4
@@ -568,16 +568,22 @@ 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());
|
||||
final Money interestAfterRefund = interestRefundService.totalInterestByTransactions(this, loan.getId(), targetDate,
|
||||
modifiedTransactions, unmodifiedTransactionIds);
|
||||
final Money newAmount = interestBeforeRefund.minus(progCtx.getSumOfInterestRefundAmount()).minus(interestAfterRefund);
|
||||
loanTransaction.updateAmount(newAmount.getAmount());
|
||||
if (validateInterestRefundTransactionRelation(loanTransaction)) {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
handleRepayment(loanTransaction, ctx);
|
||||
}
|
||||
|
||||
private boolean validateInterestRefundTransactionRelation(final LoanTransaction interestRefundTransaction) {
|
||||
return interestRefundTransaction.getLoanTransactionRelations(tr -> tr.getToTransaction().getId() != null).isEmpty();
|
||||
}
|
||||
|
||||
private boolean chargeOffIsInEffect(TransactionCtx ctx, LoanTransaction chargeOffTransaction, LoanTransaction loanTransaction) {
|
||||
if (ctx instanceof ProgressiveTransactionCtx progressiveCtx && progressiveCtx.isChargedOff()) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user