{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.haydigitalsolutions.co.uk/private-aviation/schemas/cost-review-v1.schema.json",
  "title": "Fictional aviation cost review demo case v1",
  "description": "Shape for synthetic-only local workflow demonstrations. Never use this schema to infer that real-document processing is available.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "caseId", "fictionalOnly", "title", "period", "documents", "agreement", "invoice"],
  "properties": {
    "schemaVersion": {"const": "1.0"},
    "caseId": {"type": "string", "minLength": 1, "maxLength": 80},
    "fictionalOnly": {"const": true},
    "title": {"type": "string", "minLength": 1, "maxLength": 160},
    "period": {
      "type": "object", "additionalProperties": false, "required": ["start", "end"],
      "properties": {"start": {"type": "string", "format": "date"}, "end": {"type": "string", "format": "date"}}
    },
    "documents": {
      "type": "array", "minItems": 2, "items": {
        "type": "object", "additionalProperties": false, "required": ["id", "kind", "title", "sourceRef"],
        "properties": {
          "id": {"type": "string", "minLength": 1, "maxLength": 80},
          "kind": {"enum": ["management_agreement", "budget", "rate_schedule", "invoice", "supporting_record"]},
          "title": {"type": "string", "minLength": 1, "maxLength": 180},
          "sourceRef": {"type": "string", "minLength": 1, "maxLength": 180}
        }
      }
    },
    "agreement": {
      "type": "object", "additionalProperties": false, "required": ["documentId", "currency", "terms"],
      "properties": {
        "documentId": {"type": "string", "minLength": 1},
        "currency": {"type": "string", "pattern": "^[A-Z]{3}$"},
        "terms": {"type": "array", "minItems": 1, "items": {
          "type": "object", "additionalProperties": false, "required": ["id", "matchKey", "label", "amountMinor", "currency", "sourceRef"],
          "properties": {
            "id": {"type": "string", "minLength": 1},
            "matchKey": {"type": "string", "minLength": 1},
            "label": {"type": "string", "minLength": 1},
            "amountMinor": {"type": "integer", "minimum": 0},
            "currency": {"type": "string", "pattern": "^[A-Z]{3}$"},
            "sourceRef": {"type": "string", "minLength": 1}
          }
        }}
      }
    },
    "invoice": {
      "type": "object", "additionalProperties": false, "required": ["documentId", "currency", "period", "lines"],
      "properties": {
        "documentId": {"type": "string", "minLength": 1},
        "currency": {"type": "string", "pattern": "^[A-Z]{3}$"},
        "period": {"type": "object", "additionalProperties": false, "required": ["start", "end"], "properties": {"start": {"type": "string", "format": "date"}, "end": {"type": "string", "format": "date"}}},
        "lines": {"type": "array", "minItems": 1, "items": {
          "type": "object", "additionalProperties": false, "required": ["id", "description", "matchKey", "amountMinor", "currency", "sourceDocumentId", "sourceRef"],
          "properties": {
            "id": {"type": "string", "minLength": 1},
            "description": {"type": "string", "minLength": 1},
            "matchKey": {"type": "string", "minLength": 1},
            "amountMinor": {"type": "integer", "minimum": 0},
            "currency": {"type": "string", "pattern": "^[A-Z]{3}$"},
            "sourceDocumentId": {"type": "string", "minLength": 1},
            "sourceRef": {"type": "string", "minLength": 1}
          }
        }}
      }
    }
  }
}
