Skip to main content

One fact table for store finance: grain, keys and honest loads

Seamline Editorial · Finance content team · Updated

Three dashboards disagree because they sit on three different grains. The fix is one fact table at one declared grain, one row per financial event, joined across systems by stable ids (Stripe’s balance_transaction, Shopify’s OrderTransaction), loaded idempotently so late refunds restate instead of duplicate, and checked by control totals: the net events inside a payout must sum to the payout amount.

The spreadsheet war

Every store past a certain size fights the same war: the ads dashboard says one revenue number, the Shopify analytics page says another, and the finance spreadsheet says a third. Nobody is lying. Each report aggregates a different table, at a different grain, refreshed at a different time, with different refund cutoffs.

You cannot win this war with a meeting about definitions. You win it with infrastructure: one fact table, one declared grain, one load discipline, and control totals that fail loudly. Everything else becomes a view over that table instead of a separate opinion: dashboards, waterfalls, tax reports.

Declare the grain before anything else

The grain is what one row means. It is the single most consequential decision in the whole model, and it must be written down before the first load. For money truth, the strongest candidate is one row per financial event: every movement of funds, positive or negative, as its own immutable row.

Stripe’s API makes this grain natural: a balance transaction is created for every movement of funds in the account, and each describes its net impact on the balance, with gross, fee and net as first-class fields. Shopify’s OrderTransaction plays the analogous role on the order side: each payment capture, refund or void is a transaction record attached to the order.

Candidate grains and what they cost you
GrainAnswers wellBreaks on
One row per orderSales reporting, AOVPartial refunds, edits, multi-capture: the row mutates
One row per paymentConversion, method mixRefunds and disputes need separate handling
One row per financial eventMoney truth, reconciliationRequires discipline: events are append-only, restatements are new rows
One row per payoutBank matchingToo coarse: hides which orders and fees composed it
Event model per Stripe balance transactions API and Shopify OrderTransaction docs (checked 2026-11-20).

Join on ids the platforms guarantee

A fact table is only as honest as its joins. Never join on amounts, timestamps or customer emails; join on the ids the platforms mint. On Stripe, the charge object carries the id of the balance transaction describing its impact, so order-side charges link to money-side events without guessing. On Shopify, OrderTransaction records hang off the order id, and payout-side references tie events to the bank deposit.

The sample rows below are sample data: invented ids and amounts to show the shape, not real transactions. Note that the refund is a new negative event referencing the same order, never an edit of the original row.

Sample data: hypothetical fact-table rows
event_idtypeorder_refgrossfeenetpayout_ref
evt_001chargeord_9001$90.00−$2.97$87.03po_501
evt_002chargeord_9002$120.00−$3.87$116.13po_501
evt_003refundord_9001−$90.00$0.00−$90.00po_502
evt_004disputeord_9002−$120.00−$15.00−$135.00po_502
Sample data: invented ids and amounts. Fee arithmetic illustrative; dispute fee shown as an assumed example, not a quoted rate.

Loads must be idempotent

Financial events arrive late, out of order, and sometimes twice. A refund lands three weeks after the sale; a dispute reverses a charge months later; a webhook retries after your loader already committed. The load discipline that survives all three:

  • Upsert by event id, never blind-insert. Re-processing the same event must be a no-op.
  • Keep a per-source cursor (created timestamp plus id tiebreak) and re-scan a safety window behind it for late arrivals.
  • Restate, don’t mutate: a refund is a new negative event at the same grain; the original charge row stays untouched.
  • Record load metadata such as source, cursor, row counts and run time, so every number in a report can be traced to the run that produced it.

Running any load twice, in any order, with any overlap, must produce the same table. If it does not, you do not have a fact table. You have a pile of exports.

Control totals: the table checks itself

The strongest check in payment reconciliation is also the simplest: group events by payout reference and sum the net column. The sum must equal the payout amount the processor actually sent, to the cent. Stripe’s balance transactions exist precisely to describe each movement’s net impact, which makes this identity hold by construction when the load is complete.

Add two more checks and the table audits itself daily: event counts per source per day against the API’s own counts, and a gross-to-net identity per event (gross minus fee equals net). Any failure is a load bug or a data gap, and both are findings, not noise. This is the layer Seamline’s published reconciliation detectors operate on: mismatches surfaced per transaction, traced to the event and the payout behind them.

FAQ

Why not just one row per order?

Because orders mutate: partial refunds, edits, additional captures. A mutating row means yesterday’s report changes silently today. Events are immutable, and a refund is a new row, so history stays reproducible and every restatement is visible.

Do I need a data warehouse to start?

No. One table, one declared grain, idempotent loads and control totals work in a plain database, or even a disciplined spreadsheet at small volume. The warehouse is a scaling decision; the grain is a correctness decision. Get the second one right first.

How do disputes fit the model?

As negative events at the same grain, referencing the original charge, plus any dispute fee as its own event line. The payout that carries the reversal becomes the control total that proves the load caught it.

See the checks run on real-shaped data

The demo runs Seamline’s published detectors over sample store data: payout control totals, fee residuals and refund gaps, each traced to the transaction behind it.

Open the demo