Finding $32,337 the dashboard said wasn't missing
A dbt pipeline that reconciles every storefront order against every processor payment, classifies each gap, and turns 57 automated checks into a one-page report that finance can act on.
Honesty note: this is a portfolio project, not a client engagement. The data is synthetic but modelled on real e-commerce failure modes: webhook replays, partial captures, currency mix-ups, double charges, over-refunds and gaps in the FX feed. Every planted defect is recorded, so detection is measured, not claimed. The code is public and runs in about two minutes.
The situation
A multi-currency online store sells in USD, EUR, GBP, AUD and SGD. Orders come from the storefront, cash comes from the payment processor, and finance reports from the warehouse. The three numbers rarely match. The gap is small enough to ignore any one month, but large enough to matter by year-end audit.
What was broken
| Exception | Records | Impact (USD) |
|---|---|---|
| Captured amount ≠ order total | 52 | $12,209 |
| Completed order, no payment captured | 53 | $11,052 |
| Customer charged twice | 22 | $5,739 |
| Charged in the wrong currency | 27 | $3,041 |
| Payment with no matching order | 3 | $297 |
| Refund larger than payment | 14 | flagged separately |
The pipeline also caught 32 duplicate order rows from webhook replays, 22 future-dated and 22 negative orders, 31 orders converted with a stale FX rate, and 32 missing or invalid customer emails.
Approach
- Warn at the source, error at the mart. Upstream defects are reported without stopping the pipeline. Tables that BI reads are tested strictly, so bad data never reaches a dashboard.
- Exclude, don't fix. Corrupt records are removed from the BI fact table and listed in an issue queue for operations, instead of being quietly "corrected".
- Contract-enforced BI table. A dbt model contract fixes column types and the primary key, so an upstream schema change fails the build instead of breaking dashboards.
- Gap-tolerant currency conversion. An ASOF join uses the latest available FX rate and flags any order that relied on a stale one.
- A business SLA as a test. A warning fires when unreconciled revenue goes above 0.5% of gross. Finance chooses the threshold, not engineering.
- Unit-tested logic. A dbt unit test pins how all 8 exception types are classified and in what order of precedence.
- CI on every change. GitHub Actions runs source freshness, the full build and the report on every pull request.
The deliverable a stakeholder sees
Engineers get test output. Finance gets this one-page report: total exposure, where the money is leaking, the ten largest exceptions, and which checks need attention.
Applying it to your stack
The models are standard SQL. Moving to Snowflake or BigQuery means changing the dbt adapter and rewriting the FX lookup in about ten lines. Sources would typically be Shopify or WooCommerce plus Stripe or Adyen, loaded with Fivetran or Airbyte. A first version on real client data usually fits the Revenue Reconciliation Build.
Stack
dbt-core 1.11DuckDBPythonGitHub Actionsdbt unit testsmodel contractssource freshness