Case study, synthetic brands
Making every brand's exports agree with the bank
dtc-cash-onboarding
Every brand sends different files. This maps a consumer brand's Shopify, Amazon, Faire, bank, card and chart-of-accounts exports into one cash ledger, and accepts the result only when independent records of the same money agree. What it cannot prove, it sends to a person instead of guessing.
The problem
Mapping columns is the easy part. The hard part is that a column can be mapped correctly and the money can still be wrong:
- A Shopify payout is net of fees and refunds. Counting it as revenue next to the orders counts sales twice.
- An Amazon settlement report spreads one deposit across dozens of fee rows.
- A transfer back from savings, a credit line draw and a vendor refund all look like income in a bank CSV.
- Paying the card bill from the bank and listing the ad charges on the card counts the same spend twice.
- Exports overlap, and some order exports repeat the order total on every line item.
In the project's data, adding up every deposit overstated customer receipts by 0.1% to 90%, depending on the brand and upload.
The approach
- Read CSV, tab-separated, semicolon or Excel files, and find the real header under summary lines.
- Recognize and map each file. A column is accepted only when the header and the values agree.
- Standardize signs, day-first dates, decimal commas, line-item exports and repeated rows.
- Tie out. This is the gate: payouts and settlements must appear in the bank to the cent, card payments must match bank debits, and the running balance must agree with the amounts.
- Label each line by proof first, then by the brand's memory of earlier reviewer answers, then by a model only above a threshold picked for 99% precision on brands it never saw.
- Decide: accepted, ties out with open items, or blocked with the failing check named.
The controls
| What has to agree | The error it stops |
|---|---|
| Each Shopify payout, Amazon settlement and Faire payout, and a bank deposit, to the cent, within 3 to 5 days | A missing or wrong export; payouts counted as revenue twice |
| Daily order charges and payout charges, at the payout lag found in the data, within 0.5% | Line-item totals summed; a subtotal mapped as the total |
| Card payment rows and card-bill debits in the bank | The same ad spend counted on the card and again as the bank payment |
| Money leaving one of the brand's accounts and arriving in another | A transfer from savings counted as income |
| The running balance and the amounts | Flipped signs, dropped rows, a misread date order |
| Every payout-looking deposit and an export behind it | Receipts from a processor with no export accepted unproven |
| At least one readable bank file, and every row read | "Not applicable" read as a pass; rows silently dropped |
What the brand sees
The review queue is what reaches the brand. The model's best guess for this bank line was a card payment, at 0.17 confidence, far under the 0.49 threshold, so it did not label the line. It asked:
| Bank line, Aug 31 | Amount | Model's guess |
|---|---|---|
| payment received from old mill market | $4,405.34 | card payment, 0.17 |
The note I would send the founder:
On Aug 31 your bank shows $4,405.34 from Old Mill Market. Is that a wholesale customer paying an invoice? If so, I'll record it as wholesale revenue. Everything else in this upload matched your Shopify and Amazon exports, so this and two account categories are all I need from you.
On the next upload the same customer paid three more times and was asked about again. Memory only keeps words that recur within an upload, so a customer seen once left nothing to remember. That is the fifth product ask below.
Results
| Brands and upload | Auto-labeled (from the committed run) | Precision (from the committed run) | Review items per brand (from the committed run) |
|---|---|---|---|
| 3 development brands, 1st upload | 97.1% | 100% | 7.0 |
| Same brands, 2nd upload | 99.3% | 100% | 1.3 |
| 3 holdout brands, blind run | 46.9% | 84.5% | 47.3 |
| Holdout brands after fixes (not blind) | 95.2% | 99.7% | 15.7 |
| Same brands after fixes, 2nd upload | 97.9% | 99.8% | 4.3 |
| 3 new brands, second blind run on the current code | 78.1% | 100% | 7.3 |
| Same brands, 2nd upload | 79.8% | 100% | 4.0 |
(from the committed run) copied from the committed run, as published in the project README.
Memory works. On the second upload all 22 development files were recognized from memory and all 58 rows repeated from the first upload were dropped, with no false flags. Thirteen bank files with flipped signs were repaired automatically from the payout matches.
The model is the last resort. Logistic regression on character and word n-grams, trained on 2,606 lines from 7 brands. In leave-one-brand-out cross-validation it is 96.2% accurate; at the chosen threshold of 0.49 it is 99.4% precise and labels 91.1% of lines.
What the first blind test found
The holdout exposed four real problems:
- A hole in the gate: two brands were accepted although their bank data never tied out, because every bank check returned "not applicable" and the gate read that as a pass.
- Dates written day-month-year with dashes did not parse, so a correct mapping read zero rows.
- Unsigned amounts with a separate debit and credit column were taken for a card statement.
- Shopify payouts exported one row per transaction. The gate refused the brand, correctly; the pipeline now rolls transactions up to payouts.
A second blind test, on the current code
Fixing the first holdout's bugs after seeing it left the current code without a blind number. So I froze the code and models again, wrote three new brands with formats the pipeline had never seen, and ran them once. The result is published untouched.
| Brand | What was new | Result |
|---|---|---|
| Fieldnote Paper Co | both accounts in one export, no running balance, dates like "Oct 7, 2026" | tied out; accepted after review |
| Vale Street Tea | newest-first bank file, plain-English memos, transaction-level payouts, a credit line | tied out; accepted after review on the second upload |
| Harbor & Hive | year-first bank dates; a card export with Debit and Credit columns | blocked, with the payout checks named |
Nothing was labeled wrong across the three brands. The blocked brand is the gate working, and two of the three gaps behind it are real: the year-first bank dates were not read, and the card export was taken for a bank statement.
I knew the card schema had a single amount column when I wrote that brand; real card exports split debits and credits, so it is in the test. Both are left unfixed so this stays a blind number, and both are product asks.
How I'd onboard a brand
- Kickoff call. Capture the legal brand name, the reporting currency and the last digits of the brand's own accounts, which is how transfers are told apart from customer money.
- Ask for the exports. Bank and card for every account, Shopify orders and payouts, Amazon settlements, Faire payouts, the chart of accounts, and any other processor they use.
- Run the first upload and read the status. A block names the missing export or the file that did not read, so the next ask to the brand is specific.
- Work the review queue with the founder, in plain language, one short note per upload.
- Commit, so the next upload's overlap is dropped and the answers carry forward.
What I'd ask Product for
- "Not applicable" must never count as "passed": acceptance needs positive evidence.
- A library of export profiles (date style, sign, grain, delimiter), so a new format is learned once, not once per brand.
- A first-class exception path for processors with no importer, tracked in dollars.
- Memory that matches on what is stable about a line, and goes quiet when its answers conflict.
- Remember a customer after one answer, even if it appeared once.
- Decide a file is a bank statement from how the money behaves, not only from its headers.
Where this fits at Highbeam
| This work | Highbeam or Luma workflow it shows | The role's work it rehearses |
|---|---|---|
| Reading each brand's Shopify, Amazon, Faire, bank and card exports into one standard ledger | Luma pulling in and cleaning financial data so forecasts and reports stay current | Configuring each customer's setup |
| Labeling each line by proof, then memory, then a model held to 99% precision | The Bookkeeping assistant, which categorizes transactions across connected accounts and reconciles them | Evaluating outputs and tuning behavior |
| Tie-outs that block an upload instead of guessing | Luma running code against the underlying data instead of giving a model direct access | Keeping outputs auditable and repeatable |
| The review queue and the note to the founder | Being someone a brand trusts to resolve issues completely | |
| Product asks from two blind holdouts | Spotting patterns across customers and turning them into clear asks for Product |
Finance concepts
This is a cash ledger: payouts are net of fees and refunds, sales tax rides inside receipts, an unpaid wholesale invoice (accounts receivable) is invisible until the cash lands, and vendor payments are seen after they happen, so there is no three-way match. The finance concepts behind these projects.
How I built this
I built this with Claude Code, Anthropic's coding agent. I chose the problem and set the rules the work had to follow: synthetic data only, freeze the code before writing a holdout, publish the blind result as it came out, block rather than guess, and no number on this page that a committed run did not produce.
Claude Code wrote most of the code, tests and first drafts of the docs under that direction and ran the evals. I read the results, decided what to fix and what to leave visible, and ran reviews from an implementation team's point of view that drove the last rounds of changes. The commit history and the CHANGELOG in the repository show the order things happened in.
Limits
- Synthetic data, designed by me. Accuracy on quirks I designed overstates accuracy on real exports; the two blind holdouts show by how much on formats I had not built for.
- The reviewer is simulated from ground truth, so review counts measure how often a person is asked, not how long each answer takes.
- A cash ledger, not an accrual P&L: payouts are not split into gross sales and fees, and sales tax collected stays inside receipts.
- Not supported yet: PayPal, Stripe and Shopify Capital exports, 3PL invoices, more than one currency in a brand, year-first bank dates, and card exports with separate debit and credit columns. The gate blocks rather than guesses when it meets them.