Core Ledger Service
Overview
The Core Ledger Service (CLS) is the heart of Kredete's financial record-keeping system. It implements a double-entry bookkeeping system that ensures all financial transactions are accurately recorded, traceable, and immutable.
Core Principles
Double-Entry Bookkeeping
Every transaction in the system results in at least two entries:
- A debit entry to one account
- A credit entry to another account
The fundamental equation that must always balance:
Accounting Equation
Assets = Liabilities + Equity
Or expanded: Assets + Expenses = Liabilities + Equity + Revenue
Immutability
Once a ledger entry is posted, it cannot be:
- ❌ Deleted
- ❌ Modified
- ❌ Backdated
Corrections are made through reversal entries that offset the original transaction.
Entry Types
Loan Disbursement
Loan Repayment
Interest Accrual
Write-Off
Chart of Accounts
| Code | Type | Account Name | Normal Balance |
|---|---|---|---|
| 1000 | Asset | Assets | Debit |
| 1100 | Asset | Cash and Bank | Debit |
| 1200 | Asset | Loans Receivable | Debit |
| 1210 | Asset | Accrued Interest Receivable | Debit |
| 1290 | Asset | Allowance for Loan Losses | Credit (contra) |
| 2000 | Liability | Liabilities | Credit |
| 2100 | Liability | Accounts Payable | Credit |
| 2200 | Liability | Customer Deposits | Credit |
| 3000 | Equity | Equity | Credit |
| 3100 | Equity | Share Capital | Credit |
| 3200 | Equity | Retained Earnings | Credit |
| 4000 | Revenue | Revenue | Credit |
| 4100 | Revenue | Interest Income | Credit |
| 4200 | Revenue | Processing Fee Income | Credit |
| 5000 | Expense | Expenses | Debit |
| 5300 | Expense | Provision for Bad Debts | Debit |
Immutability & Hash Chain
Hash Calculation
Each entry's hash is calculated using:
def calculate_entry_hash(entry, previous_hash):
data = f"{entry['entry_id']}" \
f"{entry['journal_id']}" \
f"{entry['account_id']}" \
f"{entry['entry_type']}" \
f"{entry['amount']}" \
f"{entry['currency']}" \
f"{entry['posted_at']}" \
f"{previous_hash}"
return hashlib.sha256(data.encode()).hexdigest()
Chain Verification
# Verify ledger integrity
kubectl exec -it kredete-ledger-pod -- ./bin/cli ledger verify \
--from-date 2026-04-01 \
--to-date 2026-04-16
# Expected output:
# Verifying ledger entries from 2026-04-01 to 2026-04-16
# Entries verified: 1,234,567
# Hash chain: ✓ Valid
# Balance check: ✓ Balanced
# Verification completed successfully
API Reference
Post Journal Entry
POST /v2/ledger/journals
{
"journal_type": "loan_disbursement",
"reference": "DISB-2026041600001",
"effective_date": "2026-04-16",
"description": "Loan disbursement for LOAN-2026-00001",
"entries": [
{
"account_id": "acc_loans_receivable",
"entry_type": "debit",
"amount": 500000.00,
"currency": "NGN"
},
{
"account_id": "acc_bank_operating",
"entry_type": "credit",
"amount": 495000.00,
"currency": "NGN"
},
{
"account_id": "acc_fee_income",
"entry_type": "credit",
"amount": 5000.00,
"currency": "NGN"
}
]
}
Get Account Balance
GET /v2/ledger/accounts/{account_id}/balance?as_of=2026-04-16
Get Account Statement
GET /v2/ledger/accounts/{account_id}/statement?from=2026-04-01&to=2026-04-16