Test plan: Overview counts invoice-only vendors in the current month (#915) โ
Change under test: services/api/analytics/src/services/billing.service.js getBillingMetrics. The current-month special case (which took estimated_usd only) is deleted: amount_usd is now COALESCE(invoiced_usd, estimated_usd, 0) for every period, keyed on the invoice's own invoice_period_start. An invoice-only vendor (a posted invoice, no metered ingest) now counts in the current month instead of reading $0 until the month closes.
When the correct current-month rule turned out to be byte-identical to the rule every other period already used, the fix was removing the special case; the diff itself argues the design.
Why this is safe for metered vendors โ
currentMonthByVendor[v] is overridden by the fact-MTD figure whenever the vendor has any fact_cost_attributed rows, so the collapsed rule only decides no-fact (invoice-only) vendors. A metered vendor keeps its running month-to-date number and cannot snap to an invoiced figure.
One semantic edge, stated not hidden: the only vendor the collapsed rule can move is one that has an estimated_usd but no fact rows AND a current-month-dated invoice (nearly the empty set: arrears invoices are dated to the prior month, and a vendor with an estimate almost always has fact rows). Such a vendor would show its invoiced figure rather than its estimate; correct under one-rule- everywhere, and rare. Its historical correctness also inherits #914's resolution: invoice_period_start is exactly trustworthy only from June 2026 onward, so this plan asserts CURRENT-month behavior, not historical rows.
Live BigQuery verification (queried 2026-08-18, lantern-app-dev) โ
The current-month CASE, buggy vs fixed, per vendor:
| Vendor | old (estimated_usd only) | new (COALESCE(invoiced, estimated)) |
|---|---|---|
| anthropic | $0.00 | $200.00 |
| gcp | $32.56 | $32.56 |
| github | $6.95 | $6.95 |
| cloudflare | $0.00 | $0.00 |
Only the invoice-only vendor moves; every metered vendor is unchanged. This is the whole fix.
Scenario 1: Overview current month includes the invoice-only vendor (post-deploy) โ
Steps: After deploy, open Billing โบ Overview. Read the "Monthly / current month" total and the per-vendor figures. Expected: Anthropic appears at its posted invoice for the live month (e.g. $200) rather than $0, and the Monthly total includes it. Metered vendors (GCP, GitHub) are unchanged from before. Result: (fill in)
Scenario 2: metered vendors do not snap โ
Steps: Compare each metered vendor's Overview current-month figure before and after deploy. Expected: No change for GCP/GitHub/Cloudflare; they still show fact month-to-date. Result: (fill in)
Verification method โ
Emulators do not carry the BigQuery billing marts, so the SQL is verified against BigQuery directly (table above). The JS pivot is unit-tested (test/billing.service.test.js): an invoice-only vendor surfaces at its reconciled total, and the fact-MTD override wins for a metered vendor. The Overview browser pass is the post-deploy step (App Check blocks the client reads headless pre-deploy).