Interactive demo · synthetic dataEvery record on this page is fabricated.
What Counts As A Sale
One order-and-refund ledger, four documented mistakes, and the one written definition that reconciles with the storefront.
The production system behind this demo was engineered by Prada Dipa — LinkedIn profile, opens in a new tab and Luthfi Aditya — LinkedIn profile, opens in a new tab. I managed and directed it — requirements, technical review, QA and rollout.
THE WRITTEN DEFINITION
Four clauses. Each one has a documented alternative that is wrong in a specific way — switch any of them and watch the reconciliation below.
RECONCILIATION AGAINST THE STOREFRONT
The storefront publishes its own net sales figure. So does this computation. Where the two disagree, somebody is about to make a decision on a number that is not true.
| Month | This definition | Storefront | Delta |
|---|---|---|---|
| 2026-01 | $6,810 | $6,810 | 0 |
| 2026-02 | $7,190 | $7,190 | 0 |
| 2026-03 | $5,660 | $5,660 | 0 |
| QUARTER | $19,660 | $19,660 | 0 |
Every month reconciles exactly. That agreement is the deliverable — the dashboard, the report runner and the storefront now answer the same question the same way.
FOUR ANSWERS FROM ONE LEDGER
Each of these is one clause changed and nothing else. All five read the same 24 orders and the same 11 refunds.
THE REFUND LEDGER
The returns desk clears its queue in a batch at 06:10 local time, which is 23:10 the previous day in UTC. Bucket in UTC and every one of these eleven refunds is dated a day early. Bucketed in UTC+07:00, none of them is.
| Refund | Order | Processed | Books into | Amount |
|---|---|---|---|---|
| REF-2001 | ORD-1002 | 2026-02-05 | 2026-02 | $860 |
| REF-2002 | ORD-1003 | 2026-01-21 | 2026-01 | $640 |
| REF-2003 | ORD-1004 | 2026-02-01 | 2026-02 | $430 |
| REF-2004 | ORD-1006 | 2026-02-11 | 2026-02 | $1,780 |
| REF-2005 | ORD-1006 | 2026-02-11 | not counted | $60 |
| REF-2006 | ORD-1005 | 2026-02-17 | 2026-02 | $6,400 |
| REF-2007 | ORD-1010 | 2026-03-02 | 2026-03 | $1,220 |
| REF-2008 | ORD-1013 | 2026-03-06 | 2026-03 | $1,120 |
| REF-2009 | ORD-1014 | 2026-03-19 | 2026-03 | $780 |
| REF-2010 | ORD-1017 | 2026-03-24 | 2026-03 | $1,390 |
| REF-2011 | ORD-1018 | 2026-03-30 | 2026-03 | $560 |
WHAT THE LINE FILTER ADMITS
Every line billed on the quarter’s online orders. A storefront hands you all of them; only the first is a product sale.
- Merchandise$28,440
WHERE A CHANGE GOES
Every source is split the same three ways, with hard boundaries. The payoff is that no one has to decide where a change belongs.
- The API changed
- A business rule changed
- Write semantics changed
WHO CAN SEE THE NUMBER
A figure this contested is also a figure not everyone should have. Two rules, both server-side.
- Every API route re-fetches the user row on each request rather than trusting the session cookie's claims — so a deactivation bites on the next call, not at the next login.
- The external-partner role is scoped to traffic, marketing and reviews, and is refused sales figures outright.
What is real, and what is simulated
Runs in your browser
- The net-sales computation: merchandise lines only, orders on their creation timestamp, refunds on the timestamp they were processed, both bucketed into the storefront's trading timezone with the identical channel filter on each side
- The four documented failure modes, each computed live over the same rows
- The month-by-month reconciliation against the storefront's published figure
Rebuilt from the platform's written net-sales definition, not ported from the SQL. The storefront's three monthly figures are hand-written constants rather than a second call to the same function — a computation checked against itself proves nothing. 26 tests assert that the definition reproduces all three exactly and that each of the four mistakes fails to.
Simulated
- All six external APIs — the storefront, the analytics property, the review platform and three ad platforms — plus Salesforce, the nightly staggered cron and the report runner's background jobs
- PostgreSQL and the view itself. This is the definition rebuilt in TypeScript, because a database view cannot execute in a browser
- The ledger — 24 orders and 11 refunds, all invented, for the fictional label MERIDIAN
- The connector / transform / load decision table and the access model. Both are static architecture, stated rather than simulated, and labelled as such on the page