[
  {
    "example": "synthetic, browser-only illustration",
    "metric_id": "margin_pct",
    "version": "1.0",
    "grain": "invoice_line",
    "unit": "%",
    "expression": "100 * SUM(net_cents - cost_cents) / NULLIF(SUM(net_cents), 0)",
    "dimensions": [
      "market"
    ],
    "rule": "Aggregate profit and revenue before division. Do not average row percentages.",
    "owner": "Finance / commercial analytics"
  },
  {
    "example": "synthetic, browser-only illustration",
    "metric_id": "cash_collected",
    "version": "1.0",
    "grain": "receipt",
    "unit": "USD",
    "expression": "SUM(receipts.amount_cents) / 100.0",
    "dimensions": [
      "market"
    ],
    "rule": "Sum authorized receipt rows. Invoice totals describe revenue, not cash collected.",
    "owner": "Treasury / finance"
  },
  {
    "example": "synthetic, browser-only illustration",
    "metric_id": "available_units",
    "version": "1.0",
    "grain": "latest_product_location_snapshot",
    "unit": "units",
    "expression": "SUM(latest quantity per product/store) WHERE assigned_store AND 0 <= age_minutes <= 30",
    "dimensions": [
      "product",
      "assigned_store"
    ],
    "rule": "Select the latest non-future observation per product/store, then apply scope and freshness. Duplicate observations do not increase stock.",
    "owner": "Retail operations"
  }
]
