Generate Loan Schedules
Overview
Generates or regenerates the repayment schedule for a loan account showing all expected payments.
Endpoint
POST /api/bpm/cmd
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token for authentication |
| Content-Type | string | Yes | Must be application/json |
| X-Tenant-Id | string | Yes | Tenant identifier |
Request Body
{
"cmd": "GenerateLoanSchedulesCommand",
"data": {
"loanAmount": 500000.00,
"interestRate": 15.5,
"loanTenor": 24,
"firstRepaymentDate": "2024-02-15T00:00:00Z",
"moratoriumType": 0,
"moratoriumPeriod": 0,
"howIsInterestDeducted": 1,
"interestRateTerms": 2,
"repaymentMadeEvery": 1,
"repaymentPeriod": 2,
"interestBalanceCalculation": 1
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| cmd | string | Yes | Must be "GenerateLoanSchedulesCommand" |
| data | object | Yes | Schedule generation data |
| ↳ loanAmount | decimal | Yes | Principal loan amount |
| ↳ interestRate | decimal | Yes | Annual interest rate percentage |
| ↳ loanTenor | integer | Yes | Loan term in months |
| ↳ firstRepaymentDate | string | Yes | First repayment date (ISO 8601) |
| ↳ moratoriumType | integer | Yes | Moratorium type enum (0=None, 1=InterestOnly, 2=Full) |
| ↳ moratoriumPeriod | integer | Yes | Moratorium period in months |
| ↳ howIsInterestDeducted | integer | Yes | Interest deduction method enum |
| ↳ interestRateTerms | integer | Yes | Interest rate terms enum |
| ↳ repaymentMadeEvery | integer | Yes | Repayment frequency multiplier |
| ↳ repaymentPeriod | integer | Yes | Repayment period enum (2=Monthly) |
| ↳ interestBalanceCalculation | integer | Yes | Interest calculation method enum |
Response
Success Response (200 OK)
{
"success": true,
"message": "Loan schedule generated successfully",
"data": {
"loanId": "LA-2024-00001",
"scheduleType": "Standard",
"totalInstallments": 24,
"schedule": [
{
"installmentNumber": 1,
"dueDate": "2024-02-15T00:00:00Z",
"principalDue": 1800.00,
"interestDue": 568.75,
"totalDue": 2368.75,
"principalBalance": 48200.00
},
{
"installmentNumber": 2,
"dueDate": "2024-03-15T00:00:00Z",
"principalDue": 1820.00,
"interestDue": 548.75,
"totalDue": 2368.75,
"principalBalance": 46380.00
}
],
"summary": {
"totalPrincipal": 50000.00,
"totalInterest": 6850.00,
"totalRepayable": 56850.00,
"monthlyPayment": 2368.75
},
"generatedAt": "2024-01-15T10:00:00Z"
}
}
Status Codes
| Code | Description |
|---|---|
| 200 | Schedule generated successfully |
| 400 | Invalid request or loan not eligible for schedule generation |
| 401 | Unauthorized |
| 404 | Loan not found |
| 500 | Internal server error |
Business Rules
- Schedule can be generated after loan approval
- Regeneration may be needed after loan modifications
- Schedule reflects current loan parameters
- Interest calculation method depends on product configuration
Code Examples
C# Example
public async Task<LoanSchedule> GenerateLoanScheduleAsync(string loanId)
{
var request = new { loanId };
var json = JsonSerializer.Serialize(request);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync("/api/administration/loan/generate-schedule", content);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<ApiResponse<LoanSchedule>>(result).Data;
}
TypeScript Example
async function generateLoanSchedule(loanId: string): Promise<LoanSchedule> {
const response = await fetch('/api/administration/loan/generate-schedule', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`,
'X-Tenant-Id': tenantId
},
body: JSON.stringify({ loanId })
});
const result = await response.json();
return result.data;
}
Notes
- Schedule automatically generated after approval
- Can be regenerated if loan terms are modified
- Schedule reflects amortization method of loan product
- Export schedule for customer documentation