Search in sources :

Example 1 with SavingsProductReferenceDto

use of org.mifos.dto.screen.SavingsProductReferenceDto in project head by mifos.

the class SavingsAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    SavingsActionForm savingsActionForm = ((SavingsActionForm) form);
    logger.debug(" selectedPrdOfferingId: " + savingsActionForm.getSelectedPrdOfferingId());
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    List<InterestCalcTypeEntity> interestCalculationTypes = this.savingsProductDao.retrieveInterestCalculationTypes();
    SessionUtils.setCollectionAttribute(MasterConstants.INTEREST_CAL_TYPES, interestCalculationTypes, request);
    Integer productId = Integer.valueOf(savingsActionForm.getSelectedPrdOfferingId());
    SavingsOfferingBO savingsOfferingBO = this.savingsProductDao.findById(productId);
    SessionUtils.setAttribute(SavingsConstants.PRDOFFERING, savingsOfferingBO, request);
    // NOTE - these details are included in SavingsProductReferenceDto but left as is to satisfy JSP at present
    SessionUtils.setCollectionAttribute(MasterConstants.SAVINGS_TYPE, legacyMasterDao.findMasterDataEntitiesWithLocale(SavingsTypeEntity.class), request);
    SessionUtils.setCollectionAttribute(MasterConstants.RECOMMENDED_AMOUNT_UNIT, legacyMasterDao.findMasterDataEntitiesWithLocale(RecommendedAmntUnitEntity.class), request);
    List<CustomFieldDefinitionEntity> customFieldDefinitions = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(SavingsConstants.CUSTOM_FIELDS, customFieldDefinitions, request);
    SavingsProductReferenceDto savingsProductReferenceDto = this.savingsServiceFacade.retrieveSavingsProductReferenceData(productId);
    savingsActionForm.setRecommendedAmount(savingsProductReferenceDto.getSavingsProductDetails().getAmountForDeposit().toString());
    List<CustomFieldDto> customFields = CustomFieldDefinitionEntity.toDto(customFieldDefinitions, uc.getPreferredLocale());
    savingsActionForm.setAccountCustomFieldSet(customFields);
    return mapping.findForward("load_success");
}
Also used : InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) SavingsProductReferenceDto(org.mifos.dto.screen.SavingsProductReferenceDto) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) SavingsActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsActionForm) SavingsTypeEntity(org.mifos.accounts.productdefinition.business.SavingsTypeEntity) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with SavingsProductReferenceDto

use of org.mifos.dto.screen.SavingsProductReferenceDto in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveSavingsProductReferenceData.

@Override
public SavingsProductReferenceDto retrieveSavingsProductReferenceData(Integer productId) {
    SavingsOfferingBO savingsProduct = this.savingsProductDao.findById(productId);
    List<ListElement> interestCalcTypeOptions = new ArrayList<ListElement>();
    List<InterestCalcTypeEntity> interestCalculationTypes = this.savingsProductDao.retrieveInterestCalculationTypes();
    for (InterestCalcTypeEntity entity : interestCalculationTypes) {
        interestCalcTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
    }
    boolean savingsPendingApprovalEnabled = ProcessFlowRules.isSavingsPendingApprovalStateEnabled();
    return new SavingsProductReferenceDto(interestCalcTypeOptions, savingsProduct.toFullDto(), savingsPendingApprovalEnabled);
}
Also used : InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) SavingsProductReferenceDto(org.mifos.dto.screen.SavingsProductReferenceDto)

Example 3 with SavingsProductReferenceDto

use of org.mifos.dto.screen.SavingsProductReferenceDto 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 4 with SavingsProductReferenceDto

use of org.mifos.dto.screen.SavingsProductReferenceDto in project head by mifos.

the class CreateSavingsAccountControllerTest method testLoadProduct.

@SuppressWarnings("unchecked")
@Test
public void testLoadProduct() {
    Integer productId = 1;
    List<ListElement> interestCalculationOptions = new ArrayList<ListElement>();
    boolean groupSavingsAccount = false;
    Integer depositType = 1;
    Integer groupSavingsType = 1;
    Double amountForDeposit = 10.0;
    Double maxWithdrawal = 100.0;
    BigDecimal interestRate = new BigDecimal("5.0");
    Integer interestCalculationType = 1;
    Integer interestCalculationFrequency = 1;
    Integer interestCalculationFrequencyPeriod = 1;
    Integer interestPostingMonthlyFrequency = 1;
    BigDecimal minBalanceForInterestCalculation = new BigDecimal("1.0");
    Integer depositGlCode = 1;
    Integer interestGlCode = 1;
    ProductDetailsDto productsDetailDto = null;
    SavingsProductDto savingsProductDetails = new SavingsProductDto(productsDetailDto, groupSavingsAccount, depositType, groupSavingsType, amountForDeposit, maxWithdrawal, interestRate, interestCalculationType, interestCalculationFrequency, interestCalculationFrequencyPeriod, interestPostingMonthlyFrequency, minBalanceForInterestCalculation, depositGlCode, interestGlCode, false);
    SavingsProductReferenceDto savingsProductReference = new SavingsProductReferenceDto(interestCalculationOptions, savingsProductDetails, true);
    when(savingsServiceFacade.retrieveSavingsProductReferenceData(productId)).thenReturn(savingsProductReference);
    controller.loadProduct(productId, formBean);
    verify(formBean).setProductId(productId);
    verify(formBean).setProduct(savingsProductReference);
    verify(formBean).setMandatoryDepositAmount(any(String.class));
    verify(formBean).setSavingsTypes(any(Map.class));
    verify(formBean).setRecurrenceTypes(any(Map.class));
    verify(formBean).setRecurrenceFrequencies(any(Map.class));
}
Also used : ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) SavingsProductReferenceDto(org.mifos.dto.screen.SavingsProductReferenceDto) ProductDetailsDto(org.mifos.dto.domain.ProductDetailsDto) HashMap(java.util.HashMap) Map(java.util.Map) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 5 with SavingsProductReferenceDto

use of org.mifos.dto.screen.SavingsProductReferenceDto in project head by mifos.

the class CreateSavingsAccountFormBeanTest method setDepositType.

/**
     * Sets deposit type in the form bean.
     */
private void setDepositType(CreateSavingsAccountFormBean formBean, int depositType) {
    SavingsProductDto productDetails = mock(SavingsProductDto.class);
    when(productDetails.getDepositType()).thenReturn(depositType);
    SavingsProductReferenceDto productRef = mock(SavingsProductReferenceDto.class);
    when(productRef.getSavingsProductDetails()).thenReturn(productDetails);
    formBean.setProduct(productRef);
}
Also used : SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) SavingsProductReferenceDto(org.mifos.dto.screen.SavingsProductReferenceDto)

Aggregations

SavingsProductReferenceDto (org.mifos.dto.screen.SavingsProductReferenceDto)6 ArrayList (java.util.ArrayList)3 SavingsProductDto (org.mifos.dto.domain.SavingsProductDto)3 InterestCalcTypeEntity (org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity)2 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)2 ListElement (org.mifos.dto.screen.ListElement)2 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 RecommendedAmntUnitEntity (org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity)1 SavingsTypeEntity (org.mifos.accounts.productdefinition.business.SavingsTypeEntity)1 SavingsActionForm (org.mifos.accounts.savings.struts.actionforms.SavingsActionForm)1 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1 ProductDetailsDto (org.mifos.dto.domain.ProductDetailsDto)1 SavingsAccountCreationDto (org.mifos.dto.domain.SavingsAccountCreationDto)1 SavingsAccountDetailDto (org.mifos.dto.domain.SavingsAccountDetailDto)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1 UserContext (org.mifos.security.util.UserContext)1