Repository: fineract Updated Branches: refs/heads/1.0.0 582ef5de6 -> 0d7cf3a28
FINERACT-158 FINERACT-166 Fix Project: http://git-wip-us.apache.org/repos/asf/fineract/repo Commit: http://git-wip-us.apache.org/repos/asf/fineract/commit/0d7cf3a2 Tree: http://git-wip-us.apache.org/repos/asf/fineract/tree/0d7cf3a2 Diff: http://git-wip-us.apache.org/repos/asf/fineract/diff/0d7cf3a2 Branch: refs/heads/1.0.0 Commit: 0d7cf3a2847215401dec6770269078b51efba283 Parents: 582ef5d Author: Nazeer Hussain Shaik <[email protected]> Authored: Thu May 18 11:21:41 2017 +0530 Committer: Nazeer Hussain Shaik <[email protected]> Committed: Thu May 18 11:21:41 2017 +0530 ---------------------------------------------------------------------- .../portfolio/loanaccount/domain/Loan.java | 5 ++++- .../domain/AbstractLoanScheduleGenerator.java | 21 +++++++++++++++++--- .../service/LoanReadPlatformServiceImpl.java | 4 ++-- 3 files changed, 24 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/fineract/blob/0d7cf3a2/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java index 0c3d05d..73d8edf 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java @@ -3196,7 +3196,7 @@ public class Loan extends AbstractPersistableCustom<Long> { boolean isAllChargesPaid = true; for (final LoanCharge loanCharge : this.charges) { - if (loanCharge.isActive() && !(loanCharge.isPaid() || loanCharge.isWaived())) { + if (loanCharge.isActive() && loanCharge.amount().compareTo(BigDecimal.ZERO) == 1 && !(loanCharge.isPaid() || loanCharge.isWaived())) { isAllChargesPaid = false; break; } @@ -4744,6 +4744,9 @@ public class Loan extends AbstractPersistableCustom<Long> { if (loanCharge.isInstalmentFee()) { List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ; for (final LoanRepaymentScheduleInstallment installment : installments) { + if(installment.isRecalculatedInterestComponent()){ + continue; + } BigDecimal amount = BigDecimal.ZERO; if (loanCharge.getChargeCalculation().isFlat()) { amount = loanCharge.amountOrPercentage(); http://git-wip-us.apache.org/repos/asf/fineract/blob/0d7cf3a2/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java ---------------------------------------------------------------------- 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 bf4a64b..cb42bf5 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 @@ -210,10 +210,15 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener // this block is to generate the schedule till the specified // date(used for calculating preclosure) + boolean isCompletePeriod = true; if (scheduleParams.getScheduleTillDate() != null && !scheduledDueDate.isBefore(scheduleParams.getScheduleTillDate())) { + if(!scheduledDueDate.isEqual(scheduleParams.getScheduleTillDate())){ + isCompletePeriod = false; + } scheduledDueDate = scheduleParams.getScheduleTillDate(); isNextRepaymentAvailable = false; } + if (loanApplicationTerms.isInterestRecalculationEnabled()) { populateCompoundingDatesInPeriod(scheduleParams.getPeriodStartDate(), scheduledDueDate, loanApplicationTerms, holidayDetailDTO, scheduleParams, loanCharges, currency); @@ -313,7 +318,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener scheduleParams.getPeriodStartDate(), scheduledDueDate, currentPeriodParams.getPrincipalForThisPeriod(), scheduleParams.getOutstandingBalance(), currentPeriodParams.getInterestForThisPeriod(), currentPeriodParams.getFeeChargesForInstallment(), currentPeriodParams.getPenaltyChargesForInstallment(), - totalInstallmentDue, false); + totalInstallmentDue, !isCompletePeriod); addLoanRepaymentScheduleInstallment(scheduleParams.getInstallments(), installment); // apply loan transactions on installments to identify early/late @@ -530,8 +535,18 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener LocalDate periodStartDateApplicableForInterest, final double interestCalculationGraceOnRepaymentPeriodFraction, final ScheduleCurrentPeriodParams currentPeriodParams, final Money lastTotalOutstandingInterestPaymentDueToGrace, final LocalDate transactionDate, final LoanScheduleModelPeriod installment, Set<LoanCharge> loanCharges) { - LoanScheduleModelPeriod modifiedInstallment = installment; - if (!scheduleParams.getOutstandingBalance().isGreaterThan(currentPeriodParams.getInterestForThisPeriod()) + LoanScheduleModelPeriod modifiedInstallment = installment; + Money oustanding = scheduleParams.getOutstandingBalance(); + PrincipalInterest tempPrincipalInterest = new PrincipalInterest(currentPeriodParams.getPrincipalForThisPeriod(), + currentPeriodParams.getInterestForThisPeriod(), null); + oustanding = oustanding.minus(cumulativeFeeChargesDueWithin(transactionDate, + scheduledDueDate, loanCharges, totalInterestChargedForFullLoanTerm.getCurrency(), tempPrincipalInterest, scheduleParams.getPrincipalToBeScheduled(), + scheduleParams.getTotalCumulativeInterest(), true)); + oustanding = oustanding.minus(cumulativePenaltyChargesDueWithin(transactionDate, + scheduledDueDate, loanCharges, totalInterestChargedForFullLoanTerm.getCurrency(), tempPrincipalInterest, scheduleParams.getPrincipalToBeScheduled(), + scheduleParams.getTotalCumulativeInterest(), true)); + + if (!oustanding.isGreaterThan(currentPeriodParams.getInterestForThisPeriod()) && !scheduledDueDate.equals(transactionDate)) { final Collection<LoanTermVariationsData> interestRates = loanApplicationTerms.getLoanTermVariations().getInterestRateChanges(); LocalDate calculateTill = transactionDate; http://git-wip-us.apache.org/repos/asf/fineract/blob/0d7cf3a2/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index ab70722..6912f3c 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -436,7 +436,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { private BigDecimal adjustPrepayInstallmentCharge(Loan loan, final LocalDate onDate) { BigDecimal chargeAmount = BigDecimal.ZERO; - for(LoanCharge loanCharge: loan.charges()){ + /*for(LoanCharge loanCharge: loan.charges()){ if(loanCharge.isInstalmentFee() && loanCharge.getCharge().getChargeCalculation()==ChargeCalculationType.FLAT.getValue()){ for (LoanRepaymentScheduleInstallment installment : loan.getRepaymentScheduleInstallments()) { if(onDate.isBefore(installment.getDueDate())){ @@ -449,7 +449,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { } } } - } + }*/ return chargeAmount; }
