MIFOSX-1358,MIFOSX-1357
This commit is contained in:
+13
-1
@@ -7,7 +7,19 @@ import org.mifosplatform.organisation.holiday.domain.Holiday;
|
||||
|
||||
public class HolidayUtil {
|
||||
|
||||
public static LocalDate getRepaymentRescheduleDateToIfHoliday(final LocalDate repaymentDate, final List<Holiday> holidays) {
|
||||
public static LocalDate getRepaymentRescheduleDateToIfHoliday(LocalDate repaymentDate, final List<Holiday> holidays) {
|
||||
|
||||
for (final Holiday holiday : holidays) {
|
||||
if (repaymentDate.equals(holiday.getFromDateLocalDate()) || repaymentDate.equals(holiday.getToDateLocalDate())
|
||||
|| (repaymentDate.isAfter(holiday.getFromDateLocalDate()) && repaymentDate.isBefore(holiday.getToDateLocalDate()))) {
|
||||
repaymentDate = getRepaymentRescheduleDateIfHoliday(repaymentDate, holidays);
|
||||
}
|
||||
}
|
||||
return repaymentDate;
|
||||
}
|
||||
|
||||
private static LocalDate getRepaymentRescheduleDateIfHoliday(final LocalDate repaymentDate, final List<Holiday> holidays) {
|
||||
|
||||
for (final Holiday holiday : holidays) {
|
||||
if (repaymentDate.equals(holiday.getFromDateLocalDate()) || repaymentDate.equals(holiday.getToDateLocalDate())
|
||||
|| (repaymentDate.isAfter(holiday.getFromDateLocalDate()) && repaymentDate.isBefore(holiday.getToDateLocalDate()))) {
|
||||
|
||||
+4
@@ -40,4 +40,8 @@ public class WorkingDaysUtil {
|
||||
public static boolean isWorkingDay(final WorkingDays workingDays, final LocalDate date) {
|
||||
return CalendarUtils.isValidRedurringDate(workingDays.getRecurrence(), date, date);
|
||||
}
|
||||
|
||||
public static boolean isNonWorkingDay(final WorkingDays workingDays, final LocalDate date) {
|
||||
return !isWorkingDay(workingDays, date);
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -2112,6 +2112,7 @@ public class Loan extends AbstractPersistable<Long> {
|
||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||
|
||||
reverseExistingTransactions();
|
||||
updateLoanSummaryDerivedFields();
|
||||
|
||||
}
|
||||
|
||||
|
||||
+12
-3
@@ -53,10 +53,19 @@ public class DefaultScheduledDateGenerator implements ScheduledDateGenerator {
|
||||
@Override
|
||||
public LocalDate adjustRepaymentDate(final LocalDate dueRepaymentPeriodDate, final LoanApplicationTerms loanApplicationTerms,
|
||||
final boolean isHolidayEnabled, final List<Holiday> holidays, final WorkingDays workingDays) {
|
||||
|
||||
LocalDate adjustedDate = dueRepaymentPeriodDate;
|
||||
final LocalDate nextDueRepaymentPeriodDate = getRepaymentPeriodDate(loanApplicationTerms.getRepaymentPeriodFrequencyType(),
|
||||
loanApplicationTerms.getRepaymentEvery(), adjustedDate);
|
||||
adjustedDate = WorkingDaysUtil.getOffSetDateIfNonWorkingDay(adjustedDate, nextDueRepaymentPeriodDate, workingDays);
|
||||
/**
|
||||
* Fix for https://mifosforge.jira.com/browse/MIFOSX-1357
|
||||
*/
|
||||
// recursively check for the next working day.
|
||||
while (WorkingDaysUtil.isNonWorkingDay(workingDays, adjustedDate)) {
|
||||
|
||||
final LocalDate nextDueRepaymentPeriodDate = getRepaymentPeriodDate(loanApplicationTerms.getRepaymentPeriodFrequencyType(),
|
||||
loanApplicationTerms.getRepaymentEvery(), adjustedDate);
|
||||
adjustedDate = WorkingDaysUtil.getOffSetDateIfNonWorkingDay(adjustedDate, nextDueRepaymentPeriodDate, workingDays);
|
||||
}
|
||||
|
||||
if (isHolidayEnabled) {
|
||||
adjustedDate = HolidayUtil.getRepaymentRescheduleDateToIfHoliday(adjustedDate, holidays);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user