Skip to main content

Get All Transactions

Overview

Query and retrieve all transactions across the entire CBS system from the unified CBSTransaction table. This endpoint provides powerful filtering, pagination, and automatic account lookups for client and branch information.

Key Features

  • Universal Coverage: All transaction types in one query (deposits, loans, teller, cheques, till, vault)
  • Dynamic Filtering: Filter by date range, transaction type, status, amount, account, client, etc.
  • Automatic Joins: System automatically looks up account, client, and branch details
  • Pagination Support: Efficient handling of large result sets
  • Export Mode: Retrieve all matching records for reporting

Endpoint

POST /api/bpm/cmd/RetrieveAllTransactionsQuery

Request Parameters

Core Parameters

ParameterTypeRequiredDefaultDescription
pageNumberintegerNo1Page number for pagination
pageSizeintegerNo50Number of records per page (max 500)
isExportbooleanNofalseIf true, returns all matching records (no pagination)

Filter Parameters

ParameterTypeRequiredDescription
idintegerNoFilter by specific transaction ID
startDatestring (ISO 8601)NoFilter transactions from this date (inclusive)
endDatestring (ISO 8601)NoFilter transactions until this date (inclusive)
statusarray of integersNoFilter by transaction states (see Transaction States below)
accountReferencestringNoFilter by account number
transactionTypestringNoFilter by transaction type (DEPOSIT, WITHDRAWAL, etc.)
minAmountdecimalNoFilter transactions >= this amount
maxAmountdecimalNoFilter transactions <= this amount
branchIdintegerNoFilter by branch ID
clientIdintegerNoFilter by client ID
transactionReferencestringNoSearch by transaction reference/key

Transaction States (status values)

ValueStateDescription
0PENDINGTransaction awaiting approval
1SETTLEDTransaction completed successfully
2CANCELLEDTransaction cancelled before settlement
3REVERSEDTransaction reversed after settlement

Note: CANCELLED and REVERSED transactions are automatically excluded from results unless explicitly requested.


Request Examples

Example 1: Get Recent Transactions (Paginated)

{
"pageNumber": 1,
"pageSize": 20,
"startDate": "2026-01-01T00:00:00Z",
"endDate": "2026-01-31T23:59:59Z"
}

Example 2: Search High-Value Pending Transactions

{
"status": [0],
"minAmount": 100000,
"startDate": "2026-01-01T00:00:00Z"
}

Example 3: Find Specific Account Transactions

{
"accountReference": "1001234567",
"pageNumber": 1,
"pageSize": 50
}

Example 4: Branch Daily Report (Export Mode)

{
"branchId": 5,
"startDate": "2026-01-05T00:00:00Z",
"endDate": "2026-01-05T23:59:59Z",
"isExport": true
}
{
"startDate": "2026-01-01T00:00:00Z",
"endDate": "2026-01-31T23:59:59Z",
"status": [0, 1],
"branchId": 10,
"minAmount": 50000,
"maxAmount": 500000,
"pageNumber": 1,
"pageSize": 100
}

Response Format

Success Response

{
"success": true,
"message": "Transactions retrieved successfully",
"code": "SUCCESS",
"data": {
"items": [
{
"id": 12345,
"transactionKey": "TRX-2026-001234",
"transactionType": "DEPOSIT",
"transactionDate": "2026-01-05T10:30:00Z",
"amount": 50000.00,
"currency": "NGN",
"accountReference": "1001234567",
"accountType": "SAVINGS",
"cbsTransactionHoldState": 1,
"stateDescription": "SETTLED",
"notes": "Cash deposit via teller",

// Account Information (automatically looked up)
"depositAccountId": 789,
"depositAccountEncodedKey": "8a8587c07d...",

// Client Information (from account lookup)
"clientId": 456,
"clientName": "John Doe",
"clientEncodedKey": "8a8587c07c...",
"clientCode": "CLI-001234",

// Branch Information (from account lookup)
"branchId": 10,
"branchName": "Victoria Island Branch",
"branchEncodedKey": "8a8587c07b...",

// Transaction Details
"depositTransaction": {
"id": 567,
"transactionType": "DEPOSIT",
"amount": 50000.00,
"balanceBefore": 100000.00,
"balanceAfter": 150000.00,
"channel": "TELLER",
"tellerName": "Jane Smith"
},

"loanTransaction": null,

// Audit Fields
"createdBy": "teller@branch.com",
"dateCreated": "2026-01-05T10:30:00Z",
"lastModifiedDate": "2026-01-05T10:30:05Z"
}
],
"pageNumber": 1,
"pageSize": 20,
"totalCount": 1543,
"totalPages": 78,
"hasNextPage": true,
"hasPreviousPage": false
}
}

Response Fields

Transaction Core Fields

FieldTypeDescription
idintegerUnique transaction ID
transactionKeystringHuman-readable transaction reference
transactionTypestringType of transaction (DEPOSIT, WITHDRAWAL, LOAN_DISBURSEMENT, etc.)
transactionDatedatetimeWhen transaction occurred
amountdecimalTransaction amount
currencystringCurrency code (NGN, USD, etc.)
accountReferencestringAccount number involved
accountTypestringType of account (SAVINGS, CURRENT, LOAN, etc.)
cbsTransactionHoldStateintegerCurrent state (0=PENDING, 1=SETTLED, 2=CANCELLED, 3=REVERSED)
stateDescriptionstringHuman-readable state
notesstringTransaction notes/description

Account Lookup Fields

FieldTypeDescription
depositAccountIdintegerDeposit account ID (if applicable)
depositAccountEncodedKeystringDeposit account encoded key
loanAccountIdintegerLoan account ID (if applicable)
loanAccountEncodedKeystringLoan account encoded key

Client Lookup Fields

FieldTypeDescription
clientIdintegerClient ID
clientNamestringFull client name (individual: "FirstName LastName", group: "GroupName")
clientEncodedKeystringClient encoded key
clientCodestringClient code/number

Branch Lookup Fields

FieldTypeDescription
branchIdintegerBranch ID
branchNamestringBranch name
branchEncodedKeystringBranch encoded key

Transaction Detail Objects

DepositTransaction (for deposit-related transactions):

{
"id": 567,
"transactionType": "DEPOSIT",
"amount": 50000.00,
"balanceBefore": 100000.00,
"balanceAfter": 150000.00,
"channel": "TELLER",
"tellerName": "Jane Smith",
"tillId": 123,
"terminalId": "TERM-001"
}

LoanTransaction (for loan-related transactions):

{
"id": 890,
"transactionType": "LOAN_REPAYMENT",
"principalAmount": 10000.00,
"interestAmount": 2000.00,
"penaltyAmount": 500.00,
"totalAmount": 12500.00,
"outstandingPrincipal": 90000.00,
"channel": "DIRECT_DEBIT"
}

Pagination Fields

FieldTypeDescription
pageNumberintegerCurrent page number
pageSizeintegerNumber of items per page
totalCountintegerTotal number of matching transactions
totalPagesintegerTotal number of pages
hasNextPagebooleanWhether next page exists
hasPreviousPagebooleanWhether previous page exists

Usage Examples

Example 1: Branch End-of-Day Report

// Get all settled transactions for today
const endOfDayReport = await fetch('/api/bpm/cmd/RetrieveAllTransactionsQuery', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
branchId: userBranchId,
status: [1], // SETTLED only
startDate: new Date().toISOString().split('T')[0] + 'T00:00:00Z',
endDate: new Date().toISOString().split('T')[0] + 'T23:59:59Z',
isExport: true // Get all records
})
});

const data = await endOfDayReport.json();
console.log(`Total transactions today: ${data.data.totalCount}`);
console.log(`Total amount: ${data.data.items.reduce((sum, t) => sum + t.amount, 0)}`);

Example 2: Search Pending Approvals

// Find all pending transactions awaiting approval
const pendingApprovals = await fetch('/api/bpm/cmd/RetrieveAllTransactionsQuery', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
status: [0], // PENDING
minAmount: 100000, // High-value only
pageNumber: 1,
pageSize: 50
})
});

const data = await pendingApprovals.json();
data.data.items.forEach(txn => {
console.log(`${txn.transactionKey}: ${txn.amount} - ${txn.clientName}`);
});

Example 3: Customer Transaction History

// Get transaction history for specific customer account
const customerHistory = await fetch('/api/bpm/cmd/RetrieveAllTransactionsQuery', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
accountReference: '1001234567',
startDate: '2026-01-01T00:00:00Z',
pageNumber: 1,
pageSize: 100
})
});

const data = await customerHistory.json();
console.log(`Account ${accountNumber} has ${data.data.totalCount} transactions`);

Example 4: Fraud Detection Query

// Find suspicious large cash deposits
const suspiciousTransactions = await fetch('/api/bpm/cmd/RetrieveAllTransactionsQuery', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
transactionType: 'DEPOSIT',
minAmount: 500000, // Above threshold
startDate: new Date(Date.now() - 7*24*60*60*1000).toISOString(), // Last 7 days
pageNumber: 1,
pageSize: 100
})
});

Performance Considerations

Optimization Tips

Always use date filters for better performance:

{
"startDate": "2026-01-01T00:00:00Z",
"endDate": "2026-01-31T23:59:59Z"
}

Use pagination for large result sets:

{
"pageSize": 50,
"pageNumber": 1
}

Filter by branch to reduce result set:

{
"branchId": 10
}

Avoid querying without any filters - may timeout:

{} // Don't do this!

Avoid very large page sizes:

{
"pageSize": 10000 // Too large, use isExport instead
}

Indexing

The following fields are indexed for optimal query performance:

  • DateCreated
  • CBSTransactionHoldState
  • AccountReference
  • BranchId
  • ClientId
  • TransactionType

Error Responses

Invalid Date Range

{
"success": false,
"message": "End date must be after start date",
"code": "INVALID_DATE_RANGE"
}

Page Size Too Large

{
"success": false,
"message": "Page size cannot exceed 500. Use isExport=true for larger datasets.",
"code": "PAGE_SIZE_EXCEEDED"
}

No Results Found

{
"success": true,
"message": "No transactions found matching criteria",
"code": "SUCCESS",
"data": {
"items": [],
"totalCount": 0,
"pageNumber": 1,
"pageSize": 50,
"totalPages": 0
}
}

Security & Permissions

Required Permissions

  • Role: ViewTransactions or higher
  • Branch Access: Users can only view transactions from branches they have access to

Automatic Filtering

The system automatically applies security filters:

  • Branch-level access control
  • User role validation
  • Sensitive field masking (where applicable)


Implementation Notes

How Account Lookups Work

The system performs intelligent account lookups:

  1. Query CBSTransaction table with filters
  2. Extract unique account references from results
  3. Batch query DepositAccount and LoanAccount tables
  4. Create in-memory dictionaries for O(1) lookups
  5. Join client and branch data from accounts
  6. Map enriched data to response

This approach avoids N+1 query problems and ensures optimal performance.

Transaction Type Coverage

The query returns transactions from:

  • ✅ Deposit operations (deposits, withdrawals, transfers)
  • ✅ Loan operations (disbursements, repayments, writeoffs)
  • ✅ Teller operations (OTC transactions)
  • ✅ Till operations (cash management)
  • ✅ Vault operations (vault funding, transfers)
  • ✅ Cheque operations (deposits, withdrawals, clearing)
  • ✅ Internal transfers (account-to-account)
  • ✅ Fee/charge postings
  • ✅ Interest postings

Testing

Sample Test Cases

// Test 1: Basic pagination
test('should paginate results correctly', async () => {
const response = await getTransactions({ pageNumber: 1, pageSize: 10 });
expect(response.data.items.length).toBeLessThanOrEqual(10);
expect(response.data.pageNumber).toBe(1);
});

// Test 2: Date filtering
test('should filter by date range', async () => {
const response = await getTransactions({
startDate: '2026-01-01T00:00:00Z',
endDate: '2026-01-31T23:59:59Z'
});
response.data.items.forEach(txn => {
expect(new Date(txn.transactionDate)).toBeAfter('2026-01-01');
expect(new Date(txn.transactionDate)).toBeBefore('2026-02-01');
});
});

// Test 3: Status filtering
test('should filter by transaction state', async () => {
const response = await getTransactions({ status: [1] }); // SETTLED only
response.data.items.forEach(txn => {
expect(txn.cbsTransactionHoldState).toBe(1);
});
});