bettersight-statement-extra.../docs/bankstatement.md

26 KiB
Raw Permalink Blame History

Bank Statement Extraction — Product Build Spec

The first paid product in the Bettersight document line. Focused niche: bookkeepers and small practices working with regional (Caribbean) bank statements. Reads a statement, structures it, proves the arithmetic, lets a person fix what is wrong, and exports it for accounting software.

Relationship to other specs:

  • Supersedes bank-statement-converter-build-spec.md for the paid product. That spec's free tool becomes a limited front door to this one (see section 12).
  • Uses the layout mapper design (saved per-client column mappings) as a core feature, not an add-on.
  • Is the front end for reconciliation-tool-build-spec.md; its normalized rows and mapper are the reconciliation tool's inputs.

1. Purpose

One sentence: turn a bank or card statement into clean, editable, verified transaction data that a bookkeeper can trust enough to import.

1.1 What extraction does (the definition this build follows)

Extraction does more than show the text in an editable table and run the balance check. It does four things:

  1. Structures the statement. It finds the transaction table across all pages, ignores headers and "brought forward" lines, joins descriptions that wrap onto a second line, and turns each row into a date, description, debit, credit, and balance. It also reads statement-level facts: bank, masked account, period, and opening and closing balance. That structure is where most of the difficulty is, and it's what a plain text dump doesn't give you.
  2. Proves the arithmetic. It runs the balance check you described (opening plus credits minus debits equals closing). It also checks that each row's balance follows from the row above, that dates fall inside the statement period, and that every page was read.
  3. Shows the source beside the data. A person sees the original page next to the table, with flags in plain language on suspect rows, edits anything, and every edit is logged.
  4. Exports it. Excel, CSV, and later accounting import files.

What the balance check does and does not prove: it proves the figures are consistent, but not that every description or date is correct, because a swapped description or misread date can still balance. That is why the date and page checks exist and why the source is shown beside the data. Product copy must say this.

1.2 Where each of the four functions is specified

Function Specified in
1. Structures the statement Section 3 (pipeline), section 6 (layout mapper), section 7 (statement variants)
2. Proves the arithmetic Section 4 (the checks)
3. Shows the source beside the data Section 5 (review screen), section 9 (edit log in the data model)
4. Exports it Section 8 (exports)

1.3 Boundaries (what it does not do)

  • Does not decide how a transaction should be categorized (a later feature).
  • Does not post anything into accounting software.
  • Does not match the statement to the ledger (that is the reconciliation tool).
  • Does not replace the bookkeeper's judgment.

2. Target user and positioning

Primary user: bookkeeper or small-practice staff handling many clients whose banks give no usable feed into the accounting software.

Why this wedge (from the competitor review):

  • DocuClipper's pitch centers on bank statements and a balance check, and claims "any bank, any country" with 99.9% field-level accuracy on digital PDFs. Those are vendor claims and cannot be verified for regional banks.
  • Dext is a receipt-and-bookkeeping workflow product and is not the right comparison for this feature.
  • Our opening is checkable depth: named regional banks, a published pass rate, remappable layouts, and clear failure flags.

Claims we may make: "Extracted and checked against your closing balance." Claims we may not make: "100% accurate", "any bank".

2.1 Four deliberate improvements over the incumbent

These are the four ways this product is built to be a little better than the established tool. Each is a requirement of this build, with an acceptance test. (They come from public pages only; verify against the competitor's free trial before using any of them in marketing.)

# Improvement Where specified Acceptance test
1 Say what "accurate" means, bank by bank and document type by document type Section 11 Public coverage table exists, shows digital, scanned, and photographed results separately, and every number traces to a stored test run
2 Make failures fixable in one click Section 4.1 Every failed or flagged check either offers a suggested fix with evidence or says why none is possible; accepting a fix re-runs the checks and shows the new status
3 Explain every flag in plain language beside the source Section 5.1 No flag appears without what is wrong, where, why, and what to do; the row is highlighted on the source page
4 Show remembered layouts and let users edit them Section 6.1 A user can see, test, edit, version, roll back, and delete any saved layout without contacting support

3. What happens to a statement (pipeline)

upload → file checks → text-or-scan detection
      → Docling: layout, tables, OCR if needed
      → locate statement facts (bank, period, opening, closing)
      → locate transaction table(s), join across pages
      → map columns to fields (saved mapping or mapper)
      → normalize (dates, amounts, signs, multi-line descriptions)
      → run checks → status
      → review screen → export

Stage notes

  • Text versus scan: text-based PDFs use embedded text and skip OCR. Scans and photos use OCR and carry lower confidence.
  • Cross-page handling: repeated header rows, tables that continue on the next page, and "brought forward / carried forward" lines are recognized and not treated as transactions.
  • Multi-line descriptions: a row with no date and no amount that follows a transaction is joined to that transaction's description.
  • Normalization: dates to ISO form using the confirmed format; amounts to signed numbers with the statement's debit/credit convention; thousands separators and negative formats (parentheses, trailing minus, "DR/CR" suffix) handled.
  • Rules first, AI last: parsing, mapping, and arithmetic are rule-based. AI is used only to suggest a column mapping or description cleanup for layouts the rules cannot resolve, and its output goes through the same checks.

4. The checks

Every statement gets one of three statuses: Verified, Needs review, or Failed.

Check What it tests Result if it fails
1. Statement balance check Opening balance + credits − debits = closing balance, using the statement's printed figures Failed; shows the difference and likely causes
2. Running-balance continuity For every row with a printed balance: previous balance ± amount = this balance The first broken row is highlighted; rows after it are marked suspect
3. Totals check Extracted total debits and credits equal the statement's printed totals, when the bank prints them Needs review
4. Date sanity Every date falls within the statement period and rows are in order Needs review on the offending rows
5. Structure sanity No row with both debit and credit, no row with neither, no blank descriptions, no duplicate-looking rows Needs review on the offending rows
6. Page coverage Every page of the file was read; a page with no rows is explained (cover page, notices) or flagged Needs review

What Verified means: the arithmetic is consistent end to end. It does not prove that every description or date is correct, because a swapped description or misread date can still reconcile. That is why checks 4 to 6 exist and why the review screen shows the source beside the data. The product copy must say this.

Never silently correct: the tool may suggest a fix (for example "this row's debit and credit look swapped") but never changes a figure without the user accepting it.

Live re-check: when the user edits a cell, all checks re-run immediately and the status updates.

4.1 Suggested fixes (improvement 2: failures fixable in one click)

When a check fails, the tool does not stop at flagging. It tests a fixed list of known failure patterns, and for each one that explains the difference it offers a suggested fix, with the evidence and a preview of the resulting status.

Pattern How it is detected Suggested fix
Debit and credit swapped on a row Flipping that row's side makes the running balance continue correctly Flip the row
Transposed digits The balance difference is divisible by 9 and swapping two digits in a row's amount closes it Show the candidate rows and the corrected amount
Misread digit by OCR Common confusions (0/O, 1/l, 5/S, 8/B) in a row's amount, and the change closes the difference Show the candidate and the corrected amount
Dropped row A gap in the running balance equals an amount visible in the source page but absent from the table Add the row with the values read from the source
Merged rows One row's amount equals the sum of two source lines, or one description holds two dates Split the row
Day and month swapped Dates fall outside the period only when read as day/month, and inside it when read as month/day (or the reverse) Switch the date format for the statement
Wrapped description read as a new row A row with no date and no amount that follows a transaction Join it to the previous description
Page not read Page coverage check fails Re-run that page with OCR

Rules for suggested fixes

  • Each suggestion shows the evidence ("flipping this row makes the balance after it equal 1,204.50, which matches the printed figure") and the status the statement would have after the fix.
  • A suggestion is made only when it fully explains the difference or the flagged condition. If no pattern fits, the tool says "no automatic explanation found" and points to the first broken row; it never guesses.
  • Accepting a suggestion applies it, re-runs all checks, and logs the change as a user-accepted fix. Nothing is applied automatically.
  • Track how often each pattern is suggested and how often it is accepted or rejected, to retire patterns that mislead and to find the next one worth adding.

5. Review screen

  • Left: the source page image, with the selected row highlighted on the page. Right: the transaction table.
  • Status banner at the top: Verified / Needs review / Failed, with the balance check shown as numbers (opening, credits, debits, closing, difference).
  • Row flags explain themselves in plain language (see 5.1).
  • Editing: edit any cell; add, delete, merge, or split rows; flip debit/credit on a row; bulk-fix a column (for example change the date format).
  • Navigation: jump to next flagged row; filter to flagged rows only.
  • Accept: when status is Verified, one click accepts the statement. For Needs review or Failed, the user must clear or acknowledge each flag; acknowledged flags are recorded.
  • Change history: every edit is logged with the old value, new value, user, and time. The export can include an "edits" sheet.

5.1 Flags in plain language (improvement 3)

Every flag has four parts, written for a bookkeeper and not for a developer:

Part Example
What is wrong "The balance after this row doesn't follow from the row above."
Where Row number, page number, and the row highlighted on the source page
Why we think so "Row above ends at 4,310.20; this row is a debit of 250.00; the statement shows 4,360.20, but 4,060.20 was expected."
What to do "Check whether the debit and credit are the wrong way round. Suggested fix available."

Rules

  • No flag may appear as a code, a score, or a technical term. The flag catalog is written and reviewed as plain-language copy.
  • Flag catalog (minimum): balance does not follow, statement balance difference, date outside the period, dates out of order, row with both or neither amount, blank description, possible duplicate, page not read, low-confidence scan, layout changed, and missing opening or closing balance.
  • Severity has two levels only: "must check before accepting" and "worth a look".
  • A flag with an available suggested fix links directly to it (section 4.1).
  • A user can mark a flag as checked, with an optional note; acknowledged flags and notes are saved with the statement and appear in the edits sheet.

6. Layout mapper (core feature)

  • Fingerprint each layout: header text, column positions, page structure, key phrases. Scope: client, bank, account type.
  • On upload: exact fingerprint match applies the saved mapping silently; a near match applies it with "layout changed, please confirm"; no match opens the mapper.
  • Mapper screen: shows the page image and detected table; the user assigns each column to Date, Description, Debit, Credit, Amount, Balance, or Ignore; sets date format and sign convention; marks rows to ignore (headers, footers, brought-forward lines).
  • Preview before saving: first ten rows plus the balance check result.
  • Versioning: every mapping is versioned and can be rolled back.
  • Drift detection: if a saved mapping starts failing the balance check, mark it stale and prompt a remap.
  • Shared library (opt-in): a confirmed layout can be offered to a shared template library. Only layout fingerprints and column maps are shared, never data. State this plainly in the terms. A layout is promoted to a shared template only after several different practices have confirmed it.

6.1 Layouts page: remembered layouts that users can see and edit (improvement 4)

A "Layouts" page lists every saved layout for the practice, grouped by client and bank. Nothing the system remembers about a statement format is hidden.

Capability What the user sees or can do
List Client, bank, account type, current version, last used, number of statements processed, balance-check pass rate for that layout, and status (active, stale, retired)
Inspect The column map, date format, sign convention, ignored rows, and a sample page with the mapped columns drawn over it
Test Re-run the layout on the client's most recent statement and show the check results, without saving anything
Edit Change a column assignment, date format, or ignored-row rule, then preview the first ten rows and the balance check before saving
Version history Every change with who made it and when; compare two versions side by side
Roll back Restore any earlier version in one click; statements already accepted are not changed
Delete or retire Remove a layout, or mark it retired so it is no longer applied
Source of mapping Whether it was created by the user, suggested by the tool, or taken from the shared library

On every statement: show which layout and version was applied, with a link to it, and a "wrong layout?" action that opens the mapper with that statement loaded.

When a layout changes under the user: a near match shows what differs ("column positions moved; Debit and Credit headers now read Withdrawals and Deposits") and offers to save the updated version. A stale layout is shown on the Layouts page with the failing statements listed.

Why it matters: a bank changing its format becomes a thirty-second fix by the bookkeeper and not a support request to us.


7. Statement variants to support

Variant Notes
Single-account bank statement v1
Multi-account statement (several accounts in one PDF) Split into one statement per account before checks
Credit card statement Sign convention reversed; payments and purchases; opening and closing "balance owed"
Multi-currency or foreign-currency lines Show original currency and amount; never convert without an explicit rate
Scanned and photographed statements Supported with lower confidence and stricter flags
Password-protected PDF Ask for the password; never store it
Statements without printed running balances Statement balance check only; running-balance check is skipped and the status says so
Statements without printed opening or closing balance Status cannot be Verified; asks the user to enter the missing figure

8. Exports

  • Excel: Transactions sheet (date, description, debit, credit, balance, check flag, source page, confidence), Summary sheet (statement facts and check results), optional Edits sheet.
  • CSV: same fields, for generic import.
  • Accounting import files (later, after Excel and CSV are solid): formats for the packages your pilot practices use. Confirm each package's current import format before building the export. Entries are data files; the tool does not connect to or post into the package in v1.
  • Append mode: add a new statement to a client's running workbook; duplicates are skipped by date + description + amount + balance, and the summary sheet keeps one line per period.

9. Data model (Frappe workbench)

  • Practice (tenant), Client, Bank Account (masked number, bank, type, currency).
  • Statement: client, account, period, opening, closing, status, file hash, page count, extraction method, layout version used, accepted-by and accepted-at.
  • Transaction: statement, date, description, debit, credit, balance, source page and position, confidence, flags.
  • Check Result: statement, check name, outcome, detail, run-at.
  • Layout Mapping: client, bank, account type, fingerprint, column map, date format, sign convention, version, status, shared-library state.
  • Edit Event: statement, transaction, field, old value, new value, user, time.
  • Flag: statement, transaction (if any), flag type, plain-language text (what, where, why, what to do), severity, status (open, checked), note, checked-by and checked-at.
  • Suggested Fix: statement, flag, pattern, evidence text, status after fix, outcome (accepted, rejected, ignored), user, time. Used to measure which patterns help.
  • Layout Version: layout mapping, version number, column map, date format, sign convention, ignored-row rules, created-by, source (user, tool, shared library), created-at.
  • Usage: pages processed, success or failure, processing time, estimated cost (for pricing and cost control).

10. Privacy and retention

  • Product mode keeps data so history and mappings persist. Each practice sets retention per client (default to be decided in the pilot) with a one-click delete of a statement, a client, or everything.
  • Tenant isolation at database and storage level; encryption at rest and in transit; roles for preparer, reviewer, and admin.
  • No training on customer data. State it in the terms and the product.
  • Account numbers masked in the interface and logs except the last four digits.
  • Self-hosted by default, consistent with the privacy positioning.
  • Passwords for protected PDFs are used in memory only and never stored.

11. Accuracy program (the actual product)

  1. Bank coverage matrix (improvement 1): one row per bank, account type, and input type (digital PDF, scanned PDF, phone photo), each with sample count, the two measures defined below, and last-tested date. Digital, scanned, and photographed results are never blended into one number. Show the matrix to customers.
  2. Regression corpus: every statement that ever failed becomes a permanent test case (anonymized with the owner's consent). Releases must not lower any bank's pass rate.
  3. Published pass rates: "Tested on N real statements from Bank X (digital PDFs): Y% verified untouched; here are the failure types." Specific numbers beat a broad accuracy claim.

The two measures (defined once, used everywhere):

  • Untouched pass rate: share of statements that reached Verified with no user edit. Measured by the balance check and the other checks.
  • Field accuracy against ground truth: share of extracted fields (date, description, debit, credit, balance) that match a hand-verified copy of the statement. Measured on the regression corpus only, because it needs a human-checked answer key.
  • Report both, because the first can look good while descriptions are wrong, and the second cannot be measured on live customer statements.

Rules for the public page: every number links to a stored, dated test run; no figure is shown for a bank with fewer than a stated minimum of sample statements; banks and input types not yet tested are listed as "not yet tested" and not hidden; the page states plainly that "Verified" means the arithmetic is consistent. 4. Failure taxonomy: record why each failure happened (OCR misread, merged columns, dropped row, cross-page error, unsupported layout) so effort goes to the most common cause. 5. Failures must be visible: no statement may reach Verified through a path that skips a check.


12. Free front door

A limited version of this product is the lead-magnet tool: upload one statement, get an Excel file by email, files deleted in 24 hours, a monthly cap per email. It uses the same extraction and checks. Mapper, saved history, append mode, and client management belong to the paid product. This resolves the retention difference: the free tool deletes; the paid product retains by the practice's choice.


13. Pricing (hypotheses only, decide after the pilot)

  • DocuClipper prices by page and per firm (its own pages show inconsistent tiers, so confirm before benchmarking). Dext prices per client.
  • Options to test: per page, per client per month, or per practice with a page allowance. Choose from measured time saved and measured cost per page, not from competitor prices.
  • Record compute cost per page from the first prototype so the free cap and paid tiers rest on real numbers.

14. Test plan

  1. Collect real statements: ten per target bank, anonymized, including text-based, scanned, and phone-photographed versions. Jason must supply these; write no bank-specific logic from assumptions.
  2. Measure per bank: balance-check pass rate, row-level error rate, flag precision (flagged rows that were actually wrong), and silent failures (wrong data marked Verified), which must be zero.
  3. Side-by-side with DocuClipper: run the same statements through its 14-day, 120-page trial and compare pass rates and error types per bank.
  4. Hostile cases: merged columns, wrapped descriptions, brought-forward lines, page-break splits, foreign-currency lines, credit card statements, password-protected files, blurry scans.
  5. User test: three bookkeepers each process five real statements; record time taken against their current method, and how often they overrule a flag.
  6. Acceptance tests for the four improvements (section 2.1):
    • Improvement 1: every figure on the coverage table traces to a stored test run, and digital, scanned, and photographed results are shown separately.
    • Improvement 2: seed statements with known faults (swapped row, transposed digits, dropped row, date-format swap) and confirm each is detected, suggested, fixed with one click, and re-checked; also confirm that a fault with no matching pattern produces "no automatic explanation found" and no guess.
    • Improvement 3: have three bookkeepers read every flag in the catalog and say what they would do next; any flag they cannot act on is rewritten.
    • Improvement 4: a bookkeeper edits, tests, versions, and rolls back a layout without help, and the change in a deliberately altered statement is explained on screen.
  7. Launch gate (placeholder until real numbers exist): zero silent failures, and a pass rate per supported bank high enough that bookkeepers choose it over retyping. Set the number after step 3.

15. Build phases and growth path

Phase Scope
1 Command-line extraction for one bank, text PDFs, all six checks, Excel output. Measure against real statements. Also build the measurement harness for improvement 1: run the corpus, store dated results, and report untouched pass rate and field accuracy per bank and input type
2 Review screen with source highlighting and editing; plain-language flag catalog (improvement 3); suggested-fix patterns, starting with swapped debit/credit, transposed digits, and date-format swap (improvement 2); scanned input; second bank
3 Layout mapper with saved mappings and drift detection; Layouts page with test, edit, version history, and rollback (improvement 4); remaining suggested-fix patterns; third bank; coverage matrix
4 Practice accounts, clients, retention controls, edit history, exports for pilot practices' accounting packages
5 Free front door and public coverage table and pass-rate page (improvement 1); pilot with a few practices
6 Append mode, credit card statements, multi-account statements
7 Reconciliation against the ledger (see the reconciliation spec), then supplier statements
Later Transaction categorization, spending analysis, and more document types only if pilot customers ask

Where we deliberately do not compete early: US tax forms, lender and forensic fraud analysis, enterprise security certifications, broad API and integration catalog.


16. Risks and open questions

Risks

  • Regional layouts may be harder to extract than expected; the test in section 14 decides whether the niche works at all.
  • A free-trial comparison may show DocuClipper already handles the target banks well; if so, differentiate on the mapper, the reconciliation path, and privacy, or choose a different wedge.
  • Support load grows with every new layout; the mapper reduces but does not remove it.
  • A "Verified" label could be over-trusted; keep the plain-language limits (section 4) visible.
  • Client data held for practices carries data protection duties in each market sold into; check them before launch.

Open questions

  • Which banks and account types do the first ten users actually use?
  • Do pilot practices need accounting import files, or is Excel enough at first?
  • Is a retention default of 30, 90, or 365 days right for practices?
  • Per page, per client, or per practice pricing?