This is an automated email from the ASF dual-hosted git repository. avikg pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push: new 2db6e6d FINERACT-1106-rework-skip-holiday-for-first-reschedule-date new 21bfd1f Merge pull request #1328 from fynmanoj/FINERACT-1106-rework 2db6e6d is described below commit 2db6e6d8b7863f1ff15ddbafba5d744e79797d32 Author: Manoj <ma...@fynarfin.io> AuthorDate: Mon Sep 14 00:09:58 2020 +0530 FINERACT-1106-rework-skip-holiday-for-first-reschedule-date --- .../domain/AbstractLoanScheduleGenerator.java | 31 +++++----------------- 1 file changed, 6 insertions(+), 25 deletions(-) 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 62f6158..4168dd4 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 @@ -29,15 +29,12 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; import java.util.TreeMap; -import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.service.DateUtils; -import org.apache.fineract.organisation.holiday.service.HolidayUtil; import org.apache.fineract.organisation.monetary.domain.ApplicationCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.organisation.workingdays.data.AdjustedDateDetailsDTO; import org.apache.fineract.organisation.workingdays.domain.RepaymentRescheduleType; -import org.apache.fineract.organisation.workingdays.service.WorkingDaysUtil; import org.apache.fineract.portfolio.calendar.domain.CalendarInstance; import org.apache.fineract.portfolio.calendar.service.CalendarUtils; import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; @@ -204,6 +201,12 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener previousRepaymentDate, scheduledDueDate, interestRatesForInstallments, this.paymentPeriodsInOneYearCalculator, mc); scheduledDueDate = termVariationParams.getScheduledDueDate(); + if (!loanApplicationTerms.isFirstRepaymentDateAllowedOnHoliday()) { + AdjustedDateDetailsDTO adjustedDateDetailsDTO1 = this.scheduledDateGenerator.adjustRepaymentDate(scheduledDueDate, + loanApplicationTerms, holidayDetailDTO); + scheduledDueDate = adjustedDateDetailsDTO1.getChangedScheduleDate(); + } + // Updates total days in term scheduleParams.addLoanTermInDays(Days.daysBetween(scheduleParams.getPeriodStartDate(), scheduledDueDate).getDays()); if (termVariationParams.isSkipPeriod()) { @@ -2362,10 +2365,6 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener periods.clear(); } LoanScheduleModel loanScheduleModel = generate(mc, loanApplicationTerms, loan.charges(), holidayDetailDTO, loanScheduleParams); - // check if first installment after reschedule is a holiday - if (!loanApplicationTerms.isFirstRepaymentDateAllowedOnHoliday()) { - checkIfFirstRepaymentDateisOnHolidayOrNonWorkingDay(holidayDetailDTO, loanScheduleModel); - } for (LoanScheduleModelPeriod loanScheduleModelPeriod : loanScheduleModel.getPeriods()) { if (loanScheduleModelPeriod.isRepaymentPeriod()) { @@ -2378,24 +2377,6 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener return LoanScheduleDTO.from(retainedInstallments, loanScheduleModelwithPeriodChanges); } - private void checkIfFirstRepaymentDateisOnHolidayOrNonWorkingDay(HolidayDetailDTO holidayDetailDTO, - LoanScheduleModel loanScheduleModel) { - - if (loanScheduleModel != null && loanScheduleModel.getPeriods() != null && loanScheduleModel.getPeriods().iterator() != null - && loanScheduleModel.getPeriods().iterator().next() != null - && loanScheduleModel.getPeriods().iterator().next().periodDueDate() != null) { - - if (WorkingDaysUtil.isNonWorkingDay(holidayDetailDTO.getWorkingDays(), - loanScheduleModel.getPeriods().iterator().next().periodDueDate()) - || HolidayUtil.getApplicableHoliday(loanScheduleModel.getPeriods().iterator().next().periodDueDate(), - holidayDetailDTO.getHolidays()) != null) { - throw new GeneralPlatformDomainRuleException("error.msg.first.installment.date.after.reschedule.should.be.a.working.day", - "As per configiration, the first repayment date after reschedule should be a working day"); - } - } - - } - public List<LoanRepaymentScheduleInstallment> fetchRetainedInstallments( final List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments, final LocalDate rescheduleFrom, MonetaryCurrency currency) {