Search in sources :

Example 76 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetChildernOtherThanClosed.

@Test
public void testGetChildernOtherThanClosed() throws Exception {
    CustomerPersistence customerPersistence = new CustomerPersistence();
    center = createCenter();
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
    client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
    ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group);
    ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_PENDING, group);
    List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice().getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CLOSED);
    Assert.assertEquals(new Integer("3").intValue(), customerList.size());
    for (CustomerBO customer : customerList) {
        if (customer.getCustomerId().intValue() == client3.getCustomerId().intValue()) {
            Assert.assertTrue(true);
        }
    }
//        TestObjectFactory.cleanUp(client2);
//        TestObjectFactory.cleanUp(client3);
//        TestObjectFactory.cleanUp(client4);
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) Test(org.junit.Test)

Example 77 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class ClientServiceFacadeWebTierIntegrationTest method shouldCreateGroupWithExpectedSearchId.

@Test
public void shouldCreateGroupWithExpectedSearchId() {
    // setup
    boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
    MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
    MeetingDto meetingDto = meeting.toDto();
    String externalId = null;
    AddressDto addressDto = new AddressDto("here", "", "", "", "", "", "", "");
    PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
    Short loanOfficerId = user.getPersonnelId();
    List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>();
    CustomerStatus.CLIENT_ACTIVE.getValue();
    boolean trained = false;
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    // setup
    createOfficeHierarchyUnderHeadOffice(headOffice);
    Short officeId = branch1.getOfficeId();
    DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
    DateTime activationDate = new DateTime().minusWeeks(1);
    List<Short> selectedSavingProducts = new ArrayList<Short>();
    String clientName = "client";
    Short formedBy = loanOfficerId;
    Date dateOfBirth = new LocalDate(1990, 1, 1).toDateMidnight().toDate();
    String governmentId = "";
    Date trainedDate = new LocalDate(2000, 1, 1).toDateMidnight().toDate();
    ;
    // not in a group
    Short groupFlag = YesNoFlag.NO.getValue();
    Integer salutation = 1;
    String firstName = "first";
    String middleName = null;
    String lastName = "last";
    String secondLastName = null;
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), salutation, firstName, middleName, lastName, secondLastName);
    // magic numbers from default data
    Integer ethnicity = 218;
    Integer citizenship = 130;
    Integer handicapped = 138;
    Integer businessActivities = 225;
    Integer educationLevel = 226;
    Short numChildren = 0;
    Short gender = 49;
    Short povertyStatus = 41;
    Integer maritalStatus = ClientPersonalDetailDto.MARRIED;
    // active
    Short clientStatus = 3;
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(ethnicity, citizenship, handicapped, businessActivities, maritalStatus, educationLevel, numChildren, gender, povertyStatus);
    ClientNameDetailDto spouseFatherName = new ClientNameDetailDto(NameType.SPOUSE.getValue(), salutation, firstName, middleName, lastName, secondLastName);
    InputStream picture = null;
    String parentGroupId = null;
    List<ClientNameDetailDto> familyNames = null;
    List<ClientFamilyDetailDto> familyDetails = null;
    ClientCreationDetail clientCreationDetail = new ClientCreationDetail(selectedSavingProducts, clientName, clientStatus, mfiJoiningDate.toDate(), externalId, addressDto, formedBy, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientNameDetailDto, clientPersonalDetailDto, spouseFatherName, picture, feesToApply, parentGroupId, familyNames, familyDetails, loanOfficerId, officeId, activationDate.toLocalDate());
    // exercise test
    ClientRules.setCenterHierarchyExists(false);
    List<SavingsDetailDto> allowedSavingProducts = new ArrayList<SavingsDetailDto>();
    CustomerDetailsDto newlyCreatedCustomerDetails = clientServiceFacade.createNewClient(clientCreationDetail, meetingDto, allowedSavingProducts);
    // verification
    ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
    ClientBO client = customerDao.findClientBySystemId(newlyCreatedCustomerDetails.getGlobalCustNum());
    Assert.assertThat(client.getSearchId(), is("1." + client.getCustomerId()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) ClientCreationDetail(org.mifos.dto.domain.ClientCreationDetail) ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) InputStream(java.io.InputStream) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) AddressDto(org.mifos.dto.domain.AddressDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) MeetingDto(org.mifos.dto.domain.MeetingDto) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Test(org.junit.Test)

Example 78 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class ClientCustActionStrutsTest method createAndSetClientInSession.

private void createAndSetClientInSession() throws Exception {
    OfficeBO office = new OfficePersistence().getOffice(TestObjectFactory.HEAD_OFFICE);
    PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER);
    meeting = getMeeting();
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), 1, "Client", "", "1", "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), 1, "first", "middle", "last", "secondLast");
    spouseNameDetailView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
    Calendar dob = new GregorianCalendar();
    dob.set(Calendar.YEAR, 1970);
    client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, new Address(), getCustomFields(), null, null, personnel, office, meeting, personnel, dob.getTime(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushAndClearSession();
    client = TestObjectFactory.getClient(Integer.valueOf(client.getCustomerId()).intValue());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
}
Also used : Address(org.mifos.framework.business.util.Address) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) ClientBO(org.mifos.customers.client.business.ClientBO) GregorianCalendar(java.util.GregorianCalendar) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence)

Example 79 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testRetrieveAllLoanAccountUnderCustomer.

@Test
public void testRetrieveAllLoanAccountUnderCustomer() throws PersistenceException {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = createCenter("center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    CenterBO center1 = createCenter("center1");
    GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
    client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
    ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_ACTIVE, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_ACTIVE, group1);
    account = getLoanAccount(group, meeting, "cdfggdfs", "1qdd");
    AccountBO account1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg");
    AccountBO account2 = getLoanAccount(client2, meeting, "fasdfdsfasdf", "1qwe");
    AccountBO account3 = getLoanAccount(client3, meeting, "fdsgdfgfd", "543g");
    AccountBO account4 = getLoanAccount(group1, meeting, "fasdf23", "3fds");
    CustomerBOTestUtils.setCustomerStatus(client2, new CustomerStatusEntity(CustomerStatus.CLIENT_CLOSED));
    TestObjectFactory.updateObject(client2);
    client2 = TestObjectFactory.getClient(client2.getCustomerId());
    CustomerBOTestUtils.setCustomerStatus(client3, new CustomerStatusEntity(CustomerStatus.CLIENT_CANCELLED));
    TestObjectFactory.updateObject(client3);
    client3 = TestObjectFactory.getClient(client3.getCustomerId());
    List<AccountBO> loansForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
    Assert.assertEquals(3, loansForCenter.size());
    List<AccountBO> loansForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
    Assert.assertEquals(3, loansForGroup.size());
    List<AccountBO> loansForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
    Assert.assertEquals(1, loansForClient.size());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) Test(org.junit.Test)

Example 80 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetAllChildrenForParent.

@Test
public void testGetAllChildrenForParent() throws NumberFormatException, PersistenceException {
    center = createCenter("Center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    CenterBO center1 = createCenter("center11");
    GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
    client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
    ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
    List<CustomerBO> customerList1 = customerPersistence.getAllChildrenForParent(center.getSearchId(), Short.valueOf("3"), CustomerLevel.CENTER.getValue());
    Assert.assertEquals(2, customerList1.size());
    List<CustomerBO> customerList2 = customerPersistence.getAllChildrenForParent(center.getSearchId(), Short.valueOf("3"), CustomerLevel.GROUP.getValue());
    Assert.assertEquals(1, customerList2.size());
    //        TestObjectFactory.cleanUp(client3);
    //        TestObjectFactory.cleanUp(client2);
    group1 = null;
    center1 = null;
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerBO(org.mifos.customers.business.CustomerBO) Test(org.junit.Test)

Aggregations

ClientBO (org.mifos.customers.client.business.ClientBO)93 ArrayList (java.util.ArrayList)27 Test (org.junit.Test)27 CustomerException (org.mifos.customers.exceptions.CustomerException)25 CustomerBO (org.mifos.customers.business.CustomerBO)23 GroupBO (org.mifos.customers.group.business.GroupBO)22 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)22 UserContext (org.mifos.security.util.UserContext)21 MifosRuntimeException (org.mifos.core.MifosRuntimeException)19 CenterBO (org.mifos.customers.center.business.CenterBO)19 BusinessRuleException (org.mifos.service.BusinessRuleException)17 ClientBuilder (org.mifos.domain.builders.ClientBuilder)16 PersistenceException (org.mifos.framework.exceptions.PersistenceException)16 OfficeBO (org.mifos.customers.office.business.OfficeBO)14 GroupBuilder (org.mifos.domain.builders.GroupBuilder)14 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)14 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)14 Date (java.util.Date)13 DateTime (org.joda.time.DateTime)13 AccountException (org.mifos.accounts.exceptions.AccountException)13