Ledger Reconciliation
Last Updated: 2026-12-01 Status: Complete
Ledger reconciliation is proving that your own books are internally consistent and agree with the outside world: processor settlement files and bank statements. After this page you can design the internal consistency checks, use clearing accounts as your primary alarm, post settlement and fee files as journal entries, run a suspense process for unidentified cash, correct a bulk error without editing a row, and outline the daily job and month-end controls. It covers the ledger side only. Matching keys, break types and the exception workflow for authorization, settlement and bank deposits are in Three-Way Payment Reconciliation; this page does not repeat them.
Quick Reference
| Check | What it proves | Alert when |
|---|---|---|
| Every entry balanced | No money created or lost | Any entry with a nonzero per-currency sum |
| Trial balance per currency | Ledger-wide debits equal credits | Sum is not zero |
| Sub-ledger vs control total | Per-merchant accounts agree with the aggregate | Difference is not zero |
| Snapshot vs recomputed sum | Balance caches are right | Any difference |
| Clearing accounts at zero | Flows completed | Nonzero beyond the expected window |
| Bank cash account vs statement | Ledger cash equals real cash | Unexplained difference |
| Suspense empty or aging | Unidentified cash is being resolved | Items older than your policy |
What Internal Consistency Checks Should Run?
These need no external data, so they run continuously (or hourly) and any failure is a severity-one engineering issue.
| Check | Query idea |
|---|---|
| Unbalanced entries | SELECT entry_id, currency FROM ledger_line GROUP BY entry_id, currency HAVING SUM(amount_minor) <> 0 |
| Trial balance | SELECT currency, SUM(amount_minor) FROM ledger_line GROUP BY currency must be 0 for each currency |
| Orphans | Lines without an entry, or lines whose currency differs from the account (the schema's foreign keys should already prevent both) |
| Sub-ledger vs control | Sum of all merchant_payable_* accounts per currency, compared with an independently maintained total (for example from daily snapshots rolled forward by posted entries) |
| Snapshot vs lines | For each cached balance, recompute SUM(amount_minor) up to the snapshot's as_of_line_id and compare |
| Reversal integrity | Every reversing entry negates exactly the lines of the entry it references |
Add a funds coverage check specific to a PayFac holding other people's money: bank cash plus receivables from processors should be at least the platform's total liabilities to merchants (pending, available, reserved, in transit) in each currency. A shortfall means merchant money has been spent, lost or mis-posted. Which bank account holds the funds is set by the sponsor bank agreement; confirm the safeguarding rules that apply to you with legal counsel and your sponsor bank.
Which Accounts Should Return to Zero?
Stripe's engineering write-up of its ledger describes the principle: clearing accounts should be zero at steady state, so a nonzero balance signals a missing, late or incorrect event. Make this the heart of your monitoring.
| Clearing account | Increases when | Returns to zero when | A stuck balance usually means |
|---|---|---|---|
receivable_processor | You post a capture | Processor funding arrives and fees and refunds are netted | Late funding, missing fee file, unposted refund or chargeback |
payout_in_transit | You create a payout | The payout is paid (bank debit on the statement) or reversed | Payout stuck in submission, rejected or returned, statement not ingested |
fx_clearing (per currency) | You book an FX conversion | Treasury conversion settles | Conversion in flight or unmatched |
suspense | Unidentified cash arrives | Cash is classified or returned | Missing reference, wrong remittance data |
The alert is aging, not the balance itself, because clearing accounts are legitimately nonzero while money is in flight. Track the age of the oldest unmatched item and alert when it exceeds an expected window you set from your own funding schedule and rail behavior. Aging needs item-level detail, so every line carries object_type and object_id (a payment id, payout id or settlement item id) and you compute the open balance per object. This only works if the lines that close an item carry the same object_id as the lines that opened it. A funding credit covers a whole batch, so post it as one receivable_processor line per settled item (or allocate the batch through an allocation table); a single batch-level line would leave every per-payment item open.
-- Open items in the processor receivable, oldest first
SELECT l.object_id,
SUM(l.amount_minor) AS open_minor,
MIN(je.effective_at) AS oldest_effective_at
FROM ledger_line l
JOIN journal_entry je ON je.id = l.entry_id
WHERE l.account_id = $1
GROUP BY l.object_id
HAVING SUM(l.amount_minor) <> 0
ORDER BY oldest_effective_at;
How Do You Post Settlement Files and Bank Statements?
Processor Settlement and Fee Files as Journal Entries
Ingest, validate and persist files as described in Settlement Files, then turn each validated record into an entry with an external_ref derived from the file and record identity (for example settlement:{file_id}:{record_id}), so re-processing a file cannot double-post. Use the record's settlement date as effective_at.
| File record | Entry |
|---|---|
| Settled item (matches a captured payment) | Usually no cash entry; mark the receivable item as confirmed. If you release pending to available here, post that transfer |
| Interchange, network and processor fees | Dr processing_cost, Cr receivable_processor |
| Refund or chargeback netted in funding | Dr receivable_merchant or the merchant payable (if not already posted at notification), Cr receivable_processor |
| Adjustment from the processor | Dr or Cr receivable_processor against processing_cost or suspense, with the processor's reason |
| Funding total (from file) | Expectation only; the cash entry is posted from the bank statement |
Post fees as a distinct entry type from sales, so the cost side can be reported and reconciled separately. Matching fees to expected interchange is a Module 4 topic; see Three-Way Payment Reconciliation.
The Bank Cash Account Against Bank Statements
cash_fbo is a mirror of a real bank account, so it reconciles to that bank's statement, not to a processor file. Banks commonly deliver account activity as BAI2 or as ISO 20022 camt.053 (bank-to-customer statement) files, and intraday as camt.052 or BAI2 intraday; check which your bank supports. Both carry a closing balance and a list of entries with bank reference and trace values.
- Ingest the statement and keep the raw file; verify the opening balance equals the previous closing balance.
- Post each statement entry that is not yet in the ledger as a cash entry (funding credit, payout debit, fee, return), with
external_refbuilt from the bank's reference or trace number so the posting is idempotent. - Match each cash entry to the clearing item it settles: funding to
receivable_processor, payout debit topayout_in_transit. Unmatched credits go tosuspense. - Prove the account: ledger
cash_fbobalance as of the statement date equals the statement closing balance, plus or minus listed reconciling items (for example a payout you recorded that has not reached the bank).
Use the bank-assigned trace or reference number (and, for ACH, the trace number you generated on the outbound file) as the primary key. Amount-and-date matching is a fallback. Rails and returns are in ACH and Nacha.
How Do Suspense Accounts Work?
A suspense account holds money you have received or paid but cannot yet attribute. It keeps the ledger balanced and the bank cash account correct while the question is answered.
- Entry on receipt: Dr
cash_fbo, Crsuspense, with the bank reference and sender text in metadata. - Clearing rules: identify the owner from remittance data, a payment reference or a merchant inquiry, then reclassify with a new entry (Dr
suspense, Cr the correct account). Never delete from suspense. - Ownership and aging: every suspense item has an owner and a due date. Escalate items older than your policy.
- Unresolvable items: return to sender or handle under unclaimed-property rules, as decided by finance and legal counsel; the engineering requirement is that the disposition is an entry with an approver.
- Suspense is not a parking lot: a suspense balance that only grows means your matching rules, not your cash, are broken.
How Do You Correct Errors Without Updating Rows? (Scenario: 100 Transactions Settled With Wrong Amounts)
Suppose a bug posted a wrong amount for 100 transactions: each capture credited the merchant 105.00 instead of 100.00 (so each receivable debit and payable credit was 5.00 too high, ignoring fees for simplicity). The processor settled 100.00 each, so receivable_processor is left with a 500.00 debit balance, and some merchants have been paid the excess.
-
Stop the cause. Fix or disable the bug, and block new errors before cleaning up.
-
Identify. The aging alert on
receivable_processorflags the open items; ledger-to-file comparison confirms the affected payment ids and amounts. Freeze the list as an immutable work set. -
Compute deltas. Per transaction: correct amount minus posted amount (−5.00 on the merchant payable and receivable). Aggregate per merchant to see who was overpaid, who was paid out, and who is now negative.
-
Find where the money is now. For each affected item, check the downstream entries: still pending, released to available, or paid out. A blind reversal of the original lines would debit
merchant_payable_pendingeven when that money has already moved, leaving pending negative while the overpayment stays drawable in available. -
Post corrections against the accounts that hold the money now. The receivable side is the same in every case (credit
receivable_processorfor the overstated amount). The merchant side depends on the state:State of the item Correction (delta 5.00) Still pending Reverse the original capture and post the corrected capture, or post the delta against merchant_payable_pendingReleased to available, not paid Reverse the release first (reverse dependency order), then the capture; or post the delta against merchant_payable_availablePaid out Post the delta against merchant_payable_available; the shortfall becomes a negative available balance, recovered through the negative-balance processEither reverse the dependent entries in reverse dependency order (payout, release, capture) and repost correctly, or post a single delta against the current account; never reverse only the original. Every entry references the ticket, carries a reason and keeps the original
effective_atso period reports are right;posted_atrecords when the fix happened. A delta entry is the simpler choice for large volumes, as long as it links to the original and the ticket. -
Never update or delete rows. The immutability triggers will stop you; do not bypass them.
-
Re-run reconciliation.
receivable_processorfor the affected items must return to zero; run the trial balance and the funds coverage check. -
Notify affected merchants. Overpaid merchants may now have a negative available balance; handle it under your negative balance policy (Reserves and Negative Balances). Statements show the original and the correction with the reason.
-
Keep the audit trail. Record who approved the correction, the ticket, the query that selected the set and the before and after balances; see Audit Trails.
{
"external_ref": "correction:INC-1234:pay_01H8X",
"entry_type": "correction",
"effective_at": "2026-12-01T14:03:11Z",
"reason": "Capture posted at 10500 instead of 10000; delta against the account holding the funds",
"ticket_ref": "INC-1234",
"lines": [
{ "account": "merchant_payable_available:mrc_42:USD", "amount_minor": 500, "object_id": "pay_01H8X" },
{ "account": "receivable_processor:proc_a:USD", "amount_minor": -500, "object_id": "pay_01H8X" }
]
}
This is the delta form for an item already released to available; for an item still pending, the merchant line targets merchant_payable_pending. If you use the reversal form instead, set reverses_entry_id on each reversing entry and post the corrected entry with its own external_ref. Make the correction job idempotent, so that a retry after a crash does not correct twice: the external_ref unique constraint covers delta entries, and the unique reverses_entry_id covers reversals.
Month-End Close and Maker-Checker Controls
Close. At period end, run all checks, clear or age-justify clearing accounts, prove cash accounts to statements, and snapshot the trial balance. Then lock the period: postings with an effective_at in a closed period are rejected, and late events are posted in the open period with a note, or the period is formally reopened by finance. How you recognize revenue, accrue costs and close the books is for your finance team and auditors to decide; engineering supplies the locking and the evidence.
Maker-checker. Manual adjustments are the highest-risk postings. Require two people:
| Step | Rule |
|---|---|
| Maker | Proposes an adjustment with accounts, amounts, reason and ticket; cannot approve their own request |
| Checker | A different person with the right role reviews and approves or rejects; MFA at approval |
| Poster | The system, not a person, posts the entry after approval, with external_ref equal to the request id |
| Limits | Amount thresholds and account restrictions (for example, no direct postings to cash_fbo); high amounts need a second checker |
| Evidence | Request, approvals, entry id and timestamps retained under Audit Trails |
Access design for these roles is in Access Control.
A Daily Reconciliation Job in NestJS
@Injectable()
export class LedgerReconciliationJob {
private readonly logger = new Logger(LedgerReconciliationJob.name);
constructor(
private readonly dataSource: DataSource,
private readonly alerts: AlertService,
private readonly runs: ReconRunRepository,
) {}
@Cron('0 5 * * *', { timeZone: 'UTC' }) // run on exactly one instance (leader lock)
async run(): Promise<void> {
const run = await this.runs.start('ledger-daily');
const findings: Finding[] = [];
findings.push(...await this.unbalancedEntries());
findings.push(...await this.trialBalanceByCurrency());
findings.push(...await this.snapshotDrift());
findings.push(...await this.agedClearingItems()); // processor, payout, fx, suspense
findings.push(...await this.fundsCoverage());
findings.push(...await this.cashVsStatement()); // statements ingested earlier
await this.runs.finish(run.id, findings); // stored, never deleted
const critical = findings.filter((f) => f.severity === 'critical');
if (critical.length > 0) {
await this.alerts.page('ledger-reconciliation', critical);
}
this.logger.log(`ledger reconciliation ${run.id}: ${findings.length} findings`);
}
}
Each check returns structured findings (check name, currency, account, amount, oldest item, owner). Do not log merchant bank details or any card data in findings. Set aging thresholds from your own baseline of funding and payout behavior, and review them when schedules change. Operational monitoring of these metrics is in Observability.
File and statement formats (BAI2, camt.053, processor files) vary by bank and processor and change by version; confirm with each provider. This page describes engineering patterns, not accounting or legal advice; have finance, your auditors and legal counsel confirm close, safeguarding and unclaimed-property practices.
Self-Assessment
receivable_processorhas a small positive balance that never clears. What are the likely causes and what do you check first? A missing or late fee file, an unposted refund or chargeback, or a partial funding; list the open items by payment id and age.- Why post the bank cash entry from the statement, not from the processor funding file? The file states what the processor says it sent; the statement proves what arrived.
More scenarios are in the Ledger Quiz.
Related Topics
- Three-Way Payment Reconciliation: matching keys, break types and exception workflow
- Settlement Files: ingesting the files you post here
- Double-Entry Ledger Design: the entries, invariants and reversals used for corrections
- Pending vs Available Balance: the balances a correction can change
- Audit Trails: evidence for adjustments
- Check your understanding: Ledger Quiz
References
- Ledger: Stripe's system for tracking and validating money movement — Stripe engineering blog, Ilya Ganelin, 2024
- Transaction status and balances — Modern Treasury documentation (vendor; reversing a posted transaction with a new one)
- ISO 20022 message definitions — ISO 20022 registration authority (camt.052 and camt.053 account reporting)