413 Ledger & statements
Today: 9 Nov 2026

General ledger

Trial balance: the balance of every account. Debits must equal credits.

In balance
CodeAccountTypeTotal debitsTotal creditsDebit balanceCredit balance
Petty cash ASSET 70,000.00 36,872.20 33,127.80
Bank - KBank current account ASSET 13,025,481.73 9,128,025.48 3,897,456.25
Bank - SCB savings account ASSET 1,110,137.60 0.00 1,110,137.60
Accounts receivable ASSET 12,050,643.86 10,046,415.47 2,004,228.39
Input VAT ASSET 157,153.50 0.00 157,153.50
Withholding tax prepaid ASSET 137,005.30 0.00 137,005.30
Office equipment ASSET 300,000.00 0.00 300,000.00
Computer equipment ASSET 660,000.00 0.00 660,000.00
Accumulated depreciation ASSET 0.00 252,200.00 252,200.00
Accounts payable LIABILITY 2,972,093.44 3,060,154.44 88,061.00
Output VAT LIABILITY 3,115.00 458,563.70 455,448.70
Withholding tax payable LIABILITY 0.00 61,518.70 61,518.70
Long-term bank loan LIABILITY 200,000.00 1,000,000.00 800,000.00
Share capital EQUITY 0.00 2,000,000.00 2,000,000.00
Retained earnings EQUITY 0.00 750,000.00 750,000.00
Software sales REVENUE 0.00 6,080,563.86 6,080,563.86
Consulting services REVENUE 0.00 4,417,401.98 4,417,401.98
Training income REVENUE 0.00 1,796,483.72 1,796,483.72
Interest income REVENUE 0.00 10,240.00 10,240.00
Foreign exchange gain REVENUE 0.00 45,028.29 45,028.29
Sales returns and allowances REVENUE 44,500.00 0.00 44,500.00
Cost of services EXPENSE 200,983.25 0.00 200,983.25
Salaries and wages EXPENSE 5,313,000.00 0.00 5,313,000.00
Social security contributions EXPENSE 157,500.00 0.00 157,500.00
Office rent EXPENSE 850,000.00 0.00 850,000.00
Utilities EXPENSE 170,670.00 0.00 170,670.00
Marketing and advertising EXPENSE 836,550.00 0.00 836,550.00
Travel EXPENSE 126,480.00 0.00 126,480.00
Office supplies EXPENSE 34,460.00 0.00 34,460.00
Software subscriptions EXPENSE 427,565.79 0.00 427,565.79
Professional fees EXPENSE 90,000.00 0.00 90,000.00
Depreciation EXPENSE 132,200.00 0.00 132,200.00
Bank charges EXPENSE 4,766.00 0.00 4,766.00
Foreign exchange loss EXPENSE 32,662.37 0.00 32,662.37
Interest expense EXPENSE 36,500.00 0.00 36,500.00
Total16,756,946.2516,756,946.25
How this works - feature 413 Chart of accounts, trial balance, journals and account ledgers.

Concepts

  • Double entry: every entry has debits = credits; JournalService.post refuses anything else.
  • CHECK constraint: a line is either a debit or a credit, never negative.
  • Trial balance: if total debits = total credits the books are in balance.
  • Ledger running balance: SUM(...) OVER (ORDER BY ... ROWS UNBOUNDED PRECEDING).
  • Document numbers come from one MERGE ... OUTPUT statement (NumberingService).

Read the code

  • service/JournalService
  • service/JournalDraft
  • service/ReportService#trialBalance
  • service/NumberingService

SQL behind this page

SELECT a.id, a.code, a.name, a.type,
       COALESCE(SUM(l.debit), 0)  AS debit,
       COALESCE(SUM(l.credit), 0) AS credit
FROM account a
LEFT JOIN v_ledger l ON l.account_id = a.id AND l.entry_date <= :asOf
GROUP BY a.id, a.code, a.name, a.type
ORDER BY a.code

-- account ledger
SELECT entry_id, entry_no, entry_date, entry_description, source_type, source_ref, memo, debit, credit,
       SUM(natural_amount) OVER (ORDER BY entry_date, entry_id, line_id
                                 ROWS UNBOUNDED PRECEDING) AS running
FROM v_ledger
WHERE account_id = :accountId AND entry_date BETWEEN :from AND :to
ORDER BY entry_date, entry_id, line_id