use of org.mifos.dto.domain.SavingsAccountDetailDto 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