@Override
  public LoanProductData retrieveNewLoanProductDetails() {

    LoanProductData productData = new LoanProductData();

    productData.setAmortizationType(
        LoanEnumerations.amortizationType(AmortizationMethod.EQUAL_INSTALLMENTS));
    productData.setInterestType(LoanEnumerations.interestType(InterestMethod.DECLINING_BALANCE));
    productData.setRepaymentFrequencyType(
        LoanEnumerations.repaymentFrequencyType(PeriodFrequencyType.MONTHS));
    productData.setInterestRateFrequencyType(
        LoanEnumerations.interestRateFrequencyType(PeriodFrequencyType.MONTHS));
    productData.setInterestCalculationPeriodType(
        LoanEnumerations.interestCalculationPeriodType(
            InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD));

    populateProductDataWithDropdownOptions(productData);

    if (productData.getCurrencyOptions().size() >= 1) {
      CurrencyData currency = productData.getCurrencyOptions().get(0);
      MoneyData zero = MoneyData.zero(currency);
      productData.setPrincipal(zero);
      productData.setInArrearsTolerance(zero);
    }

    return productData;
  }
    @Override
    public LoanProductData mapRow(final ResultSet rs, final int rowNum) throws SQLException {

      Long id = rs.getLong("id");
      String name = rs.getString("name");
      String description = rs.getString("description");

      String currencyCode = rs.getString("currencyCode");
      Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");

      CurrencyData currencyData = findCurrencyByCode(currencyCode, allowedCurrencies);
      if (currencyData != null) {
        currencyData.setDecimalPlaces(currencyDigits);
      }

      BigDecimal principal = rs.getBigDecimal("principal");
      BigDecimal tolerance = rs.getBigDecimal("tolerance");

      MoneyData principalMoney = MoneyData.of(currencyData, principal);
      MoneyData toleranceMoney = MoneyData.of(currencyData, tolerance);

      Integer numberOfRepayments = JdbcSupport.getInteger(rs, "numberOfRepayments");
      Integer repaymentEvery = JdbcSupport.getInteger(rs, "repaidEvery");
      BigDecimal interestRatePerPeriod = rs.getBigDecimal("interestRatePerPeriod");
      BigDecimal annualInterestRate = rs.getBigDecimal("annualInterestRate");

      int repaymentFrequencyTypeId = JdbcSupport.getInteger(rs, "repaymentPeriodFrequency");
      EnumOptionData repaymentFrequencyType =
          LoanEnumerations.repaymentFrequencyType(repaymentFrequencyTypeId);

      int amortizationTypeId = JdbcSupport.getInteger(rs, "amortizationMethod");
      EnumOptionData amortizationType = LoanEnumerations.amortizationType(amortizationTypeId);

      int interestRateFrequencyTypeId = JdbcSupport.getInteger(rs, "interestRatePerPeriodFreq");
      EnumOptionData interestRateFrequencyType =
          LoanEnumerations.interestRateFrequencyType(interestRateFrequencyTypeId);

      int interestTypeId = JdbcSupport.getInteger(rs, "interestMethod");
      EnumOptionData interestType = LoanEnumerations.interestType(interestTypeId);

      int interestCalculationPeriodTypeId =
          JdbcSupport.getInteger(rs, "interestCalculationInPeriodMethod");
      EnumOptionData interestCalculationPeriodType =
          LoanEnumerations.interestCalculationPeriodType(interestCalculationPeriodTypeId);

      DateTime createdOn = JdbcSupport.getDateTime(rs, "createdon");
      DateTime lastModifedOn = JdbcSupport.getDateTime(rs, "modifiedon");

      return new LoanProductData(
          createdOn,
          lastModifedOn,
          id,
          name,
          description,
          principalMoney,
          toleranceMoney,
          numberOfRepayments,
          repaymentEvery,
          interestRatePerPeriod,
          annualInterestRate,
          repaymentFrequencyType,
          interestRateFrequencyType,
          amortizationType,
          interestType,
          interestCalculationPeriodType);
    }