{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/akeda-ru/json-schema/akeda-ru-core-action-request-schema.json",
  "title": "CoreActionRequest",
  "description": "Карточка заявки или ссылка на существующую нативную заявку. Согласование и исполнение независимы. Поле allowed_actions описывает текущие возможности. Стоимость склада скрывается без stock.valuation:read; legacy сохраняет нативные идентификатор, визы и остатки.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/akeda-ru-core-documents-api-openapi.yml#/components/schemas/CoreActionRequest",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "model": {
      "type": "string"
    },
    "id": {
      "$ref": "#/$defs/UUID"
    },
    "number": {
      "type": "string"
    },
    "action_key": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "revision": {
      "type": "integer"
    },
    "state": {
      "type": "string"
    },
    "approval_state": {
      "type": "string"
    },
    "fulfillment_state": {
      "type": "string"
    },
    "input": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "justification": {
      "type": "string"
    },
    "volumes": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/CoreActionVolume"
      }
    },
    "remaining_volumes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CoreActionVolume"
      }
    },
    "executions": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/CoreActionExecution"
      }
    },
    "amount": {
      "type": "string"
    },
    "currency": {
      "type": "string"
    },
    "created_at": {
      "type": "string"
    },
    "updated_at": {
      "type": "string"
    },
    "author_id": {
      "type": "integer",
      "format": "int64"
    },
    "author_name": {
      "type": "string"
    },
    "subject_module": {
      "type": "string"
    },
    "subject_kind": {
      "type": "string"
    },
    "subject_id": {
      "$ref": "#/$defs/UUID"
    },
    "open_url": {
      "type": "string"
    },
    "allowed_actions": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "boolean"
      }
    },
    "provenance": {
      "$ref": "#/$defs/CoreActionProvenance"
    },
    "legacy": {
      "type": "boolean"
    }
  },
  "required": [
    "model",
    "id",
    "number",
    "action_key",
    "title",
    "revision",
    "state",
    "approval_state",
    "fulfillment_state",
    "input",
    "justification",
    "volumes",
    "executions",
    "created_at",
    "updated_at",
    "author_id",
    "author_name",
    "subject_module",
    "subject_kind",
    "subject_id",
    "open_url",
    "allowed_actions"
  ],
  "$defs": {
    "CoreActionExecution": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/UUID"
        },
        "module": {
          "type": "string"
        },
        "kind": {
          "type": "string"
        },
        "number": {
          "type": "string"
        },
        "open_url": {
          "type": "string"
        },
        "executed_at": {
          "type": "string",
          "format": "date-time"
        },
        "actor_id": {
          "type": "integer",
          "format": "int64"
        },
        "quantities": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/CoreActionVolume"
          }
        },
        "command_key": {
          "type": "string"
        },
        "state": {
          "type": "string",
          "enum": [
            "active",
            "cancelled"
          ]
        }
      },
      "required": [
        "id",
        "module",
        "kind",
        "number",
        "open_url",
        "executed_at",
        "actor_id",
        "quantities"
      ],
      "description": "Результат отдельного исполнения с адресом единственного документа владельца. Внешней отправки или банковской подписи эта запись не означает."
    },
    "CoreActionProvenance": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "module": {
          "type": "string"
        },
        "kind": {
          "type": "string"
        },
        "id": {
          "$ref": "#/$defs/UUID"
        },
        "number": {
          "type": "string"
        },
        "version": {
          "type": "integer"
        },
        "date": {
          "type": "string",
          "format": "date"
        },
        "lines": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CoreActionProvenanceLine"
          }
        }
      },
      "required": [
        "module",
        "kind",
        "id",
        "number",
        "version",
        "date"
      ],
      "description": "Проверенная ссылка на образец и его редакцию; соответствие строк не переносит исполнение старого заказа."
    },
    "CoreActionProvenanceLine": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_line_id": {
          "$ref": "#/$defs/UUID"
        },
        "source_line_id": {
          "$ref": "#/$defs/UUID"
        }
      },
      "required": [
        "request_line_id",
        "source_line_id"
      ]
    },
    "CoreActionVolume": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "line_id": {
          "$ref": "#/$defs/UUID"
        },
        "quantity": {
          "type": "string"
        }
      },
      "required": [
        "line_id",
        "quantity"
      ],
      "description": "Количество по устойчивому идентификатору согласованной строки. Десятичная запись передаётся строкой."
    },
    "UUID": {
      "type": "string",
      "format": "uuid"
    }
  }
}