| /** |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| package org.apache.fineract.portfolio.loanproduct.api; |
| |
| import io.swagger.v3.oas.annotations.Operation; |
| import io.swagger.v3.oas.annotations.Parameter; |
| import io.swagger.v3.oas.annotations.media.ArraySchema; |
| import io.swagger.v3.oas.annotations.media.Content; |
| import io.swagger.v3.oas.annotations.media.Schema; |
| import io.swagger.v3.oas.annotations.parameters.RequestBody; |
| import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| import io.swagger.v3.oas.annotations.tags.Tag; |
| import java.util.Arrays; |
| import java.util.Collection; |
| import java.util.HashSet; |
| import java.util.List; |
| import java.util.Map; |
| import java.util.Set; |
| import java.util.stream.Collectors; |
| import javax.ws.rs.Consumes; |
| import javax.ws.rs.GET; |
| import javax.ws.rs.POST; |
| import javax.ws.rs.PUT; |
| import javax.ws.rs.Path; |
| import javax.ws.rs.PathParam; |
| import javax.ws.rs.Produces; |
| import javax.ws.rs.QueryParam; |
| import javax.ws.rs.core.Context; |
| import javax.ws.rs.core.MediaType; |
| import javax.ws.rs.core.UriInfo; |
| import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService; |
| import org.apache.fineract.accounting.glaccount.data.GLAccountData; |
| import org.apache.fineract.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; |
| import org.apache.fineract.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper; |
| import org.apache.fineract.accounting.producttoaccountmapping.service.ProductToGLAccountMappingReadPlatformService; |
| import org.apache.fineract.commands.domain.CommandWrapper; |
| import org.apache.fineract.commands.service.CommandWrapperBuilder; |
| import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; |
| import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService; |
| import org.apache.fineract.infrastructure.core.api.ApiParameterHelper; |
| import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; |
| import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; |
| import org.apache.fineract.infrastructure.core.data.EnumOptionData; |
| import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; |
| import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; |
| import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; |
| import org.apache.fineract.organisation.monetary.data.CurrencyData; |
| import org.apache.fineract.organisation.monetary.service.CurrencyReadPlatformService; |
| import org.apache.fineract.portfolio.charge.data.ChargeData; |
| import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; |
| import org.apache.fineract.portfolio.common.service.DropdownReadPlatformService; |
| import org.apache.fineract.portfolio.creditscorecard.data.CreditScorecardFeatureData; |
| import org.apache.fineract.portfolio.creditscorecard.domain.CreditScorecardFeature; |
| import org.apache.fineract.portfolio.creditscorecard.provider.ScorecardServiceProvider; |
| import org.apache.fineract.portfolio.creditscorecard.service.CreditScorecardReadPlatformService; |
| import org.apache.fineract.portfolio.floatingrates.data.FloatingRateData; |
| import org.apache.fineract.portfolio.floatingrates.service.FloatingRatesReadPlatformService; |
| import org.apache.fineract.portfolio.fund.data.FundData; |
| import org.apache.fineract.portfolio.fund.service.FundReadPlatformService; |
| import org.apache.fineract.portfolio.loanaccount.api.LoanApiConstants; |
| import org.apache.fineract.portfolio.loanproduct.LoanProductConstants; |
| import org.apache.fineract.portfolio.loanproduct.data.LoanProductData; |
| import org.apache.fineract.portfolio.loanproduct.data.TransactionProcessingStrategyData; |
| import org.apache.fineract.portfolio.loanproduct.productmix.data.ProductMixData; |
| import org.apache.fineract.portfolio.loanproduct.productmix.service.ProductMixReadPlatformService; |
| import org.apache.fineract.portfolio.loanproduct.service.LoanDropdownReadPlatformService; |
| import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService; |
| import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; |
| import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; |
| import org.apache.fineract.portfolio.rate.data.RateData; |
| import org.apache.fineract.portfolio.rate.service.RateReadService; |
| import org.springframework.beans.factory.annotation.Autowired; |
| import org.springframework.context.annotation.Scope; |
| import org.springframework.stereotype.Component; |
| |
| @Path("/loanproducts") |
| @Component |
| @Scope("singleton") |
| @Tag(name = "Loan Products", description = "A Loan product is a template that is used when creating a loan. Much of the template definition can be overridden during loan creation.") |
| public class LoanProductsApiResource { |
| |
| private final Set<String> loanProductDataParameters = new HashSet<>(Arrays.asList("id", "name", "shortName", "description", "fundId", |
| "fundName", "includeInBorrowerCycle", "currency", "principal", "minPrincipal", "maxPrincipal", "numberOfRepayments", |
| "minNumberOfRepayments", "maxNumberOfRepayments", "repaymentEvery", "repaymentFrequencyType", "graceOnPrincipalPayment", |
| "recurringMoratoriumOnPrincipalPeriods", "graceOnInterestPayment", "graceOnInterestCharged", "interestRatePerPeriod", |
| "minInterestRatePerPeriod", "maxInterestRatePerPeriod", "interestRateFrequencyType", "annualInterestRate", "amortizationType", |
| "interestType", "interestCalculationPeriodType", LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, |
| "inArrearsTolerance", "transactionProcessingStrategyId", "transactionProcessingStrategyName", "charges", "accountingRule", |
| "externalId", "accountingMappings", "paymentChannelToFundSourceMappings", "fundOptions", "paymentTypeOptions", |
| "currencyOptions", "repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "amortizationTypeOptions", |
| "interestTypeOptions", "interestCalculationPeriodTypeOptions", "transactionProcessingStrategyOptions", "chargeOptions", |
| "accountingOptions", "accountingRuleOptions", "accountingMappingOptions", "floatingRateOptions", |
| "isLinkedToFloatingInterestRates", "floatingRatesId", "interestRateDifferential", "minDifferentialLendingRate", |
| "defaultDifferentialLendingRate", "maxDifferentialLendingRate", "isFloatingInterestRateCalculationAllowed", |
| LoanProductConstants.CAN_USE_FOR_TOPUP, LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, LoanProductConstants.RATES_PARAM_NAME, |
| LoanApiConstants.fixedPrincipalPercentagePerInstallmentParamName)); |
| |
| private final Set<String> productMixDataParameters = new HashSet<>( |
| Arrays.asList("productId", "productName", "restrictedProducts", "allowedProducts", "productOptions")); |
| |
| private final String resourceNameForPermissions = "LOANPRODUCT"; |
| |
| private final PlatformSecurityContext context; |
| private final LoanProductReadPlatformService loanProductReadPlatformService; |
| private final ChargeReadPlatformService chargeReadPlatformService; |
| private final CurrencyReadPlatformService currencyReadPlatformService; |
| private final FundReadPlatformService fundReadPlatformService; |
| private final DefaultToApiJsonSerializer<LoanProductData> toApiJsonSerializer; |
| private final ApiRequestParameterHelper apiRequestParameterHelper; |
| private final LoanDropdownReadPlatformService dropdownReadPlatformService; |
| private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; |
| private final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService; |
| private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService; |
| private final DefaultToApiJsonSerializer<ProductMixData> productMixDataApiJsonSerializer; |
| private final ProductMixReadPlatformService productMixReadPlatformService; |
| private final DropdownReadPlatformService commonDropdownReadPlatformService; |
| private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; |
| private final FloatingRatesReadPlatformService floatingRateReadPlatformService; |
| private final RateReadService rateReadService; |
| private final ConfigurationDomainService configurationDomainService; |
| private final ScorecardServiceProvider scorecardServiceProvider; |
| |
| @Autowired |
| public LoanProductsApiResource(final PlatformSecurityContext context, final LoanProductReadPlatformService readPlatformService, |
| final ChargeReadPlatformService chargeReadPlatformService, final CurrencyReadPlatformService currencyReadPlatformService, |
| final FundReadPlatformService fundReadPlatformService, final LoanDropdownReadPlatformService dropdownReadPlatformService, |
| final DefaultToApiJsonSerializer<LoanProductData> toApiJsonSerializer, |
| final ApiRequestParameterHelper apiRequestParameterHelper, |
| final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, |
| final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService, |
| final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService, |
| final DefaultToApiJsonSerializer<ProductMixData> productMixDataApiJsonSerializer, |
| final ProductMixReadPlatformService productMixReadPlatformService, |
| final DropdownReadPlatformService commonDropdownReadPlatformService, |
| PaymentTypeReadPlatformService paymentTypeReadPlatformService, |
| final FloatingRatesReadPlatformService floatingRateReadPlatformService, final RateReadService rateReadService, |
| final ConfigurationDomainService configurationDomainService, final ScorecardServiceProvider scorecardServiceProvider) { |
| this.context = context; |
| this.loanProductReadPlatformService = readPlatformService; |
| this.chargeReadPlatformService = chargeReadPlatformService; |
| this.currencyReadPlatformService = currencyReadPlatformService; |
| this.fundReadPlatformService = fundReadPlatformService; |
| this.dropdownReadPlatformService = dropdownReadPlatformService; |
| this.toApiJsonSerializer = toApiJsonSerializer; |
| this.apiRequestParameterHelper = apiRequestParameterHelper; |
| this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; |
| this.accountMappingReadPlatformService = accountMappingReadPlatformService; |
| this.accountingDropdownReadPlatformService = accountingDropdownReadPlatformService; |
| this.productMixDataApiJsonSerializer = productMixDataApiJsonSerializer; |
| this.productMixReadPlatformService = productMixReadPlatformService; |
| this.commonDropdownReadPlatformService = commonDropdownReadPlatformService; |
| this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; |
| this.floatingRateReadPlatformService = floatingRateReadPlatformService; |
| this.rateReadService = rateReadService; |
| this.configurationDomainService = configurationDomainService; |
| this.scorecardServiceProvider = scorecardServiceProvider; |
| } |
| |
| @POST |
| @Consumes({ MediaType.APPLICATION_JSON }) |
| @Produces({ MediaType.APPLICATION_JSON }) |
| @Operation(summary = "Create a Loan Product", description = "Depending of the Accounting Rule (accountingRule) selected, additional fields with details of the appropriate Ledger Account identifiers would need to be passed in.\n" |
| + "\n" + "Refer MifosX Accounting Specs Draft for more details regarding the significance of the selected accounting rule\n\n" |
| + "Mandatory Fields: name, shortName, currencyCode, digitsAfterDecimal, inMultiplesOf, principal, numberOfRepayments, repaymentEvery, repaymentFrequencyType, interestRatePerPeriod, interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType, transactionProcessingStrategyId, accountingRule, isInterestRecalculationEnabled, daysInYearType, daysInMonthType\n\n" |
| + "Optional Fields: inArrearsTolerance, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, graceOnArrearsAgeing, charges, paymentChannelToFundSourceMappings, feeToIncomeAccountMappings, penaltyToIncomeAccountMappings, includeInBorrowerCycle, useBorrowerCycle,principalVariationsForBorrowerCycle, numberOfRepaymentVariationsForBorrowerCycle, interestRateVariationsForBorrowerCycle, multiDisburseLoan,maxTrancheCount, outstandingLoanBalance,overdueDaysForNPA,holdGuaranteeFunds, principalThresholdForLastInstalment, accountMovesOutOfNPAOnlyOnArrearsCompletion, canDefineInstallmentAmount, installmentAmountInMultiplesOf, allowAttributeOverrides, allowPartialPeriodInterestCalcualtion\n\n" |
| + "Additional Mandatory Fields for Cash(2) based accounting: fundSourceAccountId, loanPortfolioAccountId, interestOnLoanAccountId, incomeFromFeeAccountId, incomeFromPenaltyAccountId, writeOffAccountId, transfersInSuspenseAccountId, overpaymentLiabilityAccountId\n\n" |
| + "Additional Mandatory Fields for periodic (3) and upfront (4)accrual accounting: fundSourceAccountId, loanPortfolioAccountId, interestOnLoanAccountId, incomeFromFeeAccountId, incomeFromPenaltyAccountId, writeOffAccountId, receivableInterestAccountId, receivableFeeAccountId, receivablePenaltyAccountId, transfersInSuspenseAccountId, overpaymentLiabilityAccountId\n\n" |
| + "Additional Mandatory Fields if interest recalculation is enabled(true): interestRecalculationCompoundingMethod, rescheduleStrategyMethod, recalculationRestFrequencyType\n\n" |
| + "Additional Optional Fields if interest recalculation is enabled(true): isArrearsBasedOnOriginalSchedule, preClosureInterestCalculationStrategy\n\n" |
| + "Additional Optional Fields if interest recalculation is enabled(true) and recalculationRestFrequencyType is not same as repayment period: recalculationRestFrequencyInterval, recalculationRestFrequencyDate\n\n" |
| + "Additional Optional Fields if interest recalculation is enabled(true) and interestRecalculationCompoundingMethod is enabled: recalculationCompoundingFrequencyType\n\n" |
| + "Additional Optional Fields if interest recalculation is enabled(true) and interestRecalculationCompoundingMethod is enabled and recalculationCompoundingFrequencyType is not same as repayment period: recalculationCompoundingFrequencyInterval, recalculationCompoundingFrequencyDate\n\n" |
| + "Additional Mandatory Fields if Hold Guarantee funds is enabled(true): mandatoryGuarantee\n\n" |
| + "Additional Optional Fields if Hold Guarantee funds is enabled(true): minimumGuaranteeFromOwnFunds,minimumGuaranteeFromGuarantor") |
| @RequestBody(required = true, content = @Content(schema = @Schema(implementation = LoanProductsApiResourceSwagger.PostLoanProductsRequest.class))) |
| @ApiResponses({ |
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = LoanProductsApiResourceSwagger.PostLoanProductsResponse.class))) }) |
| public String createLoanProduct(@Parameter(hidden = true) final String apiRequestBodyAsJson) { |
| |
| final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanProduct().withJson(apiRequestBodyAsJson).build(); |
| |
| final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); |
| |
| return this.toApiJsonSerializer.serialize(result); |
| } |
| |
| @GET |
| @Consumes({ MediaType.APPLICATION_JSON }) |
| @Produces({ MediaType.APPLICATION_JSON }) |
| @Operation(summary = "List Loan Products", description = "Lists Loan Products\n\n" + "Example Requests:\n" + "\n" + "loanproducts\n" |
| + "\n" + "\n" + "loanproducts?fields=name,description,interestRateFrequencyType,amortizationType") |
| @ApiResponses({ |
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = LoanProductsApiResourceSwagger.GetLoanProductsResponse.class)))) }) |
| public String retrieveAllLoanProducts(@Context final UriInfo uriInfo) { |
| |
| this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); |
| final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters()); |
| final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); |
| |
| if (!associationParameters.isEmpty()) { |
| if (associationParameters.contains("productMixes")) { |
| this.context.authenticatedUser().validateHasReadPermission("PRODUCTMIX"); |
| final Collection<ProductMixData> productMixes = this.productMixReadPlatformService.retrieveAllProductMixes(); |
| return this.productMixDataApiJsonSerializer.serialize(settings, productMixes, this.productMixDataParameters); |
| } |
| } |
| |
| final Collection<LoanProductData> products = this.loanProductReadPlatformService.retrieveAllLoanProducts(); |
| |
| return this.toApiJsonSerializer.serialize(settings, products, this.loanProductDataParameters); |
| } |
| |
| @GET |
| @Path("template") |
| @Consumes({ MediaType.APPLICATION_JSON }) |
| @Produces({ MediaType.APPLICATION_JSON }) |
| @Operation(summary = "Retrieve Loan Product Details Template", description = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" |
| + "\n" + "Field Defaults\n" + "Allowed description Lists\n" + "Example Request:\n" + "\n" + "loanproducts/template") |
| @ApiResponses({ |
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = LoanProductsApiResourceSwagger.GetLoanProductsTemplateResponse.class))) }) |
| public String retrieveTemplate(@Context final UriInfo uriInfo, |
| @QueryParam("isProductMixTemplate") @Parameter(description = "isProductMixTemplate") final boolean isProductMixTemplate) { |
| |
| this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); |
| final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); |
| |
| if (isProductMixTemplate) { |
| this.context.authenticatedUser().validateHasReadPermission("PRODUCTMIX"); |
| |
| final Collection<LoanProductData> productOptions = this.loanProductReadPlatformService.retrieveAvailableLoanProductsForMix(); |
| final ProductMixData productMixData = ProductMixData.template(productOptions); |
| return this.productMixDataApiJsonSerializer.serialize(settings, productMixData, this.productMixDataParameters); |
| } |
| |
| LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveNewLoanProductDetails(); |
| loanProduct = handleTemplate(loanProduct); |
| |
| return this.toApiJsonSerializer.serialize(settings, loanProduct, this.loanProductDataParameters); |
| } |
| |
| @GET |
| @Path("{productId}") |
| @Consumes({ MediaType.APPLICATION_JSON }) |
| @Produces({ MediaType.APPLICATION_JSON }) |
| @Operation(summary = "Retrieve a Loan Product", description = "Retrieves a Loan Product\n\n" + "Example Requests:\n" + "\n" |
| + "loanproducts/1\n" + "\n" + "\n" + "loanproducts/1?template=true\n" + "\n" + "\n" |
| + "loanproducts/1?fields=name,description,numberOfRepayments") |
| @ApiResponses({ |
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = LoanProductsApiResourceSwagger.GetLoanProductsProductIdResponse.class))) }) |
| public String retrieveLoanProductDetails(@PathParam("productId") @Parameter(description = "productId") final Long productId, |
| @Context final UriInfo uriInfo) { |
| |
| this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); |
| |
| final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); |
| |
| LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId); |
| |
| Map<String, Object> accountingMappings = null; |
| Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings = null; |
| Collection<ChargeToGLAccountMapper> feeToGLAccountMappings = null; |
| Collection<ChargeToGLAccountMapper> penaltyToGLAccountMappings = null; |
| if (loanProduct.hasAccountingEnabled()) { |
| accountingMappings = this.accountMappingReadPlatformService.fetchAccountMappingDetailsForLoanProduct(productId, |
| loanProduct.accountingRuleType().getId().intValue()); |
| paymentChannelToFundSourceMappings = this.accountMappingReadPlatformService |
| .fetchPaymentTypeToFundSourceMappingsForLoanProduct(productId); |
| feeToGLAccountMappings = this.accountMappingReadPlatformService.fetchFeeToGLAccountMappingsForLoanProduct(productId); |
| penaltyToGLAccountMappings = this.accountMappingReadPlatformService |
| .fetchPenaltyToIncomeAccountMappingsForLoanProduct(productId); |
| loanProduct = LoanProductData.withAccountingDetails(loanProduct, accountingMappings, paymentChannelToFundSourceMappings, |
| feeToGLAccountMappings, penaltyToGLAccountMappings); |
| } |
| |
| if (settings.isTemplate()) { |
| loanProduct = handleTemplate(loanProduct); |
| } |
| return this.toApiJsonSerializer.serialize(settings, loanProduct, this.loanProductDataParameters); |
| } |
| |
| @PUT |
| @Path("{productId}") |
| @Consumes({ MediaType.APPLICATION_JSON }) |
| @Produces({ MediaType.APPLICATION_JSON }) |
| @Operation(summary = "Update a Loan Product", description = "Updates a Loan Product") |
| @RequestBody(required = true, content = @Content(schema = @Schema(implementation = LoanProductsApiResourceSwagger.PutLoanProductsProductIdRequest.class))) |
| @ApiResponses({ |
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = LoanProductsApiResourceSwagger.PutLoanProductsProductIdResponse.class))) }) |
| public String updateLoanProduct(@PathParam("productId") @Parameter(description = "productId") final Long productId, |
| @Parameter(hidden = true) final String apiRequestBodyAsJson) { |
| |
| final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanProduct(productId).withJson(apiRequestBodyAsJson) |
| .build(); |
| |
| final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); |
| |
| return this.toApiJsonSerializer.serialize(result); |
| } |
| |
| private LoanProductData handleTemplate(final LoanProductData productData) { |
| |
| Collection<ChargeData> chargeOptions = this.chargeReadPlatformService.retrieveLoanApplicableFees(); |
| if (chargeOptions.isEmpty()) { |
| chargeOptions = null; |
| } |
| |
| Collection<ChargeData> penaltyOptions = this.chargeReadPlatformService.retrieveLoanApplicablePenalties(); |
| if (penaltyOptions.isEmpty()) { |
| penaltyOptions = null; |
| } |
| |
| boolean isRatesEnabled = this.configurationDomainService.isSubRatesEnabled(); |
| Collection<RateData> rateOptions = this.rateReadService.retrieveLoanApplicableRates(); |
| if (rateOptions.isEmpty()) { |
| rateOptions = null; |
| } |
| |
| final Collection<CurrencyData> currencyOptions = this.currencyReadPlatformService.retrieveAllowedCurrencies(); |
| final List<EnumOptionData> amortizationTypeOptions = this.dropdownReadPlatformService.retrieveLoanAmortizationTypeOptions(); |
| final List<EnumOptionData> interestTypeOptions = this.dropdownReadPlatformService.retrieveLoanInterestTypeOptions(); |
| final List<EnumOptionData> interestCalculationPeriodTypeOptions = this.dropdownReadPlatformService |
| .retrieveLoanInterestRateCalculatedInPeriodOptions(); |
| final List<EnumOptionData> repaymentFrequencyTypeOptions = this.dropdownReadPlatformService.retrieveRepaymentFrequencyTypeOptions(); |
| final List<EnumOptionData> interestRateFrequencyTypeOptions = this.dropdownReadPlatformService |
| .retrieveInterestRateFrequencyTypeOptions(); |
| final Collection<PaymentTypeData> paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); |
| |
| Collection<FundData> fundOptions = this.fundReadPlatformService.retrieveAllFunds(); |
| if (fundOptions.isEmpty()) { |
| fundOptions = null; |
| } |
| final Collection<TransactionProcessingStrategyData> transactionProcessingStrategyOptions = this.dropdownReadPlatformService |
| .retreiveTransactionProcessingStrategies(); |
| |
| final Map<String, List<GLAccountData>> accountOptions = this.accountingDropdownReadPlatformService |
| .retrieveAccountMappingOptionsForLoanProducts(); |
| |
| final List<EnumOptionData> accountingRuleTypeOptions = this.accountingDropdownReadPlatformService |
| .retrieveAccountingRuleTypeOptions(); |
| |
| final List<EnumOptionData> loanCycleValueConditionTypeOptions = this.dropdownReadPlatformService |
| .retrieveLoanCycleValueConditionTypeOptions(); |
| |
| final List<EnumOptionData> daysInMonthTypeOptions = commonDropdownReadPlatformService.retrieveDaysInMonthTypeOptions(); |
| final List<EnumOptionData> daysInYearTypeOptions = commonDropdownReadPlatformService.retrieveDaysInYearTypeOptions(); |
| final List<EnumOptionData> interestRecalculationCompoundingTypeOptions = dropdownReadPlatformService |
| .retrieveInterestRecalculationCompoundingTypeOptions(); |
| final List<EnumOptionData> rescheduleStrategyTypeOptions = dropdownReadPlatformService.retrieveRescheduleStrategyTypeOptions(); |
| final List<EnumOptionData> interestRecalculationFrequencyTypeOptions = dropdownReadPlatformService |
| .retrieveInterestRecalculationFrequencyTypeOptions(); |
| final List<EnumOptionData> interestRecalculationNthDayTypeOptions = dropdownReadPlatformService |
| .retrieveInterestRecalculationNthDayTypeOptions(); |
| final List<EnumOptionData> interestRecalculationDayOfWeekTypeOptions = dropdownReadPlatformService |
| .retrieveInterestRecalculationDayOfWeekTypeOptions(); |
| final List<EnumOptionData> preCloseInterestCalculationStrategyOptions = dropdownReadPlatformService |
| .retrivePreCloseInterestCalculationStrategyOptions(); |
| final List<FloatingRateData> floatingRateOptions = this.floatingRateReadPlatformService.retrieveLookupActive(); |
| |
| Collection<CreditScorecardFeatureData> scorecardFeatureOptions = null; |
| |
| final String serviceName = "CreditScorecardReadPlatformService"; |
| final CreditScorecardReadPlatformService scorecardService = (CreditScorecardReadPlatformService) scorecardServiceProvider |
| .getScorecardService(serviceName); |
| |
| if (scorecardService != null) { |
| scorecardFeatureOptions = scorecardService.findAllFeaturesWithNotFoundDetection().stream().map(CreditScorecardFeature::toData) |
| .collect(Collectors.toList()); |
| } |
| |
| return new LoanProductData(productData, chargeOptions, penaltyOptions, paymentTypeOptions, currencyOptions, amortizationTypeOptions, |
| interestTypeOptions, interestCalculationPeriodTypeOptions, repaymentFrequencyTypeOptions, interestRateFrequencyTypeOptions, |
| fundOptions, transactionProcessingStrategyOptions, rateOptions, accountOptions, accountingRuleTypeOptions, |
| loanCycleValueConditionTypeOptions, daysInMonthTypeOptions, daysInYearTypeOptions, |
| interestRecalculationCompoundingTypeOptions, rescheduleStrategyTypeOptions, interestRecalculationFrequencyTypeOptions, |
| preCloseInterestCalculationStrategyOptions, floatingRateOptions, interestRecalculationNthDayTypeOptions, |
| interestRecalculationDayOfWeekTypeOptions, isRatesEnabled, scorecardFeatureOptions); |
| } |
| |
| } |