Operations analytics / Billing assuranceSynthetic case study
Service activation × monthly billing

Does the bill match
the service delivered?

A SQL reconciliation that turns disconnected order, activation, and billing extracts into an actionable exception queue—with a clear business meaning for every discrepancy.

Exceptions to investigate
Potential overchargesComparable service states only
Potential underbillingIncludes one missing charge
Billed, state unverifiedSeparate from pricing variances

These are synthetic review amounts, not confirmed losses, refunds, or savings. S014 has conflicting invoice values and is excluded from dollar totals. Findings overlap; exception amounts must not be added together.

01 / Decision & method

Investigate the right source first.

One repeatable batch

Billing operations needs to know which charges deserve review. Provisioning needs to know which orders lack delivery evidence. Data engineering needs to distinguish a replayed extract from a second customer charge.

The model compares September base charges with agreed plans only when CRM and provisioning support a reliable expectation. Conflicting records remain visible and are quarantined from uncertain comparisons.

Controlled scenario. Twenty fictional service orders, all due September 1, plus one orphan billed ID. Flat $50 monthly plans, no mid-month changes, proration, credits, taxes, or usage fees.

Two clocks. Service cutoff: September 30, 23:59:59 UTC. Evidence received through October 3, 00:00:00 UTC is included. Later evidence cannot silently change this run.

02 / Exception workbench

From a flag to a next step.

Full reconciliation ↗

Select a service to inspect the business implication, raw evidence, and SQL predicate. Dollar columns repeat service-level values across overlapping rules.

Reconciliation exceptions with owner, priority, and service-level expected and billed amounts in USD
ServiceDiscrepancyPriorityOwnerExpectedBilled
03 / Inspectable logic

The checks are the product.

Open SQL file ↗

SQL executes in SQLite. No ORM, framework, or hidden transformations. Null expected or billed amounts mean unknown—not zero.

04 / Data contract

Define the grain before the join.

Full dictionary ↗
Orders / CRM

One intended snapshot per service_id. Controls agreed monthly plan and commercial status; cannot prove service delivery.

Activation extract

One intended snapshot per service_id. Controls observed provisioning state at cutoff. This fixture is a snapshot, not an event history.

Invoice lines

One intended record per line_id for the selected period. Multiple distinct line IDs are summed, even when the amounts are identical.

Money & tolerance

USD integer cents. Zero-cent tolerance: a $0.01 difference is flagged. Positive variance means billed exceeds expected; negative means a potential shortfall.

Expected amount

Both sources active → plan. Both inactive, or inactive CRM without activation evidence → zero. Missing active-service evidence, source disagreement, or conflicts → unknown.

Output & limitations

One reconciliation row per service and month; one exception per service, month, and rule. No confirmed adjustments. No production scale, real customer data, or employer assignment is implied.

05 / Acceptance evidence

Planted defects. Explicit expectations.

The fixture inventory and isolated boundary tests verify behavior beyond the example rows. Test results below come from the saved acceptance run.

    python3 run.py
    python3 -m unittest -v test_acceptance.py

    Machine-readable test evidence ↗   Inspect acceptance tests ↗   Design references & decisions ↗