Search in sources :

Example 16 with CalendarEvent

use of org.mifos.calendar.CalendarEvent 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 17 with CalendarEvent

use of org.mifos.calendar.CalendarEvent in project head by mifos.

the class UpdateCustomerMeetingScheduleTest method givenLsimIsEnabledShouldNotRegenerateSchedulesForLoanAccountsButShouldRegenerateSchedulesForCustomerAndSavingsAccounts.

@Test
public void givenLsimIsEnabledShouldNotRegenerateSchedulesForLoanAccountsButShouldRegenerateSchedulesForCustomerAndSavingsAccounts() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    DateTime mondayTwoWeeksAgo = new DateTime().withDayOfWeek(DayOfWeek.monday()).minusWeeks(2);
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(mondayTwoWeeksAgo).build();
    weeklyMeeting.updateDetails(userContext);
    CustomerAccountBuilder accountBuilder = new CustomerAccountBuilder();
    CenterBO center = new CenterBuilder().active().with(weeklyMeeting).withAccount(accountBuilder).withAccount(this.loanAccount).build();
    MeetingBO weeklyWednesdayMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    weeklyWednesdayMeeting.updateDetails(userContext);
    // stubbing
    CalendarEvent calendarEvent = new CalendarEventBuilder().build();
    when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(calendarEvent);
    when(configurationHelper.isLoanScheduleRepaymentIndependentOfCustomerMeetingEnabled()).thenReturn(true);
    // pre - verification
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.MONDAY);
    // exercise test
    customerService.updateCustomerMeetingSchedule(weeklyWednesdayMeeting, center);
    // verification
    assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(center, WeekDay.MONDAY);
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.WEDNESDAY);
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerAccountBuilder(org.mifos.domain.builders.CustomerAccountBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CalendarEvent(org.mifos.calendar.CalendarEvent) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 18 with CalendarEvent

use of org.mifos.calendar.CalendarEvent in project head by mifos.

the class GroupCreationTest method createsGroupWithCustomerAccount.

@Test
public void createsGroupWithCustomerAccount() throws Exception {
    // setup
    OfficeBO withOffice = new OfficeBO(new Short("1"), "testOffice", new Integer("1"), new Short("1"));
    CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).with(withOffice).build();
    GroupBO stubbedGroup = new GroupBuilder().withName("group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    // stub
    CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
    when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
    when(customerAccountFactory.create(stubbedGroup, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
    when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
    // exercise test
    customerService.createGroup(stubbedGroup, meeting, accountFees);
    // verification
    assertThat(stubbedGroup.getCustomerAccount(), is(customerAccount));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) CalendarEvent(org.mifos.calendar.CalendarEvent) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Matchers.anyShort(org.mockito.Matchers.anyShort) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Aggregations

CalendarEvent (org.mifos.calendar.CalendarEvent)18 AccountException (org.mifos.accounts.exceptions.AccountException)9 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 CustomerException (org.mifos.customers.exceptions.CustomerException)8 ArrayList (java.util.ArrayList)7 CustomerBO (org.mifos.customers.business.CustomerBO)7 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 BusinessRuleException (org.mifos.service.BusinessRuleException)7 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)6 DateTime (org.joda.time.DateTime)5 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)5 ClientBO (org.mifos.customers.client.business.ClientBO)5 LocalDate (org.joda.time.LocalDate)4 Test (org.junit.Test)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)4 MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)4 CenterBO (org.mifos.customers.center.business.CenterBO)4 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)4 CenterBuilder (org.mifos.domain.builders.CenterBuilder)4