Search in sources :

Example 91 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class GroupTransferToCenterTest method transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold.

@Test
public void transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold() throws Exception {
    // setup
    OfficeBO fromBranch = new OfficeBuilder().branchOffice().withName("fromBranch").withGlobalOfficeNum("xxx1").build();
    CenterBO fromCenter = new CenterBuilder().withName("fromCenter").with(fromBranch).build();
    GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
    OfficeBO receivingBranch = new OfficeBuilder().branchOffice().withName("receivingBranch").withGlobalOfficeNum("xxx2").build();
    CenterBO receivingCenter = new CenterBuilder().withName("receivingCenter").with(receivingBranch).build();
    // exercise test
    groupForTransfer.transferTo(receivingCenter);
    // verification
    assertThat(groupForTransfer.getStatus().isGroupActive(), is(false));
    assertThat(groupForTransfer.getStatus().isGroupOnHold(), is(true));
    assertThat(groupForTransfer.countOfCustomerMovements(), is(2));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 92 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class GroupTransferToOfficeServiceTest method givenOfficeIsSameAsGroupsOfficeGroupTransferToBranchShouldFailValidation.

@Test
public void givenOfficeIsSameAsGroupsOfficeGroupTransferToBranchShouldFailValidation() {
    // setup
    OfficeBO office = new OfficeBuilder().build();
    CenterBO parent = new CenterBuilder().with(office).build();
    GroupBO group = new GroupBuilder().withParentCustomer(parent).build();
    // exercise test
    try {
        customerService.transferGroupTo(group, office);
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SAME_BRANCH_TRANSFER));
    }
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 93 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class CustomerAccountBOIntegrationTest method createInitialObjects.

private void createInitialObjects() {
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    center = new CenterBuilder().withNumberOfExistingCustomersInOffice(3).with(weeklyMeeting).withName("Center_Active_test").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter((CenterBO) center, weeklyMeeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_ACTIVE, center);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder)

Example 94 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class CustomerAccountCreationTest method firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency.

@Test
public void firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency() throws Exception {
    // setup
    applicableCalendarEvents = new CalendarEventBuilder().build();
    DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
    accountFees = new ArrayList<AccountFeesEntity>();
    MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(2).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
    // exercise test
    CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
    // verification
    List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
    LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
    LocalDate mon18thOfMay = new DateTime().withDate(2011, 5, 18).toLocalDate();
    assertThat(firstCenterDate, is(mon18thOfMay));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) 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) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 95 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class CustomerAccountCreationTest method customerAccountCanBeCreatedWithNoAccountFees.

@Test
public void customerAccountCanBeCreatedWithNoAccountFees() throws Exception {
    // setup
    accountFees = new ArrayList<AccountFeesEntity>();
    customer = new CenterBuilder().inActive().build();
    // exercise test
    customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, applicableCalendarEvents);
    // verification
    assertThat(customerAccount.getAccountFees().isEmpty(), is(true));
}
Also used : CenterBuilder(org.mifos.domain.builders.CenterBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Aggregations

CenterBuilder (org.mifos.domain.builders.CenterBuilder)123 Test (org.junit.Test)98 CenterBO (org.mifos.customers.center.business.CenterBO)82 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)73 MeetingBO (org.mifos.application.meeting.business.MeetingBO)54 GroupBuilder (org.mifos.domain.builders.GroupBuilder)53 DateTime (org.joda.time.DateTime)52 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)46 ArrayList (java.util.ArrayList)42 GroupBO (org.mifos.customers.group.business.GroupBO)36 ClientBuilder (org.mifos.domain.builders.ClientBuilder)30 OfficeBO (org.mifos.customers.office.business.OfficeBO)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)19 CustomerException (org.mifos.customers.exceptions.CustomerException)18 FeeBuilder (org.mifos.domain.builders.FeeBuilder)18 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)17 LocalDate (org.joda.time.LocalDate)14 Before (org.junit.Before)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 ClientBO (org.mifos.customers.client.business.ClientBO)13