FINERACT-1106-rework-skip-holiday-for-first-reschedule-date
This commit is contained in:
+6
-25
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user