From 72a1fff6454b76514da45efb9f0ce7fc1e5d22e1 Mon Sep 17 00:00:00 2001 From: pramod Date: Wed, 11 May 2016 11:39:15 +0530 Subject: [PATCH] MIFOSX-2565 : fixed prepay with floating rates --- .../domain/AbstractLoanScheduleGenerator.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java index d06b3f1b0..474b852af 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java @@ -547,12 +547,24 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener updateFixedInstallmentAmount(mc, loanApplicationTerms, scheduleParams.getPeriodNumber(), loanApplicationTerms .getPrincipal().minus(scheduleParams.getTotalCumulativePrincipal())); } + + // this is to make sure we are recalculating using correct interest rate + // once calculation is done system will set the actual interest rate + BigDecimal currentInterestRate = loanApplicationTerms.getAnnualNominalInterestRate(); + for(LoanTermVariationsData interestRate : interestRates){ + if(interestRate.isApplicable(periodStartDateApplicableForInterest)){ + loanApplicationTerms.updateAnnualNominalInterestRate(interestRate.getDecimalValue()); + } + } + PrincipalInterest interestTillDate = calculatePrincipalInterestComponentsForPeriod(this.paymentPeriodsInOneYearCalculator, interestCalculationGraceOnRepaymentPeriodFraction, scheduleParams.getTotalCumulativePrincipal(), scheduleParams.getTotalCumulativeInterest(), totalInterestChargedForFullLoanTerm, lastTotalOutstandingInterestPaymentDueToGrace, scheduleParams.getOutstandingBalanceAsPerRest(), loanApplicationTerms, scheduleParams.getPeriodNumber(), mc, mergeVariationsToMap(scheduleParams), scheduleParams.getCompoundingMap(), periodStartDateApplicableForInterest, calculateTill, interestRates); + loanApplicationTerms.updateAnnualNominalInterestRate(currentInterestRate); + // applies charges for the period final ScheduleCurrentPeriodParams tempPeriod = new ScheduleCurrentPeriodParams( totalInterestChargedForFullLoanTerm.getCurrency(), interestCalculationGraceOnRepaymentPeriodFraction);