Search in sources :

Example 26 with HolidayBuilder

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

the class HolidayServiceFacadeWebTierTest method validateDisbursementDateIsNotInHolidayShouldThrowExceptionWhenDateIsInAHoliday.

@Test
public void validateDisbursementDateIsNotInHolidayShouldThrowExceptionWhenDateIsInAHoliday() throws Exception {
    DateTime disbursementDate = new DateMidnight().toDateTime().withDayOfWeek(DayOfWeek.monday());
    List<Holiday> holidays = new ArrayList<Holiday>();
    Holiday holiday = new HolidayBuilder().from(disbursementDate.minusDays(1)).to(disbursementDate.plusDays(6)).build();
    holidays.add(holiday);
    try {
        when(holidayDao.findAllHolidaysFromDateAndNext(officeId, new LocalDate(disbursementDate).toString())).thenReturn(holidays);
        holidayServiceFacade.validateDisbursementDateForNewLoan(officeId, disbursementDate);
        fail("Should have thrown BusinessRuleException");
    } catch (BusinessRuleException e) {
        assertThat(e.getMessageKey(), is(LoanExceptionConstants.DISBURSEMENTDATE_MUST_NOT_BE_IN_A_HOLIDAY));
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) DateMidnight(org.joda.time.DateMidnight) Holiday(org.mifos.application.holiday.business.Holiday) ArrayList(java.util.ArrayList) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 27 with HolidayBuilder

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

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method weeklyScheduledEventSecondThirdFourthDateInThreeWeekNextMeetingHolidayShouldQuadrupleUpDatesAfterHoliday.

@Test
public void weeklyScheduledEventSecondThirdFourthDateInThreeWeekNextMeetingHolidayShouldQuadrupleUpDatesAfterHoliday() {
    Holiday threeWeekNextMeetngHolidayStartingJuly4th = new HolidayBuilder().from(mon_2011_07_04).to(mon_2011_07_04.plusWeeks(3)).withNextMeetingRule().build();
    validateDates(new ScheduleBuilder().withHolidays(threeWeekNextMeetngHolidayStartingJuly4th).withWeeklyEvent(1, wed_2011_06_29.getDayOfWeek()).withNumberOfDates(4).withStartDate(wed_2011_06_29.minusDays(1)).build(), wed_2011_06_29, wed_2011_06_29.plusWeeks(4), wed_2011_06_29.plusWeeks(4), wed_2011_06_29.plusWeeks(4));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) Test(org.junit.Test)

Example 28 with HolidayBuilder

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

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method biMonthlyByDayScheduleSecondDateInSameDayHolidayShouldNotShiftAnyDates.

@Test
public void biMonthlyByDayScheduleSecondDateInSameDayHolidayShouldNotShiftAnyDates() {
    Holiday twoWeekNextWorkingDayHoliday = new HolidayBuilder().from(date(2011, 7, 4)).to(date(2011, 7, 17)).withSameDayAsRule().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 29 with HolidayBuilder

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

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

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