kjozsa commented on code in PR #4297:
URL: https://github.com/apache/fineract/pull/4297#discussion_r1939197294


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/ProgressiveEMICalculator.java:
##########
@@ -441,34 +550,32 @@ private BigDecimal calculateRateFactorPerPeriod(final 
ProgressiveLoanInterestSch
         final PeriodFrequencyType repaymentFrequency = 
loanProductRelatedDetail.getRepaymentPeriodFrequencyType();
         final BigDecimal repaymentEvery = 
BigDecimal.valueOf(loanProductRelatedDetail.getRepayEvery());
 
-        final BigDecimal daysInMonth = 
BigDecimal.valueOf(daysInMonthType.getNumberOfDays(interestPeriodFromDate));
         final BigDecimal daysInYear = 
BigDecimal.valueOf(daysInYearType.getNumberOfDays(interestPeriodFromDate));
         final BigDecimal actualDaysInPeriod = BigDecimal
                 .valueOf(DateUtils.getDifferenceInDays(interestPeriodFromDate, 
interestPeriodDueDate));
         final BigDecimal calculatedDaysInPeriod = BigDecimal
                 
.valueOf(DateUtils.getDifferenceInDays(repaymentPeriod.getFromDate(), 
repaymentPeriod.getDueDate()));
         final int numberOfYearsDifferenceInPeriod = 
interestPeriodDueDate.getYear() - interestPeriodFromDate.getYear();
         final boolean partialPeriodCalculationNeeded = daysInYearType == 
DaysInYearType.ACTUAL && numberOfYearsDifferenceInPeriod > 0;
-
-        long addedDays = !isTillDate || scheduleModel.loanTermVariations() == 
null ? 0L
-                : 
scheduleModel.loanTermVariations().getDueDateVariation().stream()
-                        .filter(x -> 
!repaymentPeriod.getFromDate().isAfter(x.getTermVariationApplicableFrom())
-                                && 
!repaymentPeriod.getDueDate().isBefore(x.getTermVariationApplicableFrom())
-                                && 
!repaymentPeriod.getDueDate().isAfter(x.getDateValue()))
-                        .map(x -> 
DateUtils.getDifferenceInDays(x.getTermVariationApplicableFrom(), 
x.getDateValue()))
-                        .reduce(0L, Long::sum);
+        final BigDecimal daysInMonth = daysInMonthType.isDaysInMonth_30() ? 
BigDecimal.valueOf(30) : calculatedDaysInPeriod;
 
         // TODO check: 
loanApplicationTerms.calculatePeriodsBetweenDates(startDate, endDate); // 
calculate period data
         // TODO review: (repayment frequency: days, weeks, years; validation 
day is month fix 30)
         // TODO refactor this logic to represent in interest period
         if (partialPeriodCalculationNeeded) {
             final BigDecimal cumulatedPeriodFractions = 
calculatePeriodFractions(interestPeriodFromDate, interestPeriodDueDate, mc);
-            return rateFactorByRepaymentPartialPeriod(interestRate, 
repaymentEvery, cumulatedPeriodFractions, BigDecimal.ONE,
+            return rateFactorByRepaymentPartialPeriod(interestRate, 
BigDecimal.ONE, cumulatedPeriodFractions, BigDecimal.ONE,
                     BigDecimal.ONE, mc);
         }
 
-        return 
calculateRateFactorPerPeriodBasedOnRepaymentFrequency(interestRate, 
repaymentFrequency, repaymentEvery, daysInMonth,
-                daysInYear, actualDaysInPeriod, 
calculatedDaysInPeriod.subtract(BigDecimal.valueOf(addedDays), mc), mc);
+        if (daysInMonthType == DaysInMonthType.ACTUAL) {

Review Comment:
   switch?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to