use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method weeklyScheduledEventWithMoratoriumImmediatelyFollowingNexRepaymentHoliday.
@Test
public void weeklyScheduledEventWithMoratoriumImmediatelyFollowingNexRepaymentHoliday() {
//First holiday extends for 14 consecutive days from 2011/6/27
Holiday twoWeekNextRepaymentHoliday = new HolidayBuilder().from(mon_2011_06_27).to(mon_2011_06_27.plusWeeks(2).minusDays(1)).withNextMeetingRule().build();
// Next moratorium follows for 14 days
Holiday twoWeekMoratorium = new HolidayBuilder().from(mon_2011_06_27.plusWeeks(2)).to(mon_2011_06_27.plusWeeks(4).plusDays(-1)).withRepaymentMoratoriumRule().build();
/*
* Generate a Wednesday schedule from the Monday the week before the first holiday starts, 2011/6/20.
* Schedule should start on the next Wednesday, 2011/6/22 (2 days from the starting point).
* The second and third dates get shifted into the first week of the moratorium, on the same
* date as the fourth date. These and the remaining schedule get shifted two mor weeks
* past the moratorium.
*/
validateDates(new ScheduleBuilder().withHolidays(twoWeekNextRepaymentHoliday, twoWeekMoratorium).withWeeklyEvent(1, DayOfWeek.wednesday()).withNumberOfDates(6).withStartDate(mon_2011_06_20).build(), wed_2011_06_22, wed_2011_06_22.plusWeeks(5), wed_2011_06_22.plusWeeks(5), wed_2011_06_22.plusWeeks(5), wed_2011_06_22.plusWeeks(6), wed_2011_06_22.plusWeeks(7));
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method biWeeklyScheduleSecondDateHitsThreeDayMoratoriumShouldPushOutSecondAndThirdDates.
@Test
public void biWeeklyScheduleSecondDateHitsThreeDayMoratoriumShouldPushOutSecondAndThirdDates() {
Holiday independenceDay = new HolidayBuilder().from(date(2011, 7, 4)).to(date(2011, 7, 6)).withRepaymentMoratoriumRule().build();
validateDates(new ScheduleBuilder().withHolidays(independenceDay).withWeeklyEvent(2, DateTimeConstants.MONDAY).withStartDate(date(2011, 6, 20)).withNumberOfDates(3).build(), date(2011, 6, 27), date(2011, 7, 11), date(2011, 7, 25));
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method weeklyScheduleMoratoriumOverlapsNextWorkingDayHolidayDoesNotIncludeOneScheduledDateShouldShiftTheDate.
@Test
public void weeklyScheduleMoratoriumOverlapsNextWorkingDayHolidayDoesNotIncludeOneScheduledDateShouldShiftTheDate() {
// Second date, 6/29, falls in next-working-day holiday
Holiday oneWeekNextWorkingDayHoliday = new HolidayBuilder().from(mon_2011_06_27).to(mon_2011_06_27.plusWeeks(1).minusDays(1)).withNextWorkingDayRule().build();
// Moratorium starts on 6/30, overlapping above holiday but does not include the second date.
Holiday twoWeekMoratorium = new HolidayBuilder().from(// 6/30
mon_2011_06_27.plusDays(3)).to(// Monday 7/4
mon_2011_06_27.plusWeeks(1)).withRepaymentMoratoriumRule().build();
/*
* Schedule should start on the next Wednesday (2 days from the starting point).
* The second date is in both holidays, so it and remaining dates are shifted one week. The
* second date is now past the normal holiday.
*/
validateDates(new ScheduleBuilder().withHolidays(oneWeekNextWorkingDayHoliday, twoWeekMoratorium).withWeeklyEvent(1, DayOfWeek.wednesday()).withNumberOfDates(6).withStartDate(mon_2011_06_20).build(), wed_2011_06_22, // Tuesday 7/5 (next working day after moratorium)
wed_2011_06_22.plusWeeks(2).withDayOfWeek(DayOfWeek.tuesday()), // Wednesday, 7/6
wed_2011_06_22.plusWeeks(2), wed_2011_06_22.plusWeeks(3), wed_2011_06_22.plusWeeks(4), wed_2011_06_22.plusWeeks(5));
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayAndWorkingDaysScheduledDateGenerationTest method givenAHolidayFallsOnScheduledDateAndAdjustmentRuleForHolidayIsNextMeetingShouldGenerateScheduledDatesThatTakeIntoAccountHolidaysAndDuplicateAnyScheduledDatesThatOccurOnHoliday.
@Test
public void givenAHolidayFallsOnScheduledDateAndAdjustmentRuleForHolidayIsNextMeetingShouldGenerateScheduledDatesThatTakeIntoAccountHolidaysAndDuplicateAnyScheduledDatesThatOccurOnHoliday() {
// setup
DateTime fourthOfJuly = new DateTime().plusYears(1).withMonthOfYear(7).withDayOfMonth(4).toDateMidnight().toDateTime();
Holiday independenceDay = new HolidayBuilder().from(fourthOfJuly).to(fourthOfJuly.plusDays(3)).withNextMeetingRule().build();
List<Holiday> upcomingHolidays = Arrays.asList(independenceDay);
scheduleGeneration = new HolidayAndWorkingDaysScheduledDateGeneration(workingDays, upcomingHolidays);
DateTime june29thNextYear = new DateTime().plusYears(1).withMonthOfYear(6).withDayOfMonth(29).toDateMidnight().toDateTime();
DateTime startingFrom = june29thNextYear.minusDays(1);
ScheduledEvent scheduleEvent = new ScheduledEventBuilder().every(1).weeks().on(june29thNextYear.getDayOfWeek()).build();
// exercise test
List<DateTime> scheduledDates = scheduleGeneration.generateScheduledDates(10, startingFrom, scheduleEvent, false);
assertThat(scheduledDates.get(0), is(june29thNextYear));
assertThat(scheduledDates.get(1), is(june29thNextYear.plusWeeks(2)));
assertThat(scheduledDates.get(2), is(june29thNextYear.plusWeeks(2)));
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method monthlyByDayScheduleSecondDateInNextMeetingHolidayShouldShiftSecondDateByOneMonth.
@Test
public void monthlyByDayScheduleSecondDateInNextMeetingHolidayShouldShiftSecondDateByOneMonth() {
Holiday twoWeekNextWorkingDayHoliday = new HolidayBuilder().from(date(2011, 7, 4)).to(date(2011, 7, 17)).withNextMeetingRule().build();
validateDates(new ScheduleBuilder().withHolidays(twoWeekNextWorkingDayHoliday).withDayOfMonthEvent(1, 6).withStartDate(date(2011, 6, 6)).withNumberOfDates(3).build(), date(2011, 6, 6), date(2011, 8, 8), date(2011, 8, 8));
}
Aggregations