← projects

[Always Projected]

Executive Margin Cockpit

A live P&L down to contribution margin per order line, for leadership only — where net is always projected.

● In productionProduct & FrontendCompany↑ Analytics Dashboards HubReactTanStackPostgresSQLRechartsTypeScript
01 /context

Leadership noticed that a quarter with lower ROAS had made more money than one with higher ROAS. The difference was refunds and costs that the existing “net” didn't project.

02 /my role

Built the backend and the dashboard end to end, from the epic's hypotheses to the reconciliation checks, with finance reviewing every rule.

03 /problem

The old net mixed refunds-so-far with constants nobody could trace, so recent days always looked better than they would end up.

04 /how it works
  1. 01 · Net is always projected

    A “net with refunds so far” column anywhere is a bug. Each order line's net equals its contribution margin.

  2. 02 · A refund curve you can backtest

    From a 90-day chain-ladder to a Bornhuetter–Ferguson-style 180-day curve: daily head, a tail borrowed from older cohorts with a measured ratio, plateaus with a floor — and a backtest per platform as a merge gate.

  3. 03 · No dead constants

    Every factor — unit cost from the finance ERP, call-center take rate, media cost, gateway fees, dispatch cost — lives in a factors table with formula, window and warning.

  4. 04 · Hypothesis-sized stories

    H0…H8, each with acceptance numbers. H0 was a business decision, not code: agreeing what “net” means and on one unit-cost base.

  5. 05 · Checks as a gate

    Eight critical checks (perimeter, copy, reconciliation, refunds, backtest) must pass before a rebuild publishes.

05 /architecture
01
Gold sales + call center
02
Factors table
03
Refund curve (180d)
04
Margin per order line
05
Critical checks
06
Leadership view
06 /interactive demo

what you're seeing

A waterfall from revenue to contribution margin, one bar per cost factor. Below, refund curves by cohort with the 180-day projection, a backtest of projected vs realized refunds, and the factors table that feeds every bar.

try this

  1. 1.Switch to “net with refunds so far” and set the sale age to 7 days — the margin looks much better than it will be.
  2. 2.Drag the age toward 180 days and watch the gap close.
  3. 3.Click a row of the factors table to highlight where it enters the waterfall.

real vs simplified

The rule (net is always projected), the curve's shape and the factors-table idea are real. The cost structure and every number are synthetic.

days since sale: 7

Revenue100kGateway−5kAffiliate−22kProduct−17kShipping−6kMedia−24kDispatch−2kRefunds−9kMargin15k

contribution margin: $15,000

refund development · cumulative % by day since sale

borrowed tailday 0day 180

cyan: observed cohorts · dashed: 180-day projection with a floor

backtest · projected vs realized refund %

cohort A8.6% × 8.9%
cohort B9.4% × 9.1%
cohort C8.1% × 8.4%
cohort D9.8% × 9.6%

factors table — click a row to see where it enters

factorformulawindowwarning
Gateway feesper-order fee + % of collectedper order⚠ fee table missing for one gateway → fallback rate
Affiliate costcommission on list price (not on collected)per order line
Product costunits × unit cost from the finance ERPmonthly cost table
Shippingorders × average label costtrailing 30 days
Mediaad spend by niche (fallback: trailing ratio)daily⚠ spend feed late → fallback + warning
DispatchSMS + e-mail + messaging volume × unit pricedaily
Projected refundscollected × 180-day curve − realized180-day curve, backtested⚠ tail borrowed from older cohorts

[synthetic data · fictional cost structure]

07 /results
All 15 adjustments from finance's 29-page review implemented.
Backtest error on the main platform at 60 days dropped from about 11 pp to about 0.2 pp after fixing how the prior matched refunds.
Access restricted to leadership, with functions revoked from PUBLIC and a role guard.
08 /what broke and what I changed
  • ! brokeThe checks ran inside the transaction that rolled back, so the screen showed 14 hours of green while every rebuild failed.

    → changedChecks report outside the rollback, and freshness is measured on the data.

  • ! brokeTwo copies of the same sale used different FX rates for one platform (up to about 5% apart) and no check saw it — in a ratio, the rate cancels out.

    → changedOne shared conversion module, an 18-month backfill and a check on absolute mass in dollars.

  • ! brokeThe plateau calibrated on cohorts “mature” by age, which in practice meant one old month.

    → changedEligibility by completeness (≥ 0.85) instead of age. An alternative estimator was measured and rejected: it erred 3× more at 30 days.

09 /related