Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 916FB200B27 for ; Wed, 22 Jun 2016 13:37:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 90287160A35; Wed, 22 Jun 2016 11:37:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B0A1D160A2E for ; Wed, 22 Jun 2016 13:37:29 +0200 (CEST) Received: (qmail 33841 invoked by uid 500); 22 Jun 2016 11:37:28 -0000 Mailing-List: contact commits-help@fineract.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@fineract.incubator.apache.org Delivered-To: mailing list commits@fineract.incubator.apache.org Received: (qmail 33831 invoked by uid 99); 22 Jun 2016 11:37:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2016 11:37:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 7D664180290 for ; Wed, 22 Jun 2016 11:37:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id n9WpsaKZCWa0 for ; Wed, 22 Jun 2016 11:37:24 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id 8669B5F3FC for ; Wed, 22 Jun 2016 11:37:23 +0000 (UTC) Received: (qmail 33761 invoked by uid 99); 22 Jun 2016 11:37:22 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2016 11:37:22 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3FE2DDFF03; Wed, 22 Jun 2016 11:37:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nazeer1100126@apache.org To: commits@fineract.incubator.apache.org Date: Wed, 22 Jun 2016 11:37:22 -0000 Message-Id: <92ba4a406f444a8282b120a6c2f62068@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] incubator-fineract git commit: compounding issues fixed archived-at: Wed, 22 Jun 2016 11:37:30 -0000 Repository: incubator-fineract Updated Branches: refs/heads/develop b7ba92417 -> e338658a4 compounding issues fixed Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/4945040f Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/4945040f Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/4945040f Branch: refs/heads/develop Commit: 4945040fffd9e7d176ac1abef865fa382675d4b0 Parents: a89a43a Author: venkatconflux Authored: Mon Jun 20 14:45:39 2016 +0530 Committer: venkatconflux Committed: Mon Jun 20 14:45:39 2016 +0530 ---------------------------------------------------------------------- .../domain/AbstractLoanScheduleGenerator.java | 40 ++++++++++++++------ ...anWritePlatformServiceJpaRepositoryImpl.java | 2 +- 2 files changed, 30 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/4945040f/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 080689e..3581558 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 @@ -549,6 +549,12 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener .getPrincipal().minus(scheduleParams.getTotalCumulativePrincipal())); } + scheduleParams.getCompoundingDateVariations().put(periodStartDateApplicableForInterest, + new TreeMap<>(scheduleParams.getCompoundingMap())); + scheduleParams.getCompoundingMap().clear(); + populateCompoundingDatesInPeriod(periodStartDateApplicableForInterest, calculateTill, loanApplicationTerms, holidayDetailDTO, + scheduleParams, loanCharges, totalInterestChargedForFullLoanTerm.getCurrency()); + // 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(); @@ -577,7 +583,9 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener Money penaltyDiff = currentPeriodParams.getPenaltyChargesForInstallment().minus(tempPeriod.getPenaltyChargesForInstallment()); Money diff = interestDiff.plus(chargeDiff).plus(penaltyDiff); - if (!scheduleParams.getOutstandingBalance().minus(diff).isGreaterThanZero()) { + if (scheduleParams.getOutstandingBalance().minus(diff).isGreaterThanZero()) { + updateCompoundingDetails(scheduleParams, periodStartDateApplicableForInterest); + } else { scheduleParams.reduceOutstandingBalance(diff); currentPeriodParams.minusInterestForThisPeriod(interestDiff); currentPeriodParams.minusFeeChargesForInstallment(chargeDiff); @@ -593,7 +601,6 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener currentPeriodParams.fetchTotalAmountForPeriod(), false); scheduleParams.setTotalOutstandingInterestPaymentDueToGrace(interestTillDate.interestPaymentDueToGrace()); } - } return modifiedInstallment; } @@ -637,8 +644,9 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener private void updateCompoundingDetails(LoanScheduleParams scheduleParams, LocalDate periodStartDateApplicableForInterest) { if (scheduleParams.getCompoundingDateVariations().containsKey(periodStartDateApplicableForInterest)) { scheduleParams.getCompoundingMap().clear(); - scheduleParams.getCompoundingMap().putAll( - scheduleParams.getCompoundingDateVariations().get(periodStartDateApplicableForInterest)); + scheduleParams.getCompoundingMap() + .putAll(scheduleParams.getCompoundingDateVariations().get(periodStartDateApplicableForInterest)); + scheduleParams.getCompoundingDateVariations().remove(periodStartDateApplicableForInterest); } } @@ -821,7 +829,9 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener if (!scheduleParams.getOutstandingBalance().isGreaterThan(unprocessed) && !loanApplicationTerms.getPreClosureInterestCalculationStrategy() .calculateTillRestFrequencyEnabled()) { - + + scheduleParams.getCompoundingDateVariations().put(periodStartDateApplicableForInterest, + new TreeMap<>(scheduleParams.getCompoundingMap())); LocalDate calculateTill = transactionDate; PrincipalInterest principalInterestForThisPeriod = calculatePrincipalInterestComponentsForPeriod( this.paymentPeriodsInOneYearCalculator, @@ -1177,7 +1187,8 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener int periodNumberTemp = 1; LocalDate lastRestDate = getNextRestScheduleDate(currentDate.minusDays(1), loanApplicationTerms, holidayDetailDTO); Collection applicableVariations = loanApplicationTerms.getLoanTermVariations().getInterestRateChanges(); - + Money uncompoundedFromLastInstallment = params.getUnCompoundedAmount(); + LocalDate additionalPeriodsStartDate = params.getPeriodStartDate(); do { params.setActualRepaymentDate(this.scheduledDateGenerator.generateNextRepaymentDate(params.getActualRepaymentDate(), @@ -1220,9 +1231,10 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener updateCompoundingMap(loanApplicationTerms, holidayDetailDTO, params, lastRestDate, transactionDate); populateCompoundingDatesInPeriod(installment.periodDueDate(), params.getActualRepaymentDate(), loanApplicationTerms, holidayDetailDTO, params, loanCharges, currency); - params.setCompoundedInLastInstallment(params.getUnCompoundedAmount()); + uncompoundedFromLastInstallment = params.getUnCompoundedAmount(); params.setPeriodStartDate(transactionDate); startDate = transactionDate; + additionalPeriodsStartDate = startDate; } loanRepaymentScheduleTransactionProcessor.handleRepaymentSchedule(currentTransactions, currency, params.getInstallments()); updateLatePaidAmountsToPrincipalMap(detail.getTransaction(), loanApplicationTerms, currency, holidayDetailDTO, @@ -1256,6 +1268,10 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener compounded = compounded.plus(mapEntry.getValue()); } } + if (compounded.isGreaterThanZero() && startDate.isEqual(additionalPeriodsStartDate)) { + params.setCompoundedInLastInstallment(uncompoundedFromLastInstallment);// uncompounded in last installment + additionalPeriodsStartDate = additionalPeriodsStartDate.plusDays(1); + } Money compoundedForThisPeriod = compounded.minus(uncompounded); Money uncompoundedForThisPeriod = interest.minus(compoundedForThisPeriod); params.setUnCompoundedAmount(uncompoundedForThisPeriod); @@ -1506,7 +1522,11 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener final LocalDate restDate = getNextRestScheduleDate(scheduledDueDate.minusDays(1), loanApplicationTerms, holidayDetailDTO); if (!compoundingEffectiveDate.isAfter(loanRepaymentScheduleInstallment.getDueDate())) { - totalCompoundedAmount = totalCompoundedAmount.minus(params.getUnCompoundedAmount()); + Money amountCompoundedFromLastPeriod = params.getCompoundedInLastInstallment(); + if (amountCompoundedFromLastPeriod.isZero()) { + amountCompoundedFromLastPeriod = params.getUnCompoundedAmount(); + } + totalCompoundedAmount = totalCompoundedAmount.minus(amountCompoundedFromLastPeriod); periodHasCompoundingDate = true; } while (!compoundingEffectiveDate.isAfter(loanRepaymentScheduleInstallment.getDueDate())) { @@ -1544,13 +1564,11 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener for (Map.Entry mapEntry : params.getCompoundingMap().entrySet()) { if (!mapEntry.getKey().isAfter(loanRepaymentScheduleInstallment.getDueDate())) { updateMapWithAmount(params.getPrincipalPortionMap(), mapEntry.getValue().negated(), mapEntry.getKey()); - }else if(params.getUnCompoundedAmount().isEqualTo( mapEntry.getValue())){ - totalCompoundedAmount = totalCompoundedAmount.plus(params.getUnCompoundedAmount()); } } params.minusUnCompoundedAmount(params.getUnCompoundedAmount()); params.getCompoundingMap().clear(); - params.addUnCompoundedAmount(amountCharged.minus(totalCompoundedAmount.minus(params.getCompoundedInLastInstallment()))); + params.addUnCompoundedAmount(amountCharged.minus(totalCompoundedAmount)); } else { params.getCompoundingMap().clear(); params.getCompoundingDateVariations().put(loanRepaymentScheduleInstallment.getFromDate(), http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/4945040f/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 6e35e51..c56e230 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -1433,7 +1433,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf this.loanTransactionRepository.save(applyLoanChargeTransaction); } boolean isAppliedOnBackDate = false; - if (loanCharge.getDueLocalDate() == null || LocalDate.now().isAfter(loanCharge.getDueLocalDate())) { + if (loanCharge.getDueLocalDate() == null || DateUtils.getLocalDateOfTenant().isAfter(loanCharge.getDueLocalDate())) { isAppliedOnBackDate = true; } return isAppliedOnBackDate;