Avinash RayuduEmail me

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

All 13 brands are synthetic, generated with the quirks real exports have: net payouts, fee rows, overlapping downloads, flipped signs.

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

  1. Read CSV, tab-separated, semicolon or Excel files, and find the real header under summary lines.
  2. Recognize and map each file. A column is accepted only when the header and the values agree.
  3. Standardize signs, day-first dates, decimal commas, line-item exports and repeated rows.
  4. 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.
  5. 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.
  6. Decide: accepted, ties out with open items, or blocked with the failing check named.

The controls

Each check is in onboard/tieout.py. How payouts, sales tax, refunds, the Amazon reserve and the card bill are treated is written up in accounting_treatment.md.
Tie-out checks and the errors they prevent
What has to agreeThe error it stops
Each Shopify payout, Amazon settlement and Faire payout, and a bank deposit, to the cent, within 3 to 5 daysA 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 bankThe same ad spend counted on the card and again as the bank payment
Money leaving one of the brand's accounts and arriving in anotherA transfer from savings counted as income
The running balance and the amountsFlipped signs, dropped rows, a misread date order
Every payout-looking deposit and an export behind itReceipts 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

From the second blind holdout: Vale Street Tea's first upload. Everything else tied out; the queue held this line and two account categories.

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:

One review item
Bank line, Aug 31AmountModel's guess
payment received from old mill market$4,405.34card 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

First pass, before any review. Each holdout was written after the code and model were frozen; the hashes are in evals/FREEZE.json and evals/FREEZE_v2.json.
First pass results by brand group and upload
Brands and uploadLinesAuto-labeled (from the committed run)Precision (from the committed run)Review items per brand (from the committed run)
3 development brands, 1st upload63097.1%100%7.0
Same brands, 2nd upload55799.3%100%1.3
3 holdout brands, blind run61846.9%84.5%47.3
Holdout brands after fixes (not blind)61895.2%99.7%15.7
Same brands after fixes, 2nd upload57897.9%99.8%4.3
3 new brands, second blind run on the current code62178.1%100%7.3
Same brands, 2nd upload55979.8%100%4.0

(from the committed run) copied from the committed run, as published in the project README.

Each square is one error I injected into an upload. Solid: blocked by the gate (49). Hatched: held for review (2). Silently accepted: none.

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

BlindAfter fixesAuto-labeled46.9%95.2%Precision84.5%99.7%Review items per brand47.315.7
Holdout brands, blind run (open red circle) against the run after the four fixes (solid). The fixes came after seeing the holdout, so the second run is not a blind test.

The holdout exposed four real problems:

  1. 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.
  2. Dates written day-month-year with dashes did not parse, so a correct mapping read zero rows.
  3. Unsigned amounts with a separate debit and credit column were taken for a card statement.
  4. 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

The commit order on GitHub shows freeze, then the new brands, then the result. The runner refuses to run twice or on changed 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.

Second blind holdout by brand
BrandWhat was newResult
Fieldnote Paper Coboth accounts in one export, no running balance, dates like "Oct 7, 2026"tied out; accepted after review
Vale Street Teanewest-first bank file, plain-English memos, transaction-level payouts, a credit linetied out; accepted after review on the second upload
Harbor & Hiveyear-first bank dates; a card export with Debit and Credit columnsblocked, 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

The full runbook is onboarding_runbook.md.
  1. 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.
  2. 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.
  3. 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.
  4. Work the review queue with the founder, in plain language, one short note per upload.
  5. Commit, so the next upload's overlap is dropped and the answers carry forward.

What I'd ask Product for

Each ask comes with the evidence and a success metric in product_asks.md.
  1. "Not applicable" must never count as "passed": acceptance needs positive evidence.
  2. A library of export profiles (date style, sign, grain, delimiter), so a new format is learned once, not once per brand.
  3. A first-class exception path for processors with no importer, tracked in dollars.
  4. Memory that matches on what is stable about a line, and goes quiet when its answers conflict.
  5. Remember a customer after one answer, even if it appeared once.
  6. Decide a file is a bank statement from how the money behaves, not only from its headers.

Where this fits at Highbeam

My reading of Highbeam's public pages (Luma, Highbeam Intelligence, Building Luma) and the AI Implementation Associate posting. Not affiliated with Highbeam; no Highbeam data is used.
Where this fits at Highbeam
This workHighbeam or Luma workflow it showsThe role's work it rehearses
Reading each brand's Shopify, Amazon, Faire, bank and card exports into one standard ledgerLuma pulling in and cleaning financial data so forecasts and reports stay currentConfiguring each customer's setup
Labeling each line by proof, then memory, then a model held to 99% precisionThe Bookkeeping assistant, which categorizes transactions across connected accounts and reconciles themEvaluating outputs and tuning behavior
Tie-outs that block an upload instead of guessingLuma running code against the underlying data instead of giving a model direct accessKeeping outputs auditable and repeatable
The review queue and the note to the founderBeing someone a brand trusts to resolve issues completely
Product asks from two blind holdoutsSpotting 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.

Back to all projects