Search in sources :

Example 21 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class CenterServiceFacadeWebTier method initializeCenterStates.

@Override
public void initializeCenterStates(String centerGlobalNum) {
    CenterBO center = this.customerDao.findCenterBySystemId(centerGlobalNum);
    try {
        List<ListElement> savingsStatesList = new ArrayList<ListElement>();
        AccountStateMachines.getInstance().initializeCenterStates();
        List<CustomerStatusEntity> statusList = AccountStateMachines.getInstance().getCenterStatusList(center.getCustomerStatus());
        for (CustomerStatusEntity customerState : statusList) {
            savingsStatesList.add(new ListElement(customerState.getId().intValue(), customerState.getName()));
        }
    } catch (StatesInitializationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) CenterBO(org.mifos.customers.center.business.CenterBO) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 22 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class CenterServiceFacadeWebTier method initializeGroupStates.

@Override
public void initializeGroupStates(String groupGlobalNum) {
    GroupBO group = this.customerDao.findGroupBySystemId(groupGlobalNum);
    try {
        List<ListElement> savingsStatesList = new ArrayList<ListElement>();
        AccountStateMachines.getInstance().initializeGroupStates();
        List<CustomerStatusEntity> statusList = AccountStateMachines.getInstance().getGroupStatusList(group.getCustomerStatus());
        for (CustomerStatusEntity customerState : statusList) {
            savingsStatesList.add(new ListElement(customerState.getId().intValue(), customerState.getName()));
        }
    } catch (StatesInitializationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) GroupBO(org.mifos.customers.group.business.GroupBO) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 23 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class CustomerPersistence method retrieveAllCustomerStatusList.

public List<CustomerStatusEntity> retrieveAllCustomerStatusList(final Short levelId) throws PersistenceException {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("LEVEL_ID", levelId);
    List<CustomerStatusEntity> queryResult = executeNamedQuery(NamedQueryConstants.GET_CUSTOMER_STATUS_LIST, queryParameters);
    for (CustomerStatusEntity customerStatus : queryResult) {
        for (CustomerStatusFlagEntity customerStatusFlagEntity : customerStatus.getFlagSet()) {
            Hibernate.initialize(customerStatusFlagEntity);
            Hibernate.initialize(customerStatusFlagEntity.getNames());
        }
        Hibernate.initialize(customerStatus.getLookUpValue());
    }
    return queryResult;
}
Also used : HashMap(java.util.HashMap) CustomerStatusFlagEntity(org.mifos.customers.business.CustomerStatusFlagEntity) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity)

Example 24 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class EditCustomerStatusActionStrutsTest method testUpdateStatusForClientForActiveLoanOfficer.

@SuppressWarnings("unchecked")
@Test
public void testUpdateStatusForClientForActiveLoanOfficer() throws CustomerException, PageExpiredException {
    createInitialObjects();
    CustomerBOTestUtils.setCustomerStatus(client, new CustomerStatusEntity(CustomerStatus.CLIENT_PARTIAL.getValue()));
    client.update();
    StaticHibernateUtil.flushAndClearSession();
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.loadStatus.toString());
    addRequestParameter("customerId", client.getCustomerId().toString());
    actionPerform();
    verifyForward(ActionForwards.loadStatus_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
    Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.previewStatus.toString());
    addRequestParameter("notes", "Test");
    addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
    addRequestParameter("newStatusId", "3");
    addRequestParameter("flagId", "");
    actionPerform();
    verifyForward(ActionForwards.previewStatus_success.toString());
    verifyNoActionErrors();
    verifyNoActionMessages();
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
    Assert.assertNull("Since new Status is not Closed,so flag should be null.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request.getSession()));
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.updateStatus.toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.client_detail_page.toString());
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    Assert.assertTrue(client.isActive());
    cleanInitialObjects();
}
Also used : CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Test(org.junit.Test)

Example 25 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity 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)

Aggregations

CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)30 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 PersistenceException (org.mifos.framework.exceptions.PersistenceException)6 StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)6 CustomerLevelEntity (org.mifos.customers.business.CustomerLevelEntity)5 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)5 HashMap (java.util.HashMap)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 UserContext (org.mifos.security.util.UserContext)4 StateEntity (org.mifos.application.master.business.StateEntity)3 CustomerStatusFlagEntity (org.mifos.customers.business.CustomerStatusFlagEntity)3 CustomerCheckListBO (org.mifos.customers.checklist.business.CustomerCheckListBO)3 ClientBO (org.mifos.customers.client.business.ClientBO)3 CustomerException (org.mifos.customers.exceptions.CustomerException)3 OfficeBO (org.mifos.customers.office.business.OfficeBO)3 CustomerDao (org.mifos.customers.persistence.CustomerDao)3 ListElement (org.mifos.dto.screen.ListElement)3 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2