{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/akeda-ru/json-schema/akeda-ru-core-accounting-period-state-schema.json",
  "title": "CoreAccountingPeriodState",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/akeda-ru-core-accounting-api-openapi.yml#/components/schemas/CoreAccountingPeriodState",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "closed_through",
    "businesses",
    "history"
  ],
  "properties": {
    "closed_through": {
      "type": "string",
      "description": "Закрытая дата бизнеса из параметра business; пусто — учёт открыт или бизнес не выбран"
    },
    "businesses": {
      "type": "array",
      "description": "Закрытая дата каждого бизнеса кабинета",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "business_id",
          "business_name",
          "closed_through"
        ],
        "properties": {
          "business_id": {
            "$ref": "#/$defs/UUID"
          },
          "business_name": {
            "type": "string"
          },
          "closed_through": {
            "type": "string",
            "description": "Пусто — учёт бизнеса открыт"
          }
        }
      }
    },
    "history": {
      "type": "array",
      "maxItems": 50,
      "items": {
        "$ref": "#/$defs/CoreAccountingPeriodEvent"
      }
    }
  },
  "$defs": {
    "CoreAccountingPeriodEvent": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "action",
        "closed_through",
        "actor_user_id",
        "actor_name",
        "happened_at",
        "reason",
        "forced",
        "warnings"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/UUID"
        },
        "action": {
          "type": "string",
          "enum": [
            "close",
            "reopen"
          ]
        },
        "closed_through": {
          "type": "string",
          "description": "Empty means fully reopened"
        },
        "actor_user_id": {
          "type": "integer",
          "format": "int64"
        },
        "actor_name": {
          "type": "string"
        },
        "happened_at": {
          "type": "string",
          "format": "date-time"
        },
        "reason": {
          "type": "string"
        },
        "forced": {
          "type": "boolean",
          "description": "История: прежнее закрытие вопреки проверкам. Сейчас сервер сам проверяет период, и новое решение несёт false"
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "История: предупреждения прежнего закрытия; у нового решения список пуст"
        }
      }
    },
    "UUID": {
      "type": "string",
      "format": "uuid"
    }
  }
}