Search in sources :

Example 36 with ClientBO

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

the class CustomerPersistenceIntegrationTest method testRetrieveAllSavingsAccountUnderCustomer.

@Test
public void testRetrieveAllSavingsAccountUnderCustomer() throws Exception {
    center = createCenter("new_center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    CenterBO center1 = createCenter("new_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_CLOSED, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
    account = getSavingsAccount(center, "Savings Prd1", "Abc1");
    AccountBO account1 = getSavingsAccount(client, "Savings Prd2", "Abc2");
    AccountBO account2 = getSavingsAccount(client2, "Savings Prd3", "Abc3");
    AccountBO account3 = getSavingsAccount(client3, "Savings Prd4", "Abc4");
    AccountBO account4 = getSavingsAccount(group1, "Savings Prd5", "Abc5");
    AccountBO account5 = getSavingsAccount(group, "Savings Prd6", "Abc6");
    AccountBO account6 = getSavingsAccount(center1, "Savings Prd7", "Abc7");
    List<AccountBO> savingsForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
    Assert.assertEquals(4, savingsForCenter.size());
    List<AccountBO> savingsForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
    Assert.assertEquals(3, savingsForGroup.size());
    List<AccountBO> savingsForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
    Assert.assertEquals(1, savingsForClient.size());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 37 with ClientBO

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

the class CustomerPersistenceIntegrationTest method testGetChildernActiveAndHold.

@Test
public void testGetChildernActiveAndHold() 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_PARTIAL, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_PENDING, group);
    ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_HOLD, group);
    List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice().getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.ACTIVE_AND_ONHOLD);
    Assert.assertEquals(new Integer("2").intValue(), customerList.size());
    for (CustomerBO customer : customerList) {
        if (customer.getCustomerId().intValue() == client.getCustomerId().intValue()) {
            Assert.assertTrue(true);
        }
        if (customer.getCustomerId().intValue() == client4.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 38 with ClientBO

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

the class CustomerPersistenceIntegrationTest method testGetChildernOtherThanClosedAndCancelled.

@Test
public void testGetChildernOtherThanClosedAndCancelled() 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_CANCELLED_AND_CLOSED);
    Assert.assertEquals(new Integer("2").intValue(), customerList.size());
    for (CustomerBO customer : customerList) {
        if (customer.getCustomerId().equals(client4.getCustomerId())) {
            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 39 with ClientBO

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

the class TestObjectPersistence method getClient.

public ClientBO getClient(Integer clientId) {
    ClientBO client = null;
    client = ApplicationContextProvider.getBean(CustomerDao.class).findClientById(clientId);
    return client;
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO)

Example 40 with ClientBO

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

the class ClientServiceFacadeWebTier method transferClientToGroup.

@Override
public String transferClientToGroup(Integer groupId, String clientGlobalCustNum, Integer previousClientVersionNo) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    ClientBO client;
    try {
        client = this.customerService.transferClientTo(userContext, groupId, clientGlobalCustNum, previousClientVersionNo);
        return client.getGlobalCustNum();
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) MifosUser(org.mifos.security.MifosUser)

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