Skip to main content

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​

CheckWhat it provesAlert when
Every entry balancedNo money created or lostAny entry with a nonzero per-currency sum
Trial balance per currencyLedger-wide debits equal creditsSum is not zero
Sub-ledger vs control totalPer-merchant accounts agree with the aggregateDifference is not zero
Snapshot vs recomputed sumBalance caches are rightAny difference
Clearing accounts at zeroFlows completedNonzero beyond the expected window
Bank cash account vs statementLedger cash equals real cashUnexplained difference
Suspense empty or agingUnidentified cash is being resolvedItems 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.

CheckQuery idea
Unbalanced entriesSELECT entry_id, currency FROM ledger_line GROUP BY entry_id, currency HAVING SUM(amount_minor) <> 0
Trial balanceSELECT currency, SUM(amount_minor) FROM ledger_line GROUP BY currency must be 0 for each currency
OrphansLines without an entry, or lines whose currency differs from the account (the schema's foreign keys should already prevent both)
Sub-ledger vs controlSum 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 linesFor each cached balance, recompute SUM(amount_minor) up to the snapshot's as_of_line_id and compare
Reversal integrityEvery 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 accountIncreases whenReturns to zero whenA stuck balance usually means
receivable_processorYou post a captureProcessor funding arrives and fees and refunds are nettedLate funding, missing fee file, unposted refund or chargeback
payout_in_transitYou create a payoutThe payout is paid (bank debit on the statement) or reversedPayout stuck in submission, rejected or returned, statement not ingested
fx_clearing (per currency)You book an FX conversionTreasury conversion settlesConversion in flight or unmatched
suspenseUnidentified cash arrivesCash is classified or returnedMissing 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 recordEntry
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 feesDr processing_cost, Cr receivable_processor
Refund or chargeback netted in fundingDr receivable_merchant or the merchant payable (if not already posted at notification), Cr receivable_processor
Adjustment from the processorDr 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.

  1. Ingest the statement and keep the raw file; verify the opening balance equals the previous closing balance.
  2. Post each statement entry that is not yet in the ledger as a cash entry (funding credit, payout debit, fee, return), with external_ref built from the bank's reference or trace number so the posting is idempotent.
  3. Match each cash entry to the clearing item it settles: funding to receivable_processor, payout debit to payout_in_transit. Unmatched credits go to suspense.
  4. Prove the account: ledger cash_fbo balance 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, Cr suspense, 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.

  1. Stop the cause. Fix or disable the bug, and block new errors before cleaning up.

  2. Identify. The aging alert on receivable_processor flags the open items; ledger-to-file comparison confirms the affected payment ids and amounts. Freeze the list as an immutable work set.

  3. 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.

  4. 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_pending even when that money has already moved, leaving pending negative while the overpayment stays drawable in available.

  5. Post corrections against the accounts that hold the money now. The receivable side is the same in every case (credit receivable_processor for the overstated amount). The merchant side depends on the state:

    State of the itemCorrection (delta 5.00)
    Still pendingReverse the original capture and post the corrected capture, or post the delta against merchant_payable_pending
    Released to available, not paidReverse the release first (reverse dependency order), then the capture; or post the delta against merchant_payable_available
    Paid outPost the delta against merchant_payable_available; the shortfall becomes a negative available balance, recovered through the negative-balance process

    Either 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_at so period reports are right; posted_at records 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.

  6. Never update or delete rows. The immutability triggers will stop you; do not bypass them.

  7. Re-run reconciliation. receivable_processor for the affected items must return to zero; run the trial balance and the funds coverage check.

  8. 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.

  9. 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:

StepRule
MakerProposes an adjustment with accounts, amounts, reason and ticket; cannot approve their own request
CheckerA different person with the right role reviews and approves or rejects; MFA at approval
PosterThe system, not a person, posts the entry after approval, with external_ref equal to the request id
LimitsAmount thresholds and account restrictions (for example, no direct postings to cash_fbo); high amounts need a second checker
EvidenceRequest, 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.

Time-Sensitive

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​

  1. receivable_processor has 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.
  2. 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.

References​

Share: