Search in sources :

Example 1 with SavingsProductDto

use of org.mifos.dto.domain.SavingsProductDto in project head by mifos.

the class SavingsProductFormBeanAssembler method assembleSavingsProductRequest.

public SavingsProductDto assembleSavingsProductRequest(SavingsProductFormBean formBean) {
    Integer category = Integer.valueOf(formBean.getGeneralDetails().getSelectedCategory());
    Integer applicableFor = Integer.valueOf(formBean.getGeneralDetails().getSelectedApplicableFor());
    DateTime startDate = new DateTime().withDate(Integer.valueOf(formBean.getGeneralDetails().getStartDateYear()), formBean.getGeneralDetails().getStartDateMonth(), formBean.getGeneralDetails().getStartDateDay());
    DateTime endDate = null;
    if (StringUtils.isNotBlank(formBean.getGeneralDetails().getEndDateYear())) {
        endDate = new DateTime().withDate(Integer.valueOf(formBean.getGeneralDetails().getEndDateYear()), formBean.getGeneralDetails().getEndDateMonth(), formBean.getGeneralDetails().getEndDateDay());
    }
    ProductDetailsDto productDetails = new ProductDetailsDto(formBean.getGeneralDetails().getName(), formBean.getGeneralDetails().getShortName(), formBean.getGeneralDetails().getDescription(), category, startDate, endDate, applicableFor);
    productDetails.setId(formBean.getGeneralDetails().getId());
    if (StringUtils.isNotBlank(formBean.getGeneralDetails().getSelectedStatus())) {
        Integer status = Integer.valueOf(formBean.getGeneralDetails().getSelectedStatus());
        productDetails.setStatus(status);
    }
    Integer depositType = Integer.valueOf(formBean.getSelectedDepositType());
    Integer groupSavingsType = null;
    if (StringUtils.isNotBlank(formBean.getSelectedGroupSavingsApproach())) {
        groupSavingsType = Integer.valueOf(formBean.getSelectedGroupSavingsApproach());
    }
    Double amountForDeposit = formBean.getAmountForDeposit();
    Double maxWithdrawal = formBean.getMaxWithdrawalAmount();
    BigDecimal interestRate = formBean.getInterestRate();
    Integer interestCalculationType = Integer.valueOf(formBean.getSelectedInterestCalculation());
    Integer interestCalculationFrequencyPeriod = Integer.valueOf(formBean.getSelectedFequencyPeriod());
    BigDecimal minBalanceForInterestCalculation = BigDecimal.valueOf(Double.valueOf(formBean.getMinBalanceRequiredForInterestCalculation()));
    Integer interestGlCode = Integer.parseInt(formBean.getSelectedInterestGlCode());
    Integer depositGlCode = Integer.parseInt(formBean.getSelectedPrincipalGlCode());
    return new SavingsProductDto(productDetails, formBean.isGroupSavingAccount(), depositType, groupSavingsType, amountForDeposit, maxWithdrawal, interestRate, interestCalculationType, formBean.getInterestCalculationFrequency(), interestCalculationFrequencyPeriod, formBean.getInterestPostingMonthlyFrequency(), minBalanceForInterestCalculation, depositGlCode, interestGlCode, formBean.getIsDaily());
}
Also used : SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) ProductDetailsDto(org.mifos.dto.domain.ProductDetailsDto) DateTime(org.joda.time.DateTime) BigDecimal(java.math.BigDecimal)

Example 2 with SavingsProductDto

use of org.mifos.dto.domain.SavingsProductDto 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 3 with SavingsProductDto

use of org.mifos.dto.domain.SavingsProductDto in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveSavingsProductDetails.

@Override
public SavingsProductDto retrieveSavingsProductDetails(Integer productId) {
    SavingsOfferingBO savingsProduct = this.savingsProductDao.findById(productId);
    boolean openSavingsAccountsExist = this.savingsProductDao.activeOrInactiveSavingsAccountsExistForProduct(productId);
    SavingsProductDto dto = savingsProduct.toFullDto();
    dto.setOpenSavingsAccountsExist(openSavingsAccountsExist);
    return dto;
}
Also used : SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto)

Example 4 with SavingsProductDto

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

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

SavingsProductDto (org.mifos.dto.domain.SavingsProductDto)9 ProductDetailsDto (org.mifos.dto.domain.ProductDetailsDto)4 SavingsProductReferenceDto (org.mifos.dto.screen.SavingsProductReferenceDto)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 BigDecimal (java.math.BigDecimal)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)1 AuditLogDto (org.mifos.dto.domain.AuditLogDto)1 PrdOfferingDto (org.mifos.dto.domain.PrdOfferingDto)1 SavingsAccountCreationDto (org.mifos.dto.domain.SavingsAccountCreationDto)1 SavingsAccountDetailDto (org.mifos.dto.domain.SavingsAccountDetailDto)1 AuditLogScreenDto (org.mifos.dto.screen.AuditLogScreenDto)1 ListElement (org.mifos.dto.screen.ListElement)1 SavingsProductFormDto (org.mifos.dto.screen.SavingsProductFormDto)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1