Search in sources :

Example 36 with ClientBuilder

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

the class CustomerSearchIdGenerationTest method transferClientFromGroupToGroupTest.

@Test
public void transferClientFromGroupToGroupTest() throws Exception {
    final short office1_id = 2;
    final Integer group1_id = 33;
    final Integer group2_id = 22;
    final int group2_child_count = 8;
    // setup
    UserContext userContext = TestUtils.makeUser();
    OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
    PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
    GroupBO existingGroup = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).with(userContext).buildAsTopOfHierarchy();
    existingGroup = spy(existingGroup);
    when(existingGroup.getCustomerId()).thenReturn(group1_id);
    existingGroup.generateSearchId();
    ClientBO existingClient = new ClientBuilder().pendingApproval().withParentCustomer(existingGroup).withVersion(1).buildForUnitTests();
    existingGroup.addChild(existingClient);
    existingGroup.setCustomerDao(customerDao);
    GroupBO existingGroup2 = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).with(userContext).withSearchId(group2_child_count).withOffice(office1).buildAsTopOfHierarchy();
    existingGroup2.setCustomerDao(customerDao);
    existingGroup2 = spy(existingGroup2);
    when(existingGroup2.getCustomerId()).thenReturn(group2_id);
    existingGroup2.generateSearchId();
    // stubbing
    when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
    when(customerDao.findClientBySystemId("clientid")).thenReturn(existingClient);
    when(customerDao.findCustomerById(group2_id)).thenReturn(existingGroup2);
    when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(calendarEvent);
    when(configurationHelper.isLoanScheduleRepaymentIndependentOfCustomerMeetingEnabled()).thenReturn(true);
    // exercise test
    assertThat(existingGroup.getSearchId(), is("1." + group1_id));
    assertThat(existingClient.getSearchId(), is("1." + group1_id + ".1"));
    customerService.transferClientTo(userContext, group2_id, "clientid", 1);
    // verification
    assertThat(existingGroup2.getSearchId(), is("1." + group2_id));
    assertThat(existingClient.getSearchId(), is("1." + group2_id + "." + (group2_child_count + 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 37 with ClientBuilder

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

the class SavingsScheduleIntegrationTest method createClientSavingsAccount.

public void createClientSavingsAccount() throws Exception {
    meeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(expectedFirstDepositDate).build();
    IntegrationTestObjectMother.saveMeeting(meeting);
    center = new CenterBuilder().with(meeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, meeting);
    group = new GroupBuilder().withMeeting(meeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, meeting);
    client = new ClientBuilder().withMeeting(meeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, meeting);
    savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
    HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
    List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext(client.getOfficeId());
    savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).with(holidays).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) Holiday(org.mifos.application.holiday.business.Holiday) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Example 38 with ClientBuilder

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

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

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

the class ClientBoTest method testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasSuchAccountsButIsDefinedAsSameForAllLoans.

@Test
public void testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasSuchAccountsButIsDefinedAsSameForAllLoans() throws Exception {
    // Same for all loans is the default in the LoanProductBuilder
    // setup
    client = new ClientBuilder().active().buildForUnitTests();
    LoanOfferingBO loanProduct = new LoanProductBuilder().active().buildForUnitTests();
    client.addAccount(loanAccount);
    // stubbing
    when(loanAccount.isActiveLoanAccount()).thenReturn(true);
    when(loanAccount.getLoanOffering()).thenReturn(loanProduct);
    // exercise
    boolean isDisbursalPrevented = client.isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct);
    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)

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