예제 #1
0
  public Map<String, Object> toMapData(final CurrencyData currencyData) {
    final Map<String, Object> thisTransactionData = new LinkedHashMap<String, Object>();

    final SavingsAccountTransactionEnumData transactionType =
        SavingsEnumerations.transactionType(this.typeOf);

    thisTransactionData.put("id", this.getId());
    thisTransactionData.put("type", transactionType);
    thisTransactionData.put("reversed", Boolean.valueOf(this.isReversed()));
    thisTransactionData.put("date", this.getTransactionLocalDate());
    thisTransactionData.put("currency", currencyData);
    thisTransactionData.put("amount", this.amount);

    if (this.paymentDetail != null) {
      thisTransactionData.put("paymentTypeId", this.paymentDetail.getPaymentType().getId());
    }

    return thisTransactionData;
  }
  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;
  }
    @Override
    public SavingsAccountSummaryData mapRow(
        final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {

      final Long id = JdbcSupport.getLong(rs, "id");
      final String accountNo = rs.getString("accountNo");
      final String externalId = rs.getString("externalId");
      final Long productId = JdbcSupport.getLong(rs, "productId");
      final String productName = rs.getString("productName");
      final Integer statusId = JdbcSupport.getInteger(rs, "statusEnum");
      final BigDecimal accountBalance =
          JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "accountBalance");
      final SavingsAccountStatusEnumData status = SavingsEnumerations.status(statusId);
      final Integer accountType = JdbcSupport.getInteger(rs, "accountType");
      final EnumOptionData accountTypeData = AccountEnumerations.loanType(accountType);

      final String currencyCode = rs.getString("currencyCode");
      final String currencyName = rs.getString("currencyName");
      final String currencyNameCode = rs.getString("currencyNameCode");
      final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
      final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
      final Integer inMultiplesOf = JdbcSupport.getInteger(rs, "inMultiplesOf");
      final CurrencyData currency =
          new CurrencyData(
              currencyCode,
              currencyName,
              currencyDigits,
              inMultiplesOf,
              currencyDisplaySymbol,
              currencyNameCode);

      final LocalDate submittedOnDate = JdbcSupport.getLocalDate(rs, "submittedOnDate");
      final String submittedByUsername = rs.getString("submittedByUsername");
      final String submittedByFirstname = rs.getString("submittedByFirstname");
      final String submittedByLastname = rs.getString("submittedByLastname");

      final LocalDate rejectedOnDate = JdbcSupport.getLocalDate(rs, "rejectedOnDate");
      final String rejectedByUsername = rs.getString("rejectedByUsername");
      final String rejectedByFirstname = rs.getString("rejectedByFirstname");
      final String rejectedByLastname = rs.getString("rejectedByLastname");

      final LocalDate withdrawnOnDate = JdbcSupport.getLocalDate(rs, "withdrawnOnDate");
      final String withdrawnByUsername = rs.getString("withdrawnByUsername");
      final String withdrawnByFirstname = rs.getString("withdrawnByFirstname");
      final String withdrawnByLastname = rs.getString("withdrawnByLastname");

      final LocalDate approvedOnDate = JdbcSupport.getLocalDate(rs, "approvedOnDate");
      final String approvedByUsername = rs.getString("approvedByUsername");
      final String approvedByFirstname = rs.getString("approvedByFirstname");
      final String approvedByLastname = rs.getString("approvedByLastname");

      final LocalDate activatedOnDate = JdbcSupport.getLocalDate(rs, "activatedOnDate");
      final String activatedByUsername = rs.getString("activatedByUsername");
      final String activatedByFirstname = rs.getString("activatedByFirstname");
      final String activatedByLastname = rs.getString("activatedByLastname");

      final LocalDate closedOnDate = JdbcSupport.getLocalDate(rs, "closedOnDate");
      final String closedByUsername = rs.getString("closedByUsername");
      final String closedByFirstname = rs.getString("closedByFirstname");
      final String closedByLastname = rs.getString("closedByLastname");

      final SavingsAccountApplicationTimelineData timeline =
          new SavingsAccountApplicationTimelineData(
              submittedOnDate,
              submittedByUsername,
              submittedByFirstname,
              submittedByLastname,
              rejectedOnDate,
              rejectedByUsername,
              rejectedByFirstname,
              rejectedByLastname,
              withdrawnOnDate,
              withdrawnByUsername,
              withdrawnByFirstname,
              withdrawnByLastname,
              approvedOnDate,
              approvedByUsername,
              approvedByFirstname,
              approvedByLastname,
              activatedOnDate,
              activatedByUsername,
              activatedByFirstname,
              activatedByLastname,
              closedOnDate,
              closedByUsername,
              closedByFirstname,
              closedByLastname);

      return new SavingsAccountSummaryData(
          id,
          accountNo,
          externalId,
          productId,
          productName,
          status,
          currency,
          accountBalance,
          accountTypeData,
          timeline);
    }