Search in sources :

Example 51 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 52 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 53 with Holiday

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

the class SavingsScheduleIntegrationTest method createClientSavingsAccount.

public void createClientSavingsAccount() throws Exception {
    meeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(expectedFirstDepositDate).build();
    IntegrationTestObjectMother.saveMeeting(meeting);
    center = new CenterBuilder().with(meeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, meeting);
    group = new GroupBuilder().withMeeting(meeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, meeting);
    client = new ClientBuilder().withMeeting(meeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, meeting);
    savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
    HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
    List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext(client.getOfficeId());
    savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).with(holidays).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) Holiday(org.mifos.application.holiday.business.Holiday) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Example 54 with Holiday

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

the class SavingsBOIntegrationTest method testGenerateMeetingForNextYear.

@Test
public void testGenerateMeetingForNextYear() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("center1", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    SavingsTestHelper SavingsTestHelper = new SavingsTestHelper();
    SavingsOfferingBO savingsOfferingBO = SavingsTestHelper.createSavingsOffering("dfasdasd1", "sad1");
    savingsOfferingBO.setRecommendedAmntUnit(RecommendedAmountUnit.COMPLETE_GROUP);
    SavingsBO savingsBO = SavingsTestHelper.createSavingsAccount(savingsOfferingBO, group, AccountState.SAVINGS_ACTIVE, TestUtils.makeUser());
    Short LastInstallmentId = savingsBO.getLastInstallmentId();
    AccountActionDateEntity lastYearLastInstallment = savingsBO.getAccountActionDate(LastInstallmentId);
    Integer installmetId = lastYearLastInstallment.getInstallmentId().intValue() + (short) 1;
    List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
    List<Holiday> holidays = new ArrayList<Holiday>();
    savingsBO.generateNextSetOfMeetingDates(workingDays, holidays);
    TestObjectFactory.updateObject(savingsBO);
    TestObjectFactory.updateObject(center);
    TestObjectFactory.updateObject(group);
    TestObjectFactory.updateObject(savingsBO);
    center = (CustomerBO) StaticHibernateUtil.getSessionTL().get(CustomerBO.class, center.getCustomerId());
    group = (CustomerBO) StaticHibernateUtil.getSessionTL().get(CustomerBO.class, group.getCustomerId());
    savingsBO = (SavingsBO) StaticHibernateUtil.getSessionTL().get(SavingsBO.class, savingsBO.getAccountId());
    MeetingBO meetingBO = center.getCustomerMeeting().getMeeting();
    meetingBO.setMeetingStartDate(lastYearLastInstallment.getActionDate());
    List<Date> meetingDates = TestObjectFactory.getMeetingDates(group.getOfficeId(), meetingBO, 10);
    meetingDates.remove(0);
    Date FirstSavingInstallmetDate = savingsBO.getAccountActionDate(installmetId.shortValue()).getActionDate();
    Calendar calendar2 = Calendar.getInstance();
    calendar2.setTime(meetingDates.get(0));
    Calendar calendar3 = Calendar.getInstance();
    calendar3.setTime(FirstSavingInstallmetDate);
    Assert.assertEquals(0, new GregorianCalendar(calendar3.get(Calendar.YEAR), calendar3.get(Calendar.MONTH), calendar3.get(Calendar.DATE), 0, 0, 0).compareTo(new GregorianCalendar(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DATE), 0, 0, 0)));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) GregorianCalendar(java.util.GregorianCalendar) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Date(java.util.Date) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules) 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