Search in sources :

Example 6 with CustomerStatusEntity

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

the class AccountStateMachines method retrieveNextPossibleCustomerStateForGroup.

private List<CustomerStatusEntity> retrieveNextPossibleCustomerStateForGroup(StateEntity customerStateEntityObj) throws ApplicationException {
    logger.debug("In AccountStateMachines::retrieveNextPossibleCustomerStateForGroup()");
    List<CustomerStatusEntity> stateEntityList = new ArrayList<CustomerStatusEntity>();
    try {
        List<StateEntity> stateList = statesMapForGroup.get(customerStateEntityObj);
        if (null != stateList) {
            for (StateEntity customerStateEntity : stateList) {
                for (CustomerStatusEntity customerStatusEntry : customerStatusListForGroup) {
                    if (customerStatusEntry.sameId(customerStateEntity)) {
                        stateEntityList.add(customerStatusEntry);
                        break;
                    }
                }
            }
        }
        return stateEntityList;
    } catch (Exception e) {
        throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
    }
}
Also used : ArrayList(java.util.ArrayList) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) StateEntity(org.mifos.application.master.business.StateEntity)

Example 7 with CustomerStatusEntity

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

the class EditCustomerStatusAction method loadStatus.

@TransactionDemarcate(joinToken = true)
public ActionForward loadStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In EditCustomerStatusAction:load()");
    EditCustomerStatusActionForm editCustomerStatusActionForm = (EditCustomerStatusActionForm) form;
    editCustomerStatusActionForm.clear();
    UserContext userContext = getUserContext(request);
    Integer customerId = editCustomerStatusActionForm.getCustomerIdValue();
    CustomerBO customer = this.customerDao.findCustomerById(customerId);
    customer.setUserContext(userContext);
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customer, request);
    List<CustomerStatusEntity> statusList = new ArrayList<CustomerStatusEntity>();
    switch(customer.getLevel()) {
        case CENTER:
            this.centerServiceFacade.initializeCenterStates(customer.getGlobalCustNum());
            statusList = AccountStateMachines.getInstance().getCenterStatusList(customer.getCustomerStatus());
            editCustomerStatusActionForm.setInput("center");
            break;
        case GROUP:
            this.centerServiceFacade.initializeGroupStates(customer.getGlobalCustNum());
            statusList = AccountStateMachines.getInstance().getGroupStatusList(customer.getCustomerStatus());
            editCustomerStatusActionForm.setInput("group");
            break;
        case CLIENT:
            this.centerServiceFacade.initializeClientStates(customer.getGlobalCustNum());
            statusList = AccountStateMachines.getInstance().getClientStatusList(customer.getCustomerStatus());
            editCustomerStatusActionForm.setInput("client");
            break;
        default:
            break;
    }
    ;
    for (CustomerStatusEntity customerStatusEntity : statusList) {
        for (CustomerStatusFlagEntity flag : customerStatusEntity.getFlagSet()) {
            String statusMessageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(flag.getLookUpValue().getPropertiesKey());
            flag.setStatusFlagMessageText(statusMessageText);
        }
    }
    editCustomerStatusActionForm.setLevelId(customer.getCustomerLevel().getId().toString());
    editCustomerStatusActionForm.setCurrentStatusId(customer.getCustomerStatus().getId().toString());
    editCustomerStatusActionForm.setGlobalAccountNum(customer.getGlobalCustNum());
    editCustomerStatusActionForm.setCustomerName(customer.getDisplayName());
    SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_LIST, statusList, request);
    return mapping.findForward(ActionForwards.loadStatus_success.toString());
}
Also used : EditCustomerStatusActionForm(org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm) UserContext(org.mifos.security.util.UserContext) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerStatusFlagEntity(org.mifos.customers.business.CustomerStatusFlagEntity) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with CustomerStatusEntity

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

the class CheckListBOIntegrationTest method testCreateCheckListExceptionForCustomer.

@Test
public void testCreateCheckListExceptionForCustomer() throws Exception {
    CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.CENTER);
    CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.CENTER_ACTIVE);
    try {
        customerCheckList = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, null, CheckListConstants.STATUS_ACTIVE, getCheckListDetails(), (short) 1, (short) 1);
        Assert.fail();
    } catch (CheckListException ce) {
        Assert.assertTrue(true);
    }
}
Also used : CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) Test(org.junit.Test)

Example 9 with CustomerStatusEntity

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

the class CheckListBOIntegrationTest method testUpdateCustomerCheckListInvalidState.

@Test
public void testUpdateCustomerCheckListInvalidState() throws Exception {
    CustomerCheckListBO customerCheckList1 = TestObjectFactory.createCustomerChecklist(CustomerLevel.CENTER.getValue(), CustomerStatus.CENTER_INACTIVE.getValue(), CheckListConstants.STATUS_ACTIVE);
    customerCheckList = TestObjectFactory.createCustomerChecklist(CustomerLevel.CENTER.getValue(), CustomerStatus.CENTER_ACTIVE.getValue(), CheckListConstants.STATUS_ACTIVE);
    CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.fromInt(CustomerStatus.CENTER_INACTIVE.getValue()));
    StaticHibernateUtil.flushSession();
    customerCheckList = (CustomerCheckListBO) TestObjectFactory.getObject(CustomerCheckListBO.class, customerCheckList.getChecklistId());
    try {
        customerCheckList.update(customerCheckList.getCustomerLevel(), customerStatusEntity, "Customer CheckList", CheckListConstants.STATUS_INACTIVE, getCheckListDetails(), (short) 1, (short) 1);
        Assert.fail();
    } catch (CheckListException ce) {
        Assert.assertTrue(true);
    } finally {
        TestObjectFactory.deleteChecklist(customerCheckList1);
        StaticHibernateUtil.flushSession();
    }
}
Also used : CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) Test(org.junit.Test)

Example 10 with CustomerStatusEntity

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

the class ProcessFlowRulesIntegrationTest method testValidOverrideAgainstDb.

@Test
public void testValidOverrideAgainstDb() throws Exception {
    CustomerPersistence cp = new CustomerPersistence();
    CustomerStatusEntity cse = (CustomerStatusEntity) cp.loadPersistentObject(CustomerStatusEntity.class, CustomerStatus.CLIENT_PENDING.getValue());
    Assert.assertTrue(cse.getIsOptional());
    cse.setIsOptional(false);
    StaticHibernateUtil.flushSession();
    Assert.assertFalse(cse.getIsOptional());
    Assert.assertTrue(ProcessFlowRules.isClientPendingApprovalStateEnabled());
    ProcessFlowRules.init();
    Assert.assertTrue(cse.getIsOptional());
}
Also used : CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) 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