Search in sources :

Example 41 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method setupAndInjectDependencies.

@Before
public void setupAndInjectDependencies() {
    workingDays = Arrays.asList(DayOfWeek.mondayAsDay(), DayOfWeek.tuesdayAsDay(), DayOfWeek.wednesdayAsDay(), DayOfWeek.thursdayAsDay(), DayOfWeek.fridayAsDay());
    List<Holiday> upcomingHolidays = new ArrayList<Holiday>();
    scheduleGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, upcomingHolidays);
//Dates frequently used in tests
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) ArrayList(java.util.ArrayList) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) Before(org.junit.Before)

Example 42 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method weeklyScheduledEventWithMoratoriumImmediatelyFollowingSameDayHoliday.

@Test
public void weeklyScheduledEventWithMoratoriumImmediatelyFollowingSameDayHoliday() {
    //First holiday extends for 14 consecutive days
    Holiday twoWeekSameDayHoliday = new HolidayBuilder().from(mon_2011_06_27).to(mon_2011_06_27.plusWeeks(2).minusDays(1)).withSameDayAsRule().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).minusDays(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 don't move (same-day holiday)
         * Fourth and fifth dates get shifted two weeks past the moratorium.
         */
    validateDates(new ScheduleBuilder().withHolidays(twoWeekSameDayHoliday, twoWeekMoratorium).withWeeklyEvent(1, DayOfWeek.wednesday()).withNumberOfDates(6).withStartDate(mon_2011_06_20).build(), wed_2011_06_22, wed_2011_06_22.plusWeeks(1), wed_2011_06_22.plusWeeks(2), 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 43 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method weeklyScheduleMoratoriumOverlapsNextWorkingDayHolidayAndIncludesOneScheduledDateShouldIgnoreNextWorkingDayHoliday.

@Test
public void weeklyScheduleMoratoriumOverlapsNextWorkingDayHolidayAndIncludesOneScheduledDateShouldIgnoreNextWorkingDayHoliday() {
    Holiday oneWeekNextWorkingDayHoliday = new HolidayBuilder().from(mon_2011_06_27).to(mon_2011_06_27.plusWeeks(1).minusDays(1)).withNextWorkingDayRule().build();
    Holiday twoWeekMoratorium = new HolidayBuilder().from(mon_2011_06_29).to(mon_2011_06_29).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, wed_2011_06_22.plusWeeks(2), wed_2011_06_22.plusWeeks(3), wed_2011_06_22.plusWeeks(4), wed_2011_06_22.plusWeeks(5), wed_2011_06_22.plusWeeks(6));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) Test(org.junit.Test)

Example 44 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method biMonthlyByDayScheduleSecondDateInNextWorkingDayHolidayShouldShiftSecondDateToNextWorkingDay.

@Test
public void biMonthlyByDayScheduleSecondDateInNextWorkingDayHolidayShouldShiftSecondDateToNextWorkingDay() {
    Holiday twoWeekNextWorkingDayHoliday = new HolidayBuilder().from(date(2011, 7, 4)).to(date(2011, 7, 17)).withNextWorkingDayRule().build();
    validateDates(new ScheduleBuilder().withHolidays(twoWeekNextWorkingDayHoliday).withDayOfMonthEvent(2, 6).withStartDate(date(2011, 5, 6)).withNumberOfDates(3).build(), date(2011, 6, 6), date(2011, 8, 8), date(2011, 10, 6));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) Test(org.junit.Test)

Example 45 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method weeklyScheduledEventWithMoratoriumImmediatelyFollowingNextWorkingDayHoliday.

@Test
public void weeklyScheduledEventWithMoratoriumImmediatelyFollowingNextWorkingDayHoliday() {
    Holiday twoWeekNextWorkingDayHoliday = new HolidayBuilder().from(mon_2011_06_27).to(mon_2011_06_27.plusWeeks(2).minusDays(1)).withNextWorkingDayRule().build();
    Holiday twoWeekMoratorium = new HolidayBuilder().from(mon_2011_06_27.plusWeeks(2)).to(mon_2011_06_27.plusWeeks(4).minusDays(1)).withRepaymentMoratoriumRule().build();
    /*
         * Schedule should start on the next Wednesday (2 days from the starting point).
         * The second and third unadjusted dates, being in the next-working-day holiday shift to the
         * first Monday after the holiday and moratorium. Because the fourth unadjusted date is in the moratorium,
         * it and the remaining schedule are shifted two more weeks past the moratorium.
         */
    validateDates(new ScheduleBuilder().withHolidays(twoWeekNextWorkingDayHoliday, twoWeekMoratorium).withWeeklyEvent(1, DayOfWeek.wednesday()).withNumberOfDates(6).withStartDate(mon_2011_06_20).build(), wed_2011_06_22, wed_2011_06_22.plusWeeks(5).withDayOfWeek(DayOfWeek.monday()), wed_2011_06_22.plusWeeks(5).withDayOfWeek(DayOfWeek.monday()), 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)

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