Merge pull request #1328 from fynmanoj/FINERACT-1106-rework
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.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException;
|
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
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.ApplicationCurrency;
|
||||||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
||||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||||
import org.apache.fineract.organisation.workingdays.data.AdjustedDateDetailsDTO;
|
import org.apache.fineract.organisation.workingdays.data.AdjustedDateDetailsDTO;
|
||||||
import org.apache.fineract.organisation.workingdays.domain.RepaymentRescheduleType;
|
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.domain.CalendarInstance;
|
||||||
import org.apache.fineract.portfolio.calendar.service.CalendarUtils;
|
import org.apache.fineract.portfolio.calendar.service.CalendarUtils;
|
||||||
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
|
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
|
||||||
@@ -204,6 +201,12 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
|
|||||||
previousRepaymentDate, scheduledDueDate, interestRatesForInstallments, this.paymentPeriodsInOneYearCalculator, mc);
|
previousRepaymentDate, scheduledDueDate, interestRatesForInstallments, this.paymentPeriodsInOneYearCalculator, mc);
|
||||||
|
|
||||||
scheduledDueDate = termVariationParams.getScheduledDueDate();
|
scheduledDueDate = termVariationParams.getScheduledDueDate();
|
||||||
|
if (!loanApplicationTerms.isFirstRepaymentDateAllowedOnHoliday()) {
|
||||||
|
AdjustedDateDetailsDTO adjustedDateDetailsDTO1 = this.scheduledDateGenerator.adjustRepaymentDate(scheduledDueDate,
|
||||||
|
loanApplicationTerms, holidayDetailDTO);
|
||||||
|
scheduledDueDate = adjustedDateDetailsDTO1.getChangedScheduleDate();
|
||||||
|
}
|
||||||
|
|
||||||
// Updates total days in term
|
// Updates total days in term
|
||||||
scheduleParams.addLoanTermInDays(Days.daysBetween(scheduleParams.getPeriodStartDate(), scheduledDueDate).getDays());
|
scheduleParams.addLoanTermInDays(Days.daysBetween(scheduleParams.getPeriodStartDate(), scheduledDueDate).getDays());
|
||||||
if (termVariationParams.isSkipPeriod()) {
|
if (termVariationParams.isSkipPeriod()) {
|
||||||
@@ -2383,10 +2386,6 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
|
|||||||
periods.clear();
|
periods.clear();
|
||||||
}
|
}
|
||||||
LoanScheduleModel loanScheduleModel = generate(mc, loanApplicationTerms, loan.charges(), holidayDetailDTO, loanScheduleParams);
|
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()) {
|
for (LoanScheduleModelPeriod loanScheduleModelPeriod : loanScheduleModel.getPeriods()) {
|
||||||
if (loanScheduleModelPeriod.isRepaymentPeriod()) {
|
if (loanScheduleModelPeriod.isRepaymentPeriod()) {
|
||||||
@@ -2399,24 +2398,6 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
|
|||||||
return LoanScheduleDTO.from(retainedInstallments, loanScheduleModelwithPeriodChanges);
|
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(
|
public List<LoanRepaymentScheduleInstallment> fetchRetainedInstallments(
|
||||||
final List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments, final LocalDate rescheduleFrom,
|
final List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments, final LocalDate rescheduleFrom,
|
||||||
MonetaryCurrency currency) {
|
MonetaryCurrency currency) {
|
||||||
|
|||||||
Reference in New Issue
Block a user