Skip to main content

CreateSelfServiceLoanQuoteCommand

Overview

Creates a new loan application (loan quote) in the system. This is the starting point for the loan origination process. Once created, additional information like identity documents, guarantors, credit bureau searches, and bank statements can be attached to the loan quote.

Command Structure

{
"cmd": "CreateSelfServiceLoanQuoteCommand",
"data": "{\"selfServiceUserId\":123,\"selfServiceBranchId\":5,\"loanProductCode\":\"PERSONAL_LOAN\",\"loanAmount\":500000,\"tenor\":12,\"purpose\":\"Business expansion\"}"
}

Parameters

ParameterTypeRequiredDescription
selfServiceUserIdlongYesThe ID of the customer applying for the loan
selfServiceBranchIdlongYesThe branch where the loan is being processed
loanProductCodestringYesThe code of the loan product (e.g., "PERSONAL_LOAN", "BUSINESS_LOAN")
loanAmountdecimalYesThe requested loan amount
tenorintYesLoan tenure in months
purposestringNoPurpose of the loan (optional)
interestRatedecimalNoCustom interest rate (if allowed by product)
repaymentFrequencystringNo"MONTHLY", "QUARTERLY", etc. (defaults to product setting)

Response Structure

Success Response

{
"ok": true,
"statusCode": "00",
"message": "Loan quote created successfully",
"outData": {
"loanQuoteId": 110,
"referenceNumber": "LQ-2024-00110",
"loanAmount": 500000,
"tenor": 12,
"interestRate": 18.5,
"monthlyRepayment": 45625.50,
"totalRepayment": 547506,
"approvalState": "NOT_STARTED",
"currentApprovalLevel": 0,
"createdAt": "2024-01-12T10:30:00Z"
}
}

Error Response

{
"ok": false,
"statusCode": "04",
"message": "Invalid loan product code",
"outData": null
}

Loan Product Codes

Common loan product codes available:

Product CodeDescriptionTypical TenorInterest Rate Range
PERSONAL_LOANPersonal/Consumer Loan6-36 months15-24% p.a.
BUSINESS_LOANSME Business Loan12-60 months18-28% p.a.
SALARY_ADVANCESalary Advance Loan1-6 months5-10% p.a.
ASSET_FINANCEVehicle/Equipment Finance12-60 months16-22% p.a.
OVERDRAFTOverdraft Facility12 months20-30% p.a.

Loan Quote States

After creation, the loan quote progresses through these states:

StateDescriptionNext Action
NOT_STARTEDJust createdAdd supporting documents
PENDING_APPROVALSubmitted for approvalAwait approval workflow
FULLY_APPROVEDAll approvals completedDisburse loan
REJECTEDApplication rejectedReview or reapply
DISBURSEDLoan disbursedLoan account created

Approval Levels

The currentApprovalLevel indicates where the loan is in the approval chain:

LevelCodeDescriptionTypical Threshold
0NOT_STARTEDNot yet submitted-
1BRANCHBranch ManagerUp to ₦1M
2AREAArea ManagerUp to ₦5M
3DIVISIONDivision ManagerUp to ₦10M
4CREDIT_ADMINCredit AdministratorUp to ₦20M
5HEAD_CREDIT_ADMINHead of CreditUp to ₦50M
6CONTROL_OFFICERControl OfficerUp to ₦100M
7MDManaging DirectorAbove ₦100M

Workflow After Creation

Integration Examples

cURL

curl -X POST https://api.yourbank.com/commands \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"cmd": "CreateSelfServiceLoanQuoteCommand",
"data": "{\"selfServiceUserId\":123,\"selfServiceBranchId\":5,\"loanProductCode\":\"PERSONAL_LOAN\",\"loanAmount\":500000,\"tenor\":12,\"purpose\":\"Business expansion\"}"
}'

JavaScript (Fetch API)

const response = await fetch('https://api.yourbank.com/commands', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
cmd: 'CreateSelfServiceLoanQuoteCommand',
data: JSON.stringify({
selfServiceUserId: 123,
selfServiceBranchId: 5,
loanProductCode: 'PERSONAL_LOAN',
loanAmount: 500000,
tenor: 12,
purpose: 'Business expansion'
})
})
});

const result = await response.json();
console.log('Loan Quote ID:', result.outData.loanQuoteId);

C# (MediatR)

var command = new CreateSelfServiceLoanQuoteCommand
{
Data = JsonConvert.SerializeObject(new
{
selfServiceUserId = 123,
selfServiceBranchId = 5,
loanProductCode = "PERSONAL_LOAN",
loanAmount = 500000,
tenor = 12,
purpose = "Business expansion"
})
};

var response = await _mediator.Send(command);

if (response.Ok)
{
var loanQuoteId = response.OutData.loanQuoteId;
// Proceed with adding documents
}

Validation Rules

The system validates:

  1. User Exists: selfServiceUserId must be a valid customer
  2. Branch Exists: selfServiceBranchId must be a valid branch
  3. Product Valid: loanProductCode must exist and be active
  4. Amount Within Limits: Loan amount must be within product's min/max limits
  5. Tenor Valid: Tenor must be within product's allowed range
  6. No Duplicate: Customer cannot have multiple pending applications for same product

Error Scenarios

ErrorStatus CodeCauseSolution
User not found04Invalid selfServiceUserIdVerify user exists
Branch not found04Invalid selfServiceBranchIdUse valid branch ID
Invalid product04Product code doesn't existCheck available products
Amount too low99Below product minimumIncrease loan amount
Amount too high99Above product maximumReduce loan amount or use different product
Duplicate application99Pending application existsComplete or cancel existing

Best Practices

  1. Validate User First: Check user exists and is eligible before creating quote
  2. Calculate Before Submit: Use loan calculator to show customer repayment amount
  3. Set Realistic Tenor: Match tenor to customer's repayment capacity
  4. Add Purpose: Including loan purpose helps in approval process
  5. Follow Up Quickly: Add all supporting documents immediately after creation
  6. Track Status: Poll or subscribe to status updates during approval

Technical Notes

  • Entity: LoanQuote (table: [BPMLoanSelfService].[LoanQuote])
  • Primary Key: Id (becomes loanQuoteId in responses)
  • Foreign Keys:
    • SelfServiceUserIdSelfServiceUser.Id
    • SelfServiceBranchIdSelfServiceBranch.Id
  • Auto-Generated: ReferenceNumber, CreatedAt, UpdateAt
  • Default State: ApprovalState = NOT_STARTED, CurrentApprovalLevel = 0
  • Calculation: System automatically calculates repayment schedule based on product interest rate and tenor
  • CreateIdentityDocumentCommand - Add identity verification documents
  • CreateAddressInformationCommand - Add address verification
  • CreateGuarantorCommand - Add loan guarantors
  • CreateCreditBureauSearchCommand - Record credit bureau checks
  • CreateStatementCommand - Add bank statement analysis
  • InitiateLoanApprovalWorkflow - Submit for approval
  • GetCustomerLoanDetailsQuery - Retrieve loan application details

See Also