Search in sources :

Example 11 with SavingsAccountDetailDto

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;
}
Also used : HashMap(java.util.HashMap) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) CustomerBO(org.mifos.customers.business.CustomerBO) SavingsAccountCreationDto(org.mifos.dto.domain.SavingsAccountCreationDto) AccountState(org.mifos.accounts.util.helpers.AccountState) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

SavingsAccountDetailDto (org.mifos.dto.domain.SavingsAccountDetailDto)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 IncludePage (freemarker.ext.servlet.IncludePage)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 LocalDate (org.joda.time.LocalDate)2 AccountException (org.mifos.accounts.exceptions.AccountException)2 PaymentDto (org.mifos.dto.domain.PaymentDto)2 SavingsAccountCreationDto (org.mifos.dto.domain.SavingsAccountCreationDto)2 SavingsWithdrawalDto (org.mifos.dto.domain.SavingsWithdrawalDto)2 SavingsRecentActivityDto (org.mifos.dto.screen.SavingsRecentActivityDto)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1