adamsaghy commented on code in PR #4743:
URL: https://github.com/apache/fineract/pull/4743#discussion_r2132269009
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/ProgressiveEMICalculator.java:
##########
@@ -861,6 +856,43 @@ public EmiAdjustment getEmiAdjustment(final
List<RepaymentPeriod> repaymentPerio
return new EmiAdjustment(repaymentPeriods.get(0).getEmi(),
repaymentPeriods.get(0).getEmi().copy(0.0), repaymentPeriods, 0);
}
+ private ProgressiveLoanInterestScheduleModel
calculateRateFactorForSchedule(ProgressiveLoanInterestScheduleModel
scheduleModel,
+ LocalDate targetDate) {
+ MathContext mc = scheduleModel.mc();
+ ProgressiveLoanInterestScheduleModel scheduleModelCopy =
scheduleModel.deepCopy(mc);
+ scheduleModelCopy.findRepaymentPeriod(targetDate).flatMap(rp ->
rp.findInterestPeriod(targetDate))
+ .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);
+ }));
+ return scheduleModelCopy;
+ }
+
+ private Money getInterestCarriedOverFromOtherPeriods(RepaymentPeriod
lastUnpaidRepaymentPeriod,
+ ProgressiveLoanInterestScheduleModel scheduleModelCopy) {
+ for (RepaymentPeriod period :
scheduleModelCopy.repaymentPeriods().reversed()) {
+ if (MathUtil.isGreaterThanZero(period.getUnrecognizedInterest())
+ &&
period.getDueDate().isAfter(lastUnpaidRepaymentPeriod.getDueDate()) &&
!period.isInterestCarriedOver()) {
+ return period.getUnrecognizedInterest();
+ }
+ }
+ return scheduleModelCopy.zero();
+ }
+
+ private void setInterestCarriedOver(ProgressiveLoanInterestScheduleModel
scheduleModel, RepaymentPeriod lastUnpaidRepaymentPeriod) {
Review Comment:
Do we need 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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]