Search in sources :

Example 1 with SavingsAccountCreationDto

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;
}
Also used : SavingsProductReferenceDto(org.mifos.dto.screen.SavingsProductReferenceDto) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) SavingsAccountCreationDto(org.mifos.dto.domain.SavingsAccountCreationDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto)

Example 2 with SavingsAccountCreationDto

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");
}
Also used : SavingsActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsActionForm) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) SavingsAccountCreationDto(org.mifos.dto.domain.SavingsAccountCreationDto) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with SavingsAccountCreationDto

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;
}
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

SavingsAccountCreationDto (org.mifos.dto.domain.SavingsAccountCreationDto)3 CustomerBO (org.mifos.customers.business.CustomerBO)2 SavingsAccountDetailDto (org.mifos.dto.domain.SavingsAccountDetailDto)2 HashMap (java.util.HashMap)1 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)1 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)1 SavingsActionForm (org.mifos.accounts.savings.struts.actionforms.SavingsActionForm)1 AccountState (org.mifos.accounts.util.helpers.AccountState)1 SavingsProductDto (org.mifos.dto.domain.SavingsProductDto)1 SavingsProductReferenceDto (org.mifos.dto.screen.SavingsProductReferenceDto)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1 UserContext (org.mifos.security.util.UserContext)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1