Search in sources :

Example 21 with Holiday

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));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) Test(org.junit.Test)

Example 22 with Holiday

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));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) Test(org.junit.Test)

Example 23 with Holiday

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));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) Test(org.junit.Test)

Example 24 with Holiday

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)));
}
Also used : HolidayAndWorkingDaysScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysScheduledDateGeneration) ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 25 with Holiday

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));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) Test(org.junit.Test)

Aggregations

Holiday (org.mifos.application.holiday.business.Holiday)54 Test (org.junit.Test)32 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)28 DateTime (org.joda.time.DateTime)22 ArrayList (java.util.ArrayList)16 Days (org.joda.time.Days)13 FiscalCalendarRules (org.mifos.config.FiscalCalendarRules)13 LocalDate (org.joda.time.LocalDate)10 HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration (org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)9 ScheduledDateGeneration (org.mifos.schedule.ScheduledDateGeneration)8 Date (java.util.Date)7 DateMidnight (org.joda.time.DateMidnight)6 Ignore (org.junit.Ignore)6 HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)6 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)4 DateTimeService (org.mifos.framework.util.DateTimeService)4 Before (org.junit.Before)3 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3