Search in sources :

Example 1 with SavingsProductFormDto

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

the class AdminServiceFacadeWebTier method retrieveSavingsProductFormReferenceData.

@Override
public SavingsProductFormDto retrieveSavingsProductFormReferenceData() {
    try {
        SavingsPrdBusinessService service = new SavingsPrdBusinessService();
        List<ListElement> statusOptions = new ArrayList<ListElement>();
        List<PrdStatusEntity> applicableStatuses = service.getApplicablePrdStatus(Short.valueOf("1"));
        for (PrdStatusEntity entity : applicableStatuses) {
            statusOptions.add(new ListElement(entity.getOfferingStatusId().intValue(), entity.getPrdState().getName()));
        }
        List<ListElement> penaltiesOptions = new ArrayList<ListElement>();
        List<PenaltyBO> applicablePenalties = this.penaltyDao.findAllSavingPenalties();
        for (PenaltyBO entity : applicablePenalties) {
            penaltiesOptions.add(new ListElement(entity.getPenaltyId().intValue(), entity.getPenaltyName()));
        }
        List<ListElement> productCategoryOptions = new ArrayList<ListElement>();
        List<ProductCategoryBO> productCategories = service.getActiveSavingsProductCategories();
        for (ProductCategoryBO category : productCategories) {
            productCategoryOptions.add(new ListElement(category.getProductCategoryID().intValue(), category.getProductCategoryName()));
        }
        List<ListElement> applicableForOptions = new ArrayList<ListElement>();
        List<PrdApplicableMasterEntity> applicableCustomerTypes = this.loanProductDao.retrieveSavingsApplicableProductCategories();
        for (PrdApplicableMasterEntity entity : applicableCustomerTypes) {
            applicableForOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> savingsTypeOptions = new ArrayList<ListElement>();
        List<SavingsTypeEntity> savingsTypes = this.loanProductDao.retrieveSavingsTypes();
        for (SavingsTypeEntity entity : savingsTypes) {
            savingsTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> recommendedAmountTypeOptions = new ArrayList<ListElement>();
        List<RecommendedAmntUnitEntity> recommendedAmountTypes = this.loanProductDao.retrieveRecommendedAmountTypes();
        for (RecommendedAmntUnitEntity entity : recommendedAmountTypes) {
            recommendedAmountTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> interestCalcTypeOptions = new ArrayList<ListElement>();
        List<InterestCalcTypeEntity> interestCalcTypes = this.savingsProductDao.retrieveInterestCalculationTypes();
        for (InterestCalcTypeEntity entity : interestCalcTypes) {
            interestCalcTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> timePeriodOptions = new ArrayList<ListElement>();
        List<RecurrenceTypeEntity> applicableRecurrences = savingsProductDao.getSavingsApplicableRecurrenceTypes();
        for (RecurrenceTypeEntity entity : applicableRecurrences) {
            timePeriodOptions.add(new ListElement(entity.getRecurrenceId().intValue(), entity.getRecurrenceName()));
        }
        List<GLCodeEntity> depositGlCodeList = new ArrayList<GLCodeEntity>();
        depositGlCodeList.addAll(new FinancialBusinessService().getGLCodes(FinancialActionConstants.MANDATORYDEPOSIT, FinancialConstants.CREDIT));
        depositGlCodeList.addAll(new FinancialBusinessService().getGLCodes(FinancialActionConstants.VOLUNTARYDEPOSIT, FinancialConstants.CREDIT));
        List<ListElement> depositGlCodeOptions = new ArrayList<ListElement>();
        for (GLCodeEntity glCode : depositGlCodeList) {
            depositGlCodeOptions.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode(), glCode.getAssociatedCOA().getAccountName()));
        }
        List<GLCodeEntity> interestGlCodeList = new FinancialBusinessService().getGLCodes(FinancialActionConstants.SAVINGS_INTERESTPOSTING, FinancialConstants.DEBIT);
        List<ListElement> interestGlCodes = new ArrayList<ListElement>();
        for (GLCodeEntity glCode : interestGlCodeList) {
            interestGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode(), glCode.getAssociatedCOA().getAccountName()));
        }
        return new SavingsProductFormDto(productCategoryOptions, applicableForOptions, savingsTypeOptions, recommendedAmountTypeOptions, interestCalcTypeOptions, timePeriodOptions, depositGlCodeOptions, interestGlCodes, statusOptions);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    } catch (SystemException e) {
        throw new MifosRuntimeException(e);
    } catch (ApplicationException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : ArrayList(java.util.ArrayList) FinancialBusinessService(org.mifos.accounts.financial.business.service.FinancialBusinessService) BusinessRuleException(org.mifos.service.BusinessRuleException) SystemException(org.mifos.framework.exceptions.SystemException) SavingsPrdBusinessService(org.mifos.accounts.productdefinition.business.service.SavingsPrdBusinessService) PenaltyBO(org.mifos.accounts.penalties.business.PenaltyBO) RecurrenceTypeEntity(org.mifos.application.meeting.business.RecurrenceTypeEntity) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) ApplicationException(org.mifos.framework.exceptions.ApplicationException) SavingsTypeEntity(org.mifos.accounts.productdefinition.business.SavingsTypeEntity) SavingsProductFormDto(org.mifos.dto.screen.SavingsProductFormDto) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with SavingsProductFormDto

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

the class EditSavingsProductsFormController method showPopulatedForm.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showPopulatedForm(@RequestParam(value = "productId", required = true) Integer productId) {
    ModelAndView modelAndView = new ModelAndView("editSavingsProduct");
    configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
    modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
    SavingsProductFormDto referenceData = this.adminServiceFacade.retrieveSavingsProductFormReferenceData();
    SavingsProductDto savingsProductDto = adminServiceFacade.retrieveSavingsProductDetails(productId);
    SavingsProductFormBean savingsProductBean = new SavingsProductFormBeanAssembler().assembleReferenceData(referenceData);
    ProductDetailsDto productDto = savingsProductDto.getProductDetails();
    GeneralProductBean productBean = new GeneralProductBeanAssembler().assembleFrom(savingsProductBean.getGeneralDetails(), productDto);
    savingsProductBean.setGeneralDetails(productBean);
    savingsProductBean.setSelectedDepositType(savingsProductDto.getDepositType().toString());
    savingsProductBean.setAmountForDeposit(savingsProductDto.getAmountForDeposit());
    if (savingsProductDto.getGroupMandatorySavingsType() > 0) {
        savingsProductBean.setSelectedGroupSavingsApproach(savingsProductDto.getGroupMandatorySavingsType().toString());
    } else {
        savingsProductBean.setSelectedGroupSavingsApproach("");
    }
    savingsProductBean.setMaxWithdrawalAmount(savingsProductDto.getMaxWithdrawal());
    savingsProductBean.setInterestRate(savingsProductDto.getInterestRate());
    savingsProductBean.setSelectedInterestCalculation(savingsProductDto.getInterestCalculationType().toString());
    savingsProductBean.setInterestCalculationFrequency(savingsProductDto.getInterestCalculationFrequency());
    savingsProductBean.setSelectedFequencyPeriod(savingsProductDto.getInterestCalculationFrequencyPeriod().toString());
    savingsProductBean.setInterestPostingMonthlyFrequency(savingsProductDto.getInterestPostingFrequency());
    savingsProductBean.setMinBalanceRequiredForInterestCalculation(Long.toString(savingsProductDto.getMinBalanceForInterestCalculation().longValue()));
    savingsProductBean.setIsDaily(savingsProductDto.isDailyPosting());
    savingsProductBean.setSelectedPrincipalGlCode(savingsProductDto.getDepositGlCode().toString());
    savingsProductBean.setSelectedInterestGlCode(savingsProductDto.getInterestGlCode().toString());
    savingsProductBean.setNotUpdateable(savingsProductDto.isOpenSavingsAccountsExist());
    modelAndView.addObject("savingsProduct", savingsProductBean);
    return modelAndView;
}
Also used : SavingsProductFormDto(org.mifos.dto.screen.SavingsProductFormDto) ModelAndView(org.springframework.web.servlet.ModelAndView) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) ProductDetailsDto(org.mifos.dto.domain.ProductDetailsDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with SavingsProductFormDto

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

the class DefineSavingsProductsFormController method showPopulatedForm.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showPopulatedForm() {
    ModelAndView modelAndView = new ModelAndView("defineSavingsProduct");
    SavingsProductFormDto referenceData = this.adminServiceFacade.retrieveSavingsProductFormReferenceData();
    SavingsProductFormBean savingsProduct = new SavingsProductFormBeanAssembler().assembleReferenceData(referenceData);
    configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
    Double zero = Double.valueOf("0");
    savingsProduct.setAmountForDeposit(zero);
    savingsProduct.setMaxWithdrawalAmount(zero);
    savingsProduct.setMinBalanceRequiredForInterestCalculation("0");
    modelAndView.addObject("savingsProduct", savingsProduct);
    modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
    return modelAndView;
}
Also used : SavingsProductFormDto(org.mifos.dto.screen.SavingsProductFormDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SavingsProductFormDto (org.mifos.dto.screen.SavingsProductFormDto)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ArrayList (java.util.ArrayList)1 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)1 FinancialBusinessService (org.mifos.accounts.financial.business.service.FinancialBusinessService)1 PenaltyBO (org.mifos.accounts.penalties.business.PenaltyBO)1 InterestCalcTypeEntity (org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity)1 PrdApplicableMasterEntity (org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)1 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)1 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)1 RecommendedAmntUnitEntity (org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity)1 SavingsTypeEntity (org.mifos.accounts.productdefinition.business.SavingsTypeEntity)1 SavingsPrdBusinessService (org.mifos.accounts.productdefinition.business.service.SavingsPrdBusinessService)1 RecurrenceTypeEntity (org.mifos.application.meeting.business.RecurrenceTypeEntity)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 ProductDetailsDto (org.mifos.dto.domain.ProductDetailsDto)1 SavingsProductDto (org.mifos.dto.domain.SavingsProductDto)1 ListElement (org.mifos.dto.screen.ListElement)1 ApplicationException (org.mifos.framework.exceptions.ApplicationException)1