Search in sources :

Example 41 with MeetingBuilder

use of org.mifos.domain.builders.MeetingBuilder 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 42 with MeetingBuilder

use of org.mifos.domain.builders.MeetingBuilder 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)

Example 43 with MeetingBuilder

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithMfiJoiningDateInPast.

@Test
public void canCreateCenterWithMfiJoiningDateInPast() throws Exception {
    // setup
    // minimal details
    String centerName = "Center-IntegrationTest";
    OfficeBO existingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    DateTime aWeekAgo = new DateTime().minusWeeks(1);
    CenterBO center = new CenterBuilder().withName(centerName).with(weeklyMeeting).with(existingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekAgo).withUserContext().build();
    List<AccountFeesEntity> noAccountFees = new ArrayList<AccountFeesEntity>();
    // exercise test
    customerService.createCenter(center, weeklyMeeting, noAccountFees);
    // verification
    assertThat(center.getCustomerId(), is(notNullValue()));
    assertThat(center.getGlobalCustNum(), is(notNullValue()));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) 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 44 with MeetingBuilder

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithMinimalDetails.

@Test
public void canCreateCenterWithMinimalDetails() throws Exception {
    // setup
    // minimal details
    String centerName = "Center-IntegrationTest";
    OfficeBO existingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    DateTime today = new DateTime();
    Address noAddress = null;
    String noExternalId = null;
    CenterBO center = new CenterBuilder().withName(centerName).with(weeklyMeeting).with(existingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(today).with(noAddress).withExternalId(noExternalId).withUserContext().build();
    List<AccountFeesEntity> noAccountFees = new ArrayList<AccountFeesEntity>();
    // exercise test
    customerService.createCenter(center, weeklyMeeting, noAccountFees);
    // verification
    assertThat(center.getCustomerId(), is(notNullValue()));
    assertThat(center.getGlobalCustNum(), is(notNullValue()));
    assertThat(center.getExternalId(), is(nullValue()));
    assertThat(center.getAddress(), is(nullValue()));
}
Also used : AddressBuilder.anAddress(org.mifos.domain.builders.AddressBuilder.anAddress) Address(org.mifos.framework.business.util.Address) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) 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 45 with MeetingBuilder

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

the class CenterHierarchyCustomerServiceIntegrationTest method cleanDatabaseTables.

@Before
public void cleanDatabaseTables() {
    databaseCleaner.clean();
    // setup
    String centerName = "Center-IntegrationTest";
    OfficeBO existingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    DateTime today = new DateTime();
    Address noAddress = null;
    String noExternalId = null;
    center = new CenterBuilder().withName(centerName).with(weeklyMeeting).with(existingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(today).with(noAddress).withExternalId(noExternalId).withUserContext().build();
    IntegrationTestObjectMother.createCenter(center, center.getCustomerMeetingValue());
    group = new GroupBuilder().withName("group1").withParentCustomer(center).active().formedBy(center.getPersonnel()).build();
    IntegrationTestObjectMother.createGroup(group, group.getCustomerMeetingValue());
    group2 = new GroupBuilder().withName("group2").withParentCustomer(center).active().formedBy(center.getPersonnel()).build();
    IntegrationTestObjectMother.createGroup(group2, group2.getCustomerMeetingValue());
    otherLoanOfficer = new PersonnelBuilder().withDisplayName("otherLoanOfficer").with(existingBranch).build();
    IntegrationTestObjectMother.createPersonnel(otherLoanOfficer);
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Address(org.mifos.framework.business.util.Address) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) Before(org.junit.Before)

Aggregations

MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)106 Test (org.junit.Test)74 MeetingBO (org.mifos.application.meeting.business.MeetingBO)74 CenterBuilder (org.mifos.domain.builders.CenterBuilder)73 DateTime (org.joda.time.DateTime)58 ArrayList (java.util.ArrayList)47 CenterBO (org.mifos.customers.center.business.CenterBO)43 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)38 LocalDate (org.joda.time.LocalDate)27 GroupBuilder (org.mifos.domain.builders.GroupBuilder)24 Before (org.junit.Before)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)20 FeeBuilder (org.mifos.domain.builders.FeeBuilder)20 OfficeBO (org.mifos.customers.office.business.OfficeBO)19 ClientBuilder (org.mifos.domain.builders.ClientBuilder)15 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)14 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)11 Ignore (org.junit.Ignore)10