Fineract-955 - Upgrade ical4j from ancient version 1.0.7 to current 3.0.18
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
16fb971f45
commit
96452f3ff4
@@ -89,7 +89,7 @@ dependencyManagement {
|
|||||||
dependency 'org.drizzle.jdbc:drizzle-jdbc:1.4'
|
dependency 'org.drizzle.jdbc:drizzle-jdbc:1.4'
|
||||||
dependency 'com.lowagie:itext:2.1.7'
|
dependency 'com.lowagie:itext:2.1.7'
|
||||||
dependency 'com.lowagie:itext-rtf:2.1.7'
|
dependency 'com.lowagie:itext-rtf:2.1.7'
|
||||||
dependency 'org.mnode.ical4j:ical4j:1.0.7'
|
dependency 'org.mnode.ical4j:ical4j:3.0.18'
|
||||||
dependency 'org.flywaydb:flyway-core:6.4.1'
|
dependency 'org.flywaydb:flyway-core:6.4.1'
|
||||||
dependency 'org.quartz-scheduler:quartz:+'
|
dependency 'org.quartz-scheduler:quartz:+'
|
||||||
dependency 'com.amazonaws:aws-java-sdk-s3:1.11.779'
|
dependency 'com.amazonaws:aws-java-sdk-s3:1.11.779'
|
||||||
|
|||||||
+1
-1
@@ -25,8 +25,8 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import net.fortuna.ical4j.model.ValidationException;
|
|
||||||
import net.fortuna.ical4j.model.property.RRule;
|
import net.fortuna.ical4j.model.property.RRule;
|
||||||
|
import net.fortuna.ical4j.validate.ValidationException;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.quartz.CronExpression;
|
import org.quartz.CronExpression;
|
||||||
|
|||||||
+1
-1
@@ -20,8 +20,8 @@ package org.apache.fineract.organisation.workingdays.service;
|
|||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.fortuna.ical4j.model.ValidationException;
|
|
||||||
import net.fortuna.ical4j.model.property.RRule;
|
import net.fortuna.ical4j.model.property.RRule;
|
||||||
|
import net.fortuna.ical4j.validate.ValidationException;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
|
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||||
|
|||||||
+79
-43
@@ -32,11 +32,11 @@ import net.fortuna.ical4j.model.DateList;
|
|||||||
import net.fortuna.ical4j.model.DateTime;
|
import net.fortuna.ical4j.model.DateTime;
|
||||||
import net.fortuna.ical4j.model.NumberList;
|
import net.fortuna.ical4j.model.NumberList;
|
||||||
import net.fortuna.ical4j.model.Recur;
|
import net.fortuna.ical4j.model.Recur;
|
||||||
import net.fortuna.ical4j.model.ValidationException;
|
|
||||||
import net.fortuna.ical4j.model.WeekDay;
|
import net.fortuna.ical4j.model.WeekDay;
|
||||||
import net.fortuna.ical4j.model.WeekDayList;
|
import net.fortuna.ical4j.model.WeekDayList;
|
||||||
import net.fortuna.ical4j.model.parameter.Value;
|
import net.fortuna.ical4j.model.parameter.Value;
|
||||||
import net.fortuna.ical4j.model.property.RRule;
|
import net.fortuna.ical4j.model.property.RRule;
|
||||||
|
import net.fortuna.ical4j.validate.ValidationException;
|
||||||
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
|
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
|
||||||
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
|
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||||
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
||||||
@@ -242,13 +242,13 @@ public class CalendarUtils {
|
|||||||
|
|
||||||
if (recur == null) { return humanReadable; }
|
if (recur == null) { return humanReadable; }
|
||||||
|
|
||||||
if (recur.getFrequency().equals(Recur.DAILY)) {
|
if (recur.getFrequency().equals(Recur.Frequency.DAILY)) {
|
||||||
if (recur.getInterval() == 1) {
|
if (recur.getInterval() == 1) {
|
||||||
humanReadable = "Daily";
|
humanReadable = "Daily";
|
||||||
} else {
|
} else {
|
||||||
humanReadable = "Every " + recur.getInterval() + " days";
|
humanReadable = "Every " + recur.getInterval() + " days";
|
||||||
}
|
}
|
||||||
} else if (recur.getFrequency().equals(Recur.WEEKLY)) {
|
} else if (recur.getFrequency().equals(Recur.Frequency.WEEKLY)) {
|
||||||
if (recur.getInterval() == 1 || recur.getInterval() == -1) {
|
if (recur.getInterval() == 1 || recur.getInterval() == -1) {
|
||||||
humanReadable = "Weekly";
|
humanReadable = "Weekly";
|
||||||
} else {
|
} else {
|
||||||
@@ -261,26 +261,26 @@ public class CalendarUtils {
|
|||||||
for (@SuppressWarnings("rawtypes")
|
for (@SuppressWarnings("rawtypes")
|
||||||
final Iterator iterator = weekDayList.iterator(); iterator.hasNext();) {
|
final Iterator iterator = weekDayList.iterator(); iterator.hasNext();) {
|
||||||
final WeekDay weekDay = (WeekDay) iterator.next();
|
final WeekDay weekDay = (WeekDay) iterator.next();
|
||||||
humanReadable += DayNameEnum.from(weekDay.getDay()).getCode();
|
humanReadable += DayNameEnum.from(weekDay.getDay().name()).getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (recur.getFrequency().equals(Recur.MONTHLY)) {
|
} else if (recur.getFrequency().equals(Recur.Frequency.MONTHLY)) {
|
||||||
NumberList nthDays = recur.getSetPosList();
|
NumberList nthDays = recur.getSetPosList();
|
||||||
Integer nthDay = null;
|
Integer nthDay = null;
|
||||||
if (!nthDays.isEmpty())
|
if (!nthDays.isEmpty())
|
||||||
nthDay = (Integer) nthDays.get(0);
|
nthDay = nthDays.get(0);
|
||||||
NumberList monthDays = recur.getMonthDayList();
|
NumberList monthDays = recur.getMonthDayList();
|
||||||
Integer monthDay = null;
|
Integer monthDay = null;
|
||||||
if (!monthDays.isEmpty())
|
if (!monthDays.isEmpty())
|
||||||
monthDay = (Integer) monthDays.get(0);
|
monthDay = monthDays.get(0);
|
||||||
WeekDayList weekdays = recur.getDayList();
|
WeekDayList weekdays = recur.getDayList();
|
||||||
WeekDay weekDay = null;
|
WeekDay weekDay = null;
|
||||||
if (!weekdays.isEmpty())
|
if (!weekdays.isEmpty())
|
||||||
weekDay = (WeekDay) weekdays.get(0);
|
weekDay = weekdays.get(0);
|
||||||
if (nthDay != null && weekDay != null) {
|
if (nthDay != null && weekDay != null) {
|
||||||
NthDayType nthDayType = NthDayType.fromInt(nthDay);
|
NthDayType nthDayType = NthDayType.fromInt(nthDay);
|
||||||
NthDayNameEnum nthDayName = NthDayNameEnum.from(nthDayType.toString());
|
NthDayNameEnum nthDayName = NthDayNameEnum.from(nthDayType.toString());
|
||||||
DayNameEnum weekdayType = DayNameEnum.from(weekDay.getDay());
|
DayNameEnum weekdayType = DayNameEnum.from(weekDay.getDay().name());
|
||||||
if (recur.getInterval() == 1 || recur.getInterval() == -1) {
|
if (recur.getInterval() == 1 || recur.getInterval() == -1) {
|
||||||
humanReadable = "Monthly on " + nthDayName.getCode().toLowerCase() + " " + weekdayType.getCode().toLowerCase();
|
humanReadable = "Monthly on " + nthDayName.getCode().toLowerCase() + " " + weekdayType.getCode().toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
@@ -308,7 +308,7 @@ public class CalendarUtils {
|
|||||||
humanReadable = "Every " + recur.getInterval() + " months on day " + startDate.getDayOfMonth();
|
humanReadable = "Every " + recur.getInterval() + " months on day " + startDate.getDayOfMonth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (recur.getFrequency().equals(Recur.YEARLY)) {
|
} else if (recur.getFrequency().equals(Recur.Frequency.YEARLY)) {
|
||||||
if (recur.getInterval() == 1) {
|
if (recur.getInterval() == 1) {
|
||||||
humanReadable = "Annually on " + startDate.toString("MMM") + " " + startDate.getDayOfMonth();
|
humanReadable = "Annually on " + startDate.toString("MMM") + " " + startDate.getDayOfMonth();
|
||||||
} else {
|
} else {
|
||||||
@@ -420,13 +420,13 @@ public class CalendarUtils {
|
|||||||
|
|
||||||
private static PeriodFrequencyType getMeetingPeriodFrequencyType(final Recur recur) {
|
private static PeriodFrequencyType getMeetingPeriodFrequencyType(final Recur recur) {
|
||||||
PeriodFrequencyType meetingFrequencyType = PeriodFrequencyType.INVALID;
|
PeriodFrequencyType meetingFrequencyType = PeriodFrequencyType.INVALID;
|
||||||
if (recur.getFrequency().equals(Recur.DAILY)) {
|
if (recur.getFrequency().equals(Recur.Frequency.DAILY)) {
|
||||||
meetingFrequencyType = PeriodFrequencyType.DAYS;
|
meetingFrequencyType = PeriodFrequencyType.DAYS;
|
||||||
} else if (recur.getFrequency().equals(Recur.WEEKLY)) {
|
} else if (recur.getFrequency().equals(Recur.Frequency.WEEKLY)) {
|
||||||
meetingFrequencyType = PeriodFrequencyType.WEEKS;
|
meetingFrequencyType = PeriodFrequencyType.WEEKS;
|
||||||
} else if (recur.getFrequency().equals(Recur.MONTHLY)) {
|
} else if (recur.getFrequency().equals(Recur.Frequency.MONTHLY)) {
|
||||||
meetingFrequencyType = PeriodFrequencyType.MONTHS;
|
meetingFrequencyType = PeriodFrequencyType.MONTHS;
|
||||||
} else if (recur.getFrequency().equals(Recur.YEARLY)) {
|
} else if (recur.getFrequency().equals(Recur.Frequency.YEARLY)) {
|
||||||
meetingFrequencyType = PeriodFrequencyType.YEARS;
|
meetingFrequencyType = PeriodFrequencyType.YEARS;
|
||||||
}
|
}
|
||||||
return meetingFrequencyType;
|
return meetingFrequencyType;
|
||||||
@@ -435,13 +435,13 @@ public class CalendarUtils {
|
|||||||
public static String getMeetingFrequencyFromPeriodFrequencyType(final PeriodFrequencyType periodFrequency) {
|
public static String getMeetingFrequencyFromPeriodFrequencyType(final PeriodFrequencyType periodFrequency) {
|
||||||
String frequency = null;
|
String frequency = null;
|
||||||
if (periodFrequency.equals(PeriodFrequencyType.DAYS)) {
|
if (periodFrequency.equals(PeriodFrequencyType.DAYS)) {
|
||||||
frequency = Recur.DAILY;
|
frequency = Recur.Frequency.DAILY.name();
|
||||||
} else if (periodFrequency.equals(PeriodFrequencyType.WEEKS)) {
|
} else if (periodFrequency.equals(PeriodFrequencyType.WEEKS)) {
|
||||||
frequency = Recur.WEEKLY;
|
frequency = Recur.Frequency.WEEKLY.name();
|
||||||
} else if (periodFrequency.equals(PeriodFrequencyType.MONTHS)) {
|
} else if (periodFrequency.equals(PeriodFrequencyType.MONTHS)) {
|
||||||
frequency = Recur.MONTHLY;
|
frequency = Recur.Frequency.MONTHLY.name();
|
||||||
} else if (periodFrequency.equals(PeriodFrequencyType.YEARS)) {
|
} else if (periodFrequency.equals(PeriodFrequencyType.YEARS)) {
|
||||||
frequency = Recur.YEARLY;
|
frequency = Recur.Frequency.YEARLY.name();
|
||||||
}
|
}
|
||||||
return frequency;
|
return frequency;
|
||||||
}
|
}
|
||||||
@@ -453,7 +453,7 @@ public class CalendarUtils {
|
|||||||
|
|
||||||
public static CalendarFrequencyType getFrequency(final String recurringRule) {
|
public static CalendarFrequencyType getFrequency(final String recurringRule) {
|
||||||
final Recur recur = CalendarUtils.getICalRecur(recurringRule);
|
final Recur recur = CalendarUtils.getICalRecur(recurringRule);
|
||||||
return CalendarFrequencyType.fromString(recur.getFrequency());
|
return CalendarFrequencyType.fromString(recur.getFrequency().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CalendarWeekDaysType getRepeatsOnDay(final String recurringRule) {
|
public static CalendarWeekDaysType getRepeatsOnDay(final String recurringRule) {
|
||||||
@@ -461,8 +461,8 @@ public class CalendarUtils {
|
|||||||
final WeekDayList weekDays = recur.getDayList();
|
final WeekDayList weekDays = recur.getDayList();
|
||||||
if (weekDays.isEmpty()) return CalendarWeekDaysType.INVALID;
|
if (weekDays.isEmpty()) return CalendarWeekDaysType.INVALID;
|
||||||
// supports only one day
|
// supports only one day
|
||||||
WeekDay weekDay = (WeekDay) weekDays.get(0);
|
WeekDay weekDay = weekDays.get(0);
|
||||||
return CalendarWeekDaysType.fromString(weekDay.getDay());
|
return CalendarWeekDaysType.fromString(weekDay.getDay().name());
|
||||||
}
|
}
|
||||||
public static NthDayType getRepeatsOnNthDayOfMonth(final String recurringRule) {
|
public static NthDayType getRepeatsOnNthDayOfMonth(final String recurringRule) {
|
||||||
final Recur recur = CalendarUtils.getICalRecur(recurringRule);
|
final Recur recur = CalendarUtils.getICalRecur(recurringRule);
|
||||||
@@ -473,7 +473,7 @@ public class CalendarUtils {
|
|||||||
monthDays = recur.getSetPosList();
|
monthDays = recur.getSetPosList();
|
||||||
if (monthDays.isEmpty()) return NthDayType.INVALID;
|
if (monthDays.isEmpty()) return NthDayType.INVALID;
|
||||||
if (!recur.getMonthDayList().isEmpty() && recur.getSetPosList().isEmpty()) return NthDayType.ONDAY;
|
if (!recur.getMonthDayList().isEmpty() && recur.getSetPosList().isEmpty()) return NthDayType.ONDAY;
|
||||||
Integer monthDay = (Integer) monthDays.get(0);
|
Integer monthDay = monthDays.get(0);
|
||||||
return NthDayType.fromInt(monthDay);
|
return NthDayType.fromInt(monthDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,7 +484,7 @@ public class CalendarUtils {
|
|||||||
if (recur == null) { return null; }
|
if (recur == null) { return null; }
|
||||||
LocalDate startDate = disbursementDate;
|
LocalDate startDate = disbursementDate;
|
||||||
final LocalDate seedDate = calendar.getStartDateLocalDate();
|
final LocalDate seedDate = calendar.getStartDateLocalDate();
|
||||||
if (isValidRedurringDate(calendar.getRecurrence(), seedDate, startDate, isSkipRepaymentOnFirstDayOfMonth, numberOfDays) && !frequency.equals(Recur.DAILY)) {
|
if (isValidRedurringDate(calendar.getRecurrence(), seedDate, startDate, isSkipRepaymentOnFirstDayOfMonth, numberOfDays) && !frequency.equals(Recur.Frequency.DAILY.name())) {
|
||||||
startDate = startDate.plusDays(1);
|
startDate = startDate.plusDays(1);
|
||||||
}
|
}
|
||||||
// Recurring dates should follow loanRepaymentInterval.
|
// Recurring dates should follow loanRepaymentInterval.
|
||||||
@@ -493,7 +493,9 @@ public class CalendarUtils {
|
|||||||
// where as for loan product with fortnightly frequency interval is 2
|
// where as for loan product with fortnightly frequency interval is 2
|
||||||
// to generate currect set of meeting dates reset interval same as loan
|
// to generate currect set of meeting dates reset interval same as loan
|
||||||
// repayment interval.
|
// repayment interval.
|
||||||
recur.setInterval(loanRepaymentInterval);
|
|
||||||
|
Recur.Builder recurBuilder = getRecurBuilder(recur);
|
||||||
|
recurBuilder = recurBuilder.interval(loanRepaymentInterval);
|
||||||
|
|
||||||
// Recurring dates should follow loanRepayment frequency.
|
// Recurring dates should follow loanRepayment frequency.
|
||||||
// e.g.
|
// e.g.
|
||||||
@@ -501,11 +503,13 @@ public class CalendarUtils {
|
|||||||
// frequency type.
|
// frequency type.
|
||||||
// to generate currect set of meeting dates reset frequency same as loan
|
// to generate currect set of meeting dates reset frequency same as loan
|
||||||
// repayment frequency.
|
// repayment frequency.
|
||||||
if (recur.getFrequency().equals(Recur.DAILY)) {
|
|
||||||
recur.setFrequency(frequency);
|
if (recur.getFrequency().equals(Recur.Frequency.DAILY)) {
|
||||||
|
recurBuilder = recurBuilder.frequency(Recur.Frequency.valueOf(frequency));
|
||||||
}
|
}
|
||||||
|
|
||||||
final LocalDate firstRepaymentDate = getNextRecurringDate(recur, seedDate, startDate);
|
Recur modifiedRecur = recurBuilder.build();
|
||||||
|
final LocalDate firstRepaymentDate = getNextRecurringDate(modifiedRecur, seedDate, startDate);
|
||||||
if (isSkipRepaymentOnFirstDayOfMonth && firstRepaymentDate.getDayOfMonth() == 1) { return adjustRecurringDate(firstRepaymentDate,
|
if (isSkipRepaymentOnFirstDayOfMonth && firstRepaymentDate.getDayOfMonth() == 1) { return adjustRecurringDate(firstRepaymentDate,
|
||||||
numberOfDays); }
|
numberOfDays); }
|
||||||
|
|
||||||
@@ -518,10 +522,10 @@ public class CalendarUtils {
|
|||||||
final Recur recur = CalendarUtils.getICalRecur(recurringRule);
|
final Recur recur = CalendarUtils.getICalRecur(recurringRule);
|
||||||
if (recur == null) { return null; }
|
if (recur == null) { return null; }
|
||||||
if (isValidRecurringDate(recur, seedDate, oldRepaymentDate, isSkipRepaymentOnFirstDayOfMonth, numberOfDays)) { return oldRepaymentDate; }
|
if (isValidRecurringDate(recur, seedDate, oldRepaymentDate, isSkipRepaymentOnFirstDayOfMonth, numberOfDays)) { return oldRepaymentDate; }
|
||||||
LocalDate nextRapaymentDate = getNextRepaymentMeetingDate(recurringRule, seedDate, oldRepaymentDate, loanRepaymentInterval,
|
LocalDate nextRepaymentDate = getNextRepaymentMeetingDate(recurringRule, seedDate, oldRepaymentDate, loanRepaymentInterval,
|
||||||
frequency, workingDays, isSkipRepaymentOnFirstDayOfMonth, numberOfDays);
|
frequency, workingDays, isSkipRepaymentOnFirstDayOfMonth, numberOfDays);
|
||||||
|
|
||||||
return nextRapaymentDate;
|
return nextRepaymentDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LocalDate getNextRepaymentMeetingDate(final String recurringRule, final LocalDate seedDate,
|
public static LocalDate getNextRepaymentMeetingDate(final String recurringRule, final LocalDate seedDate,
|
||||||
@@ -541,7 +545,11 @@ public class CalendarUtils {
|
|||||||
* with fortnightly frequency will have interval of 2, to generate right
|
* with fortnightly frequency will have interval of 2, to generate right
|
||||||
* set of meeting dates reset interval same as loan repayment interval.
|
* set of meeting dates reset interval same as loan repayment interval.
|
||||||
*/
|
*/
|
||||||
recur.setInterval(loanRepaymentInterval);
|
|
||||||
|
Recur.Builder recurBuilder = getRecurBuilder(recur);
|
||||||
|
|
||||||
|
recurBuilder = recurBuilder.interval(loanRepaymentInterval);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Recurring dates should follow loanRepayment frequency. //e.g. daily
|
* Recurring dates should follow loanRepayment frequency. //e.g. daily
|
||||||
@@ -549,12 +557,16 @@ public class CalendarUtils {
|
|||||||
* frequency. to generate right set of meeting dates reset frequency
|
* frequency. to generate right set of meeting dates reset frequency
|
||||||
* same as loan repayment frequency.
|
* same as loan repayment frequency.
|
||||||
*/
|
*/
|
||||||
if (recur.getFrequency().equals(Recur.DAILY)) {
|
|
||||||
recur.setFrequency(frequency);
|
|
||||||
|
if (recur.getFrequency().equals(Recur.Frequency.DAILY)) {
|
||||||
|
recurBuilder = recurBuilder.frequency(Recur.Frequency.valueOf(frequency));
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDate newRepaymentDate = getNextRecurringDate(recur, seedDate, tmpDate);
|
Recur modifiedRecur = recurBuilder.build();
|
||||||
final LocalDate nextRepaymentDate = getNextRecurringDate(recur, seedDate, newRepaymentDate);
|
|
||||||
|
LocalDate newRepaymentDate = getNextRecurringDate(modifiedRecur, seedDate, tmpDate);
|
||||||
|
final LocalDate nextRepaymentDate = getNextRecurringDate(modifiedRecur, seedDate, newRepaymentDate);
|
||||||
|
|
||||||
newRepaymentDate = WorkingDaysUtil.getOffSetDateIfNonWorkingDay(newRepaymentDate, nextRepaymentDate, workingDays);
|
newRepaymentDate = WorkingDaysUtil.getOffSetDateIfNonWorkingDay(newRepaymentDate, nextRepaymentDate, workingDays);
|
||||||
if (isSkipRepaymentOnFirstDayOfMonth) {
|
if (isSkipRepaymentOnFirstDayOfMonth) {
|
||||||
@@ -639,13 +651,13 @@ public class CalendarUtils {
|
|||||||
|
|
||||||
if (isValidRecurringDate(recur, seedDate, currentDate, isSkipMeetingOnFirstDay, numberOfDays)) { return currentDate; }
|
if (isValidRecurringDate(recur, seedDate, currentDate, isSkipMeetingOnFirstDay, numberOfDays)) { return currentDate; }
|
||||||
|
|
||||||
if (recur.getFrequency().equals(Recur.DAILY)) {
|
if (recur.getFrequency().equals(Recur.Frequency.DAILY)) {
|
||||||
currentDate = currentDate.plusDays(recur.getInterval());
|
currentDate = currentDate.plusDays(recur.getInterval());
|
||||||
} else if (recur.getFrequency().equals(Recur.WEEKLY)) {
|
} else if (recur.getFrequency().equals(Recur.Frequency.WEEKLY)) {
|
||||||
currentDate = currentDate.plusWeeks(recur.getInterval());
|
currentDate = currentDate.plusWeeks(recur.getInterval());
|
||||||
} else if (recur.getFrequency().equals(Recur.MONTHLY)) {
|
} else if (recur.getFrequency().equals(Recur.Frequency.MONTHLY)) {
|
||||||
currentDate = currentDate.plusMonths(recur.getInterval());
|
currentDate = currentDate.plusMonths(recur.getInterval());
|
||||||
} else if (recur.getFrequency().equals(Recur.YEARLY)) {
|
} else if (recur.getFrequency().equals(Recur.Frequency.YEARLY)) {
|
||||||
currentDate = currentDate.plusYears(recur.getInterval());
|
currentDate = currentDate.plusYears(recur.getInterval());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -694,7 +706,7 @@ public class CalendarUtils {
|
|||||||
if (getMeetingPeriodFrequencyType(recur).isMonthly()) {
|
if (getMeetingPeriodFrequencyType(recur).isMonthly()) {
|
||||||
monthDayList = recur.getMonthDayList();
|
monthDayList = recur.getMonthDayList();
|
||||||
if (!monthDayList.isEmpty()) {
|
if (!monthDayList.isEmpty()) {
|
||||||
monthOnDay = (Integer) monthDayList.get(0);
|
monthOnDay = monthDayList.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return monthOnDay;
|
return monthOnDay;
|
||||||
@@ -746,17 +758,22 @@ public class CalendarUtils {
|
|||||||
* frequency. to generate right set of meeting dates reset frequency
|
* frequency. to generate right set of meeting dates reset frequency
|
||||||
* same as loan repayment frequency.
|
* same as loan repayment frequency.
|
||||||
*/
|
*/
|
||||||
if (recur.getFrequency().equals(Recur.DAILY)) {
|
|
||||||
recur.setFrequency(frequency);
|
Recur.Builder recurBuilder = getRecurBuilder(recur);
|
||||||
|
|
||||||
|
if (recur.getFrequency().equals(Recur.Frequency.DAILY)) {
|
||||||
|
recurBuilder = recurBuilder.frequency(Recur.Frequency.valueOf(frequency));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Recur modifiedRecur = recurBuilder.build();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Below code modified as discussed with Pramod N
|
* Below code modified as discussed with Pramod N
|
||||||
*/
|
*/
|
||||||
LocalDate newRepaymentDate = tmpDate;
|
LocalDate newRepaymentDate = tmpDate;
|
||||||
int newRepayment = rep;
|
int newRepayment = rep;
|
||||||
while (newRepayment > 0) {
|
while (newRepayment > 0) {
|
||||||
newRepaymentDate = getNextRecurringDate(recur, seedDate, newRepaymentDate);
|
newRepaymentDate = getNextRecurringDate(modifiedRecur, seedDate, newRepaymentDate);
|
||||||
newRepayment--;
|
newRepayment--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,9 +819,28 @@ public class CalendarUtils {
|
|||||||
* monthly and meeting frequency is weekly, then generate repayments
|
* monthly and meeting frequency is weekly, then generate repayments
|
||||||
* schedule as every 4 weeks
|
* schedule as every 4 weeks
|
||||||
*/
|
*/
|
||||||
if (frequency.equals(Recur.MONTHLY) && recur.getFrequency().equals(Recur.WEEKLY)) {
|
if (frequency.equals(Recur.Frequency.MONTHLY.name()) && recur.getFrequency().equals(Recur.Frequency.WEEKLY)) {
|
||||||
repaymentInterval = loanRepaymentInterval*interval;
|
repaymentInterval = loanRepaymentInterval*interval;
|
||||||
}
|
}
|
||||||
return repaymentInterval;
|
return repaymentInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Recur.Builder getRecurBuilder(Recur recur) {
|
||||||
|
Recur.Builder recurBuilder = new Recur.Builder();
|
||||||
|
recurBuilder = recurBuilder.frequency(recur.getFrequency())
|
||||||
|
.until(recur.getUntil())
|
||||||
|
.count(recur.getCount())
|
||||||
|
.interval(recur.getInterval())
|
||||||
|
.secondList(recur.getSecondList())
|
||||||
|
.minuteList(recur.getMinuteList())
|
||||||
|
.hourList(recur.getHourList())
|
||||||
|
.dayList(recur.getDayList())
|
||||||
|
.monthDayList(recur.getMonthDayList())
|
||||||
|
.yearDayList(recur.getYearDayList())
|
||||||
|
.weekNoList(recur.getWeekNoList())
|
||||||
|
.monthList(recur.getMonthList())
|
||||||
|
.setPosList(recur.getSetPosList())
|
||||||
|
.weekStartDay(recur.getWeekStartDay());
|
||||||
|
return recurBuilder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user