# finance.ledger.trial-balance
Totals every account's debits and credits and shows each account's balance on
the side it falls, the way a trial balance is printed. If double entry was kept,
the debit column equals the credit column; `balanced` says whether it does.
The lines can come from any number of journals: a trial balance is built from
the whole ledger for a period, not one journal at a time. The lines are checked
with finance.ledger.journal-validate first, and a line that cannot be totalled
meaningfully is an error, thrown with that capability's message: an amount in
another currency, a negative amount, or a malformed account code. An unbalanced
set of lines is not an error. Proving whether the ledger balances is what a
trial balance is for, so that is the `balanced` answer.
Lines with a zero debit and a zero credit are skipped and do not create a row.
A line with both a debit and a credit is totalled on both sides. An account
whose debits and credits cancel still has a row, with both balances zero,
because it had postings.
Rows are sorted by account code as text (byte order), which is how a chart of
accounts with codes like `1200-01` sorts. Codes of different lengths do not sort
numerically: `1000` comes before `900`. Pad codes to a fixed width if a numeric
order is wanted.