Skip to main content

Loan Origination Commands Overview

Introduction

The BankLingo Loan Origination system exposes a comprehensive set of commands for managing the entire loan lifecycle — from product setup through disbursement and collection. All commands follow the CQRS pattern and return a consistent response envelope.

Loan Lifecycle — Stages & Commands

Stage 1 — Setup & Configuration

Configure loan products before any application can be created.

CommandDescriptionDocs
CreateSelfServiceLoanProductCommandCreate a new loan productView →
GetSelfServiceLoanProductsQueryList all loan products (YAML-first)View →
UpdateSelfServiceLoanProductCommandUpdate a loan product's parametersView →
UpdateLoanInterestRateCommandAdjust interest rate on a loan in progressView →

Stage 2 — Application

Customer submits a loan request.

CommandDescriptionDocs
CreateSelfServiceLoanRequestCommandSubmit a loan applicationView →
CreateQuoteUserDetailCommandCreate profile for anonymous (walk-in) applicantView →
GetLoanQuoteWithDetailsQueryRetrieve full loan application with all related dataView →
GetAllMyLoanApplicationsQueryList all applications for the authenticated userView →
GetLoanQuotesWithFiltersQueryAdmin view — filter loan applicationsView →
BankListQueryRetrieve available banks for mandate/collection setupView →

Stage 3 — Information Gathering

Collect guarantors, next of kin, employment, and identity information.

CommandDescriptionDocs
CreateGuarantorInformationCommandAdd a single guarantorView →
CreateMultipleGuarantorInformationCommandAdd multiple guarantors in one requestView →
UpdateGuarantorInformationCommandEdit guarantor contact detailsView →
GetCustomerLoanGuarantorsQueryList all guarantors for a loanView →
CreateNextOfKinInformationCommandAdd next of kinView →
GetCustomerNextOfKinDetailsQueryRetrieve next of kin informationView →
GetCustomerEmploymentDetailsQueryRetrieve employment informationView →
GetCustomerIdentityDetailsQueryRetrieve identity documentsView →

Stage 4 — Assessment

Run credit bureau checks and fetch salary statements.

CommandDescriptionDocs
FetchStatementCommandFetch bank statement for salary verificationView →
CreateStatementCommandCreate a statement recordView →
InitiateCreditCheckCommandRun credit bureau searchView →
GetCustomerLoanCreditBureauSearchesQueryRetrieve credit bureau resultsView →
GetCustomerLoanSalaryHistoryQueryRetrieve salary verification historyView →

Stage 5 — Approval Workflow

Multi-level review and approval chain.

CommandDescriptionDocs
InitiateApproveLoanRequestCommandSubmit to approval workflow (Relationship Manager)View →
SetRecommendedLoanAmountCommandRecord advisory recommended amountView →
SetFinalLoanAmountCommandSet the binding approved loan amountView →
ApproveLoanRequestCommandApprove at current levelView →
RejectLoanRequestCommandReject the application (final)View →
ReturnToPreviousLevelCommandReturn for correction (revisable)View →
GetLoanApprovalHistoryQueryView full approval audit trail (includes comments)View →
GetLoanQuoteActivityQueryComment-free activity timeline for UI displayView →
SendLoanOfferCommandSend offer letter after full approvalView →
Approval Workflow GuideRoles, hierarchy, and state machine

Stage 6 — Deductions

Add or remove custom per-loan deductions before disbursement.

CommandDescriptionDocs
GetLoanDeductionsQueryList deductions on a loanView →
AddLoanDeductionCommandAdd a deduction (insurance, legal fees, etc.)View →
RemoveLoanDeductionCommandRemove a deduction by codeView →

Stage 7 — Mandate & Settlement Setup

Configure mandate and repayment settlement routing.

CommandDescriptionDocs
InitiateMandateOnLoanCommandSet up NIBSS/Remita direct debit mandateView →
UpdateLoanSettlementDetailsCommandSet settlement account or virtual accountView →
RetrieveICADAccountsQueryList available ICAD accountsView →

Stage 8 — Disbursement Setup & Execution

Configure how funds are released, then execute disbursement.

CommandDescriptionDocs
SetDisbursementDetailsCommandSet disbursement account, mode, and generate repayment scheduleView →
DisburseLoanRequestCommandExecute the disbursementView →
GetLoanDisbursementInformationQueryView disbursement details and statusView →

Stage 9 — Disbursement Batch (Back-office)

Bulk disbursement processing with full review/approval workflow.

CommandDescriptionDocs
InitiateDisbursementBatchCommandCreate a new disbursement batchView →
AddDisbursementBatchEntryCommandAdd loan to batchView →
RemoveDisbursementBatchEntryCommandRemove loan from batchView →
ValidateDisbursementBatchCommandValidate batch entriesView →
ConfirmDisbursementBatchCommandConfirm batch after validationView →
ReviewDisbursementBatchCommandSubmit batch for reviewView →
ApproveDisbursementBatchCommandApprove batch for processingView →
RejectDisbursementReviewCommandReject at review stageView →
RejectDisbursementApprovalCommandReject at approval stageView →
CancelDisbursementBatchCommandCancel the batchView →
DeleteDisbursementBatchCommandDelete a batch recordView →
RetrieveDisbursementBatchesQueryList batches with filtersView →
RetrieveDisbursementBatchByIdQueryGet a specific batchView →
RetrieveDisbursementBatchEntriesQueryList entries in a batchView →
RetrieveDisbursementSourcesQueryList disbursement source accountsView →
RetrieveDisbursementsQueryList individual disbursementsView →

Stage 10 — Collection & Repayment

Configure repayment account and manage the repayment schedule.

CommandDescriptionDocs
SetCollectionDetailsCommandConfigure repayment account and auto-debitView →
GetLoanCollectionInformationQueryView collection setupView →
GetRepaymentScheduleQueryView repayment schedule with installmentsView →
WaiveRepaymentScheduleInstallmentCommandWaive a specific installmentView →

Stage 11 — KYC Verification (Back-office, parallel)

Approve or reject identity and address documentation.

CommandDescriptionDocs
ApproveIdentityDocumentCommandApprove identity documentView →
RejectIdentityDocumentCommandReject identity documentView →
ApproveCustomerAddressInformationCommandApprove addressView →
RejectCustomerAddressInformationCommandReject addressView →
InitiateGuarantorVerificationCommandStart guarantor verificationView →
ApproveGuarantorVerificationCommandApprove guarantorView →
DeclineGuarantorVerificationCommandDecline guarantorView →

Command Architecture

Command Pattern

All commands follow the CQRS (Command Query Responsibility Segregation) pattern:

{
"cmd": "CommandName",
"data": "{\"parameter\":\"value\"}"
}

Response Structure

All commands return a consistent response structure:

{
"ok": true,
"message": "Operation completed successfully",
"statusCode": "00",
"outData": {
// Command-specific data
}
}

Performance Monitoring

Many commands include performance timing data:

{
"ok": true,
"outData": {
"...": "data",
"PerformanceTimings": {
"0_TotalExecutionTime": 245,
"1_ParseParameters": 2,
"2_FetchData": 180,
"3_ProcessData": 50
},
"PerformanceSummary": {
"TotalExecutionTimeMs": 245,
"SlowestOperation": "2_FetchData"
}
}
}

Command Categories

1. Customer Management Commands

Commands for managing customer information and KYC:

CommandPurposeDocumented
GetCustomerBasicDetailsQueryGet complete customer profileView →
GetCustomerKycInformationQueryGet KYC verification statusView →
GetCustomerAddressDetailsQueryGet address informationView →
GetCustomerBranchAssociationsQueryGet customer's branch access⏳ Pending
GetCustomerRoleAssociationsQueryGet customer's role assignments⏳ Pending
GetCustomerIdentityDetailsQueryGet identity documents⏳ Pending
GetCustomerNextOfKinDetailsQueryGet next of kin details⏳ Pending
GetCustomerEmploymentDetailsQueryGet employment information⏳ Pending

2. KYC Verification Commands

Commands for approving/rejecting KYC documents:

CommandPurpose
ApproveIdentityDocumentCommandApprove identity document
RejectIdentityDocumentCommandReject identity document
ApproveCustomerAddressInformationCommandApprove address verification
RejectCustomerAddressInformationCommandReject address verification

3. Loan Application Commands

Commands for managing loan applications:

CommandPurposeDocumented
GetCustomerLoanDetailsQueryGet loan application detailsView →
GetCustomerLoanSalaryHistoryQueryGet salary verification historyView →
GetCustomerLoanCreditBureauSearchesQueryGet credit bureau searchesView →
GetCustomerLoanGuarantorsQueryGet loan guarantorsView →

4. Guarantor Management Commands

Commands for managing loan guarantors:

CommandPurpose
InitiateGuarantorVerificationCommandStart guarantor verification
ApproveGuarantorVerificationCommandApprove guarantor
DeclineGuarantorVerificationCommandDecline guarantor

Authorization

User Classifications

Commands check user classification for authorization:

  • BACKOFFICE_ADMINISTRATORS: Full access to all customer data
  • Organization Users: Limited to their organization's data

Role-Based Access

Some commands require specific roles:

RoleAccess Level
RELATIONSHIP_MANAGERInitiate loan applications
BRANCH_MANAGERBranch-level approval
AREA_MANAGERArea-level approval
DIVISION_MANAGERDivision-level approval
CREDIT_ADMINCredit review and approval
HEAD_CREDIT_ADMINSenior credit review
CONTROL_OFFICERCompliance and final review
FINANCELoan disbursement
MDManaging Director approval
GMDGroup Managing Director approval

Common Parameters

userId

Type: long (integer)
Required: Yes (in most commands)
Description: The ID of the customer/user

Example:

{
"cmd": "GetCustomerBasicDetailsQuery",
"data": "{\"userId\":\"129\"}"
}

loanQuoteId

Type: long (integer)
Required: Yes (in loan-specific commands)
Description: The ID of the loan application

Example:

{
"cmd": "GetCustomerLoanDetailsQuery",
"data": "{\"userId\":\"129\",\"loanQuoteId\":\"110\"}"
}

Error Handling

Standard Error Codes

CodeMeaningDescription
00SuccessOperation completed successfully
04Not FoundResource not found or unauthorized
99System ErrorAn unexpected error occurred

Error Response Example

{
"ok": false,
"statusCode": "04",
"message": "User not found or unauthorized",
"outData": null
}

Performance Optimization

Use Dedicated Commands

Instead of fetching all data with GetCustomerBasicDetailsQuery, use dedicated commands for specific data:

❌ Slow - Fetches everything (245ms):

{
"cmd": "GetCustomerBasicDetailsQuery",
"data": "{\"userId\":\"129\"}"
}

✅ Fast - Fetches only KYC (85ms, 65% faster):

{
"cmd": "GetCustomerKycInformationQuery",
"data": "{\"userId\":\"129\"}"
}

Parallel Requests

When fetching independent data, make parallel requests:

const [kyc, branches, roles] = await Promise.all([
api.query({ cmd: "GetCustomerKycInformationQuery", data: "{\"userId\":\"129\"}" }),
api.query({ cmd: "GetCustomerBranchAssociationsQuery", data: "{\"userId\":\"129\"}" }),
api.query({ cmd: "GetCustomerRoleAssociationsQuery", data: "{\"userId\":\"129\"}" })
]);

// Total time: ~85ms (slowest query)
// vs GetCustomerBasicDetailsQuery: ~245ms

Next Steps

Explore specific command categories: