fixed MIFOSX-301 to select a valid disbursement date
This commit is contained in:
+17
-4
@@ -34,6 +34,7 @@ import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
|||||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||||
|
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
import org.mifosplatform.portfolio.calendar.data.CalendarData;
|
import org.mifosplatform.portfolio.calendar.data.CalendarData;
|
||||||
import org.mifosplatform.portfolio.calendar.domain.Calendar;
|
import org.mifosplatform.portfolio.calendar.domain.Calendar;
|
||||||
@@ -56,7 +57,7 @@ public class CalendarsApiResource {
|
|||||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "entityId", "entityType", "title",
|
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "entityId", "entityType", "title",
|
||||||
"description", "location", "startDate", "endDate", "duration", "type", "repeating", "recurrence", "remindBy", "firstReminder",
|
"description", "location", "startDate", "endDate", "duration", "type", "repeating", "recurrence", "remindBy", "firstReminder",
|
||||||
"secondReminder", "humanReadable", "createdDate", "lastUpdatedDate", "createdByUserId", "createdByUsername",
|
"secondReminder", "humanReadable", "createdDate", "lastUpdatedDate", "createdByUserId", "createdByUsername",
|
||||||
"lastUpdatedByUserId", "lastUpdatedByUsername", "recurringDates"));
|
"lastUpdatedByUserId", "lastUpdatedByUsername", "recurringDates","nextTenRecurringDates"));
|
||||||
private final String resourceNameForPermissions = "CALENDAR";
|
private final String resourceNameForPermissions = "CALENDAR";
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
@@ -197,9 +198,21 @@ public class CalendarsApiResource {
|
|||||||
|
|
||||||
private CalendarData handleRecurringDate(final CalendarData calendarData){
|
private CalendarData handleRecurringDate(final CalendarData calendarData){
|
||||||
if(!calendarData.isRepeating()) return calendarData;
|
if(!calendarData.isRepeating()) return calendarData;
|
||||||
|
final String rrule = calendarData.getRecurrence();
|
||||||
final Collection<LocalDate> recurringDates = CalendarHelper.getRecurringDates(calendarData.getRecurrence(), calendarData.getStartDate(), calendarData.getEndDate());
|
final LocalDate currentDate = DateUtils.getLocalDateOfTenant();
|
||||||
return new CalendarData(calendarData, recurringDates);
|
LocalDate seedDate = calendarData.getStartDate();
|
||||||
|
LocalDate endDate = calendarData.getEndDate();
|
||||||
|
if(seedDate.isBefore(currentDate.minusYears(1))){
|
||||||
|
seedDate = currentDate.minusYears(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(endDate == null || endDate.isAfter(currentDate.plusYears(1))){
|
||||||
|
endDate = currentDate.plusYears(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Collection<LocalDate> recurringDates = CalendarHelper.getRecurringDates(rrule, seedDate, seedDate, endDate, -1);
|
||||||
|
final Collection<LocalDate> nextTenRecurringDates = CalendarHelper.getRecurringDates(rrule, seedDate, endDate);
|
||||||
|
return new CalendarData(calendarData, recurringDates, nextTenRecurringDates);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<CalendarData> handleRecurringDates(final Collection<CalendarData> calendarsData) {
|
private Collection<CalendarData> handleRecurringDates(final Collection<CalendarData> calendarsData) {
|
||||||
|
|||||||
+5
-1
@@ -35,6 +35,7 @@ public class CalendarData {
|
|||||||
private final Integer firstReminder;
|
private final Integer firstReminder;
|
||||||
private final Integer secondReminder;
|
private final Integer secondReminder;
|
||||||
private final Collection<LocalDate> recurringDates;
|
private final Collection<LocalDate> recurringDates;
|
||||||
|
private final Collection<LocalDate> nextTenRecurringDates;
|
||||||
private final String humanReadable;
|
private final String humanReadable;
|
||||||
|
|
||||||
private final LocalDate createdDate;
|
private final LocalDate createdDate;
|
||||||
@@ -74,6 +75,7 @@ public class CalendarData {
|
|||||||
this.calendarTypeOptions = null;
|
this.calendarTypeOptions = null;
|
||||||
this.remindByOptions = null;
|
this.remindByOptions = null;
|
||||||
this.recurringDates = null;
|
this.recurringDates = null;
|
||||||
|
this.nextTenRecurringDates = null;
|
||||||
this.humanReadable = humanReadable;
|
this.humanReadable = humanReadable;
|
||||||
|
|
||||||
this.createdDate = createdDate;
|
this.createdDate = createdDate;
|
||||||
@@ -105,6 +107,7 @@ public class CalendarData {
|
|||||||
this.calendarTypeOptions = calendarTypeOptions;
|
this.calendarTypeOptions = calendarTypeOptions;
|
||||||
this.remindByOptions = remindByOptions;
|
this.remindByOptions = remindByOptions;
|
||||||
this.recurringDates = calendarData.recurringDates;
|
this.recurringDates = calendarData.recurringDates;
|
||||||
|
this.nextTenRecurringDates = calendarData.nextTenRecurringDates;
|
||||||
this.humanReadable = calendarData.humanReadable;
|
this.humanReadable = calendarData.humanReadable;
|
||||||
this.createdDate = calendarData.createdDate;
|
this.createdDate = calendarData.createdDate;
|
||||||
this.lastUpdatedDate = calendarData.lastUpdatedDate;
|
this.lastUpdatedDate = calendarData.lastUpdatedDate;
|
||||||
@@ -114,7 +117,7 @@ public class CalendarData {
|
|||||||
this.lastUpdatedByUsername = calendarData.lastUpdatedByUsername;
|
this.lastUpdatedByUsername = calendarData.lastUpdatedByUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarData(final CalendarData calendarData, final Collection<LocalDate> recurringDates) {
|
public CalendarData(final CalendarData calendarData, final Collection<LocalDate> recurringDates, final Collection<LocalDate> nextTenRecurringDates) {
|
||||||
this.id = calendarData.id;
|
this.id = calendarData.id;
|
||||||
this.entityId = calendarData.entityId;
|
this.entityId = calendarData.entityId;
|
||||||
this.entityType = calendarData.entityType;
|
this.entityType = calendarData.entityType;
|
||||||
@@ -134,6 +137,7 @@ public class CalendarData {
|
|||||||
this.calendarTypeOptions = null;
|
this.calendarTypeOptions = null;
|
||||||
this.remindByOptions = null;
|
this.remindByOptions = null;
|
||||||
this.recurringDates = recurringDates;
|
this.recurringDates = recurringDates;
|
||||||
|
this.nextTenRecurringDates = nextTenRecurringDates;
|
||||||
this.humanReadable = calendarData.humanReadable;
|
this.humanReadable = calendarData.humanReadable;
|
||||||
this.createdDate = calendarData.createdDate;
|
this.createdDate = calendarData.createdDate;
|
||||||
this.lastUpdatedDate = calendarData.lastUpdatedDate;
|
this.lastUpdatedDate = calendarData.lastUpdatedDate;
|
||||||
|
|||||||
Reference in New Issue
Block a user