Search in sources :

Example 16 with ClientBuilder

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

the class ClientBoTest method testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductDoesNotFetchLoanOfferingIfNoActiveLoanAccounts.

@Test
public void testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductDoesNotFetchLoanOfferingIfNoActiveLoanAccounts() throws Exception {
    // setup
    client = new ClientBuilder().active().buildForUnitTests();
    LoanOfferingBO loanProduct1 = new LoanProductBuilder().withGlobalProductNumber("xxxx-111").withoutLoanAmountSameForAllLoans().buildForUnitTests();
    client.addAccount(loanAccount);
    // stubbing
    when(loanAccount.isActiveLoanAccount()).thenReturn(false);
    // exercise
    boolean isDisbursalPrevented = client.isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct1);
    assertThat(isDisbursalPrevented, is(false));
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 17 with ClientBuilder

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

the class ClientBoTest method testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasNoSuchAccountsForThatProduct.

@Test
public void testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasNoSuchAccountsForThatProduct() throws Exception {
    // setup
    client = new ClientBuilder().active().buildForUnitTests();
    LoanOfferingBO loanProduct1 = new LoanProductBuilder().withGlobalProductNumber("xxxx-111").withoutLoanAmountSameForAllLoans().buildForUnitTests();
    LoanOfferingBO loanProduct2 = new LoanProductBuilder().withGlobalProductNumber("xxxx-222").buildForUnitTests();
    client.addAccount(loanAccount);
    // stubbing
    when(loanAccount.isActiveLoanAccount()).thenReturn(true);
    when(loanAccount.getLoanOffering()).thenReturn(loanProduct2);
    // exercise
    boolean isDisbursalPrevented = client.isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct1);
    assertThat(isDisbursalPrevented, is(false));
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 18 with ClientBuilder

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

the class CustomerSearchIdGenerationTest method transferClientFromOfficeToOfficeTest.

@Test
public void transferClientFromOfficeToOfficeTest() throws Exception {
    final short office1_id = 2;
    // setup
    OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
    PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
    ClientBO existingClient = new ClientBuilder().pendingApproval().withNoParent().withLoanOfficer(loanOfficer).buildForUnitTests();
    existingClient.setCustomerDao(customerDao);
    existingClient = spy(existingClient);
    int customer_id = 22;
    when(existingClient.getCustomerId()).thenReturn(customer_id);
    existingClient.generateSearchId();
    UserContext userContext = TestUtils.makeUser();
    existingClient.setUserContext(userContext);
    // stubbing
    when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
    // exercise test
    assertThat(existingClient.getSearchId(), is("1." + customer_id));
    customerService.transferClientTo(existingClient, office1);
    // verification
    assertThat(existingClient.getSearchId(), is("1." + customer_id));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 19 with ClientBuilder

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

the class CustomerSearchIdGenerationTest method transferGroupFromOfficeToOfficeTest.

@Test
public void transferGroupFromOfficeToOfficeTest() throws Exception {
    final short office1_id = 2;
    // setup
    OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
    PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
    GroupBO existingGroup = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).buildAsTopOfHierarchy();
    existingGroup = spy(existingGroup);
    int customer_id = 22;
    when(existingGroup.getCustomerId()).thenReturn(customer_id);
    existingGroup.generateSearchId();
    ClientBO existingClient = new ClientBuilder().pendingApproval().withParentCustomer(existingGroup).buildForUnitTests();
    existingGroup.addChild(existingClient);
    existingGroup.setCustomerDao(customerDao);
    UserContext userContext = TestUtils.makeUser();
    existingGroup.setUserContext(userContext);
    // stubbing
    when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
    // exercise test
    assertThat(existingGroup.getSearchId(), is("1." + customer_id));
    assertThat(existingClient.getSearchId(), is("1." + customer_id + ".1"));
    customerService.transferGroupTo(existingGroup, office1);
    // verification
    assertThat(existingGroup.getSearchId(), is("1." + customer_id));
    assertThat(existingClient.getSearchId(), is("1." + customer_id + ".1"));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 20 with ClientBuilder

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

the class TestCollectionSheetRetrieveSavingsAccountsUtils method createSampleCenterHierarchy.

/**
     * By default generates 1 center with a mandatory savings account (center savings accounts are always
     * PER_INDIVIDUAL)
     *
     * 1 group with a voluntary COMPLETE_GROUP savings account
     *
     * 1 client with a mandatory savings account
     *
     * 1 group with a mandatory PER_INDIVIDUAL savings account
     *
     * 1 client with a voluntary savings account
     */
public void createSampleCenterHierarchy() throws Exception {
    // TODO - correct clientBuilder so that when there are "PER_INDIVIDUAL" savings accounts relevant to it... a
    // saving schedule is created.
    //
    // As a work-around for this problem... the two "PER_INDIVIDUAL" savings accounts (centerSavingsAccount and
    // groupPerIndividualSavingsAccount) are created last... this kicks of a process that creates schedules for all
    // the relevant clients.
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    center = new CenterBuilder().withNumberOfExistingCustomersInOffice(3).with(weeklyMeeting).withName("Savings Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
    if (!onlyCreateCenterAndItsSavingsAccount) {
        groupCompleteGroup = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group Complete Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
        IntegrationTestObjectMother.createGroup(groupCompleteGroup, weeklyMeeting);
        groupCompleteGroupSavingsAccount = createSavingsAccount(groupCompleteGroup, "gvcg", "2.0", true, false);
        MeetingBO weeklyClientMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
        groupCompleteGroup.setMeeting(weeklyClientMeeting);
        clientOfGroupCompleteGroup = new ClientBuilder().withSearchId(center.getSearchId() + ".1.1").withMeeting(weeklyClientMeeting).withName("Savings Client Of Group Complete Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(groupCompleteGroup).buildForIntegrationTests();
        IntegrationTestObjectMother.createClient(clientOfGroupCompleteGroup, weeklyClientMeeting);
        clientOfGroupCompleteGroupSavingsAccount = createSavingsAccount(clientOfGroupCompleteGroup, "clm", "3.0", false, false);
        groupPerIndividual = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group Per Individual").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
        IntegrationTestObjectMother.createGroup(groupPerIndividual, weeklyMeeting);
        clientOfGroupPerIndividual = new ClientBuilder().withSearchId(center.getSearchId() + ".2.1").withMeeting(weeklyMeeting).withName("Savings Client Of Group Per Individual").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(groupPerIndividual).buildForIntegrationTests();
        IntegrationTestObjectMother.createClient(clientOfGroupPerIndividual, weeklyMeeting);
        clientOfGroupPerIndividualSavingsAccount = createSavingsAccount(clientOfGroupPerIndividual, "clv", "5.0", true, false);
        groupPerIndividualSavingsAccount = createSavingsAccount(groupPerIndividual, "gmi", "4.0", false, true);
    }
    centerSavingsAccount = createSavingsAccount(center, "cemi", "1.0", false, false);
}
Also used : 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) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Aggregations

ClientBuilder (org.mifos.domain.builders.ClientBuilder)45 GroupBuilder (org.mifos.domain.builders.GroupBuilder)31 CenterBuilder (org.mifos.domain.builders.CenterBuilder)30 Test (org.junit.Test)26 ClientBO (org.mifos.customers.client.business.ClientBO)16 GroupBO (org.mifos.customers.group.business.GroupBO)15 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)15 CenterBO (org.mifos.customers.center.business.CenterBO)13 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 Before (org.junit.Before)10 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)8 MeetingBO (org.mifos.application.meeting.business.MeetingBO)8 CustomerNoteEntity (org.mifos.customers.business.CustomerNoteEntity)8 CustomerStatusFlag (org.mifos.customers.util.helpers.CustomerStatusFlag)8 CustomerException (org.mifos.customers.exceptions.CustomerException)7 LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)7 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)7 Date (java.util.Date)6 OfficeBO (org.mifos.customers.office.business.OfficeBO)6 Money (org.mifos.framework.util.helpers.Money)6