Search in sources :

Example 11 with ScheduledEventBuilder

use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.

the class HolidayAndWorkingDaysScheduledDateGenerationTest method canGenerateScheduledDates.

@Test
public void canGenerateScheduledDates() {
    DateTime lastScheduledDate = DayOfWeek.mondayMidnight();
    ScheduledEvent recurringEvent = new ScheduledEventBuilder().every(1).weeks().on(DayOfWeek.monday()).build();
    List<DateTime> scheduledDates = scheduleGeneration.generateScheduledDates(10, lastScheduledDate, recurringEvent, false);
    assertThat(scheduledDates.size(), is(notNullValue()));
    assertThat(scheduledDates.size(), is(10));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 12 with ScheduledEventBuilder

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

use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.

the class HolidayAndWorkingDaysScheduledDateGenerationTest method canGenerateScheduledDatesThatMatchScheduledEventBasedOnLastScheduledDate.

@Test
public void canGenerateScheduledDatesThatMatchScheduledEventBasedOnLastScheduledDate() {
    DateTime lastScheduledDate = DayOfWeek.mondayMidnight();
    ScheduledEvent recurringEvent = new ScheduledEventBuilder().every(1).weeks().on(DayOfWeek.monday()).build();
    List<DateTime> scheduledDates = scheduleGeneration.generateScheduledDates(10, lastScheduledDate, recurringEvent, false);
    assertThat(scheduledDates.get(0), is(lastScheduledDate));
    assertThat(scheduledDates.get(1), is(DayOfWeek.oneWeekFrom(lastScheduledDate)));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 14 with ScheduledEventBuilder

use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.

the class MonthlyOnDateScheduledEventTest method canRollForwardDateToNextMonthToMatchDayOfMonthWhenDayOfMonthHasBeingPast.

@Test
public void canRollForwardDateToNextMonthToMatchDayOfMonthWhenDayOfMonthHasBeingPast() {
    scheduledEvent = new ScheduledEventBuilder().every(1).months().onDayOfMonth(3).build();
    DateTime fifthDayOfMonth = new DateTime().plusMonths(1).withDayOfMonth(5).toDateMidnight().toDateTime();
    DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(fifthDayOfMonth);
    assertThat(result, is(fifthDayOfMonth.plusMonths(1).minusDays(2)));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 15 with ScheduledEventBuilder

use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.

the class MonthlyOnWeekAndWeekDayScheduledEventTest method canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayAhead.

@Test
public void canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayAhead() {
    scheduledEvent = new ScheduledEventBuilder().every(1).months().onWeekOfMonth(1).on(DayOfWeek.tuesday()).build();
    DateTime wednesday7thOfApril = new DateTime().withDayOfMonth(7).withMonthOfYear(4).withYear(2010).withDayOfWeek(DayOfWeek.wednesday()).toDateMidnight().toDateTime();
    DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(wednesday7thOfApril);
    assertThat(result, is(tuesdayOnFirstWeekOneMonthFrom(wednesday7thOfApril)));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)32 ScheduledEventBuilder (org.mifos.domain.builders.ScheduledEventBuilder)32 DateTime (org.joda.time.DateTime)17 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)9 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)9 FeeBO (org.mifos.accounts.fees.business.FeeBO)9 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)9 ScheduledEvent (org.mifos.schedule.ScheduledEvent)9 Holiday (org.mifos.application.holiday.business.Holiday)1 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)1 HolidayAndWorkingDaysScheduledDateGeneration (org.mifos.schedule.internal.HolidayAndWorkingDaysScheduledDateGeneration)1