コード例 #1
0
  private SavingsProductData handleTemplateRelatedData(final SavingsProductData savingsProduct) {

    final EnumOptionData interestCompoundingPeriodType =
        SavingsEnumerations.compoundingInterestPeriodType(
            SavingsCompoundingInterestPeriodType.DAILY);

    final EnumOptionData interestPostingPeriodType =
        SavingsEnumerations.interestPostingPeriodType(SavingsPostingInterestPeriodType.MONTHLY);

    final EnumOptionData interestCalculationType =
        SavingsEnumerations.interestCalculationType(SavingsInterestCalculationType.DAILY_BALANCE);

    final EnumOptionData interestCalculationDaysInYearType =
        SavingsEnumerations.interestCalculationDaysInYearType(
            SavingsInterestCalculationDaysInYearType.DAYS_365);

    final EnumOptionData accountingRule =
        AccountingEnumerations.accountingRuleType(AccountingRuleType.NONE);

    CurrencyData currency = CurrencyData.blank();
    final Collection<CurrencyData> currencyOptions =
        this.currencyReadPlatformService.retrieveAllowedCurrencies();
    if (currencyOptions.size() == 1) {
      currency = new ArrayList<CurrencyData>(currencyOptions).get(0);
    }

    final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions =
        this.dropdownReadPlatformService.retrieveCompoundingInterestPeriodTypeOptions();

    final Collection<EnumOptionData> interestPostingPeriodTypeOptions =
        this.dropdownReadPlatformService.retrieveInterestPostingPeriodTypeOptions();

    final Collection<EnumOptionData> interestCalculationTypeOptions =
        this.dropdownReadPlatformService.retrieveInterestCalculationTypeOptions();

    final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions =
        this.dropdownReadPlatformService.retrieveInterestCalculationDaysInYearTypeOptions();

    final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions =
        this.dropdownReadPlatformService.retrieveLockinPeriodFrequencyTypeOptions();

    final Collection<EnumOptionData> withdrawalFeeTypeOptions =
        this.dropdownReadPlatformService.retrievewithdrawalFeeTypeOptions();

    final Collection<CodeValueData> paymentTypeOptions =
        this.codeValueReadPlatformService.retrieveCodeValuesByCode(
            PaymentDetailConstants.paymentTypeCodeName);
    final Collection<EnumOptionData> accountingRuleOptions =
        this.accountingDropdownReadPlatformService.retrieveAccountingRuleTypeOptions();
    final Map<String, List<GLAccountData>> accountingMappingOptions =
        this.accountingDropdownReadPlatformService
            .retrieveAccountMappingOptionsForSavingsProducts();

    // charges
    final boolean feeChargesOnly = true;
    Collection<ChargeData> chargeOptions =
        this.chargeReadPlatformService.retrieveSavingsAccountApplicableCharges(feeChargesOnly);
    chargeOptions = CollectionUtils.isEmpty(chargeOptions) ? null : chargeOptions;

    Collection<ChargeData> penaltyOptions =
        this.chargeReadPlatformService.retrieveSavingsAccountApplicablePenalties();
    penaltyOptions = CollectionUtils.isEmpty(penaltyOptions) ? null : penaltyOptions;

    SavingsProductData savingsProductToReturn = null;
    if (savingsProduct != null) {
      savingsProductToReturn =
          SavingsProductData.withTemplate(
              savingsProduct,
              currencyOptions,
              interestCompoundingPeriodTypeOptions,
              interestPostingPeriodTypeOptions,
              interestCalculationTypeOptions,
              interestCalculationDaysInYearTypeOptions,
              lockinPeriodFrequencyTypeOptions,
              withdrawalFeeTypeOptions,
              paymentTypeOptions,
              accountingRuleOptions,
              accountingMappingOptions,
              chargeOptions,
              penaltyOptions);
    } else {
      savingsProductToReturn =
          SavingsProductData.template(
              currency,
              interestCompoundingPeriodType,
              interestPostingPeriodType,
              interestCalculationType,
              interestCalculationDaysInYearType,
              accountingRule,
              currencyOptions,
              interestCompoundingPeriodTypeOptions,
              interestPostingPeriodTypeOptions,
              interestCalculationTypeOptions,
              interestCalculationDaysInYearTypeOptions,
              lockinPeriodFrequencyTypeOptions,
              withdrawalFeeTypeOptions,
              paymentTypeOptions,
              accountingRuleOptions,
              accountingMappingOptions,
              chargeOptions,
              penaltyOptions);
    }

    return savingsProductToReturn;
  }