Billing normalization and FOCUS
Normalize without losing financial meaning
The bookstore has billing exports from AWS, Azure and Google Cloud, each with different naming, discounts and corrections. A single total built by adding raw numeric fields is not necessarily meaningful. FOCUS (FinOps Open Cost and Usage Specification) provides common definitions to improve analysis across sources. This lesson pins FOCUS 1.2 for reproducibility, not because it is the latest version. The local fixture is a small illustrative projection, NOT a conformant FOCUS dataset. Production mappings must follow the full pinned specification and exact provider export version.
By the end, map common columns, preserve signed corrections, reconcile billed totals by invoice and currency, and reject incomplete data. Prerequisites: FinOps allocation and the previous lesson.
Cost measures and required context
| FOCUS 1.2 field | Meaning for this exercise |
|---|---|
| BilledCost | Invoiced charge basis, including applicable adjustments |
| EffectiveCost | Analytical cost with applicable amortization and discounts |
| ListCost | Cost at published list rates under the defined usage basis |
| ContractedCost | Cost at negotiated rates before applicable further adjustments |
| BillingCurrency | Currency in which billed and effective cost are expressed |
| InvoiceId | Invoice identifier, recommended in 1.2; required by this local reconciler |
| ChargeCategory | Distinguishes usage, purchase, tax, credit and other categories defined by the schema |
Preserve BillingAccountId, billing and charge periods, provider and invoice issuer, service, resource, consumed quantity/unit, pricing unit, and source export revision wherever relevant. Not every field is present on every source or charge. ListCost is not an invoice amount. EffectiveCost supports allocating commitment cost to benefited periods; it need not match current invoice timing. Do not add BilledCost and EffectiveCost together. Do not silently drop tax or credits to make a chart look cleaner. Treat currency conversion as a separate documented analytical process, not alteration of invoice amounts.
A synthetic projection and mapping
Each row in the local example has seven values in a fixed order: local unique line ID, provider label (also stands in for issuer in this fictional fixture), InvoiceId, BillingCurrency, ChargeCategory, BilledCost, EffectiveCost. The line ID is a local ingestion control, not a FOCUS column. Real invoice issuers can differ from provider and invoices can span accounts; use stable issuer/account/period scope and the corresponding invoice identifier. Here all rows represent one fixed billing period. Invoices are independently supplied expected totals, not reconstructed from the rows.
| Local ID | Provider | Invoice | Currency | Category | Billed | Effective |
|---|---|---|---|---|---|---|
| a | AWS | A1 | USD | Usage | 80 | 70 |
| b | AWS | A1 | USD | Purchase | 30 | 0 |
| c | AWS | A1 | USD | Credit | -10 | -10 |
| d | Azure | Z1 | EUR | Usage | 40 | 40 |
| e | Azure | Z1 | EUR | Tax | 8 | 8 |
| f | G1 | USD | Usage | 25 | 25 |
For this pedagogical subset, effective charges can differ due to timing of commitment amortization across periods. The example is not a full amortization ledger or conformance test. AWS A1 billed USD 100, Azure Z1 billed EUR 48, Google G1 billed USD 25. USD billed portfolio total 125, EUR billed total 48; no cross-currency sum. USD effective total 85, EUR effective total 48. Tax is retained on invoice basis and can be separately excluded for a consistently defined pre-tax KPI. If an FX reporting view converts EUR to USD at a fictional 1.10 USD/EUR, the reporting total is USD 177.80; original currency values and invoice totals remain unchanged. Preserve FX rate source, date and rounding policy.
Run a local reconciliation
This example uses Python 3 standard library Decimal for exact decimal inputs. It rejects missing currency, unknown category, duplicate local ID, missing invoice evidence and nonfinite numbers. Only USD and EUR are supported by this toy validator. Values are assumed already normalized, in whole cents and from a single settled period. Signed credits and corrections are accepted; category-specific rules and all FOCUS columns are not validated. In a real ingestion process, quarantine rejected rows and mark the report incomplete rather than dropping them.
from decimal import Decimal, InvalidOperation
def reconcile(rows, invoices): seen = set() billed, effective, by_currency = {}, {}, {} for line, provider, invoice, currency, category, raw_b, raw_e in rows: if not line or line in seen or not provider or not invoice: raise ValueError("missing or duplicate identity") if currency not in {"USD", "EUR"}: raise ValueError("unsupported or missing currency") if category not in {"Usage", "Purchase", "Credit", "Tax", "Adjustment"}: raise ValueError("unsupported category") seen.add(line) try: b, e = Decimal(raw_b), Decimal(raw_e) except (InvalidOperation, TypeError) as exc: raise ValueError("invalid amount") from exc if not b.is_finite() or not e.is_finite(): raise ValueError("nonfinite amount") if b != b.quantize(Decimal("0.01")) or e != e.quantize(Decimal("0.01")): raise ValueError("expected whole cents") key = (provider, invoice, currency) billed[key] = billed.get(key, Decimal(0)) + b effective[currency] = effective.get(currency, Decimal(0)) + e by_currency[currency] = by_currency.get(currency, Decimal(0)) + b if billed.keys() != invoices.keys(): raise ValueError("invoice scope mismatch") differences = {key: billed[key] - Decimal(invoices[key]) for key in billed} return by_currency, effective, differences
rows = [ ("a", "AWS", "A1", "USD", "Usage", "80", "70"), ("b", "AWS", "A1", "USD", "Purchase", "30", "0"), ("c", "AWS", "A1", "USD", "Credit", "-10", "-10"), ("d", "Azure", "Z1", "EUR", "Usage", "40", "40"), ("e", "Azure", "Z1", "EUR", "Tax", "8", "8"), ("f", "Google", "G1", "USD", "Usage", "25", "25"),]invoices = {("AWS", "A1", "USD"): "100", ("Azure", "Z1", "EUR"): "48", ("Google", "G1", "USD"): "25"}billed, effective, delta = reconcile(rows, invoices)for currency in sorted(billed): print(f"{currency}: billed {billed[currency]:.2f}; effective {effective[currency]:.2f}")print("Invoices match:", all(value == 0 for value in delta.values()))Expected output:
EUR: billed 48.00; effective 48.00USD: billed 125.00; effective 85.00Invoices match: TrueRead the return values as separate measures. A nonzero difference is a reconciliation exception, not an instruction to overwrite billed cost. Scope mismatches raise ValueError. This model assumes trusted finite invoice amounts from an independent ledger and valid seven-column rows. It is not a production parser; real invoices may require multi-account grouping, currency minor-unit rules, late adjustments, duplicate export detection, precision controls and rounding reconciliation.
Production mapping and controls
First archive immutable raw exports with source, export time, schema version and scope. Map fields using versioned mappings and preserve raw lineage, including unrecognized charge categories. Google Cloud documents a FOCUS export to BigQuery; availability, schema and billing agreements differ across providers. AWS and Azure exports must be checked against their own supported schemas rather than assuming identical column names. Do not combine a native export and its normalized derivative as if independent charges. Compare aggregates by issuer, account scope, invoice ID and billing currency. For incomplete or unsettled data, label the report provisional and reconcile again after final invoice and corrections arrive.
Apply analytical allocations on EffectiveCost only under a stated policy, and use BilledCost for payable invoice reconciliation. A dashboard should disclose missing currency, missing IDs, excluded categories, export freshness and reconciliation differences. Track data-quality owner and remediation date. Secure raw exports: resource names, tags and billing accounts may contain sensitive business metadata.
Practice and checkpoint
Run the example unchanged, then replace row d currency with an empty string; the local model rejects it. Restore the currency and change the expected AWS invoice to 101; the reported difference is −1 USD, not zero. Add a second copy of row a; duplicate identity is rejected. Explain why USD and EUR cannot be added without an explicit exchange-rate basis. Compare the USD billed and effective totals and explain why they differ. Refer to the pinned FOCUS 1.2 column definitions in the source register; verify the complete standard and provider schema before any implementation.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Billing normalization and FOCUS — knowledge check
Choose the best answer for each offline scenario.
Which FOCUS cost field is used to align with a payable invoice?
Why keep EUR and USD totals separate?
What does a duplicate local line ID indicate in this model?
AWS expected invoice becomes $101; rows total $100. What is the difference?
Is the seven-column projection fully FOCUS compliant?