Search in sources :

Example 26 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CustomerAccountCreationTest method givenTriWeeklyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent.

@Test
public void givenTriWeeklyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent() throws Exception {
    // setup
    applicableCalendarEvents = new CalendarEventBuilder().build();
    DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
    DateTime tue26thOfApril = new DateTime().withDate(2011, 4, 26);
    accountFees = new ArrayList<AccountFeesEntity>();
    MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().weekly().every(3).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).build();
    MeetingBO groupMeeting = new MeetingBuilder().customerMeeting().weekly().every(3).occuringOnA(WeekDay.MONDAY).startingFrom(tue26thOfApril.minusDays(1).toDate()).build();
    CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
    GroupBO group = new GroupBuilder().active().withParentCustomer(center).withActivationDate(tue26thOfApril).withMeeting(groupMeeting).build();
    // exercise test
    CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
    CustomerAccountBO groupAccount = CustomerAccountBO.createNew(group, accountFees, groupMeeting, applicableCalendarEvents);
    // verification
    List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
    List<AccountActionDateEntity> groupSchedules = new ArrayList<AccountActionDateEntity>(groupAccount.getAccountActionDates());
    LocalDate secondCenterDate = new LocalDate(centerSchedules.get(1).getActionDate());
    LocalDate thirdCenterDate = new LocalDate(centerSchedules.get(2).getActionDate());
    LocalDate firstGroupDate = new LocalDate(groupSchedules.get(0).getActionDate());
    LocalDate secondGroupDate = new LocalDate(groupSchedules.get(1).getActionDate());
    assertThat(firstGroupDate, is(secondCenterDate));
    assertThat(secondGroupDate, is(thirdCenterDate));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) DateTime(org.joda.time.DateTime) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) GroupBO(org.mifos.customers.group.business.GroupBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 27 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CustomerAccountCreationTest method givenMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent.

@Test
public void givenMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent() throws Exception {
    // setup
    applicableCalendarEvents = new CalendarEventBuilder().build();
    DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
    DateTime tue26thOfApril = new DateTime().withDate(2011, 4, 26);
    accountFees = new ArrayList<AccountFeesEntity>();
    MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(1).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    MeetingBO groupMeeting = new MeetingBuilder().customerMeeting().monthly().every(1).occuringOnA(WeekDay.MONDAY).startingFrom(tue26thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
    GroupBO group = new GroupBuilder().active().withParentCustomer(center).withActivationDate(tue26thOfApril).withMeeting(groupMeeting).build();
    // exercise test
    CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
    CustomerAccountBO groupAccount = CustomerAccountBO.createNew(group, accountFees, groupMeeting, applicableCalendarEvents);
    // verification
    List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
    List<AccountActionDateEntity> groupSchedules = new ArrayList<AccountActionDateEntity>(groupAccount.getAccountActionDates());
    LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
    LocalDate secondCenterDate = new LocalDate(centerSchedules.get(1).getActionDate());
    LocalDate firstGroupDate = new LocalDate(groupSchedules.get(0).getActionDate());
    LocalDate secondGroupDate = new LocalDate(groupSchedules.get(1).getActionDate());
    assertThat(firstGroupDate, is(firstCenterDate));
    assertThat(secondGroupDate, is(secondCenterDate));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) DateTime(org.joda.time.DateTime) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) GroupBO(org.mifos.customers.group.business.GroupBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 28 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CustomerAccountCreationTest method givenBiMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent.

@Test
public void givenBiMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent() throws Exception {
    // setup
    applicableCalendarEvents = new CalendarEventBuilder().build();
    DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
    DateTime tue26thOfApril = new DateTime().withDate(2011, 4, 26);
    accountFees = new ArrayList<AccountFeesEntity>();
    MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(2).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    MeetingBO groupMeeting = new MeetingBuilder().customerMeeting().monthly().every(2).occuringOnA(WeekDay.MONDAY).startingFrom(tue26thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
    GroupBO group = new GroupBuilder().active().withParentCustomer(center).withActivationDate(tue26thOfApril).withMeeting(groupMeeting).build();
    // exercise test
    CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
    CustomerAccountBO groupAccount = CustomerAccountBO.createNew(group, accountFees, groupMeeting, applicableCalendarEvents);
    // verification
    List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
    List<AccountActionDateEntity> groupSchedules = new ArrayList<AccountActionDateEntity>(groupAccount.getAccountActionDates());
    LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
    LocalDate secondCenterDate = new LocalDate(centerSchedules.get(1).getActionDate());
    LocalDate firstGroupDate = new LocalDate(groupSchedules.get(0).getActionDate());
    LocalDate secondGroupDate = new LocalDate(groupSchedules.get(1).getActionDate());
    assertThat(firstGroupDate, is(firstCenterDate));
    assertThat(secondGroupDate, is(secondCenterDate));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) DateTime(org.joda.time.DateTime) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) GroupBO(org.mifos.customers.group.business.GroupBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 29 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CustomerAccountCreationTest method givenTriMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent.

@Test
public void givenTriMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent() throws Exception {
    // setup
    applicableCalendarEvents = new CalendarEventBuilder().build();
    DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
    DateTime tue26thOfApril = new DateTime().withDate(2011, 4, 26);
    accountFees = new ArrayList<AccountFeesEntity>();
    MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(3).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    MeetingBO groupMeeting = new MeetingBuilder().customerMeeting().monthly().every(3).occuringOnA(WeekDay.MONDAY).startingFrom(tue26thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
    GroupBO group = new GroupBuilder().active().withParentCustomer(center).withActivationDate(tue26thOfApril).withMeeting(groupMeeting).build();
    // exercise test
    CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
    CustomerAccountBO groupAccount = CustomerAccountBO.createNew(group, accountFees, groupMeeting, applicableCalendarEvents);
    // verification
    List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
    List<AccountActionDateEntity> groupSchedules = new ArrayList<AccountActionDateEntity>(groupAccount.getAccountActionDates());
    LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
    LocalDate secondCenterDate = new LocalDate(centerSchedules.get(1).getActionDate());
    LocalDate firstGroupDate = new LocalDate(groupSchedules.get(0).getActionDate());
    LocalDate secondGroupDate = new LocalDate(groupSchedules.get(1).getActionDate());
    assertThat(firstGroupDate, is(firstCenterDate));
    assertThat(secondGroupDate, is(secondCenterDate));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) DateTime(org.joda.time.DateTime) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) GroupBO(org.mifos.customers.group.business.GroupBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 30 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CenterValidationTest method cannotCreateCenterWithFeeThatHasDifferentPeriod.

@Test
public void cannotCreateCenterWithFeeThatHasDifferentPeriod() {
    // setup
    DateTime today = new DateTime();
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly();
    CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(aWeeklyMeeting).withMfiJoiningDate(today).build();
    MeetingBuilder aMonthlyMeeting = new MeetingBuilder().periodicFeeMeeting().monthly();
    AmountFeeBO montlyPeriodicFee = new FeeBuilder().appliesToCenterOnly().with(aMonthlyMeeting).build();
    AccountFeesEntity accountFee = new AccountFeesEntity(null, montlyPeriodicFee, montlyPeriodicFee.getFeeAmount().getAmountDoubleValue());
    List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
    centerAccountFees.add(accountFee);
    // exercise test
    try {
        center.validateMeetingAndFees(centerAccountFees);
        fail("cannotCreateCenterWithFeeThatHasDifferentPeriod");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH));
    }
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTime(org.joda.time.DateTime) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Aggregations

CenterBO (org.mifos.customers.center.business.CenterBO)117 Test (org.junit.Test)91 CenterBuilder (org.mifos.domain.builders.CenterBuilder)82 DateTime (org.joda.time.DateTime)47 MeetingBO (org.mifos.application.meeting.business.MeetingBO)46 GroupBO (org.mifos.customers.group.business.GroupBO)45 ArrayList (java.util.ArrayList)43 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)43 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)39 GroupBuilder (org.mifos.domain.builders.GroupBuilder)35 CustomerException (org.mifos.customers.exceptions.CustomerException)22 OfficeBO (org.mifos.customers.office.business.OfficeBO)21 ClientBO (org.mifos.customers.client.business.ClientBO)19 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)19 UserContext (org.mifos.security.util.UserContext)18 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)15 ClientBuilder (org.mifos.domain.builders.ClientBuilder)13 LocalDate (org.joda.time.LocalDate)12 Ignore (org.junit.Ignore)12 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)12