Search in sources :

Example 16 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder 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 17 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder 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 18 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder 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 19 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder 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 20 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder 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

HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)35 Test (org.junit.Test)34 Holiday (org.mifos.application.holiday.business.Holiday)28 DateTime (org.joda.time.DateTime)16 Ignore (org.junit.Ignore)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 DateMidnight (org.joda.time.DateMidnight)6 HolidayBO (org.mifos.application.holiday.business.HolidayBO)4 ArrayList (java.util.ArrayList)3 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)3 Money (org.mifos.framework.util.helpers.Money)3 LocalDate (org.joda.time.LocalDate)2 GenericDao (org.mifos.accounts.savings.persistence.GenericDao)2 GenericDaoHibernate (org.mifos.accounts.savings.persistence.GenericDaoHibernate)2 HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)2 HolidayDaoHibernate (org.mifos.application.holiday.persistence.HolidayDaoHibernate)2 OfficeDao (org.mifos.customers.office.persistence.OfficeDao)2 OfficeDaoHibernate (org.mifos.customers.office.persistence.OfficeDaoHibernate)2 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)2 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)2