use of org.mifos.dto.domain.SavingsAccountCreationDto in project head by mifos.
the class CreateSavingsAccountController method createAccount.
private SavingsAccountDetailDto createAccount(CreateSavingsAccountFormBean formBean, Short accountState) {
SavingsProductReferenceDto productReference = formBean.getProduct();
SavingsProductDto savingsProduct = productReference.getSavingsProductDetails();
Integer productId = savingsProduct.getProductDetails().getId();
Integer customerId = formBean.getCustomer().getCustomerId();
// TODO - deposit amount should be validated before reaching here...
String recommendedOrMandatoryAmount = formBean.getMandatoryDepositAmount();
SavingsAccountCreationDto savingsAccountCreation = new SavingsAccountCreationDto(productId, customerId, accountState, recommendedOrMandatoryAmount);
Long savingsId = savingsServiceFacade.createSavingsAccount(savingsAccountCreation, formBean.getQuestionGroups());
SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(savingsId);
return savingsAccountDetailDto;
}
use of org.mifos.dto.domain.SavingsAccountCreationDto in project head by mifos.
the class SavingsAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
SavingsActionForm savingsActionForm = ((SavingsActionForm) form);
logger.debug("In SavingsAction::create(), accountStateId: " + savingsActionForm.getStateSelected());
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
CustomerBO customer = (CustomerBO) SessionUtils.getAttribute(SavingsConstants.CLIENT, request);
Integer customerId = customer.getCustomerId();
Integer productId = Integer.valueOf(savingsActionForm.getSelectedPrdOfferingId());
String recommendedOrMandatoryAmount = savingsActionForm.getRecommendedAmount();
Short accountState = Short.valueOf(savingsActionForm.getStateSelected());
customer = this.customerDao.findCustomerById(customerId);
checkPermissionForCreate(accountState, uc, customer.getOffice().getOfficeId(), customer.getPersonnel().getPersonnelId());
SavingsAccountCreationDto savingsAccountCreation = new SavingsAccountCreationDto(productId, customerId, accountState, recommendedOrMandatoryAmount);
Long savingsId = this.savingsServiceFacade.createSavingsAccount(savingsAccountCreation);
SavingsBO saving = this.savingsDao.findById(savingsId);
createGroupQuestionnaire.saveResponses(request, savingsActionForm, saving.getAccountId());
request.setAttribute(SavingsConstants.GLOBALACCOUNTNUM, saving.getGlobalAccountNum());
request.setAttribute(SavingsConstants.RECORD_OFFICE_ID, saving.getOffice().getOfficeId());
request.setAttribute(SavingsConstants.CLIENT_NAME, customer.getDisplayName());
request.setAttribute(SavingsConstants.CLIENT_ID, customer.getCustomerId());
request.setAttribute(SavingsConstants.CLIENT_LEVEL, customer.getCustomerLevel().getId());
logger.info("In SavingsAction::create(), Savings object saved successfully ");
return mapping.findForward("create_success");
}
use of org.mifos.dto.domain.SavingsAccountCreationDto in project head by mifos.
the class SavingsAccountRESTController method createSavingsAccount.
@RequestMapping(value = "/account/savings/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createSavingsAccount(@RequestParam String globalCustomerNum, @RequestParam(required = false) String amount, @RequestParam Integer productId) throws Throwable {
CustomerBO customer = validateGlobalCustNum(globalCustomerNum);
SavingsOfferingBO product = validateProductId(productId);
String recommendedAmount = null != amount ? amount : product.getRecommendedAmount().toString();
Integer customerId = customer.getCustomerId();
AccountState accountState = AccountState.SAVINGS_PENDING_APPROVAL;
SavingsAccountCreationDto savingsAccountCreation = new SavingsAccountCreationDto(productId, customerId, accountState.getValue(), recommendedAmount);
Long savings = savingsServiceFacade.createSavingsAccount(savingsAccountCreation);
SavingsAccountDetailDto details = savingsServiceFacade.retrieveSavingsAccountDetails(savings);
Map<String, String> map = new HashMap<String, String>();
map.put("customerName", customer.getDisplayName());
map.put("productName", product.getPrdOfferingName());
map.put("interesRate", details.getProductDetails().getInterestRate().toString());
map.put("interestRatePeriod", details.getProductDetails().getInterestCalculationFrequency().toString());
map.put("recommendedAmount", recommendedAmount);
return map;
}
Aggregations