Skip to content

Trust Ledger

The trust ledger must remain a single financial source of truth. Do not add JSON-backed trust balances or per-feature trust stores.

Canonical Tables

TrustTransaction.caseId is nullable and uses ON DELETE SET NULL so ledger history survives case deletion.

Posting Path

Use postTrustTransaction() from src/lib/trust/ledger.ts for every trust mutation that creates money movement. It:

Current writers using this path:

Reconciliation

/api/trust/reconcile calculates:

It persists every attempt in TrustReconciliation. TrustAccount.lastReconciledAt is stamped only when bank = book = client ledger. A failed recon is an audit row, not a successful recon.

Tests

Focused coverage lives in:

Any new trust writer should add a failing test proving it calls the canonical posting path and does not write trust data into metadata JSON.

Source: docs/dev/trust-ledger.md