Search in sources :

Example 21 with ScheduledEventBuilder

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

the class MonthlyOnDateScheduledEventTest method canRollForwardDateToMatchDayOfMonthWhenCurrentDayOfMonthIsBehind.

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

Example 22 with ScheduledEventBuilder

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

the class MonthlyOnDateScheduledEventTest method canRollForwardDateTwoMonthsToMatchDayOfMonthWhenDayOfMonthHasBeingPast.

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

Example 23 with ScheduledEventBuilder

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

the class MonthlyOnWeekAndWeekDayScheduledEventTest method canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayBehind.

@Test
public void canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayBehind() {
    scheduledEvent = new ScheduledEventBuilder().every(1).months().onWeekOfMonth(2).on(DayOfWeek.tuesday()).build();
    DateTime firstMondayOfMay2010 = new DateTime().withYear(2010).withMonthOfYear(5).withDayOfMonth(3).toDateMidnight().toDateTime();
    DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(firstMondayOfMay2010);
    assertThat(result, is(firstMondayOfMay2010.plusDays(1).plusWeeks(1)));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 24 with ScheduledEventBuilder

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

the class MonthlyOnWeekAndWeekDayScheduledEventTest method canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingInSameWeekButOneDayBehind.

@Test
public void canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingInSameWeekButOneDayBehind() {
    scheduledEvent = new ScheduledEventBuilder().every(1).months().onWeekOfMonth(1).on(DayOfWeek.tuesday()).build();
    DateTime firstMondayOfMay2010 = new DateTime().withYear(2010).withMonthOfYear(5).withDayOfMonth(3).toDateMidnight().toDateTime();
    DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(firstMondayOfMay2010);
    assertThat(result, is(firstMondayOfMay2010.plusDays(1)));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 25 with ScheduledEventBuilder

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

the class ScheduledEventTest method numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryThree.

@Test
public void numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryThree() {
    ScheduledEvent master = new ScheduledEventBuilder().every(2).weeks().build();
    ScheduledEvent slave = new ScheduledEventBuilder().every(3).weeks().build();
    assertThat(master.numberOfEventsRollingUpToThis(slave, 1), is(1));
    assertThat(master.numberOfEventsRollingUpToThis(slave, 2), is(0));
    assertThat(master.numberOfEventsRollingUpToThis(slave, 3), is(1));
    assertThat(master.numberOfEventsRollingUpToThis(slave, 4), is(1));
    assertThat(master.numberOfEventsRollingUpToThis(slave, 5), is(0));
    assertThat(master.numberOfEventsRollingUpToThis(slave, 6), is(1));
    assertThat(master.numberOfEventsRollingUpToThis(slave, 7), is(1));
    assertThat(master.numberOfEventsRollingUpToThis(slave, 8), is(0));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) 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