public void validateGroup(SavingsProductFormBean savingsProductFormBean, BindingResult result) { if (savingsProductFormBean.isGroupSavingAccount() && StringUtils.isBlank(savingsProductFormBean.getSelectedGroupSavingsApproach())) { ObjectError error = new ObjectError( "savingsProduct", new String[] {"NotEmpty.savingsProduct.selectedGroupSavingsApproach"}, new Object[] {}, "default: "); result.addError(error); } }
public void validateManadtorySavingsProduct( SavingsProductFormBean savingsProductFormBean, BindingResult result) { if (savingsProductFormBean.isMandatory() && savingsProductFormBean.getAmountForDeposit() == null || savingsProductFormBean.getAmountForDeposit().intValue() <= 0) { ObjectError error = new ObjectError( "savingsProduct", new String[] {"Min.savingsProduct.amountForDesposit"}, new Object[] {}, "default: "); result.addError(error); } }
public SavingsProductFormBean assembleReferenceData(SavingsProductFormDto referenceData) { SavingsProductFormBean formBean = new SavingsProductFormBean(); GeneralProductBean productDetails = productBeanAssembler.assembleFromRefData(referenceData); formBean.setGeneralDetails(productDetails); // assembler for accounting section populatePrincipalGlCodesDropdown(referenceData, formBean); populateInterestGlCodesDropdown(referenceData, formBean); populateDepositTypesDropdown(referenceData, formBean); populateAppliesToDropdown(referenceData, formBean); populateInterestBalanceDropdown(referenceData, formBean); populateFrequencyPeriodDropdown(referenceData, formBean); return formBean; }
private void populatePrincipalGlCodesDropdown( SavingsProductFormDto referenceData, SavingsProductFormBean formBean) { Map<String, String> principalGeneralLedgerOptions = new LinkedHashMap<String, String>(); for (ListElement glCode : referenceData.getPrincipalGlCodes()) { principalGeneralLedgerOptions.put(glCode.getId().toString(), glCode.getName()); } formBean.setPrincipalGeneralLedgerOptions(principalGeneralLedgerOptions); }
private void populateDepositTypesDropdown( SavingsProductFormDto referenceData, SavingsProductFormBean formBean) { Map<String, String> depositTypes = new LinkedHashMap<String, String>(); for (ListElement option : referenceData.getDepositTypes()) { depositTypes.put(option.getId().toString(), option.getName()); } formBean.setDepositTypeOptions(depositTypes); }
private void populateAppliesToDropdown( SavingsProductFormDto referenceData, SavingsProductFormBean formBean) { Map<String, String> groupSavingsApproachOptions = new LinkedHashMap<String, String>(); for (ListElement option : referenceData.getDespositAmountAppliesTo()) { groupSavingsApproachOptions.put(option.getId().toString(), option.getName()); } formBean.setGroupSavingsApproachOptions(groupSavingsApproachOptions); }
private void populateInterestBalanceDropdown( SavingsProductFormDto referenceData, SavingsProductFormBean formBean) { Map<String, String> interestBalanceTypes = new LinkedHashMap<String, String>(); for (ListElement option : referenceData.getInterestBalanceTypes()) { interestBalanceTypes.put(option.getId().toString(), option.getName()); } formBean.setInterestCaluclationOptions(interestBalanceTypes); }
private void populateFrequencyPeriodDropdown( SavingsProductFormDto referenceData, SavingsProductFormBean formBean) { Map<String, String> frequencyPeriods = new LinkedHashMap<String, String>(); for (ListElement option : referenceData.getInterestTimePeriodTypes()) { frequencyPeriods.put(option.getId().toString(), option.getName()); } formBean.setFrequencyPeriodOptions(frequencyPeriods); }
@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; }
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); }