Search in sources :

Example 6 with ScheduledEventBuilder

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

the class FeeInstallmentTest method createMergedFeeInstallmentsForTwoFeesAccountScheduledBiWeeklyFee1ScheduledWeeklyFee2ScheduledEveryThreeWeeks.

/**
     * Expected results:
     * | week           |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 | 10 | 11 | 12 |
     * | account event  |    |  1 |    |  2 |    |  3 |    |  4 |    |  5 |    |  6 |
     * | fee1 event     |  x |  x |  x |  x |  x |  x |  x |  x |  x |  x |  x |  x |
     * | fee2 event     |    |    |  y |    |    |  y |    |    |  y |    |    |  y |
     */
@Test
public void createMergedFeeInstallmentsForTwoFeesAccountScheduledBiWeeklyFee1ScheduledWeeklyFee2ScheduledEveryThreeWeeks() {
    ScheduledEvent masterEvent = new ScheduledEventBuilder().every(2).weeks().build();
    FeeBO feeBO1 = createWeeklyFeeBO(1);
    FeeBO feeBO2 = createWeeklyFeeBO(3);
    AccountFeesEntity accountFeesEntity1 = createAccountFeesEntity(feeBO1, 10.0);
    AccountFeesEntity accountFeesEntity2 = createAccountFeesEntity(feeBO2, 13.0);
    List<AccountFeesEntity> accountFees = Arrays.asList(new AccountFeesEntity[] { accountFeesEntity1, accountFeesEntity2 });
    List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallments(masterEvent, accountFees, 6);
    assertThat(feeInstallments.size(), is(10));
    assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO1);
    assertFeeInstallment(feeInstallments.get(1), 2, 20.0, feeBO1);
    assertFeeInstallment(feeInstallments.get(2), 3, 20.0, feeBO1);
    assertFeeInstallment(feeInstallments.get(3), 4, 20.0, feeBO1);
    assertFeeInstallment(feeInstallments.get(4), 5, 20.0, feeBO1);
    assertFeeInstallment(feeInstallments.get(5), 6, 20.0, feeBO1);
    assertFeeInstallment(feeInstallments.get(6), 1, 13.0, feeBO2);
    assertFeeInstallment(feeInstallments.get(7), 3, 13.0, feeBO2);
    assertFeeInstallment(feeInstallments.get(8), 4, 13.0, feeBO2);
    assertFeeInstallment(feeInstallments.get(9), 6, 13.0, feeBO2);
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 7 with ScheduledEventBuilder

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

the class FeeInstallmentTest method createMergedFeeInstallmentsForOneFeeAccountScheduledEveryThirdWeekFeeScheduledEverySecondWeek.

@Test
public void createMergedFeeInstallmentsForOneFeeAccountScheduledEveryThirdWeekFeeScheduledEverySecondWeek() {
    ScheduledEvent accountScheduledEvent = new ScheduledEventBuilder().every(3).weeks().build();
    FeeBO feeBO = createWeeklyFeeBO(2);
    AccountFeesEntity accountFeesEntity = createAccountFeesEntity(feeBO, 10.0);
    List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallmentsForOneFee(accountScheduledEvent, accountFeesEntity, 4);
    assertThat(feeInstallments.size(), is(4));
    assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO);
    assertFeeInstallment(feeInstallments.get(1), 2, 10.0, feeBO);
    assertFeeInstallment(feeInstallments.get(2), 3, 20.0, feeBO);
    assertFeeInstallment(feeInstallments.get(3), 4, 10.0, feeBO);
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 8 with ScheduledEventBuilder

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

the class WeeklyScheduledEventTest method canRollForwardDateToNextNearestDateMatchingScheduleWhenUsingBiWeeklySchedule.

@Test
public void canRollForwardDateToNextNearestDateMatchingScheduleWhenUsingBiWeeklySchedule() {
    scheduledEvent = new ScheduledEventBuilder().every(2).weeks().on(DayOfWeek.wednesday()).build();
    DateTime thursday = DayOfWeek.thursdayMidnight();
    DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(thursday);
    assertThat(result, is(thursday.plusDays(13)));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 9 with ScheduledEventBuilder

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

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest 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 10 with ScheduledEventBuilder

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

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest 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)

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