Search in sources :

Example 61 with GroupBuilder

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

the class SavingsAccountSchedulesIntegrationTest method createCenterGroupClientHierarchy.

private void createCenterGroupClientHierarchy(MeetingBO aWeeklyMeeting) throws CustomerException {
    center = new CenterBuilder().withName("Savings Center").with(aWeeklyMeeting).with(sampleBranchOffice()).withLoanOfficer(testUser()).withActivationDate(mondayTwoWeeksAgo()).build();
    IntegrationTestObjectMother.createCenter(center, aWeeklyMeeting);
    group = new GroupBuilder().withName("Group").withMeeting(aWeeklyMeeting).withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, aWeeklyMeeting);
    client = new ClientBuilder().withName("Client 1").active().withMeeting(aWeeklyMeeting).withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, aWeeklyMeeting);
}
Also used : GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Example 62 with GroupBuilder

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

the class SavingsBOMoreIntegrationTest method cleanDatabaseTables.

@Before
public void cleanDatabaseTables() throws Exception {
    databaseCleaner.clean();
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    center = new CenterBuilder().with(weeklyMeeting).withName("Savings Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
    group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
    client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Savings Client").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, weeklyMeeting);
    String recommendedAmountString = "3.0";
    recommendedAmount = new Money(Money.getDefaultCurrency(), recommendedAmountString);
    savings = new TestCollectionSheetRetrieveSavingsAccountsUtils().createSavingsAccount(client, "clm", recommendedAmountString, false, false);
}
Also used : Money(org.mifos.framework.util.helpers.Money) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) TestCollectionSheetRetrieveSavingsAccountsUtils(org.mifos.application.servicefacade.TestCollectionSheetRetrieveSavingsAccountsUtils) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Before(org.junit.Before)

Example 63 with GroupBuilder

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

the class GroupCreationUsingCustomerServiceIntegrationTest method shouldCreateGroupAsTopOfHierarchy.

@Test
public void shouldCreateGroupAsTopOfHierarchy() throws Exception {
    // setup
    GroupBO group = new GroupBuilder().withName("group-on-top-of-hierarchy").withStatus(CustomerStatus.GROUP_ACTIVE).withLoanOfficer(existingLoanOfficer).withOffice(existingOffice).withMeeting(existingMeeting).formedBy(existingUser).isNotTrained().trainedOn(null).buildAsTopOfHierarchy();
    // exercise test
    this.customerService.createGroup(group, existingMeeting, noAccountFees);
    // verification
    assertThat(group.getDisplayName(), is("group-on-top-of-hierarchy"));
    assertThat(group.getSearchId(), is("1." + group.getCustomerId()));
    assertThat(group.getStatus(), is(CustomerStatus.GROUP_ACTIVE));
    assertThat(group.getGroupPerformanceHistory().getGroup().getCustomerId(), is(group.getCustomerId()));
    assertThat(group.getCustomFields().size(), is(0));
    assertThat(group.getMaxChildCount(), is(0));
}
Also used : GroupBuilder(org.mifos.domain.builders.GroupBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 64 with GroupBuilder

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

the class GroupPerformanceHistoryUsingCustomerServiceIntegrationTest method cleanDatabaseTables.

@Before
public void cleanDatabaseTables() throws Exception {
    databaseCleaner.clean();
    existingUser = IntegrationTestObjectMother.testUser();
    existingLoanOfficer = IntegrationTestObjectMother.testUser();
    existingOffice = IntegrationTestObjectMother.sampleBranchOffice();
    existingMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(existingMeeting);
    existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    existingGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingGroup, existingMeeting);
    existingActiveClient = new ClientBuilder().withName("activeClient").withStatus(CustomerStatus.CLIENT_ACTIVE).withParentCustomer(existingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingActiveClient, existingMeeting);
    existingOnHoldClient = new ClientBuilder().withName("onHoldClient").withStatus(CustomerStatus.CLIENT_HOLD).withParentCustomer(existingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingOnHoldClient, existingMeeting);
    existingCancelledClient = new ClientBuilder().withName("cancelledClient").withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
    DateTime startDate = new DateTime().toDateMidnight().toDateTime();
    LoanOfferingBO groupLoanProduct = new LoanProductBuilder().appliesToGroupsOnly().active().withMeeting(existingMeeting).withName("Loandsdasd").withShortName("fsad").withStartDate(startDate).withDefaultInterest(1.2).buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(groupLoanProduct);
    account1 = new LoanAccountBuilder().withLoanProduct(groupLoanProduct).withCustomer(existingGroup).withOriginalLoanAmount(400.0).build();
    IntegrationTestObjectMother.saveLoanAccount(account1);
    LoanOfferingBO clientLoanProduct = new LoanProductBuilder().appliesToClientsOnly().withGlobalProductNumber("XXX-00002").active().withMeeting(existingMeeting).withName("Loan-client").withShortName("dsvd").withStartDate(startDate).withDefaultInterest(1.2).buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(clientLoanProduct);
    account2 = new LoanAccountBuilder().withLoanProduct(clientLoanProduct).withCustomer(existingActiveClient).withOriginalLoanAmount(600.0).build();
    IntegrationTestObjectMother.saveLoanAccount(account2);
    StaticHibernateUtil.flushAndClearSession();
}
Also used : LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) GroupBuilder(org.mifos.domain.builders.GroupBuilder) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Before(org.junit.Before)

Example 65 with GroupBuilder

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

the class GroupStatusChangeIntegrationTest method givenGroupIsPendingAndContainsClientsInPartialStateThenWhenTransitioningToCancelledStateAllClientsAreTransitionedToPartial.

@Test
public void givenGroupIsPendingAndContainsClientsInPartialStateThenWhenTransitioningToCancelledStateAllClientsAreTransitionedToPartial() throws Exception {
    // setup
    CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    GroupBO existingPendingGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_PENDING).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingPendingGroup, existingMeeting);
    ClientBO existingPartialClient = new ClientBuilder().withName("partialClient").withStatus(CustomerStatus.CLIENT_PARTIAL).withParentCustomer(existingPendingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingPartialClient, existingMeeting);
    ClientBO existingPendingClient = new ClientBuilder().withName("pendingClient").withStatus(CustomerStatus.CLIENT_PENDING).withParentCustomer(existingPendingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingPendingClient, existingMeeting);
    existingPendingGroup = this.customerDao.findGroupBySystemId(existingPendingGroup.getGlobalCustNum());
    existingPendingGroup.setUserContext(TestUtils.makeUser());
    StaticHibernateUtil.startTransaction();
    existingPartialClient = this.customerDao.findClientBySystemId(existingPartialClient.getGlobalCustNum());
    existingPendingClient = this.customerDao.findClientBySystemId(existingPendingClient.getGlobalCustNum());
    CustomerStatusFlag customerStatusFlag = CustomerStatusFlag.GROUP_CANCEL_BLACKLISTED;
    CustomerNoteEntity customerNote = new CustomerNoteEntity("Made Inactive", new java.util.Date(), existingPendingGroup.getPersonnel(), existingPendingGroup);
    // exercise test
    customerService.updateGroupStatus(existingPendingGroup, existingPendingGroup.getStatus(), CustomerStatus.GROUP_CANCELLED, customerStatusFlag, customerNote);
    // verification
    assertThat(existingPendingGroup.getStatus(), is(CustomerStatus.GROUP_CANCELLED));
    assertThat(existingPendingClient.getStatus(), is(CustomerStatus.CLIENT_PENDING));
    assertThat(existingPartialClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Aggregations

GroupBuilder (org.mifos.domain.builders.GroupBuilder)67 CenterBuilder (org.mifos.domain.builders.CenterBuilder)53 Test (org.junit.Test)49 GroupBO (org.mifos.customers.group.business.GroupBO)42 CenterBO (org.mifos.customers.center.business.CenterBO)35 ClientBuilder (org.mifos.domain.builders.ClientBuilder)31 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)24 CustomerException (org.mifos.customers.exceptions.CustomerException)21 MeetingBO (org.mifos.application.meeting.business.MeetingBO)16 ClientBO (org.mifos.customers.client.business.ClientBO)14 OfficeBO (org.mifos.customers.office.business.OfficeBO)14 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)13 ArrayList (java.util.ArrayList)12 LocalDate (org.joda.time.LocalDate)11 DateTime (org.joda.time.DateTime)10 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)10 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)9 Before (org.junit.Before)8 CustomerNoteEntity (org.mifos.customers.business.CustomerNoteEntity)8 CustomerStatusFlag (org.mifos.customers.util.helpers.CustomerStatusFlag)8