{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/luckpanda-app/json-schema/luckpanda-app-document-schema.json",
  "title": "Document",
  "description": "The document view (abridged).",
  "x-generated": "2026-10-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/luckpanda-app-openapi.yaml#/components/schemas/Document",
  "type": "object",
  "required": [
    "id",
    "kind",
    "lifecycle",
    "version"
  ],
  "properties": {
    "id": {
      "$ref": "#/$defs/Uuid"
    },
    "kind": {
      "type": "string"
    },
    "lifecycle": {
      "type": "string",
      "enum": [
        "draft",
        "issued",
        "cancelled"
      ]
    },
    "settlement": {
      "type": "string",
      "enum": [
        "unpaid",
        "part_paid",
        "paid",
        "overpaid",
        "not_applicable"
      ]
    },
    "version": {
      "type": "integer"
    },
    "currency": {
      "$ref": "#/$defs/Currency"
    },
    "payable_minor": {
      "type": "integer"
    },
    "paid_minor": {
      "type": "integer"
    },
    "external_ref": {
      "type": [
        "string",
        "null"
      ]
    },
    "doc": {
      "type": "object",
      "description": "The editor document: number, dates, parties, lines, totals",
      "additionalProperties": true
    },
    "operation": {
      "$ref": "#/$defs/CommandResult"
    }
  },
  "additionalProperties": true,
  "$defs": {
    "CommandResult": {
      "type": "object",
      "required": [
        "operation_id",
        "status",
        "correlation_id"
      ],
      "properties": {
        "operation_id": {
          "$ref": "#/$defs/Uuid"
        },
        "status": {
          "type": "string",
          "enum": [
            "succeeded",
            "awaiting_approval",
            "preview"
          ]
        },
        "correlation_id": {
          "$ref": "#/$defs/Uuid"
        },
        "resource": {
          "type": "object",
          "additionalProperties": true
        },
        "approval_request_id": {
          "$ref": "#/$defs/Uuid"
        }
      }
    },
    "Currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "Uuid": {
      "type": "string",
      "format": "uuid"
    }
  }
}