@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;
  }
  private void populateProductDataWithDropdownOptions(LoanProductData productData) {

    List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
    List<EnumOptionData> amortizationTypeOptions =
        dropdownReadPlatformService.retrieveLoanAmortizationTypeOptions();
    List<EnumOptionData> interestTypeOptions =
        dropdownReadPlatformService.retrieveLoanInterestTypeOptions();
    List<EnumOptionData> interestCalculationPeriodTypeOptions =
        dropdownReadPlatformService.retrieveLoanInterestRateCalculatedInPeriodOptions();
    List<EnumOptionData> repaymentFrequencyTypeOptions =
        dropdownReadPlatformService.retrieveRepaymentFrequencyTypeOptions();
    List<EnumOptionData> interestRateFrequencyTypeOptions =
        dropdownReadPlatformService.retrieveInterestRateFrequencyTypeOptions();

    productData.setCurrencyOptions(currencyOptions);
    productData.setAmortizationTypeOptions(amortizationTypeOptions);
    productData.setInterestTypeOptions(interestTypeOptions);
    productData.setInterestCalculationPeriodTypeOptions(interestCalculationPeriodTypeOptions);
    productData.setRepaymentFrequencyTypeOptions(repaymentFrequencyTypeOptions);
    productData.setInterestRateFrequencyTypeOptions(interestRateFrequencyTypeOptions);
  }
  @GET
  @Path("{productId}")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retrieveLoanProductDetails(
      @PathParam("productId") final Long productId, @Context final UriInfo uriInfo) {

    Set<String> typicalResponseParameters =
        new HashSet<String>(
            Arrays.asList(
                "id",
                "name",
                "description",
                "fundId",
                "fundName",
                "transactionProcessingStrategyId",
                "transactionProcessingStrategyName",
                "principal",
                "inArrearsTolerance",
                "numberOfRepayments",
                "repaymentEvery",
                "interestRatePerPeriod",
                "annualInterestRate",
                "repaymentFrequencyType",
                "interestRateFrequencyType",
                "amortizationType",
                "interestType",
                "interestCalculationPeriodType",
                "charges",
                "createdOn",
                "lastModifedOn"));

    Set<String> responseParameters =
        ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
    if (responseParameters.isEmpty()) {
      responseParameters.addAll(typicalResponseParameters);
    }
    boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
    boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());

    LoanProductData loanProduct =
        this.loanProductReadPlatformService.retrieveLoanProduct(productId);
    if (template) {
      responseParameters.addAll(
          Arrays.asList(
              "currencyOptions",
              "amortizationTypeOptions",
              "interestTypeOptions",
              "interestCalculationPeriodTypeOptions",
              "repaymentFrequencyTypeOptions",
              "interestRateFrequencyTypeOptions",
              "fundOptions",
              "transactionProcessingStrategyOptions",
              "chargeOptions"));
      Collection<ChargeData> chargeOptions =
          this.chargeReadPlatformService.retrieveLoanApplicableCharges();
      chargeOptions.removeAll(loanProduct.getCharges());
      loanProduct.setChargeOptions(chargeOptions);
    }

    return this.apiJsonSerializerService.serializeLoanProductDataToJson(
        prettyPrint, responseParameters, loanProduct);
  }