adamsaghy commented on code in PR #4743:
URL: https://github.com/apache/fineract/pull/4743#discussion_r2132265381


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/ProgressiveEMICalculator.java:
##########
@@ -332,24 +332,9 @@ public Money 
getOutstandingLoanBalanceOfPeriod(ProgressiveLoanInterestScheduleMo
 
     @Override
     public OutstandingDetails 
getOutstandingAmountsTillDate(ProgressiveLoanInterestScheduleModel 
scheduleModel, LocalDate targetDate) {
-        MathContext mc = scheduleModel.mc();
-        ProgressiveLoanInterestScheduleModel scheduleModelCopy = 
scheduleModel.deepCopy(mc);
-        // TODO use findInterestPeriod
-        scheduleModelCopy.repaymentPeriods().stream()//
-                .filter(rp -> targetDate.isAfter(rp.getFromDate()) && 
!targetDate.isAfter(rp.getDueDate())).findFirst()//
-                .flatMap(rp -> rp.getInterestPeriods().stream()//
-                        .filter(ip -> targetDate.isAfter(ip.getFromDate()) && 
!targetDate.isAfter(ip.getDueDate())) //
-                        .reduce((one, two) -> two))
-                .ifPresent(ip -> ip.setDueDate(targetDate)); //
-
-        calculateRateFactorForPeriods(scheduleModelCopy.repaymentPeriods(), 
scheduleModelCopy);
-        scheduleModelCopy.repaymentPeriods()
-                .forEach(rp -> rp.getInterestPeriods().stream().filter(ip -> 
targetDate.isBefore(ip.getDueDate())).forEach(ip -> {
-                    ip.setRateFactor(BigDecimal.ZERO);
-                    ip.setRateFactorTillPeriodDueDate(BigDecimal.ZERO);
-                }));
+        ProgressiveLoanInterestScheduleModel scheduleModelCopy = 
calculateRateFactorForSchedule(scheduleModel, targetDate);

Review Comment:
   This does not look correct! It is doing 3 things but 
`calculateRateFactorForSchedule` only explains or refer to the last one....



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