FINERACT-1971: Fix EMI Calculator: Last Unpaid Repayment Period Handling.
call calculateLastUnpaidRepaymentPeriodEMI recursively when emi would be less than already paid to adjust remaining emi correction for previous period. Fixing AdvancedPaymentScheduleTransactionProcessor to handle division by installment count adjustment part in case of IN_ADVANCED payment
This commit is contained in:
+4
-4
@@ -1689,16 +1689,16 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
|
||||
transactionMappings, loanTransaction, inAdvanceInstallment, currency);
|
||||
|
||||
Loan loan = loanTransaction.getLoan();
|
||||
// Adjust the portion for the last installment
|
||||
if (inAdvanceInstallment.equals(inAdvanceInstallments.get(numberOfInstallments - 1))) {
|
||||
evenPortion = evenPortion.add(balanceAdjustment);
|
||||
}
|
||||
if (transactionCtx instanceof ProgressiveTransactionCtx ctx && loan.isInterestBearing()
|
||||
&& loan.getLoanProductRelatedDetail().isInterestRecalculationEnabled() && !ctx.isChargedOff()) {
|
||||
paidPortion = handlingPaymentAllocationForInterestBearingProgressiveLoan(loanTransaction, evenPortion,
|
||||
balances, paymentAllocationType, inAdvanceInstallment, ctx,
|
||||
loanTransactionToRepaymentScheduleMapping, inAdvanceInstallmentCharges);
|
||||
} else {
|
||||
// Adjust the portion for the last installment
|
||||
if (inAdvanceInstallment.equals(inAdvanceInstallments.get(numberOfInstallments - 1))) {
|
||||
evenPortion = evenPortion.add(balanceAdjustment);
|
||||
}
|
||||
paidPortion = processPaymentAllocation(paymentAllocationType, inAdvanceInstallment, loanTransaction,
|
||||
evenPortion, loanTransactionToRepaymentScheduleMapping, inAdvanceInstallmentCharges, balances,
|
||||
LoanRepaymentScheduleInstallment.PaymentAction.PAY);
|
||||
|
||||
+2
-2
@@ -309,8 +309,8 @@ public final class ProgressiveEMICalculator implements EMICalculator {
|
||||
.reduce((first, second) -> second);
|
||||
findLastUnpaidRepaymentPeriod.ifPresent(repaymentPeriod -> {
|
||||
repaymentPeriod.setEmi(repaymentPeriod.getEmi().add(diff, mc));
|
||||
if (repaymentPeriod.getEmi().isLessThanZero()) {
|
||||
repaymentPeriod.setEmi(repaymentPeriod.getEmi().zero());
|
||||
if (repaymentPeriod.getEmi().isLessThan(repaymentPeriod.getTotalPaidAmount())) {
|
||||
repaymentPeriod.setEmi(repaymentPeriod.getTotalPaidAmount());
|
||||
calculateLastUnpaidRepaymentPeriodEMI(scheduleModel);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user