Search in sources :

Example 31 with CenterBO

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

the class UpdateCustomerMeetingScheduleTest method givenDayOfWeekIsDifferentShouldRegenerateSchedules.

@Test
public void givenDayOfWeekIsDifferentShouldRegenerateSchedules() 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).build();
    MeetingBO weeklyWednesdayMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    weeklyWednesdayMeeting.updateDetails(userContext);
    // stubbing
    when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(new CalendarEventBuilder().build());
    // 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) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 32 with CenterBO

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canNotCreateCenterWithNameOfAlreadyExistingCenter.

@Test(expected = BusinessRuleException.class)
public void canNotCreateCenterWithNameOfAlreadyExistingCenter() throws Exception {
    // minimal details
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
    String centerName = "existingCenterName";
    OfficeBO anExistingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    DateTime aWeekFromNow = new DateTime().plusWeeks(1);
    CenterBO existingCenter = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingCenter.getCustomerMeetingValue());
    CenterBO newCenter = new CenterBuilder().withName(existingCenter.getDisplayName()).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
    // setup
    List<AccountFeesEntity> noCenterAccountFees = new ArrayList<AccountFeesEntity>();
    // exercise test
    customerService.createCenter(newCenter, newCenter.getCustomerMeetingValue(), noCenterAccountFees);
    // verification
    assertThat(existingCenter.getGlobalCustNum(), is(not(newCenter.getGlobalCustNum())));
    assertThat(existingCenter.getDisplayName(), is(newCenter.getDisplayName()));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) 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) Test(org.junit.Test)

Example 33 with CenterBO

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithAddress.

@Test
public void canCreateCenterWithAddress() throws Exception {
    // minimal details
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
    String centerName = "Center-IntegrationTest";
    OfficeBO anExistingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    DateTime aWeekFromNow = new DateTime().plusWeeks(1);
    CenterBO center = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).with(anAddress()).withUserContext().build();
    List<AccountFeesEntity> noAccountFees = new ArrayList<AccountFeesEntity>();
    // exercise test
    customerService.createCenter(center, center.getCustomerMeetingValue(), noAccountFees);
    // verification
    assertThat(center.getCustomerId(), is(notNullValue()));
    assertThat(center.getGlobalCustNum(), is(notNullValue()));
    assertThat(center.getAddress(), is(notNullValue()));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) 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) Test(org.junit.Test)

Example 34 with CenterBO

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithFeeThatMatchesMeetingPeriod.

@Test
public void canCreateCenterWithFeeThatMatchesMeetingPeriod() throws Exception {
    // minimal details
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
    String centerName = "Center-IntegrationTest";
    OfficeBO anExistingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    DateTime aWeekFromNow = new DateTime().plusWeeks(1);
    CenterBO center = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
    // setup
    AmountFeeBO existingWeeklyFee = new FeeBuilder().with(aWeeklyMeeting).appliesToCenterOnly().with(anExistingBranch).build();
    IntegrationTestObjectMother.saveFee(existingWeeklyFee);
    AccountFeesEntity accountFee = new AccountFeesEntity(null, existingWeeklyFee, existingWeeklyFee.getFeeAmount().getAmountDoubleValue());
    List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
    centerAccountFees.add(accountFee);
    // exercise test
    customerService.createCenter(center, center.getCustomerMeetingValue(), centerAccountFees);
    // verification
    assertThat(center.getCustomerId(), is(notNullValue()));
    assertThat(center.getGlobalCustNum(), is(notNullValue()));
    assertThat(center.getCustomerAccount().getAccountFees().isEmpty(), is(false));
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) 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)

Example 35 with CenterBO

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithExternalIdThatAlreadyExistsForAnotherCenter.

@Test
public void canCreateCenterWithExternalIdThatAlreadyExistsForAnotherCenter() throws Exception {
    // minimal details
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
    OfficeBO anExistingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    DateTime aWeekFromNow = new DateTime().plusWeeks(1);
    String externalId = "xxx111";
    CenterBO existingCenter = new CenterBuilder().withName("existingCenterName").withExternalId(externalId).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingCenter.getCustomerMeetingValue());
    CenterBO newCenter = new CenterBuilder().withName("newCenterName").withExternalId(externalId).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
    // setup
    List<AccountFeesEntity> noCenterAccountFees = new ArrayList<AccountFeesEntity>();
    // exercise test
    customerService.createCenter(newCenter, newCenter.getCustomerMeetingValue(), noCenterAccountFees);
    // verification
    assertThat(existingCenter.getGlobalCustNum(), is(not(newCenter.getGlobalCustNum())));
    assertThat(existingCenter.getExternalId(), is(newCenter.getExternalId()));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) 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) 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