{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:open-utility-stack:product-notice:1",
  "title": "product-notice@1",
  "description": "A product's terms change or its term ends or renews while its state stays the same: a price change, the end of a fixed term, an automatic renewal, a move. Usually announced ahead: `effective` may lie in the future. The stack's own profile beside product-lifecycle@1, which carries state changes only. Every role that holds products emits it; a sales system decides by it whether a customer may be approached.",
  "type": "object",
  "additionalProperties": false,
  "required": ["profile", "product", "notice", "effective", "sector"],
  "properties": {
    "profile": { "const": "product-notice@1" },
    "product": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id"],
      "properties": {
        "id": { "description": "The emitter's product id, as in product-lifecycle@1.", "type": "string", "pattern": "\\S", "maxLength": 128 },
        "number": { "description": "The number a customer sees on letters.", "type": "string", "pattern": "\\S", "maxLength": 64 },
        "account": { "description": "The customer account the product belongs to (konto's account reference), where the emitter knows it.", "type": "string", "pattern": "\\S", "maxLength": 128 }
      }
    },
    "notice": {
      "description": "`price-change`: new prices apply; `term-ends`: a fixed term ends without renewal; `renewed`: the term renews automatically; `move`: the customer moves and takes or ends the contract.",
      "enum": ["price-change", "term-ends", "renewed", "move"]
    },
    "effective": {
      "description": "Per notice: the day the new prices apply; the last day of the fixed term; the first day of the renewed term; the move-out day.",
      "$ref": "urn:open-utility-stack:common:time:1#/$defs/ZonedDate"
    },
    "pass_through": {
      "description": "Only with `price-change`: the change does nothing but pass these through, so no special right to terminate arises (§ 41 EnWG). Absent: the customer may terminate.",
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": { "enum": ["vat-rate", "aggregate-relief"] }
    },
    "sector": { "enum": ["electricity", "gas", "heat", "water", "telco", "charging", "other"] },
    "extensions": {
      "description": "Sector or emitter detail, one object per namespace: `energy` (BO4E names, such as `marktlokation`), `de.mako` (the emitter's own event data).",
      "type": "object",
      "propertyNames": { "pattern": "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)*$" },
      "additionalProperties": { "type": "object" }
    }
  },
  "allOf": [
    {
      "if": { "properties": { "notice": { "not": { "const": "price-change" } } }, "required": ["notice"] },
      "then": { "not": { "required": ["pass_through"] } }
    }
  ]
}
