How to validate bank statement extraction

The checks that prove extracted statement data is right, using the figures the bank already printed.

Published · Updated

Whether you use a vendor API, an open-source library or your own code, bank statement extraction fails quietly. A wrong row looks like a right one. A deposit read as a withdrawal, a missing row at a page break, or a narration that swallowed an amount won’t raise an error. It shows up later as a ledger that doesn’t close.

The good news is that every statement carries its own answer key. The bank printed an opening balance, a closing balance and, usually, a running balance on every row. If your extracted data can’t reproduce those figures, it is wrong. This guide sets out the checks we run in production, in the order we run them.

1. Use exact arithmetic

Before any check, make sure amounts are decimals or integer minor units (cents, paise), never binary floating point. A float sum of a few thousand rows can drift by fractions of a cent, and then every tie-out needs a tolerance that hides real errors too. Parse “1,23,456.78” and “1,234.56 Dr” into exact values at the point of extraction, with the sign decided once.

2. Tie the statement end to end

The first check is one line:

opening balance + sum of signed amounts = closing balance

Credits are positive, debits negative. Compute the gap (left side minus right side) and store it with the result, not just a pass or fail. A gap equal to one transaction’s amount, or twice it, points straight at a missing row or a flipped sign.

Decide your tolerance deliberately. We allow one rupee of slack in regression tests, because some source documents round. The gate for writing to the books is an exact zero. A tolerance that lets data in should be zero unless you can say which documents need more, and why.

3. Check the running balance row by row

An end-to-end tie can pass by accident, for example when two errors cancel. The running balance closes that gap:

balance[i] = balance[i−1] + amount[i]

Banks sort oldest-first or newest-first, and some exports reverse the order. Test both directions and keep the one with fewer mismatches. Then report the first mismatching row with its description, the balance movement and the extracted amount. That one line usually names the bug: a sign error, an amount in the wrong column, or a balance read from the wrong cell.

Rows the bank marks as failed or reversed need a rule. In our parser they are kept and flagged, with a signed amount of zero, so they stay visible without breaking the chain.

4. Know which figures were printed and which were derived

Some statements don’t print an opening balance. A common fix is to reconstruct it from the first row: its running balance minus its amount. That is reasonable, but the end-to-end tie now only proves the chain is internally consistent. It no longer checks against an independent printed figure.

Record, for each statement, which balances came off the page and which were derived. Treat derived figures as weaker evidence. A statement that reports an opening and closing of 0.00 while showing transactions in between is almost always a parsing placeholder, not a real balance. Mark it as assumed and don’t let it anchor later checks.

5. Use page and summary totals

Many layouts print more than balances:

  • Summary blocks with total debits, total credits and transaction counts. Sum your extracted debits and credits separately and compare each, and compare the counts. A count mismatch finds a dropped row even when the amounts happen to tie.
  • Brought-forward and carried-forward lines on each page. These are page figures, not the statement’s. Take the opening from the first page and the closing from the last, and use each page’s carry-forward to locate which page lost a row.

If you use a printed summary to correct the extraction, for instance by inferring a missing debit or credit direction from balance movements, apply the correction only when the corrected rows reproduce every printed figure exactly. Otherwise leave the statement unbalanced so the check catches it.

6. Check that nothing printed went missing

Balances prove the amounts you extracted are consistent. They don’t prove you extracted every figure the bank printed. A coverage check helps: collect every amount-shaped token on each page, and confirm each one appears in the output or sits on a line you have decided to ignore, such as a reference number or a header. Whatever is left over is something your parser dropped.

7. Detect duplicates without deleting real payments

Overlapping statement periods and re-uploads are normal. Fingerprint each transaction by account, date, amount and normalized description. The trap is that two genuine identical payments on one day share that fingerprint. Add an occurrence number, counting identical rows within the statement, so the first and second copies of a real pair stay distinct while a re-uploaded statement matches what is already stored.

Across statements, compare each statement’s opening with the closing of the one before it. A difference means a missing period, a missing statement or an extraction error at a boundary.

8. When a figure doesn’t tie

Don’t fix it in place, and don’t drop it. In order:

  1. Hold the statement. Stop it before its transactions reach your database. Keep the gap, the parser and its version, and the reason.
  2. Find the first broken row. The running-balance check gives you the row. Compare it with the PDF.
  3. Classify the cause. Usually it is an extraction bug: a sign, a column, a wrapped line, a page break. Sometimes the bank’s own document is inconsistent; we have seen a layout print a lagging running balance for clusters of same-day credits.
  4. Fix the parser, not the row. Add the statement to your regression fixtures, then reparse the held import.
  5. Record the exceptions. If the source itself doesn’t reconcile, mark that fixture as known not to reconcile, with the reason, so the exception is documented.
  6. Log every decision. Whoever accepts, rejects or reparses a held statement should leave a trace.

One more rule: if extraction happens in one service and the books in another, the consumer should recompute the checks itself rather than trust a quality flag sent with the data.

Putting it into practice

These checks are cheap to run and catch most of what goes wrong. They are how Lekhavo’s statement parser works, and how we build custom bank statement parsers for clients. If you want a second opinion on your own extraction pipeline, talk to us.

Have financial data that has to tie out?

Tell us what you want to build. We reply with questions, a plan and an estimate.

Start a project