# Create a Loan Product

`POST /lokta-lms/api/v1/loanproducts`

Depending of the Accounting Rule (accountingRule) selected, additional fields with details of the appropriate Ledger Account identifiers would need to be passed in.

Refer the accounting specification for more details regarding the significance of the selected accounting rule

Mandatory Fields: name, shortName, currencyCode, digitsAfterDecimal, inMultiplesOf, principal, numberOfRepayments, repaymentEvery, repaymentFrequencyType, interestRatePerPeriod, interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType, transactionProcessingStrategyCode, accountingRule, isInterestRecalculationEnabled, daysInYearType, daysInMonthType

Optional Fields: inArrearsTolerance, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, graceOnArrearsAgeing, charges, paymentChannelToFundSourceMappings, feeToIncomeAccountMappings, penaltyToIncomeAccountMappings, chargeOffReasonToExpenseAccountMappings, includeInBorrowerCycle, useBorrowerCycle,principalVariationsForBorrowerCycle, numberOfRepaymentVariationsForBorrowerCycle, interestRateVariationsForBorrowerCycle, multiDisburseLoan,maxTrancheCount, outstandingLoanBalance,overdueDaysForNPA,holdGuaranteeFunds, principalThresholdForLastInstalment, accountMovesOutOfNPAOnlyOnArrearsCompletion, canDefineInstallmentAmount, installmentAmountInMultiplesOf, allowAttributeOverrides, allowPartialPeriodInterestCalculation,dueDaysForRepaymentEvent,overDueDaysForRepaymentEvent,enableDownPayment,disbursedAmountPercentageDownPayment,enableAutoRepaymentForDownPayment,repaymentStartDateType,enableBuyDownFee

Additional Mandatory Fields for Cash(2) based accounting: fundSourceAccountId, loanPortfolioAccountId, interestOnLoanAccountId, incomeFromFeeAccountId, incomeFromPenaltyAccountId, writeOffAccountId, transfersInSuspenseAccountId, overpaymentLiabilityAccountId

Additional Mandatory Fields for periodic (3) and upfront (4)accrual accounting: fundSourceAccountId, loanPortfolioAccountId, interestOnLoanAccountId, incomeFromFeeAccountId, incomeFromPenaltyAccountId, writeOffAccountId, receivableInterestAccountId, receivableFeeAccountId, receivablePenaltyAccountId, transfersInSuspenseAccountId, overpaymentLiabilityAccountId

Additional Mandatory Fields if interest recalculation is enabled(true): interestRecalculationCompoundingMethod, rescheduleStrategyMethod, recalculationRestFrequencyType

Additional Optional Fields if interest recalculation is enabled(true): isArrearsBasedOnOriginalSchedule, preClosureInterestCalculationStrategy

Additional Optional Fields if interest recalculation is enabled(true) and recalculationRestFrequencyType is not same as repayment period: recalculationRestFrequencyInterval, recalculationRestFrequencyDate

Additional Optional Fields if interest recalculation is enabled(true) and interestRecalculationCompoundingMethod is enabled: recalculationCompoundingFrequencyType

Additional Optional Fields if interest recalculation is enabled(true) and interestRecalculationCompoundingMethod is enabled and recalculationCompoundingFrequencyType is not same as repayment period: recalculationCompoundingFrequencyInterval, recalculationCompoundingFrequencyDate

Additional Mandatory Fields if Hold Guarantee funds is enabled(true): mandatoryGuarantee

Additional Optional Fields if Hold Guarantee funds is enabled(true): minimumGuaranteeFromOwnFunds,minimumGuaranteeFromGuarantor

## Request body (application/json)
- `accountMovesOutOfNPAOnlyOnArrearsCompletion` (boolean)
- `accountingRule` (integer)
- `allowApprovedDisbursedAmountsOverApplied` (boolean)
- `allowAttributeOverrides` (AllowAttributeOverrides)
- `allowCompoundingOnEod` (boolean)
- `allowFullTermForTranche` (boolean): Allow full term length for each tranche disbursement. Only available for PROGRESSIVE schedule type with multi-disbursement enabled.
- `allowPartialPeriodInterestCalculation` (boolean)
- `allowVariableInstallments` (boolean)
- `amortizationType` (integer)
- `buyDownExpenseAccountId` (integer)
- `buyDownFeeCalculationType` (string)
- `buyDownFeeIncomeType` (string)
- `buyDownFeeStrategy` (string)
- `buydownfeeClassificationToIncomeAccountMappings` (array of PostClassificationToIncomeAccountMappings)
- `canDefineInstallmentAmount` (boolean)
- `canUseForTopup` (boolean)
- `capitalizedIncomeCalculationType` (string)
- `capitalizedIncomeClassificationToIncomeAccountMappings` (array of PostClassificationToIncomeAccountMappings)
- `capitalizedIncomeStrategy` (string)
- `capitalizedIncomeType` (string)
- `chargeOffBehaviour` (string)
- `chargeOffExpenseAccountId` (integer)
- `chargeOffFraudExpenseAccountId` (integer)
- `chargeOffReasonToExpenseAccountMappings` (array of PostChargeOffReasonToExpenseAccountMappings)
- `charges` (array of LoanProductChargeData)
- `closeDate` (string)
- `creditAllocation` (array of CreditAllocationData)
- `currencyCode` (string)
- `dateFormat` (string)
- `daysInMonthType` (integer)
- `daysInYearCustomStrategy` (string)
- `daysInYearType` (integer)
- `deferredFeeIncomeAccountId` (integer)
- `deferredIncomeLiabilityAccountId` (integer)
- `delinquencyBucketId` (integer)
- `description` (string)
- `digitsAfterDecimal` (integer)
- `disallowExpectedDisbursements` (boolean)
- `disallowInterestCalculationOnPastDue` (boolean)
- `disbursedAmountPercentageForDownPayment` (number)
- `dueDaysForRepaymentEvent` (integer)
- `enableAccrualActivityPosting` (boolean)
- `enableAutoRepaymentForDownPayment` (boolean)
- `enableBuyDownFee` (boolean)
- `enableDownPayment` (boolean)
- `enableIncomeCapitalization` (boolean)
- `enableInstallmentLevelDelinquency` (boolean)
- `externalId` (string)
- `feeToIncomeAccountMappings` (array of LoanProductChargeToGLAccountMapper)
- `fixedLength` (integer)
- `fixedPrincipalPercentagePerInstallment` (number)
- `fundId` (integer)
- `fundSourceAccountId` (integer)
- `goodwillCreditAccountId` (integer)
- `graceOnArrearsAgeing` (integer)
- `graceOnInterestPayment` (integer)
- `graceOnPrincipalPayment` (integer)
- `holdGuaranteeFunds` (boolean)
- `inArrearsTolerance` (integer)
- `inMultiplesOf` (integer)
- `includeInBorrowerCycle` (boolean)
- `incomeFromBuyDownAccountId` (integer)
- `incomeFromCapitalizationAccountId` (integer)
- `incomeFromChargeOffFeesAccountId` (integer)
- `incomeFromChargeOffInterestAccountId` (integer)
- `incomeFromChargeOffPenaltyAccountId` (integer)
- `incomeFromFeeAccountId` (integer)
- `incomeFromGoodwillCreditFeesAccountId` (integer)
- `incomeFromGoodwillCreditInterestAccountId` (integer)
- `incomeFromGoodwillCreditPenaltyAccountId` (integer)
- `incomeFromPenaltyAccountId` (integer)
- `incomeFromRecoveryAccountId` (integer)
- `installmentAmountInMultiplesOf` (integer)
- `interestCalculationPeriodType` (integer)
- `interestOnLoanAccountId` (integer)
- `interestRateFrequencyType` (integer)
- `interestRatePerPeriod` (number)
- `interestRateVariationsForBorrowerCycle` (array)
- `interestRecalculationCompoundingMethod` (integer)
- `interestRecognitionOnDisbursementDate` (boolean)
- `interestType` (integer)
- `isArrearsBasedOnOriginalSchedule` (boolean)
- `isCompoundingToBePostedAsTransaction` (boolean)
- `isEqualAmortization` (boolean)
- `isInterestRecalculationEnabled` (boolean)
- `isLinkedToFloatingInterestRates` (boolean)
- `loanPortfolioAccountId` (integer)
- `loanScheduleProcessingType` (string)
- `loanScheduleType` (string)
- `locale` (string)
- `maxInterestRatePerPeriod` (number)
- `maxNumberOfRepayments` (integer)
- `maxPrincipal` (number)
- `maxTrancheCount` (integer)
- `merchantBuyDownFee` (boolean)
- `minInterestRatePerPeriod` (number)
- `minNumberOfRepayments` (integer)
- `minPrincipal` (number)
- `minimumDaysBetweenDisbursalAndFirstRepayment` (integer)
- `multiDisburseLoan` (boolean)
- `name` (string)
- `numberOfRepaymentVariationsForBorrowerCycle` (array)
- `numberOfRepayments` (integer)
- `outstandingLoanBalance` (number)
- `overAppliedCalculationType` (string)
- `overAppliedNumber` (integer)
- `overDueDaysForRepaymentEvent` (integer)
- `overdueDaysForNPA` (integer)
- `overpaymentLiabilityAccountId` (integer)
- `paymentAllocation` (array of AdvancedPaymentData)
- `paymentChannelToFundSourceMappings` (array of GetLoanPaymentChannelToFundSourceMappings)
- `penaltyToIncomeAccountMappings` (array of LoanProductChargeToGLAccountMapper)
- `preClosureInterestCalculationStrategy` (integer)
- `principal` (number)
- `principalThresholdForLastInstallment` (integer)
- `principalVariationsForBorrowerCycle` (array)
- `rates` (array of RateData)
- `recalculationCompoundingFrequencyInterval` (integer)
- `recalculationCompoundingFrequencyOnDayType` (integer)
- `recalculationCompoundingFrequencyType` (integer)
- `recalculationRestFrequencyInterval` (integer)
- `recalculationRestFrequencyType` (integer)
- `receivableFeeAccountId` (integer)
- `receivableInterestAccountId` (integer)
- `receivablePenaltyAccountId` (integer)
- `repaymentEvery` (integer)
- `repaymentFrequencyType` (integer)
- `repaymentStartDateType` (integer)
- `rescheduleStrategyMethod` (integer)
- `shortName` (string)
- `startDate` (string)
- `supportedInterestRefundTypes` (array)
- `transactionProcessingStrategyCode` (string)
- `transfersInSuspenseAccountId` (integer)
- `useBorrowerCycle` (boolean)
- `writeOffAccountId` (integer)
- `writeOffReasonsToExpenseMappings` (array of PostWriteOffReasonToExpenseAccountMappings)

## Responses
- `200`: OK

## Response fields
- `resourceId` (integer)

## Example request (cURL)
```bash
curl -X POST \
  'http://localhost:8080/lokta-lms/api/v1/loanproducts' \
  -u '{username}:{password}' \
  -H 'Tenant-Identifier: default' \
  -H 'Content-Type: application/json' \
  -d '{
  "accountMovesOutOfNPAOnlyOnArrearsCompletion": false,
  "accountingRule": 3,
  "allowApprovedDisbursedAmountsOverApplied": true,
  "allowAttributeOverrides": {
    "amortizationType": true,
    "graceOnArrearsAgeing": true,
    "graceOnPrincipalAndInterestPayment": true,
    "inArrearsTolerance": true
  },
  "allowCompoundingOnEod": false,
  "allowFullTermForTranche": false,
  "allowPartialPeriodInterestCalculation": true,
  "allowVariableInstallments": false,
  "amortizationType": 1,
  "buyDownExpenseAccountId": 27
}'
```

## Example response
```json
{
  "resourceId": 3
}
```

Interactive: https://developer.lokta.ai/reference.html#operation/createLoanProduct
