Search in sources :

Example 1 with CustomerHistoricalDataDto

use of org.mifos.dto.screen.CustomerHistoricalDataDto in project head by mifos.

the class GroupServiceFacadeWebTier method retrieveCustomerHistoricalData.

@Override
public CustomerHistoricalDataDto retrieveCustomerHistoricalData(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CustomerBO customer = this.customerDao.findCustomerBySystemId(globalCustNum);
    boolean client = false;
    boolean group = false;
    if (customer.isClient()) {
        client = true;
    } else if (customer.isGroup()) {
        group = true;
    }
    CustomerHistoricalDataEntity customerHistoricalDataEntity = customer.getHistoricalData();
    if (customerHistoricalDataEntity == null) {
        customerHistoricalDataEntity = new CustomerHistoricalDataEntity(customer);
    }
    try {
        String currentDate = DateUtils.getCurrentDate(userContext.getPreferredLocale());
        java.sql.Date mfiJoiningDate = null;
        if (customerHistoricalDataEntity.getMfiJoiningDate() == null) {
            mfiJoiningDate = DateUtils.getLocaleDate(userContext.getPreferredLocale(), currentDate);
        } else {
            mfiJoiningDate = new Date(customerHistoricalDataEntity.getMfiJoiningDate().getTime());
        }
        return new CustomerHistoricalDataDto(client, group, mfiJoiningDate);
    } catch (InvalidDateException e) {
        throw new BusinessRuleException(e.getMessage(), e);
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerHistoricalDataDto(org.mifos.dto.screen.CustomerHistoricalDataDto) UserContext(org.mifos.security.util.UserContext) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) CustomerHistoricalDataEntity(org.mifos.customers.business.CustomerHistoricalDataEntity) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) Date(java.sql.Date) Date(java.sql.Date)

Example 2 with CustomerHistoricalDataDto

use of org.mifos.dto.screen.CustomerHistoricalDataDto in project head by mifos.

the class CustHistoricalDataAction method getHistoricalData.

@TransactionDemarcate(saveToken = true)
public ActionForward getHistoricalData(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CustHistoricalDataActionForm actionForm = (CustHistoricalDataActionForm) form;
    String globalCustNum = request.getParameter(CustomerConstants.GLOBAL_CUST_NUM);
    CustomerHistoricalDataDto historicalData = this.groupServiceFacade.retrieveCustomerHistoricalData(globalCustNum);
    CustomerBO customer = this.customerDao.findCustomerBySystemId(globalCustNum);
    UserContext userContext = getUserContext(request);
    customer.updateDetails(userContext);
    if (historicalData.isClient()) {
        actionForm.setType("Client");
    } else if (historicalData.isGroup()) {
        actionForm.setType("Group");
    }
    CustomerHistoricalDataEntity customerHistoricalDataEntity = customer.getHistoricalData();
    if (customerHistoricalDataEntity == null) {
        customerHistoricalDataEntity = new CustomerHistoricalDataEntity(customer);
    }
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customer, request);
    SessionUtils.setAttribute(CustomerConstants.MFIJOININGDATE, historicalData.getMfiJoiningDate(), request);
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_HISTORICAL_DATA, customerHistoricalDataEntity, request);
    return mapping.findForward(ActionForwards.getHistoricalData_success.toString());
}
Also used : CustomerHistoricalDataDto(org.mifos.dto.screen.CustomerHistoricalDataDto) UserContext(org.mifos.security.util.UserContext) CustomerHistoricalDataEntity(org.mifos.customers.business.CustomerHistoricalDataEntity) CustHistoricalDataActionForm(org.mifos.customers.struts.actionforms.CustHistoricalDataActionForm) CustomerBO(org.mifos.customers.business.CustomerBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

CustomerBO (org.mifos.customers.business.CustomerBO)2 CustomerHistoricalDataEntity (org.mifos.customers.business.CustomerHistoricalDataEntity)2 CustomerHistoricalDataDto (org.mifos.dto.screen.CustomerHistoricalDataDto)2 UserContext (org.mifos.security.util.UserContext)2 Date (java.sql.Date)1 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)1 CustHistoricalDataActionForm (org.mifos.customers.struts.actionforms.CustHistoricalDataActionForm)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1 MifosUser (org.mifos.security.MifosUser)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1