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);
}
}
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());
}
Aggregations