Search in sources :

Example 31 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class BasicHolidayStrategyTest method whenAHolidayFallsOnDateTheDateShouldBeAdjusted.

@Test
public void whenAHolidayFallsOnDateTheDateShouldBeAdjusted() {
    // setup
    List<Holiday> upcomingHolidays = Arrays.asList(holiday);
    holidayStrategy = new BasicHolidayStrategy(upcomingHolidays, workingDays, scheduledEvent);
    DateTime firstOfNextMonth = new DateTime().plusMonths(1).withDayOfMonth(1).toDateMidnight().toDateTime();
    // stubbing
    when(holiday.encloses(firstOfNextMonth.toDate())).thenReturn(true);
    when(holiday.adjust(firstOfNextMonth, workingDays, scheduledEvent)).thenReturn(firstOfNextMonth.plusDays(1));
    // exercise test
    DateTime adjustedDate = holidayStrategy.adjust(firstOfNextMonth);
    assertThat(adjustedDate, is(firstOfNextMonth.plusDays(1)));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 32 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class BasicHolidayStrategyTest method whenAHolidayAdjustmentCausesAdjustedDateToFallOnAnotherHolidayTheDateShouldAgainBeAdjustedForSubsequentHoliday.

@Test
public void whenAHolidayAdjustmentCausesAdjustedDateToFallOnAnotherHolidayTheDateShouldAgainBeAdjustedForSubsequentHoliday() {
    // setup
    List<Holiday> upcomingHolidays = Arrays.asList(holiday, holiday2);
    holidayStrategy = new BasicHolidayStrategy(upcomingHolidays, workingDays, scheduledEvent);
    DateTime firstOfNextMonth = new DateTime().plusMonths(1).withDayOfMonth(1).toDateMidnight().toDateTime();
    DateTime secondOfNextMonth = firstOfNextMonth.plusDays(1);
    when(holiday.encloses(firstOfNextMonth.toDate())).thenReturn(true);
    when(holiday.adjust(firstOfNextMonth, workingDays, scheduledEvent)).thenReturn(secondOfNextMonth);
    when(holiday2.encloses(secondOfNextMonth.toDate())).thenReturn(true);
    when(holiday2.adjust(secondOfNextMonth, workingDays, scheduledEvent)).thenReturn(secondOfNextMonth.plusDays(1));
    DateTime adjustedDate = holidayStrategy.adjust(firstOfNextMonth);
    assertThat(adjustedDate, is(secondOfNextMonth.plusDays(1)));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 33 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class CalendarEventBuilder method build.

public CalendarEvent build() {
    List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
    List<Holiday> holidays = new ArrayList<Holiday>();
    return new CalendarEvent(workingDays, holidays);
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) ArrayList(java.util.ArrayList) CalendarEvent(org.mifos.calendar.CalendarEvent) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules)

Example 34 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class HolidayDaoHibernateIntegrationTest method nextDayRepaymentIsFutureRepaymentHoliday.

@Test
@Ignore
public void nextDayRepaymentIsFutureRepaymentHoliday() {
    DateTime secondLastDayOfYear = new DateTime().withMonthOfYear(12).withDayOfMonth(30).toDateMidnight().toDateTime();
    Holiday nextDayRepaymentHoliday = new HolidayBuilder().from(secondLastDayOfYear).to(secondLastDayOfYear).withNextMeetingRule().build();
    insertHoliday(nextDayRepaymentHoliday);
    Assert.assertTrue(holidayDao.isFutureRepaymentHoliday((short) 1, secondLastDayOfYear.toLocalDate().toString()));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 35 with Holiday

use of org.mifos.application.holiday.business.Holiday in project head by mifos.

the class HolidayDaoHibernateIntegrationTest method sameDayHolidayIsNotFutureRepaymentHoliday.

@Test
@Ignore
public void sameDayHolidayIsNotFutureRepaymentHoliday() {
    DateTime secondLastDayOfYear = new DateTime().withMonthOfYear(12).withDayOfMonth(30).toDateMidnight().toDateTime();
    Holiday sameDayRepaymentHoliday = new HolidayBuilder().from(secondLastDayOfYear).to(secondLastDayOfYear).withSameDayAsRule().build();
    insertHoliday(sameDayRepaymentHoliday);
    Assert.assertFalse(holidayDao.isFutureRepaymentHoliday((short) 1, secondLastDayOfYear.toLocalDate().toString()));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Holiday (org.mifos.application.holiday.business.Holiday)54 Test (org.junit.Test)32 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)28 DateTime (org.joda.time.DateTime)22 ArrayList (java.util.ArrayList)16 Days (org.joda.time.Days)13 FiscalCalendarRules (org.mifos.config.FiscalCalendarRules)13 LocalDate (org.joda.time.LocalDate)10 HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration (org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)9 ScheduledDateGeneration (org.mifos.schedule.ScheduledDateGeneration)8 Date (java.util.Date)7 DateMidnight (org.joda.time.DateMidnight)6 Ignore (org.junit.Ignore)6 HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)6 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)4 DateTimeService (org.mifos.framework.util.DateTimeService)4 Before (org.junit.Before)3 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3