You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2020/08/13 21:18:36 UTC

[GitHub] [fineract] avikganguly01 commented on a change in pull request #1220: FINERACT-1109 appropriate-interest-larger-than-emi

avikganguly01 commented on a change in pull request #1220:
URL: https://github.com/apache/fineract/pull/1220#discussion_r470247807



##########
File path: fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java
##########
@@ -252,6 +252,16 @@ public boolean isSkippingMeetingOnFirstDayOfMonthEnabled() {
         return getGlobalConfigurationPropertyData("skip-repayment-on-first-day-of-month").isEnabled();
     }
 
+    @Override
+    public boolean isFirstRepaymentDateAfterRescheduleAllowedOnHoliday() {
+        return getGlobalConfigurationPropertyData("loan-reschedule-is-first-payday-allowed-on-holiday").isEnabled();
+    }

Review comment:
       This should have been part of PR FIN-1106.

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java
##########
@@ -279,7 +282,8 @@ private LoanScheduleModel generate(final MathContext mc, final LoanApplicationTe
 
             // will check for EMI amount greater than interest calculated
             if (loanApplicationTerms.getFixedEmiAmount() != null
-                    && loanApplicationTerms.getFixedEmiAmount().compareTo(principalInterestForThisPeriod.interest().getAmount()) < 0) {
+                    && loanApplicationTerms.getFixedEmiAmount().compareTo(principalInterestForThisPeriod.interest().getAmount()) < 0
+                    && !loanApplicationTerms.isInterestToBeAppropriatedEquallyWhenGreaterThanEMIEnabled()) {

Review comment:
       Is tranche loan approval failing due to flag?

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java
##########
@@ -125,7 +125,30 @@ public PrincipalInterest calculatePrincipalInterestComponentsForPeriod(final Pay
                 interestCalculationGraceOnRepaymentPeriodFraction, periodNumber, mc, cumulatingInterestDueToGrace,
                 balanceForInterestCalculation, interestStartDate, periodEndDate);
 
-        interestForThisInstallment = interestForThisInstallment.plus(result.interest());
+        if (loanApplicationTerms.isInterestToBeAppropriatedEquallyWhenGreaterThanEMIEnabled() && !result.interest().isZero()
+                && !interestForThisInstallment.isZero()) {
+            loanApplicationTerms.setInterestTobeApproppriated(result.interest());
+        } else {
+            interestForThisInstallment = interestForThisInstallment.plus(result.interest());
+        }
+
+        if (loanApplicationTerms.getFixedEmiAmount() != null
+                && loanApplicationTerms.isInterestToBeAppropriatedEquallyWhenGreaterThanEMIEnabled() && interestForThisInstallment
+                        .isGreaterThan(Money.of(interestForThisInstallment.getCurrency(), loanApplicationTerms.getFixedEmiAmount()))) {
+            LocalDate actualPeriodEndDate = this.scheduledDateGenerator.generateNextRepaymentDate(interestStartDate, loanApplicationTerms,
+                    false);
+            // AdjustedDateDetailsDTO adjustedDateDetailsDTO = this.scheduledDateGenerator
+            // .adjustRepaymentDate(actualPeriodEndDate, loanApplicationTerms,
+            // loanApplicationTerms.getHolidayDetailDTO());
+
+            PrincipalInterest tempInterest = loanApplicationTerms.calculateTotalInterestForPeriod(calculator,
+                    interestCalculationGraceOnRepaymentPeriodFraction, periodNumber, mc, cumulatingInterestDueToGrace,
+                    balanceForInterestCalculation, interestStartDate, actualPeriodEndDate);
+
+            loanApplicationTerms.setInterestTobeApproppriated(interestForThisInstallment.minus(tempInterest.interest()));
+            interestForThisInstallment = tempInterest.interest();
+        }

Review comment:
       LGTM

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelRepaymentPeriod.java
##########
@@ -154,7 +154,7 @@ public boolean isRecalculatedInterestComponent() {
     @Override
     public void addInterestAmount(Money interestDue) {
         this.interestDue = this.interestDue.plus(interestDue);
-        this.totalDue = this.totalDue.plus(principalDue);
+        this.totalDue = this.totalDue.plus(interestDue);

Review comment:
       Looks like a different bug got squashed here. What effects could this bug have been producing? Shall we create a different ticket to track this?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org