{
  "$id": "https://hupe1980.github.io/telco/schemas/events/de.telco.bill.held.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "de.telco.bill.held",
  "description": "A bill could not be sealed: the refusal code, the failed e-invoice rules, and the one field that fixes it.",
  "type": "object",
  "properties": {
    "billing_account": {
      "description": "The account whose month waits.",
      "type": "string",
      "format": "uuid"
    },
    "code": {
      "description": "The refusal code (`bill.einvoice-invalid`).",
      "type": "string"
    },
    "fix": {
      "description": "The one field that fixes it, when telco knows.",
      "anyOf": [
        {
          "$ref": "#/$defs/Fix"
        },
        {
          "type": "null"
        }
      ]
    },
    "period": {
      "description": "The month, `YYYY-MM`.",
      "type": "string"
    },
    "rules": {
      "description": "The failed EN 16931 / XRechnung rule ids, for an e-invoice.",
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "billing_account",
    "period",
    "code",
    "rules"
  ],
  "$defs": {
    "Fix": {
      "description": "The one field that fixes a held bill, and the operation that sets it.",
      "type": "object",
      "properties": {
        "field": {
          "description": "The field (`invoice_email`, `buyer_reference`, `book_version`).",
          "type": "string"
        },
        "operation": {
          "description": "What sets it.",
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "field",
        "operation"
      ]
    }
  }
}
