Get Loan Activities
Retrieve all activities related to a specific loan account. This is a convenience query that wraps GetActivitiesQuery with entity type set to Loan.
Command
Use GetActivitiesQuery with entity: "Loan":
{
"Cmd": "GetActivitiesQuery",
"Data": {
"entity": "Loan",
"entityId": "12345",
"pageSize": 50
}
}
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
entity | string | Yes | Must be "Loan" |
entityId | string | No* | Database ID of the loan |
encodedKey | string | No* | Loan's encoded key |
startDate | string | No | Start date filter (YYYY-MM-DD) |
endDate | string | No | End date filter (YYYY-MM-DD) |
pageNumber | integer | No | Page number (default: 1) |
pageSize | integer | No | Items per page (default: 50) |
*Either entityId or encodedKey is required.
Examples
Using Loan ID
{
"Cmd": "GetActivitiesQuery",
"Data": {
"entity": "Loan",
"entityId": "12345",
"startDate": "2025-01-01",
"pageSize": 100
}
}
Using Loan Encoded Key
{
"Cmd": "GetActivitiesQuery",
"Data": {
"entity": "Loan",
"encodedKey": "8a80866e7f987654",
"pageSize": 50
}
}
Response Example
{
"Status": "00",
"Message": "Activities retrieved successfully",
"Data": {
"activities": [
{
"Id": 2001,
"CreationDate": "2025-12-24T09:00:00",
"UserName": "loan.officer@banklingo.com",
"UserKey": "8a80866e7f123456",
"Action": "Create",
"ActivityDescription": "Loan application created",
"AffectedItemType": "LoanAccount",
"AffectedLoanAccountName": "Personal Loan",
"AffectedLoanEncodedKey": "8a80866e7f987654",
"AffectedLoanId": "LN-2025-00123"
},
{
"Id": 2002,
"CreationDate": "2025-12-24T10:30:00",
"UserName": "credit.manager@banklingo.com",
"Action": "Approval",
"ActivityDescription": "Loan approved by credit committee",
"AffectedItemType": "LoanAccount",
"AffectedLoanAccountName": "Personal Loan",
"AffectedLoanEncodedKey": "8a80866e7f987654",
"AffectedLoanId": "LN-2025-00123"
},
{
"Id": 2003,
"CreationDate": "2025-12-24T14:00:00",
"UserName": "operations@banklingo.com",
"Action": "Disbursement",
"ActivityDescription": "Loan disbursed - Amount: ₦5,000,000",
"AffectedItemType": "LoanAccount",
"AffectedLoanAccountName": "Personal Loan",
"AffectedLoanEncodedKey": "8a80866e7f987654",
"AffectedLoanId": "LN-2025-00123"
}
],
"totalRows": 15,
"totalPages": 1,
"currentPage": 1,
"pageSize": 50
}
}
TypeScript Example
async function getLoanActivities(loanId: string, startDate?: string): Promise<ActivityResponse> {
const response = await fetch('/api/core/cmd', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
Cmd: 'GetActivitiesQuery',
Data: {
entity: 'Loan',
entityId: loanId,
startDate: startDate,
pageSize: 50
}
})
});
return await response.json();
}
// Usage
const activities = await getLoanActivities('12345');
console.log(`Loan has ${activities.Data.totalRows} activities`);
// Display loan timeline
activities.Data.activities.forEach(activity => {
console.log(`${activity.CreationDate}: ${activity.Action} by ${activity.UserName}`);
});
Common Activity Types for Loans
- Create: Loan application created
- Update: Loan details updated
- Approval: Loan approved
- Rejection: Loan application rejected
- Disbursement: Loan amount disbursed
- Repayment: Loan payment received
- Restructure: Loan restructured
- Write-off: Loan written off
- Penalty: Penalty assessed
- Status Change: Loan status changed (Active, Closed, Defaulted)
Use Cases
Loan Lifecycle Timeline
View complete lifecycle of a loan from application to closure:
{
"Cmd": "GetActivitiesQuery",
"Data": {
"entity": "Loan",
"encodedKey": "8a80866e7f987654",
"pageSize": 100
}
}
Disbursement Audit
Track all disbursement activities for a loan:
{
"Cmd": "GetActivitiesQuery",
"Data": {
"entity": "Loan",
"entityId": "12345",
"searchText": "Disbursement",
"pageSize": 50
}
}
Payment History
View all payment-related activities:
{
"Cmd": "GetActivitiesQuery",
"Data": {
"entity": "Loan",
"entityId": "12345",
"searchText": "Repayment",
"startDate": "2025-01-01",
"pageSize": 100
}
}
Loan Problem Investigation
Investigate issues with a problematic loan:
{
"Cmd": "GetActivitiesQuery",
"Data": {
"entity": "Loan",
"encodedKey": "8a80866e7f987654",
"startDate": "2025-12-01",
"pageSize": 50
}
}
Frontend Integration Example
// React component for loan activity timeline
import React, { useEffect, useState } from 'react';
interface LoanActivity {
Id: number;
CreationDate: string;
UserName: string;
Action: string;
ActivityDescription: string;
}
export const LoanActivityTimeline: React.FC<{ loanId: string }> = ({ loanId }) => {
const [activities, setActivities] = useState<LoanActivity[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
async function fetchActivities() {
const response = await fetch('/api/core/cmd', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
Cmd: 'GetActivitiesQuery',
Data: {
entity: 'Loan',
entityId: loanId,
pageSize: 50
}
})
});
const result = await response.json();
if (result.Status === '00') {
setActivities(result.Data.activities);
}
setLoading(false);
}
fetchActivities();
}, [loanId]);
if (loading) return <div>Loading...</div>;
return (
<div className="loan-activity-timeline">
<h3>Loan Activity History</h3>
<ul>
{activities.map(activity => (
<li key={activity.Id}>
<strong>{new Date(activity.CreationDate).toLocaleString()}</strong>
<br />
<span>{activity.Action}</span>: {activity.ActivityDescription}
<br />
<small>by {activity.UserName}</small>
</li>
))}
</ul>
</div>
);
};
Related Commands
- Get Activities - Main query with all entity types
- Get Client Activities - Client-specific activities
- Get Deposit Activities - Deposit-specific activities
- Get User Activities - User-specific activities
Best Practice: Combine loan activities with loan transaction history for complete loan management visibility.