Search in sources :

Example 6 with CustomerLevel

use of org.mifos.customers.api.CustomerLevel in project head by mifos.

the class CheckListServiceFacadeWebTier method createCustomerChecklist.

@Override
public void createCustomerChecklist(Short levelId, Short stateId, String checklistName, List<String> checklistDetails) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    CustomerLevel level = CustomerLevel.getLevel(levelId);
    CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(level);
    CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(stateId);
    try {
        hibernateTransactionHelper.startTransaction();
        CustomerCheckListBO customerCheckListBO = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, checklistName, CheckListConstants.STATUS_ACTIVE, checklistDetails, userContext.getLocaleId(), userContext.getId());
        customerDao.save(customerCheckListBO);
        hibernateTransactionHelper.commitTransaction();
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException)

Example 7 with CustomerLevel

use of org.mifos.customers.api.CustomerLevel in project head by mifos.

the class CenterServiceFacadeWebTier method retrieveCustomerStatusDetails.

@Override
public CustomerStatusDetailDto retrieveCustomerStatusDetails(Short newStatusId, Short flagIdValue, Short customerLevelId) {
    CustomerLevel customerLevel = CustomerLevel.getLevel(customerLevelId);
    CustomerStatus customerStatus = CustomerStatus.fromInt(newStatusId);
    CustomerStatusFlag statusFlag = null;
    if (customerStatus.isCustomerCancelledOrClosed()) {
        statusFlag = CustomerStatusFlag.getStatusFlag(flagIdValue);
    }
    String statusName = AccountStateMachines.getInstance().getCustomerStatusName(customerStatus, customerLevel);
    String flagName = AccountStateMachines.getInstance().getCustomerFlagName(statusFlag, customerLevel);
    return new CustomerStatusDetailDto(statusName, flagName);
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus)

Example 8 with CustomerLevel

use of org.mifos.customers.api.CustomerLevel in project head by mifos.

the class CustomerSearchServiceFacadeWebTier method getAvailibleCustomerStates.

@Override
public Map<String, ArrayList<CustomerStatusDetailDto>> getAvailibleCustomerStates() throws PersistenceException {
    HashMap<String, ArrayList<CustomerStatusDetailDto>> customerStates = new HashMap<String, ArrayList<CustomerStatusDetailDto>>();
    for (CustomerLevel customerLevel : CustomerLevel.values()) {
        List<CustomerStatusEntity> states = new CustomerPersistence().retrieveAllCustomerStatusList(customerLevel.getValue());
        ArrayList<CustomerStatusDetailDto> statesDtos = new ArrayList<CustomerStatusDetailDto>();
        for (CustomerStatusEntity customerStatusEntity : states) {
            CustomerStatusDetailDto customerStatusDetailDto = new CustomerStatusDetailDto(customerStatusEntity.getId().toString(), customerStatusEntity.getName(), null);
            statesDtos.add(customerStatusDetailDto);
        }
        customerStates.put(customerLevel.toString(), statesDtos);
    }
    return customerStates;
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity)

Example 9 with CustomerLevel

use of org.mifos.customers.api.CustomerLevel in project head by mifos.

the class AccountStateMachines method initializeClientStates.

public void initializeClientStates() throws StatesInitializationException {
    AccountTypes accountType = AccountTypes.CUSTOMER_ACCOUNT;
    CustomerLevel level = CustomerLevel.CLIENT;
    String configName = getConfigurationName(accountType, level);
    try {
        statesMapForClient = loadMap(CustomerConstants.TRANSITION_CONFIG_FILE_PATH_CLIENT, configName);
        customerStatusListForClient = retrieveAllCustomerStatusList(level);
        populateClientStatesViewMap();
    } catch (Exception e) {
        throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
    }
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) AccountTypes(org.mifos.accounts.util.helpers.AccountTypes) ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) ApplicationException(org.mifos.framework.exceptions.ApplicationException)

Example 10 with CustomerLevel

use of org.mifos.customers.api.CustomerLevel in project head by mifos.

the class WebTierAccountServiceFacade method applyCharge.

@Override
public void applyCharge(Integer accountId, Short chargeId, Double chargeAmount, boolean isPenaltyType) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        AccountBO account = new AccountBusinessService().getAccount(accountId);
        if (account instanceof LoanBO && !account.isGroupLoanAccount()) {
            List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(account.getAccountId());
            if (individualLoans != null && individualLoans.size() > 0) {
                for (LoanBO individual : individualLoans) {
                    individual.updateDetails(userContext);
                    if (isPenaltyType && !chargeId.equals(Short.valueOf(AccountConstants.MISC_PENALTY))) {
                        PenaltyBO penalty = this.penaltyDao.findPenaltyById(chargeId.intValue());
                        individual.addAccountPenalty(new AccountPenaltiesEntity(individual, penalty, chargeAmount));
                    } else {
                        FeeBO fee = this.feeDao.findById(chargeId);
                        if (fee instanceof RateFeeBO) {
                            individual.applyCharge(chargeId, chargeAmount);
                        } else {
                            Double radio = individual.getLoanAmount().getAmount().doubleValue() / ((LoanBO) account).getLoanAmount().getAmount().doubleValue();
                            individual.applyCharge(chargeId, chargeAmount * radio);
                        }
                    }
                }
            }
        }
        account.updateDetails(userContext);
        CustomerLevel customerLevel = null;
        if (account.isCustomerAccount()) {
            customerLevel = account.getCustomer().getLevel();
        }
        if (account.getPersonnel() != null) {
            checkPermissionForApplyCharges(account.getType(), customerLevel, userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
        } else {
            checkPermissionForApplyCharges(account.getType(), customerLevel, userContext, account.getOffice().getOfficeId(), userContext.getId());
        }
        this.transactionHelper.startTransaction();
        if (isPenaltyType && account instanceof LoanBO) {
            PenaltyBO penalty = this.penaltyDao.findPenaltyById(chargeId.intValue());
            ((LoanBO) account).addAccountPenalty(new AccountPenaltiesEntity(account, penalty, chargeAmount));
        } else {
            account.applyCharge(chargeId, chargeAmount);
        }
        this.transactionHelper.commitTransaction();
    } catch (ServiceException e) {
        this.transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } catch (ApplicationException e) {
        this.transactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) AccountPenaltiesEntity(org.mifos.accounts.business.AccountPenaltiesEntity) CustomerLevel(org.mifos.customers.api.CustomerLevel) PenaltyBO(org.mifos.accounts.penalties.business.PenaltyBO) RatePenaltyBO(org.mifos.accounts.penalties.business.RatePenaltyBO) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) MifosUser(org.mifos.security.MifosUser) AccountBO(org.mifos.accounts.business.AccountBO) BusinessRuleException(org.mifos.service.BusinessRuleException) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ServiceException(org.mifos.framework.exceptions.ServiceException) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

CustomerLevel (org.mifos.customers.api.CustomerLevel)12 ServiceException (org.mifos.framework.exceptions.ServiceException)8 ApplicationException (org.mifos.framework.exceptions.ApplicationException)7 AccountTypes (org.mifos.accounts.util.helpers.AccountTypes)5 PersistenceException (org.mifos.framework.exceptions.PersistenceException)5 StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 MifosUser (org.mifos.security.MifosUser)4 UserContext (org.mifos.security.util.UserContext)4 AccountBO (org.mifos.accounts.business.AccountBO)3 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)3 BusinessRuleException (org.mifos.service.BusinessRuleException)3 HashMap (java.util.HashMap)2 AccountPenaltiesEntity (org.mifos.accounts.business.AccountPenaltiesEntity)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 PenaltyBO (org.mifos.accounts.penalties.business.PenaltyBO)2 RatePenaltyBO (org.mifos.accounts.penalties.business.RatePenaltyBO)2 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)2