{
  "openapi": "3.1.0",
  "info": {
    "title": "Oscar API",
    "version": "0.1.0",
    "description": "The one API of Oscar, for the frontend, integrations, MCP clients and the agent."
  },
  "paths": {
    "/api/companies/{company_id}/": {
      "get": {
        "operationId": "companies_retrieve",
        "description": "Return the company.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "companies"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyDetail"
                }
              }
            },
            "description": ""
          }
        }
      }
    },
    "/api/companies/{company_id}/accounts/": {
      "get": {
        "operationId": "books_accounts_list",
        "description": "The chart of accounts, ordered by code.",
        "summary": "List accounts",
        "parameters": [
          {
            "in": "query",
            "name": "active",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Active (true) or inactive (false) accounts only."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "control_kind",
            "schema": {
              "enum": [
                "payable",
                "receivable",
                "suspense_payable",
                "suspense_receivable",
                "bank",
                "transit",
                "vat"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Accounts with this control kind only.\n\n* `payable` - payable\n* `receivable` - receivable\n* `suspense_payable` - suspense_payable\n* `suspense_receivable` - suspense_receivable\n* `bank` - bank\n* `transit` - transit\n* `vat` - vat"
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "pattern": "^[0-9a-f]+$"
            },
            "description": "The `next_cursor` of the previous page. Omit it for the first page."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1
            },
            "description": "The page size, 1 to 200. Default 50."
          },
          {
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "description": "A code prefix, or text anywhere in the name."
          },
          {
            "in": "query",
            "name": "type",
            "schema": {
              "enum": [
                "asset",
                "liability",
                "equity",
                "income",
                "expense"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Accounts of this type only.\n\n* `asset` - asset\n* `liability` - liability\n* `equity` - equity\n* `income` - income\n* `expense` - expense"
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksAccountPage"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/bank-accounts/": {
      "get": {
        "operationId": "books_bank_accounts_list",
        "description": "The bank feeds with their ledger account, transaction count and ledger balance. Ordered by label.",
        "summary": "List bank accounts",
        "parameters": [
          {
            "in": "query",
            "name": "active",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Active (true) or inactive (false) bank accounts only."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "pattern": "^[0-9a-f]+$"
            },
            "description": "The `next_cursor` of the previous page. Omit it for the first page."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1
            },
            "description": "The page size, 1 to 200. Default 50."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksBankAccountPage"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/bank-transactions/": {
      "get": {
        "operationId": "books_bank_transactions_list",
        "description": "The bank transactions with their settlement status, derived on read. Ordered by booking date.\n\n`has_document` and `file_ids` name the uploaded files that explain a\ntransaction (an upload with `bank_transaction_id`). `to_explain=true`\nlists the payments to explain: money out still open that no file explains.\n",
        "summary": "List bank transactions",
        "parameters": [
          {
            "in": "query",
            "name": "bank_account_id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "Transactions of this bank account only."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "pattern": "^[0-9a-f]+$"
            },
            "description": "The `next_cursor` of the previous page. Omit it for the first page."
          },
          {
            "in": "query",
            "name": "date_from",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The earliest booking date, inclusive."
          },
          {
            "in": "query",
            "name": "date_to",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The latest booking date, inclusive."
          },
          {
            "in": "query",
            "name": "direction",
            "schema": {
              "enum": [
                "in",
                "out"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Money in or money out only.\n\n* `in` - in\n* `out` - out"
          },
          {
            "in": "query",
            "name": "has_document",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Only transactions an uploaded file explains (true) or that none explains (false)."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1
            },
            "description": "The page size, 1 to 200. Default 50."
          },
          {
            "in": "query",
            "name": "ordering",
            "schema": {
              "enum": [
                "booking_date",
                "-booking_date",
                "amount",
                "-amount",
                "counterparty",
                "-counterparty"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "`booking_date` (the default) is oldest first, `-booking_date` newest first. `amount` orders by the amount that moved (the absolute `total_minor`), `counterparty` by the payee (`party_name`, else `counterparty_name`) in any case. A leading `-` is descending. The id breaks ties.\n\n* `booking_date` - booking_date\n* `-booking_date` - -booking_date\n* `amount` - amount\n* `-amount` - -amount\n* `counterparty` - counterparty\n* `-counterparty` - -counterparty"
          },
          {
            "in": "query",
            "name": "party_id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "Transactions of this party only."
          },
          {
            "in": "query",
            "name": "q",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Keywords: the transactions whose payee (`party_name`, `counterparty_name`) or details (`description`, `reference`) contain this text, in any case. Trimmed; empty is no filter."
          },
          {
            "in": "query",
            "name": "statement_id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "Transactions of this statement only."
          },
          {
            "in": "query",
            "name": "status",
            "schema": {
              "enum": [
                "unmatched",
                "part_matched",
                "matched",
                "exempted",
                "classified",
                "transfer_matched",
                "transfer_unmatched",
                "posted",
                "open"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Transactions with this status; `open` is `unmatched` and `part_matched`.\n\n* `unmatched` - unmatched\n* `part_matched` - part_matched\n* `matched` - matched\n* `exempted` - exempted\n* `classified` - classified\n* `transfer_matched` - transfer_matched\n* `transfer_unmatched` - transfer_unmatched\n* `posted` - posted\n* `open` - open"
          },
          {
            "in": "query",
            "name": "to_explain",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "The payments to explain (true): money out still open (`status` `open`) that no uploaded file explains. Excludes `status`, `direction` and `has_document`."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksBankTransactionPage"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/bank-transactions/{bank_transaction_id}/": {
      "get": {
        "operationId": "books_bank_transactions_retrieve",
        "description": "One bank transaction with its source row, entries, allocations, the judgement on it, and its files.",
        "summary": "Get a bank transaction",
        "parameters": [
          {
            "in": "path",
            "name": "bank_transaction_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "The core ULID of the object, 26 characters.",
            "required": true
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksBankTransactionDetail"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/dimensions/": {
      "get": {
        "operationId": "books_dimensions_list",
        "description": "The dimension axes, each with all its values. Ordered by code.",
        "summary": "List dimensions",
        "parameters": [
          {
            "in": "query",
            "name": "active",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Active (true) or inactive (false) dimensions only."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "pattern": "^[0-9a-f]+$"
            },
            "description": "The `next_cursor` of the previous page. Omit it for the first page."
          },
          {
            "in": "query",
            "name": "kind",
            "schema": {
              "enum": [
                "project",
                "grant",
                "client",
                "department",
                "other"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Dimensions of this kind only.\n\n* `project` - project\n* `grant` - grant\n* `client` - client\n* `department` - department\n* `other` - other"
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1
            },
            "description": "The page size, 1 to 200. Default 50."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksDimensionPage"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/documents/": {
      "get": {
        "operationId": "books_documents_list",
        "description": "The document records of the books. Ordered by creation; `ordering=-created_at` is newest first.\n\n`referenced=false` lists the documents nothing in the books refers to\nyet: the uploads still to book. `bank_feed=false` leaves out the\nstatements the bank feed stored (its JSON files), `bank_feed=true` lists\nonly them. `file_id` and `download_url` name the stored file.\n",
        "summary": "List document records",
        "parameters": [
          {
            "in": "query",
            "name": "bank_feed",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Only the statements the bank feed stored (true) or every document but them (false). A statement a person uploaded is never a bank feed statement."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "pattern": "^[0-9a-f]+$"
            },
            "description": "The `next_cursor` of the previous page. Omit it for the first page."
          },
          {
            "in": "query",
            "name": "kind",
            "schema": {
              "enum": [
                "invoice",
                "receipt",
                "credit_note",
                "statement",
                "contract",
                "other"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Documents of this kind only.\n\n* `invoice` - invoice\n* `receipt` - receipt\n* `credit_note` - credit_note\n* `statement` - statement\n* `contract` - contract\n* `other` - other"
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1
            },
            "description": "The page size, 1 to 200. Default 50."
          },
          {
            "in": "query",
            "name": "ordering",
            "schema": {
              "enum": [
                "created_at",
                "-created_at"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "`created_at` (the default) is oldest first, `-created_at` newest first. The id breaks ties.\n\n* `created_at` - created_at\n* `-created_at` - -created_at"
          },
          {
            "in": "query",
            "name": "received_from",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The earliest received date, inclusive. Leaves out documents without one."
          },
          {
            "in": "query",
            "name": "received_to",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The latest received date, inclusive. Leaves out documents without one."
          },
          {
            "in": "query",
            "name": "referenced",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Only documents the books refer to (true: booked) or that nothing refers to yet (false: to book)."
          },
          {
            "in": "query",
            "name": "sha256",
            "schema": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[0-9a-f]{64}$"
            },
            "description": "The SHA-256 of the file, lowercase hex."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksDocumentPage"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/documents/{document_id}/": {
      "get": {
        "operationId": "books_documents_retrieve",
        "description": "One document record with the invoices, statements, events and VAT returns that refer to it.",
        "summary": "Get a document record",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "document_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "The core ULID of the object, 26 characters.",
            "required": true
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksDocumentDetail"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/employees/": {
      "get": {
        "operationId": "companies_employees_list",
        "description": "One page of the employees, newest first, each with the facts of its newest employment.\n\n`source` `tor_external` and `registered_outside` mark what TÖR showed\nthat was not made through OscarAI. The personal code is masked.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "description": "The pagination cursor value.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Number of results to return per page.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "tags": [
          "employees"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedEmployeeList"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`employees_disabled`: the register is off on this server."
          }
        }
      }
    },
    "/api/companies/{company_id}/employees/{employee_id}/": {
      "get": {
        "operationId": "companies_employees_retrieve",
        "description": "One employee, with every employment (the TÖR id and state, the suspensions) and the absences.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "employee_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "employees"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmployeeDetail"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`employees_disabled`: the register is off on this server."
          }
        }
      }
    },
    "/api/companies/{company_id}/employees/submissions/": {
      "get": {
        "operationId": "companies_employees_submissions_list",
        "description": "One page of the submissions, newest first, with their status and the reason of a refusal.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "description": "The pagination cursor value.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Number of results to return per page.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "tags": [
          "employees"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedSubmissionList"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`employees_disabled`: the register is off on this server."
          }
        }
      },
      "post": {
        "operationId": "companies_employees_submissions_create",
        "description": "Submit a new employee, a new employment, a change, a suspension or an end, for the firm to review.\n\nStaff review it; on approval OscarAI registers the event in TÖR. The\npersonal code of a new employee is sealed and never returned. The\nevent is checked as TÖR checks it (400 `tor_invalid_event`).",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "employees"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmissionRequestRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/SubmissionRequestRequest"
              }
            }
          },
          "required": true
        },
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Submission"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`employees_disabled`: the register is off on this server."
          }
        }
      }
    },
    "/api/companies/{company_id}/employees/submissions/{submission_id}/": {
      "get": {
        "operationId": "companies_employees_submissions_retrieve",
        "description": "One submission: its status, the reason of a refusal, TÖR's messages, the TÖR id once registered.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "submission_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "employees"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Submission"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`employees_disabled`: the register is off on this server."
          }
        }
      }
    },
    "/api/companies/{company_id}/files/": {
      "get": {
        "operationId": "companies_files_list",
        "description": "One page of the company's files, newest first. Filter: `kind`.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "description": "The pagination cursor value.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "kind",
            "schema": {
              "type": "string",
              "enum": [
                "contract",
                "credit_note",
                "invoice",
                "other",
                "receipt",
                "statement"
              ]
            },
            "description": "* `invoice` - Invoice\n* `receipt` - Receipt\n* `credit_note` - Credit note\n* `statement` - Bank statement\n* `contract` - Contract\n* `other` - Other"
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Number of results to return per page.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "tags": [
          "companies"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedStoredDocumentList"
                }
              }
            },
            "description": ""
          }
        }
      },
      "post": {
        "operationId": "companies_files_create",
        "description": "Upload a file and record it in the books.\n\nA confident extraction of an invoice, receipt or credit note is recorded and posted without a person,\nwithin what the uploader may do. With `auto_process` (the batch import), the uploader must hold\n`invoices.write`: 403 `permission_denied` for `auto_process` without `invoices.write`, 409 `not_extractable`\nfor `auto_process` on a file that is not a PDF of kind invoice, receipt or credit note.\n413 `file_too_large`, 400 `empty_file`, 415 `unsupported_file_type`.",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "type": "string"
            },
            "description": "The request key of the command (section 11.6). A repeat with the same body replays."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "companies"
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/UploadRequest"
              }
            }
          },
          "required": true
        },
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoredDocument"
                }
              }
            },
            "description": ""
          },
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoredDocument"
                }
              }
            },
            "description": ""
          }
        }
      }
    },
    "/api/companies/{company_id}/files/{file_id}/": {
      "get": {
        "operationId": "companies_files_retrieve",
        "description": "One file.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "file_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "companies"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoredDocument"
                }
              }
            },
            "description": ""
          }
        }
      }
    },
    "/api/companies/{company_id}/files/{file_id}/content/": {
      "get": {
        "operationId": "companies_files_content",
        "description": "The bytes of the file, after the permission check. PDF and images show inline.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "file_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "format",
            "schema": {
              "type": "string",
              "enum": [
                "bin",
                "json"
              ]
            }
          }
        ],
        "tags": [
          "companies"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "description": "The bytes of the file."
          }
        }
      }
    },
    "/api/companies/{company_id}/general-ledger/": {
      "get": {
        "operationId": "books_general_ledger_retrieve",
        "description": "The general ledger: each account with its lines and running balance, in the base currency.",
        "summary": "Get the general ledger",
        "parameters": [
          {
            "in": "query",
            "name": "account_code",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            },
            "description": "One account only."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "date_from",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The first day of the range, inclusive. Before it is the opening balance."
          },
          {
            "in": "query",
            "name": "date_to",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The last day of the range, inclusive."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksGeneralLedger"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Too many expensive reads (`throttled`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/inbox/": {
      "get": {
        "operationId": "companies_inbox_retrieve",
        "description": "The private forwarding address of the company, made on the first read, and what came in.\n\nAlso the Gmail search strings to paste into a Gmail filter, and the newest Gmail forwarding confirmation\nthat oscarai forwarded to the Gmail address that asked for it (never its code or link).",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "inbox"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Inbox"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`inbox_disabled`: the invoice inbox is off on this server."
          }
        }
      }
    },
    "/api/companies/{company_id}/inbox/emails/": {
      "get": {
        "operationId": "companies_inbox_emails_list",
        "description": "One page of the received mails, newest first: the sender, the outcome, the files, the attachments not kept.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "description": "The pagination cursor value.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Number of results to return per page.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "tags": [
          "inbox"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedInboundEmailList"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`inbox_disabled`: the invoice inbox is off on this server."
          }
        }
      }
    },
    "/api/companies/{company_id}/inbox/rotate/": {
      "post": {
        "operationId": "companies_inbox_rotate_create",
        "description": "Revoke the address at once and make a new one. Mail to the old address is ignored from now on.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "inbox"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Inbox"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`inbox_disabled`: the invoice inbox is off on this server."
          }
        }
      }
    },
    "/api/companies/{company_id}/invoices": {
      "post": {
        "operationId": "commands_record_invoice",
        "description": "Runs the core command `record_invoice`. Permission: `invoices.write`.",
        "summary": "Record a draft invoice.",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "type": "string"
            },
            "description": "The request key of the command (section 11.6). A repeat with the same body replays."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string"
            },
            "description": "The sqid of the company.",
            "required": true
          }
        ],
        "tags": [
          "commands"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordInvoicePayloadRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/RecordInvoicePayloadRequest"
              }
            }
          },
          "required": true
        },
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordInvoiceOutcome"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The payload is not valid (`validation_error`, core codes)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`permission_denied`, `insufficient_scope`, or `human_actor_required` for a judgement from an API key or an OAuth client: propose it instead."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The company or a books object does not exist."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "A state conflict of the core, `idempotency_conflict`, `company_not_ready`."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/invoices/": {
      "get": {
        "operationId": "books_invoices_list",
        "description": "The invoices, purchase and sales, with the header facts of their current revision and their settlement.\n\nOldest first by invoice date; `ordering=-invoice_date` is newest first.\n`settlement` filters by `settlement_state`: `open` is unpaid or part\npaid, `overdue` an open invoice due before today in the time zone of the books.\n",
        "summary": "List invoices",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "pattern": "^[0-9a-f]+$"
            },
            "description": "The `next_cursor` of the previous page. Omit it for the first page."
          },
          {
            "in": "query",
            "name": "date_from",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The earliest invoice date, inclusive."
          },
          {
            "in": "query",
            "name": "date_to",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The latest invoice date, inclusive."
          },
          {
            "in": "query",
            "name": "direction",
            "schema": {
              "enum": [
                "purchase",
                "sales"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Purchase or sales invoices only.\n\n* `purchase` - purchase\n* `sales` - sales"
          },
          {
            "in": "query",
            "name": "external_source_prefix",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            },
            "description": "Imported invoices whose external series starts with this text: `stripe` selects every Stripe series."
          },
          {
            "in": "query",
            "name": "kind",
            "schema": {
              "enum": [
                "invoice",
                "receipt",
                "credit_note",
                "prepayment"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Invoices of this kind only.\n\n* `invoice` - invoice\n* `receipt` - receipt\n* `credit_note` - credit_note\n* `prepayment` - prepayment"
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1
            },
            "description": "The page size, 1 to 200. Default 50."
          },
          {
            "in": "query",
            "name": "needs_review",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Only invoices that need review (true) or that do not (false)."
          },
          {
            "in": "query",
            "name": "number",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "description": "The exact invoice number."
          },
          {
            "in": "query",
            "name": "ordering",
            "schema": {
              "enum": [
                "invoice_date",
                "-invoice_date"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "`invoice_date` (the default) is oldest first, `-invoice_date` newest first. The id breaks ties.\n\n* `invoice_date` - invoice_date\n* `-invoice_date` - -invoice_date"
          },
          {
            "in": "query",
            "name": "party_id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "Invoices of this party only."
          },
          {
            "in": "query",
            "name": "settlement",
            "schema": {
              "enum": [
                "unposted",
                "unpaid",
                "part_paid",
                "paid",
                "open",
                "overdue"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Invoices in this settlement state; `open` is `unpaid` and `part_paid`, `overdue` is an open invoice due before today.\n\n* `unposted` - unposted\n* `unpaid` - unpaid\n* `part_paid` - part_paid\n* `paid` - paid\n* `open` - open\n* `overdue` - overdue"
          },
          {
            "in": "query",
            "name": "state",
            "schema": {
              "enum": [
                "recorded",
                "issued",
                "posted",
                "cancelled",
                "void"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Invoices in this state only.\n\n* `recorded` - recorded\n* `issued` - issued\n* `posted` - posted\n* `cancelled` - cancelled\n* `void` - void"
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksInvoicePage"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/invoices/{invoice_id}/": {
      "get": {
        "operationId": "books_invoices_retrieve",
        "description": "One invoice: its current revision with lines and documents, its revisions, its entries and its settlement.",
        "summary": "Get an invoice",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "invoice_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "The core ULID of the object, 26 characters.",
            "required": true
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksInvoiceDetail"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/invoices/{invoice_id}/cancel": {
      "post": {
        "operationId": "commands_cancel_invoice",
        "description": "Runs the core command `cancel_invoice`. Permission: `invoices.write` for a sales invoice, `invoices.post_purchase` for a purchase invoice. The path carries `invoice_id`.",
        "summary": "Cancel an issued sales invoice or a posted purchase invoice: the number is kept and a posted entry is reversed.",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "type": "string"
            },
            "description": "The request key of the command (section 11.6). A repeat with the same body replays."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string"
            },
            "description": "The sqid of the company.",
            "required": true
          },
          {
            "in": "path",
            "name": "invoice_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "A core id (ULID).",
            "required": true
          }
        ],
        "tags": [
          "commands"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelInvoiceBodyRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/CancelInvoiceBodyRequest"
              }
            }
          },
          "required": true
        },
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommandOutcome"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The payload is not valid (`validation_error`, core codes)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`permission_denied`, `insufficient_scope`, or `human_actor_required` for a judgement from an API key or an OAuth client: propose it instead."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The company or a books object does not exist."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "A state conflict of the core, `idempotency_conflict`, `company_not_ready`."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/invoices/{invoice_id}/issue": {
      "post": {
        "operationId": "commands_issue_invoice",
        "description": "Runs the core command `issue_invoice`. Permission: `invoices.issue`. The path carries `invoice_id`.",
        "summary": "Issue a sales invoice.",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "type": "string"
            },
            "description": "The request key of the command (section 11.6). A repeat with the same body replays."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string"
            },
            "description": "The sqid of the company.",
            "required": true
          },
          {
            "in": "path",
            "name": "invoice_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "A core id (ULID).",
            "required": true
          }
        ],
        "tags": [
          "commands"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IssueInvoiceBodyRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/IssueInvoiceBodyRequest"
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssueInvoiceOutcome"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The payload is not valid (`validation_error`, core codes)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`permission_denied`, `insufficient_scope`, or `human_actor_required` for a judgement from an API key or an OAuth client: propose it instead."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The company or a books object does not exist."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "A state conflict of the core, `idempotency_conflict`, `company_not_ready`."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/invoices/{invoice_id}/revise": {
      "post": {
        "operationId": "commands_revise_invoice",
        "description": "Runs the core command `revise_invoice`. Permission: `invoices.write`. The path carries `invoice_id`.",
        "summary": "Revise an invoice.",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "type": "string"
            },
            "description": "The request key of the command (section 11.6). A repeat with the same body replays."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string"
            },
            "description": "The sqid of the company.",
            "required": true
          },
          {
            "in": "path",
            "name": "invoice_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "A core id (ULID).",
            "required": true
          }
        ],
        "tags": [
          "commands"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviseInvoiceBodyRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/ReviseInvoiceBodyRequest"
              }
            }
          },
          "required": true
        },
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommandOutcome"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The payload is not valid (`validation_error`, core codes)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`permission_denied`, `insufficient_scope`, or `human_actor_required` for a judgement from an API key or an OAuth client: propose it instead."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The company or a books object does not exist."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "A state conflict of the core, `idempotency_conflict`, `company_not_ready`."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/open-items/": {
      "get": {
        "operationId": "books_open_items_retrieve",
        "description": "Every open-item line with its residual, as of a date (`as_of`, default today), aged at that date.",
        "summary": "Get the open items",
        "parameters": [
          {
            "in": "query",
            "name": "account_code",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            },
            "description": "Open items on this account only."
          },
          {
            "in": "query",
            "name": "as_of",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The residuals as of this date: the lines of entries dated by it, the allocations effective by it. Default today."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "party_id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "Open items of this party only."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksOpenItems"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Too many expensive reads (`throttled`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/parties": {
      "post": {
        "operationId": "commands_create_party",
        "description": "Runs the core command `create_party`. Permission: `parties.write`.",
        "summary": "Create a party.",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "type": "string"
            },
            "description": "The request key of the command (section 11.6). A repeat with the same body replays."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string"
            },
            "description": "The sqid of the company.",
            "required": true
          }
        ],
        "tags": [
          "commands"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePartyPayloadRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/CreatePartyPayloadRequest"
              }
            }
          },
          "required": true
        },
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatePartyOutcome"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The payload is not valid (`validation_error`, core codes)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`permission_denied`, `insufficient_scope`, or `human_actor_required` for a judgement from an API key or an OAuth client: propose it instead."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The company or a books object does not exist."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "A state conflict of the core, `idempotency_conflict`, `company_not_ready`."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/parties/": {
      "get": {
        "operationId": "books_parties_list",
        "description": "The parties, ordered by their cleaned name. Merged parties are left out unless asked for.\n\n`roles` says what each party is to the company, from its kind, its invoices and its open purchase drafts;\n`role` filters on the roles the books derive (an open draft aside), and `exclude_kind=employee` leaves out\nthe employees, as the list of customers and suppliers does.\n",
        "summary": "List parties",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "pattern": "^[0-9a-f]+$"
            },
            "description": "The `next_cursor` of the previous page. Omit it for the first page."
          },
          {
            "in": "query",
            "name": "exclude_kind",
            "schema": {
              "enum": [
                "supplier",
                "customer",
                "employee",
                "authority",
                "group_company",
                "other"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Leave out the parties of this kind: `employee` on the list of customers and suppliers.\n\n* `supplier` - supplier\n* `customer` - customer\n* `employee` - employee\n* `authority` - authority\n* `group_company` - group_company\n* `other` - other"
          },
          {
            "in": "query",
            "name": "external_key",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "description": "The exact key of the party in another system."
          },
          {
            "in": "query",
            "name": "include_merged",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Include parties merged into another. Default false."
          },
          {
            "in": "query",
            "name": "include_settled_external",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Include the parties with a key in another system (a Stripe customer) that have no open item. Default false: the list leaves them out unless it is filtered by `search`, `reg_code`, `vat_number` or `external_key`."
          },
          {
            "in": "query",
            "name": "kind",
            "schema": {
              "enum": [
                "supplier",
                "customer",
                "employee",
                "authority",
                "group_company",
                "other"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Parties of this kind only.\n\n* `supplier` - supplier\n* `customer` - customer\n* `employee` - employee\n* `authority` - authority\n* `group_company` - group_company\n* `other` - other"
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1
            },
            "description": "The page size, 1 to 200. Default 50."
          },
          {
            "in": "query",
            "name": "reg_code",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "description": "The exact registry code."
          },
          {
            "in": "query",
            "name": "role",
            "schema": {
              "enum": [
                "supplier",
                "customer"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Only the parties that play this role, as `roles` derives it from the kind and the invoices.\n\n* `supplier` - supplier\n* `customer` - customer"
          },
          {
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "description": "Text anywhere in the name, or in the cleaned matching key."
          },
          {
            "in": "query",
            "name": "vat_number",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "description": "The exact VAT number."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksPartyPage"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/parties/{party_id}/": {
      "get": {
        "operationId": "books_parties_retrieve",
        "description": "One party with its defaults and its roles.",
        "summary": "Get a party",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "party_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            "description": "The core ULID of the object, 26 characters.",
            "required": true
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksPartyDetail"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/payroll/pay-runs/": {
      "get": {
        "operationId": "companies_payroll_pay_runs_list",
        "description": "One page of the pay runs, newest month first, with their totals and the net pay not paid yet.\n\nA client sees the posted runs; firm staff also the drafts and the approved ones.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "description": "The pagination cursor value.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Number of results to return per page.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "tags": [
          "payroll"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedPayRunList"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`payroll_disabled`: payroll is off on this server."
          }
        }
      }
    },
    "/api/companies/{company_id}/payroll/pay-runs/{pay_run_id}/": {
      "get": {
        "operationId": "companies_payroll_pay_runs_retrieve",
        "description": "One pay run with every employee: the inputs, the gross and the net, the net not paid yet, the payments.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "pay_run_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "payroll"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayRunDetail"
                }
              }
            },
            "description": ""
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "description": "`payroll_disabled`: payroll is off on this server."
          }
        }
      }
    },
    "/api/companies/{company_id}/periods/": {
      "get": {
        "operationId": "books_periods_list",
        "description": "The accounting periods with their fiscal year, ordered by start date.",
        "summary": "List periods",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "pattern": "^[0-9a-f]+$"
            },
            "description": "The `next_cursor` of the previous page. Omit it for the first page."
          },
          {
            "in": "query",
            "name": "date",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The period that contains this date."
          },
          {
            "in": "query",
            "name": "fiscal_year",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            },
            "description": "The fiscal year label (`2026`)."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1
            },
            "description": "The page size, 1 to 200. Default 50."
          },
          {
            "in": "query",
            "name": "state",
            "schema": {
              "enum": [
                "open",
                "soft_closed",
                "locked"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Periods in this state only.\n\n* `open` - open\n* `soft_closed` - soft_closed\n* `locked` - locked"
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksPeriodPage"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/reports/balance-sheet/": {
      "get": {
        "operationId": "books_reports_balance_sheet_retrieve",
        "description": "The balance sheet at a date (Estonian scheme 1), with an optional comparison date and a simplified grouping.",
        "summary": "Get the balance sheet",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "compare_date",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "A second date to compare with, for example the end of the previous year."
          },
          {
            "in": "query",
            "name": "date",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The day of the balance sheet.",
            "required": true
          },
          {
            "in": "query",
            "name": "omit_empty",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Leave out the lines whose amount and comparison amount are both 0, and a heading with every row under it when none of its lines is kept. The totals, cash, receivables, issued capital, retained earnings and the profit for the year always show. Default false: the full scheme."
          },
          {
            "in": "query",
            "name": "schema",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "description": "A reporting schema key. Default the latest balance sheet schema of the books."
          },
          {
            "in": "query",
            "name": "simplified",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Group the statement into a few rows. Default false: the full statutory scheme."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksBalanceSheet"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Too many expensive reads (`throttled`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/reports/profit-and-loss/": {
      "get": {
        "operationId": "books_reports_profit_and_loss_retrieve",
        "description": "The income statement of a period (Estonian scheme 1, costs by type), with an optional comparison period and a simplified grouping.",
        "summary": "Get the profit and loss statement",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "compare_from",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The first day of a period to compare with. Goes with `compare_to`."
          },
          {
            "in": "query",
            "name": "compare_to",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The last day of a period to compare with. Goes with `compare_from`."
          },
          {
            "in": "query",
            "name": "date_from",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The first day of the period.",
            "required": true
          },
          {
            "in": "query",
            "name": "date_to",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The last day of the period.",
            "required": true
          },
          {
            "in": "query",
            "name": "omit_empty",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Leave out the lines whose amount and comparison amount are both 0, and a heading with every row under it when none of its lines is kept. The totals, cash, receivables, issued capital, retained earnings and the profit for the year always show. Default false: the full scheme."
          },
          {
            "in": "query",
            "name": "schema",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "description": "A reporting schema key. Default the latest income statement schema of the books."
          },
          {
            "in": "query",
            "name": "simplified",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Group the statement into a few rows. Default false: the full statutory scheme."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksIncomeStatement"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Too many expensive reads (`throttled`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/tax-account/balance/": {
      "get": {
        "operationId": "companies_tax_account_balance",
        "description": "The tax account from the stored copy, with its as-of time, the access status and the notices.\n\nNothing is read from EMTA here: the copy is refreshed every night, after\na filing or a tax payment, and by staff. Before the first refresh every\namount is null and `access_status` is `never`.",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "Tax account"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxAccountBalance"
                }
              }
            },
            "description": ""
          }
        }
      }
    },
    "/api/companies/{company_id}/trial-balance/": {
      "get": {
        "operationId": "books_trial_balance_retrieve",
        "description": "The trial balance of a date range or a period, in the base currency.",
        "summary": "Get the trial balance",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "date_from",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The first day of the range, inclusive. Before it is the opening balance."
          },
          {
            "in": "query",
            "name": "date_to",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The last day of the range, inclusive."
          },
          {
            "in": "query",
            "name": "period",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            },
            "description": "A period code (`2026-03`) or id. Excludes `date_from` and `date_to`."
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksTrialBalance"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Too many expensive reads (`throttled`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/vat-codes/": {
      "get": {
        "operationId": "books_vat_codes_list",
        "description": "The VAT codes of the books with their rates, ordered by code. `direction` keeps the codes of one side.",
        "summary": "List VAT codes",
        "parameters": [
          {
            "in": "query",
            "name": "active",
            "schema": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "description": "Active (true) or inactive (false) codes only."
          },
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "pattern": "^[0-9a-f]+$"
            },
            "description": "The `next_cursor` of the previous page. Omit it for the first page."
          },
          {
            "in": "query",
            "name": "direction",
            "schema": {
              "enum": [
                "purchase",
                "sales"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "The codes of this side, and those of both sides.\n\n* `purchase` - purchase\n* `sales` - sales"
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1
            },
            "description": "The page size, 1 to 200. Default 50."
          },
          {
            "in": "query",
            "name": "treatment",
            "schema": {
              "enum": [
                "standard",
                "reduced",
                "zero",
                "exempt",
                "out_of_scope",
                "rc_eu_services",
                "rc_eu_goods",
                "rc_domestic",
                "rc_non_eu",
                "foreign_vat",
                "oss",
                "unknown"
              ],
              "type": "string",
              "minLength": 1
            },
            "description": "Codes with this treatment only.\n\n* `standard` - standard\n* `reduced` - reduced\n* `zero` - zero\n* `exempt` - exempt\n* `out_of_scope` - out_of_scope\n* `rc_eu_services` - rc_eu_services\n* `rc_eu_goods` - rc_eu_goods\n* `rc_domestic` - rc_domestic\n* `rc_non_eu` - rc_non_eu\n* `foreign_vat` - foreign_vat\n* `oss` - oss\n* `unknown` - unknown"
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksVatCodePage"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/companies/{company_id}/vat-preview/": {
      "get": {
        "operationId": "books_vat_preview_retrieve",
        "description": "What preparing the VAT return of a period would write, without writing it.",
        "summary": "Preview a VAT return",
        "parameters": [
          {
            "in": "path",
            "name": "company_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "form",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            },
            "description": "The return form. Default the company's form (`KMD`)."
          },
          {
            "in": "query",
            "name": "period_from",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The first day of the return period.",
            "required": true
          },
          {
            "in": "query",
            "name": "period_to",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The last day of the return period.",
            "required": true
          }
        ],
        "tags": [
          "books"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksVatPreview"
                }
              }
            },
            "description": ""
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "A parameter is not valid (`validation_error`, `invalid_payload`)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Not authenticated."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The caller lacks `books.read` (`permission_denied`) or the `read` scope (`insufficient_scope`)."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The company, or the object, does not exist or is not visible (`not_found`)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books of the company are not provisioned yet (`company_not_ready`)."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "Too many expensive reads (`throttled`)."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProblem"
                }
              }
            },
            "description": "The books are not available (`books_unavailable`)."
          }
        }
      }
    },
    "/api/me/": {
      "get": {
        "operationId": "me_retrieve",
        "description": "Return the caller. A staff session that sees organizations without a membership is audited.\n\nSo is every read by a staff key, which sees every organization.",
        "tags": [
          "me"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            },
            "description": ""
          }
        }
      }
    },
    "/api/organizations/": {
      "get": {
        "operationId": "organizations_list",
        "description": "One page of the visible organizations. A staff list is written to the audit log.",
        "parameters": [
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "description": "The pagination cursor value.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Number of results to return per page.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "tags": [
          "organizations"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedOrganizationList"
                }
              }
            },
            "description": ""
          }
        }
      }
    },
    "/api/organizations/{organization_id}/": {
      "get": {
        "operationId": "organizations_retrieve",
        "description": "Return the organization.",
        "parameters": [
          {
            "in": "path",
            "name": "organization_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "organizations"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            },
            "description": ""
          }
        }
      }
    },
    "/api/organizations/{organization_id}/companies/": {
      "get": {
        "operationId": "organizations_companies_list",
        "description": "One page of the companies, newest first.",
        "parameters": [
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "description": "The pagination cursor value.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Number of results to return per page.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "path",
            "name": "organization_id",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-z]{10,32}$"
            },
            "required": true
          }
        ],
        "tags": [
          "organizations"
        ],
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "oauth2": []
          },
          {
            "cookieAuth": []
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedCompanyList"
                }
              }
            },
            "description": ""
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Absence": {
        "type": "object",
        "description": "A holiday or a sick leave.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "kind": {
            "$ref": "#/components/schemas/AbsenceKindEnum"
          },
          "start_date": {
            "type": "string",
            "format": "date"
          },
          "end_date": {
            "type": "string",
            "format": "date"
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "end_date",
          "id",
          "kind",
          "note",
          "start_date"
        ]
      },
      "AbsenceKindEnum": {
        "enum": [
          "holiday",
          "sick_leave"
        ],
        "type": "string",
        "description": "* `holiday` - Holiday\n* `sick_leave` - Sick leave"
      },
      "BasicExemptionEnum": {
        "enum": [
          "none",
          "full",
          "partial"
        ],
        "type": "string",
        "description": "* `none` - No application\n* `full` - The whole exemption\n* `partial` - A part of the exemption"
      },
      "BlankEnum": {
        "enum": [
          ""
        ]
      },
      "BooksAccount": {
        "type": "object",
        "description": "An account of the chart.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "code": {
            "type": "string",
            "readOnly": true
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "name_en": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "type": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksAccountTypeEnum"
              }
            ],
            "readOnly": true
          },
          "normal_side": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksNormalSideEnum"
              }
            ],
            "readOnly": true
          },
          "parent_code": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "An account kept in one currency only, or null.",
            "maxLength": 3,
            "minLength": 3
          },
          "control_kind": {
            "readOnly": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksControlKindEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "requires_party": {
            "type": "boolean",
            "readOnly": true
          },
          "is_open_item": {
            "type": "boolean",
            "readOnly": true
          },
          "source": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksAccountSourceEnum"
              }
            ],
            "readOnly": true
          },
          "active": {
            "type": "boolean",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "fixed_asset_class": {
            "readOnly": true,
            "description": "The fixed asset class of the account, or null: a purchase line posted here buys a fixed asset.\n\n* `tangible` - tangible\n* `intangible` - intangible\n* `under_construction` - under_construction\n* `investment_property` - investment_property\n* `prepayment` - prepayment",
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksAccountFixedAssetClassEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          }
        },
        "required": [
          "active",
          "code",
          "control_kind",
          "created_at",
          "currency",
          "fixed_asset_class",
          "id",
          "is_open_item",
          "name",
          "name_en",
          "normal_side",
          "parent_code",
          "requires_party",
          "source",
          "type"
        ],
        "x-oscarai-cli": {
          "title": "code",
          "columns": [
            "code",
            "name",
            "type",
            "normal_side",
            "currency",
            "active"
          ],
          "wide": [
            "parent_code",
            "control_kind",
            "is_open_item",
            "source",
            "id"
          ]
        }
      },
      "BooksAccountFixedAssetClassEnum": {
        "enum": [
          "tangible",
          "intangible",
          "under_construction",
          "investment_property",
          "prepayment"
        ],
        "type": "string",
        "description": "* `tangible` - tangible\n* `intangible` - intangible\n* `under_construction` - under_construction\n* `investment_property` - investment_property\n* `prepayment` - prepayment"
      },
      "BooksAccountPage": {
        "type": "object",
        "description": "One page of BooksAccount items, and the cursor of the next page.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksAccount"
            },
            "readOnly": true
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Send it back as `cursor` for the next page; null on the last page."
          }
        },
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "BooksAccountSourceEnum": {
        "enum": [
          "seed",
          "manual"
        ],
        "type": "string",
        "description": "* `seed` - seed\n* `manual` - manual"
      },
      "BooksAccountTypeEnum": {
        "enum": [
          "asset",
          "liability",
          "equity",
          "income",
          "expense"
        ],
        "type": "string",
        "description": "* `asset` - asset\n* `liability` - liability\n* `equity` - equity\n* `income` - income\n* `expense` - expense"
      },
      "BooksAgingBucketEnum": {
        "enum": [
          "no_due_date",
          "not_due",
          "1_30",
          "31_60",
          "61_90",
          "over_90"
        ],
        "type": "string",
        "description": "* `no_due_date` - no_due_date\n* `not_due` - not_due\n* `1_30` - 1_30\n* `31_60` - 31_60\n* `61_90` - 61_90\n* `over_90` - over_90"
      },
      "BooksAllocation": {
        "type": "object",
        "description": "An allocation between an open item and its counter line.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksAllocationKindEnum"
              }
            ],
            "readOnly": true
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksAllocationStateEnum"
              }
            ],
            "readOnly": true
          },
          "item_line_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "counter_line_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "item_currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "item_minor": {
            "type": "integer",
            "readOnly": true
          },
          "counter_currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "counter_minor": {
            "type": "integer",
            "readOnly": true
          },
          "effective_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "entry_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "origin": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "counter_currency",
          "counter_line_id",
          "counter_minor",
          "effective_date",
          "entry_id",
          "id",
          "item_currency",
          "item_line_id",
          "item_minor",
          "kind",
          "origin",
          "state"
        ]
      },
      "BooksAllocationKindEnum": {
        "enum": [
          "payment",
          "refund",
          "credit_offset",
          "prepayment_apply"
        ],
        "type": "string",
        "description": "* `payment` - payment\n* `refund` - refund\n* `credit_offset` - credit_offset\n* `prepayment_apply` - prepayment_apply"
      },
      "BooksAllocationStateEnum": {
        "enum": [
          "active",
          "reversed"
        ],
        "type": "string",
        "description": "* `active` - active\n* `reversed` - reversed"
      },
      "BooksBalanceSheet": {
        "type": "object",
        "description": "The balance sheet at a date, in the base currency.",
        "properties": {
          "schema": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksReportSchema"
              }
            ],
            "readOnly": true
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "compare_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "simplified": {
            "type": "boolean",
            "readOnly": true
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksStatementRow"
            },
            "readOnly": true
          },
          "total_assets_minor": {
            "type": "integer",
            "readOnly": true
          },
          "total_liabilities_and_equity_minor": {
            "type": "integer",
            "readOnly": true
          },
          "balanced": {
            "type": "boolean",
            "readOnly": true,
            "description": "Total assets equal total liabilities and equity."
          },
          "compare_balanced": {
            "type": [
              "boolean",
              "null"
            ],
            "readOnly": true,
            "description": "The same at the comparison date; null without one."
          },
          "unmapped_accounts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "readOnly": true,
            "description": "The codes of accounts with a balance and no line of the scheme."
          },
          "date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          }
        },
        "required": [
          "balanced",
          "compare_balanced",
          "compare_date",
          "currency",
          "date",
          "rows",
          "schema",
          "simplified",
          "total_assets_minor",
          "total_liabilities_and_equity_minor",
          "unmapped_accounts"
        ]
      },
      "BooksBankAccount": {
        "type": "object",
        "description": "A bank feed and its ledger account.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "provider": {
            "type": "string",
            "readOnly": true
          },
          "label": {
            "type": "string",
            "readOnly": true
          },
          "iban": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "bic": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "account_id": {
            "type": "string",
            "readOnly": true,
            "description": "The ledger account of the feed.",
            "maxLength": 26,
            "minLength": 26
          },
          "account_code": {
            "type": "string",
            "readOnly": true
          },
          "is_debtor": {
            "type": "boolean",
            "readOnly": true
          },
          "active": {
            "type": "boolean",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "external_account_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "A payment provider feed: the account at the provider (`acct_…`)."
          },
          "livemode": {
            "type": [
              "boolean",
              "null"
            ],
            "readOnly": true,
            "description": "A payment provider feed: live (true) or test (false) data."
          },
          "fee_accrual_account_code": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "A payment provider feed: the account its fees accrue on."
          },
          "dispute_account_code": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "A payment provider feed: the account of disputed payments."
          },
          "reserve_account_code": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "A payment provider feed: the account of funds the provider holds back."
          },
          "customer_party_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "A payment provider feed: the pooled customer party of its receipts.",
            "maxLength": 26,
            "minLength": 26
          },
          "transaction_count": {
            "type": "integer",
            "readOnly": true
          },
          "last_booking_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "ledger_balance_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "The balance of the ledger account in the feed currency."
          },
          "bank_balance_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The tie-out of verify: the latest closing balance a statement of the account printed (a bank feed sync or a statement file); null when none printed one."
          },
          "bank_balance_on": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true,
            "description": "The day `bank_balance_minor` is valid for (the end of that day)."
          },
          "ledger_balance_on_bank_date_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The balance of the ledger account at the end of `bank_balance_on`; null without a bank balance."
          },
          "bank_difference_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The ledger balance less the bank balance on `bank_balance_on`: not 0 when an opening balance or older lines are missing from the books; null without a bank balance."
          }
        },
        "required": [
          "account_code",
          "account_id",
          "active",
          "bank_balance_minor",
          "bank_balance_on",
          "bank_difference_minor",
          "bic",
          "created_at",
          "currency",
          "customer_party_id",
          "dispute_account_code",
          "external_account_id",
          "fee_accrual_account_code",
          "iban",
          "id",
          "is_debtor",
          "label",
          "last_booking_date",
          "ledger_balance_minor",
          "ledger_balance_on_bank_date_minor",
          "livemode",
          "provider",
          "reserve_account_code",
          "transaction_count"
        ],
        "x-oscarai-cli": {
          "title": "label",
          "columns": [
            "label",
            "iban",
            "currency",
            "ledger_balance_minor",
            "bank_balance_minor",
            "last_booking_date"
          ],
          "wide": [
            "account_code",
            "provider",
            "transaction_count",
            "bank_difference_minor",
            "id"
          ]
        }
      },
      "BooksBankAccountPage": {
        "type": "object",
        "description": "One page of BooksBankAccount items, and the cursor of the next page.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksBankAccount"
            },
            "readOnly": true
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Send it back as `cursor` for the next page; null on the last page."
          }
        },
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "BooksBankDirectionEnum": {
        "enum": [
          "in",
          "out"
        ],
        "type": "string",
        "description": "* `in` - in\n* `out` - out"
      },
      "BooksBankTransaction": {
        "type": "object",
        "description": "A bank transaction with its settlement status, derived on read.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "bank_account_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "bank_account_label": {
            "type": "string",
            "readOnly": true
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "statement_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "booking_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "value_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "direction": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksBankDirectionEnum"
              }
            ],
            "readOnly": true
          },
          "method": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "amount_minor": {
            "type": "integer",
            "readOnly": true
          },
          "fee_minor": {
            "type": "integer",
            "readOnly": true
          },
          "total_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "Signed: money out is negative."
          },
          "orig_currency": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "orig_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The amount in `orig_currency`."
          },
          "bank_rate": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The bank's exchange rate, a decimal string."
          },
          "balance_after_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "counterparty_name": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "counterparty_account": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "counterparty_bic": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "card_last4": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "mcc": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "is_internal": {
            "type": "boolean",
            "readOnly": true
          },
          "party_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "party_name": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "party_source": {
            "readOnly": true,
            "description": "How the party was set.\n\n* `alias` - alias\n* `human` - human",
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksPartySourceEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "suspense_residual_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The unsettled part of the suspense line; 0 once a judgement (an exemption, a money-in class) clears it; null without one."
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksBankTransactionStatusEnum"
              }
            ],
            "readOnly": true
          },
          "has_document": {
            "type": "boolean",
            "readOnly": true,
            "description": "True when an uploaded file explains the transaction."
          },
          "file_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "readOnly": true,
            "description": "The sqids of the uploaded files that explain it (`files/{file_id}/`)."
          }
        },
        "required": [
          "amount_minor",
          "balance_after_minor",
          "bank_account_id",
          "bank_account_label",
          "bank_rate",
          "booking_date",
          "card_last4",
          "counterparty_account",
          "counterparty_bic",
          "counterparty_name",
          "created_at",
          "currency",
          "description",
          "direction",
          "external_id",
          "fee_minor",
          "file_ids",
          "has_document",
          "id",
          "is_internal",
          "mcc",
          "method",
          "orig_currency",
          "orig_minor",
          "party_id",
          "party_name",
          "party_source",
          "reference",
          "statement_id",
          "status",
          "suspense_residual_minor",
          "total_minor",
          "value_date"
        ],
        "x-oscarai-cli": {
          "title": "counterparty_name",
          "columns": [
            "booking_date",
            "counterparty_name",
            "description",
            "total_minor",
            "status",
            "bank_account_label"
          ],
          "wide": [
            "reference",
            "party_name",
            "direction",
            "fee_minor",
            "id"
          ],
          "status": {
            "field": "status",
            "roles": {
              "unmatched": "warn",
              "part_matched": "warn",
              "transfer_unmatched": "warn",
              "matched": "ok",
              "classified": "ok",
              "transfer_matched": "ok",
              "posted": "ok",
              "exempted": "muted"
            }
          }
        }
      },
      "BooksBankTransactionDetail": {
        "type": "object",
        "description": "A bank transaction with its source row, entries, allocations and judgements.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "bank_account_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "bank_account_label": {
            "type": "string",
            "readOnly": true
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "statement_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "booking_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "value_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "direction": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksBankDirectionEnum"
              }
            ],
            "readOnly": true
          },
          "method": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "amount_minor": {
            "type": "integer",
            "readOnly": true
          },
          "fee_minor": {
            "type": "integer",
            "readOnly": true
          },
          "total_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "Signed: money out is negative."
          },
          "orig_currency": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "orig_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The amount in `orig_currency`."
          },
          "bank_rate": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The bank's exchange rate, a decimal string."
          },
          "balance_after_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "counterparty_name": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "counterparty_account": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "counterparty_bic": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "card_last4": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "mcc": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "is_internal": {
            "type": "boolean",
            "readOnly": true
          },
          "party_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "party_name": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "party_source": {
            "readOnly": true,
            "description": "How the party was set.\n\n* `alias` - alias\n* `human` - human",
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksPartySourceEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "suspense_residual_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The unsettled part of the suspense line; 0 once a judgement (an exemption, a money-in class) clears it; null without one."
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksBankTransactionStatusEnum"
              }
            ],
            "readOnly": true
          },
          "has_document": {
            "type": "boolean",
            "readOnly": true,
            "description": "True when an uploaded file explains the transaction."
          },
          "file_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "readOnly": true,
            "description": "The sqids of the uploaded files that explain it (`files/{file_id}/`)."
          },
          "raw": {
            "readOnly": true,
            "description": "The source row as the statement parser stored it."
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksBankTransactionEntry"
            },
            "readOnly": true
          },
          "allocations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksAllocation"
            },
            "readOnly": true
          },
          "exemption": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksExemption"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true
          },
          "money_in": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksMoneyIn"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true
          },
          "transfer_match": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksTransferMatch"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true
          }
        },
        "required": [
          "allocations",
          "amount_minor",
          "balance_after_minor",
          "bank_account_id",
          "bank_account_label",
          "bank_rate",
          "booking_date",
          "card_last4",
          "counterparty_account",
          "counterparty_bic",
          "counterparty_name",
          "created_at",
          "currency",
          "description",
          "direction",
          "entries",
          "exemption",
          "external_id",
          "fee_minor",
          "file_ids",
          "has_document",
          "id",
          "is_internal",
          "mcc",
          "method",
          "money_in",
          "orig_currency",
          "orig_minor",
          "party_id",
          "party_name",
          "party_source",
          "raw",
          "reference",
          "statement_id",
          "status",
          "suspense_residual_minor",
          "total_minor",
          "transfer_match",
          "value_date"
        ],
        "x-oscarai-cli": {
          "title": "counterparty_name",
          "columns": [
            "booking_date",
            "counterparty_name",
            "description",
            "total_minor",
            "status",
            "bank_account_label"
          ],
          "wide": [
            "reference",
            "party_name",
            "direction",
            "fee_minor",
            "id"
          ],
          "status": {
            "field": "status",
            "roles": {
              "unmatched": "warn",
              "part_matched": "warn",
              "transfer_unmatched": "warn",
              "matched": "ok",
              "classified": "ok",
              "transfer_matched": "ok",
              "posted": "ok",
              "exempted": "muted"
            }
          }
        }
      },
      "BooksBankTransactionEntry": {
        "type": "object",
        "description": "A journal entry posted from a bank transaction.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "journal": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksJournalEnum"
              }
            ],
            "readOnly": true
          },
          "entry_no": {
            "type": "integer",
            "readOnly": true
          },
          "economic_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "source_kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksEntrySourceKindEnum"
              }
            ],
            "readOnly": true
          },
          "source_role": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksEntrySourceRoleEnum"
              }
            ],
            "readOnly": true
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksEntryStateEnum"
              }
            ],
            "readOnly": true
          }
        },
        "required": [
          "economic_date",
          "entry_no",
          "id",
          "journal",
          "source_kind",
          "source_role",
          "state"
        ]
      },
      "BooksBankTransactionPage": {
        "type": "object",
        "description": "One page of BooksBankTransaction items, and the cursor of the next page.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksBankTransaction"
            },
            "readOnly": true
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Send it back as `cursor` for the next page; null on the last page."
          }
        },
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "BooksBankTransactionStatusEnum": {
        "enum": [
          "unmatched",
          "part_matched",
          "matched",
          "exempted",
          "classified",
          "transfer_matched",
          "transfer_unmatched",
          "posted"
        ],
        "type": "string",
        "description": "* `unmatched` - unmatched\n* `part_matched` - part_matched\n* `matched` - matched\n* `exempted` - exempted\n* `classified` - classified\n* `transfer_matched` - transfer_matched\n* `transfer_unmatched` - transfer_unmatched\n* `posted` - posted"
      },
      "BooksControlKindEnum": {
        "enum": [
          "payable",
          "receivable",
          "suspense_payable",
          "suspense_receivable",
          "bank",
          "transit",
          "vat"
        ],
        "type": "string",
        "description": "* `payable` - payable\n* `receivable` - receivable\n* `suspense_payable` - suspense_payable\n* `suspense_receivable` - suspense_receivable\n* `bank` - bank\n* `transit` - transit\n* `vat` - vat"
      },
      "BooksDimension": {
        "type": "object",
        "description": "A dimension axis with all its values.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "code": {
            "type": "string",
            "readOnly": true
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksDimensionKindEnum"
              }
            ],
            "readOnly": true
          },
          "basis": {
            "type": "string",
            "readOnly": true,
            "description": "`net` or `cost`."
          },
          "active": {
            "type": "boolean",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksDimensionValue"
            },
            "readOnly": true
          }
        },
        "required": [
          "active",
          "basis",
          "code",
          "created_at",
          "id",
          "kind",
          "name",
          "values"
        ],
        "x-oscarai-cli": {
          "title": "code",
          "columns": [
            "code",
            "name",
            "kind",
            "active"
          ],
          "wide": [
            "basis",
            "id"
          ]
        }
      },
      "BooksDimensionKindEnum": {
        "enum": [
          "project",
          "grant",
          "client",
          "department",
          "other"
        ],
        "type": "string",
        "description": "* `project` - project\n* `grant` - grant\n* `client` - client\n* `department` - department\n* `other` - other"
      },
      "BooksDimensionPage": {
        "type": "object",
        "description": "One page of BooksDimension items, and the cursor of the next page.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksDimension"
            },
            "readOnly": true
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Send it back as `cursor` for the next page; null on the last page."
          }
        },
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "BooksDimensionValue": {
        "type": "object",
        "description": "A value of a dimension.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "code": {
            "type": "string",
            "readOnly": true
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "valid_from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "valid_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "active": {
            "type": "boolean",
            "readOnly": true
          }
        },
        "required": [
          "active",
          "code",
          "id",
          "name",
          "valid_from",
          "valid_to"
        ]
      },
      "BooksDocument": {
        "type": "object",
        "description": "A document record of the books. The file bytes belong to the `documents` app.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "sha256": {
            "type": "string",
            "readOnly": true
          },
          "legacy_sha1": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksDocumentKindEnum"
              }
            ],
            "readOnly": true
          },
          "filename": {
            "type": "string",
            "readOnly": true
          },
          "media_type": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "size_bytes": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "storage_ref": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The sqid of the Django document that holds the file."
          },
          "received_on": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "retention_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "legal_hold": {
            "type": "boolean",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "referenced": {
            "type": "boolean",
            "readOnly": true,
            "description": "True when the books refer to the document (an invoice, a statement, an event, a return)."
          },
          "file_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The sqid of the stored file (`files/{file_id}/`), or null when none is stored."
          },
          "download_url": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The API path that gives a short-lived URL of the bytes (`files/{file_id}/download/`), or null."
          }
        },
        "required": [
          "created_at",
          "download_url",
          "file_id",
          "filename",
          "id",
          "kind",
          "legacy_sha1",
          "legal_hold",
          "media_type",
          "received_on",
          "referenced",
          "retention_until",
          "sha256",
          "size_bytes",
          "storage_ref"
        ],
        "x-oscarai-cli": {
          "title": "filename",
          "columns": [
            "filename",
            "kind",
            "received_on",
            "size_bytes",
            "referenced"
          ],
          "wide": [
            "media_type",
            "retention_until",
            "legal_hold",
            "id"
          ]
        }
      },
      "BooksDocumentDetail": {
        "type": "object",
        "description": "A document with everything in the books that refers to it.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "sha256": {
            "type": "string",
            "readOnly": true
          },
          "legacy_sha1": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksDocumentKindEnum"
              }
            ],
            "readOnly": true
          },
          "filename": {
            "type": "string",
            "readOnly": true
          },
          "media_type": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "size_bytes": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "storage_ref": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The sqid of the Django document that holds the file."
          },
          "received_on": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "retention_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "legal_hold": {
            "type": "boolean",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "referenced": {
            "type": "boolean",
            "readOnly": true,
            "description": "True when the books refer to the document (an invoice, a statement, an event, a return)."
          },
          "file_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The sqid of the stored file (`files/{file_id}/`), or null when none is stored."
          },
          "download_url": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The API path that gives a short-lived URL of the bytes (`files/{file_id}/download/`), or null."
          },
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksDocumentInvoice"
            },
            "readOnly": true
          },
          "bank_statements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksDocumentStatement"
            },
            "readOnly": true
          },
          "accounting_events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksDocumentEvent"
            },
            "readOnly": true
          },
          "vat_returns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksDocumentVatReturn"
            },
            "readOnly": true
          }
        },
        "required": [
          "accounting_events",
          "bank_statements",
          "created_at",
          "download_url",
          "file_id",
          "filename",
          "id",
          "invoices",
          "kind",
          "legacy_sha1",
          "legal_hold",
          "media_type",
          "received_on",
          "referenced",
          "retention_until",
          "sha256",
          "size_bytes",
          "storage_ref",
          "vat_returns"
        ],
        "x-oscarai-cli": {
          "title": "filename",
          "columns": [
            "filename",
            "kind",
            "received_on",
            "size_bytes",
            "referenced"
          ],
          "wide": [
            "media_type",
            "retention_until",
            "legal_hold",
            "id"
          ]
        }
      },
      "BooksDocumentEvent": {
        "type": "object",
        "description": "An accounting event that refers to a document.",
        "properties": {
          "event_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "kind": {
            "type": "string",
            "readOnly": true
          },
          "economic_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          }
        },
        "required": [
          "economic_date",
          "event_id",
          "kind"
        ]
      },
      "BooksDocumentInvoice": {
        "type": "object",
        "description": "An invoice revision that refers to a document.",
        "properties": {
          "invoice_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "revision_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "revision_no": {
            "type": "integer",
            "readOnly": true
          },
          "revision_state": {
            "type": "string",
            "readOnly": true
          },
          "role": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "invoice_id",
          "revision_id",
          "revision_no",
          "revision_state",
          "role"
        ]
      },
      "BooksDocumentKindEnum": {
        "enum": [
          "invoice",
          "receipt",
          "credit_note",
          "statement",
          "contract",
          "other"
        ],
        "type": "string",
        "description": "* `invoice` - invoice\n* `receipt` - receipt\n* `credit_note` - credit_note\n* `statement` - statement\n* `contract` - contract\n* `other` - other"
      },
      "BooksDocumentPage": {
        "type": "object",
        "description": "One page of BooksDocument items, and the cursor of the next page.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksDocument"
            },
            "readOnly": true
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Send it back as `cursor` for the next page; null on the last page."
          }
        },
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "BooksDocumentStatement": {
        "type": "object",
        "description": "A bank statement that refers to a document.",
        "properties": {
          "statement_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "bank_account_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          }
        },
        "required": [
          "bank_account_id",
          "statement_id"
        ]
      },
      "BooksDocumentVatReturn": {
        "type": "object",
        "description": "A VAT return whose response is a document.",
        "properties": {
          "return_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "form": {
            "type": "string",
            "readOnly": true
          },
          "period_from": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "revision_no": {
            "type": "integer",
            "readOnly": true
          }
        },
        "required": [
          "form",
          "period_from",
          "return_id",
          "revision_no"
        ]
      },
      "BooksEntrySourceKindEnum": {
        "enum": [
          "invoice_revision",
          "bank_transaction",
          "allocation",
          "transaction_exemption",
          "transaction_money_in",
          "accounting_event",
          "vat_return"
        ],
        "type": "string",
        "description": "* `invoice_revision` - invoice_revision\n* `bank_transaction` - bank_transaction\n* `allocation` - allocation\n* `transaction_exemption` - transaction_exemption\n* `transaction_money_in` - transaction_money_in\n* `accounting_event` - accounting_event\n* `vat_return` - vat_return"
      },
      "BooksEntrySourceRoleEnum": {
        "enum": [
          "primary",
          "reversal",
          "replacement"
        ],
        "type": "string",
        "description": "* `primary` - primary\n* `reversal` - reversal\n* `replacement` - replacement"
      },
      "BooksEntryStateEnum": {
        "enum": [
          "posted",
          "reversed"
        ],
        "type": "string",
        "description": "* `posted` - posted\n* `reversed` - reversed"
      },
      "BooksExemption": {
        "type": "object",
        "description": "The exemption that judges a bank transaction.",
        "properties": {
          "counter_role": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksExemptionRoleEnum"
              }
            ],
            "readOnly": true
          },
          "reason": {
            "type": "string",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "counter_role",
          "created_at",
          "reason"
        ]
      },
      "BooksExemptionRoleEnum": {
        "enum": [
          "transfer_transit",
          "supplier_prepayment",
          "customer_prepayment",
          "vat_input",
          "vat_input_rc",
          "vat_output",
          "vat_output_rc",
          "vat_payable",
          "vat_non_deductible",
          "tax_receivable",
          "expense_default",
          "software_expense",
          "hosting_expense",
          "prof_fees",
          "travel_expense",
          "bank_charges",
          "income_default",
          "interest_income",
          "interest_expense",
          "fx_gain",
          "fx_loss",
          "rounding",
          "payroll_expense",
          "payroll_liability",
          "payroll_tax",
          "grant_liability",
          "grant_income",
          "loan_payable",
          "loan_receivable",
          "owner_capital",
          "owner_drawings",
          "accrued_expense",
          "prepaid_expense",
          "deferred_income",
          "opening_balance",
          "retained_earnings",
          "current_year_result",
          "discount_received",
          "discount_allowed",
          "writeoff",
          "bad_debt",
          "dividend_payable",
          "distribution_tax_expense",
          "distribution_tax_liability",
          "share_capital",
          "legal_reserve"
        ],
        "type": "string",
        "description": "* `transfer_transit` - transfer_transit\n* `supplier_prepayment` - supplier_prepayment\n* `customer_prepayment` - customer_prepayment\n* `vat_input` - vat_input\n* `vat_input_rc` - vat_input_rc\n* `vat_output` - vat_output\n* `vat_output_rc` - vat_output_rc\n* `vat_payable` - vat_payable\n* `vat_non_deductible` - vat_non_deductible\n* `tax_receivable` - tax_receivable\n* `expense_default` - expense_default\n* `software_expense` - software_expense\n* `hosting_expense` - hosting_expense\n* `prof_fees` - prof_fees\n* `travel_expense` - travel_expense\n* `bank_charges` - bank_charges\n* `income_default` - income_default\n* `interest_income` - interest_income\n* `interest_expense` - interest_expense\n* `fx_gain` - fx_gain\n* `fx_loss` - fx_loss\n* `rounding` - rounding\n* `payroll_expense` - payroll_expense\n* `payroll_liability` - payroll_liability\n* `payroll_tax` - payroll_tax\n* `grant_liability` - grant_liability\n* `grant_income` - grant_income\n* `loan_payable` - loan_payable\n* `loan_receivable` - loan_receivable\n* `owner_capital` - owner_capital\n* `owner_drawings` - owner_drawings\n* `accrued_expense` - accrued_expense\n* `prepaid_expense` - prepaid_expense\n* `deferred_income` - deferred_income\n* `opening_balance` - opening_balance\n* `retained_earnings` - retained_earnings\n* `current_year_result` - current_year_result\n* `discount_received` - discount_received\n* `discount_allowed` - discount_allowed\n* `writeoff` - writeoff\n* `bad_debt` - bad_debt\n* `dividend_payable` - dividend_payable\n* `distribution_tax_expense` - distribution_tax_expense\n* `distribution_tax_liability` - distribution_tax_liability\n* `share_capital` - share_capital\n* `legal_reserve` - legal_reserve"
      },
      "BooksFiscalYearStateEnum": {
        "enum": [
          "open",
          "closing",
          "closed"
        ],
        "type": "string",
        "description": "* `open` - open\n* `closing` - closing\n* `closed` - closed"
      },
      "BooksFixedAssetLinkEnum": {
        "enum": [
          "acquisition",
          "improvement",
          "disposal_cost",
          "disposal"
        ],
        "type": "string",
        "description": "* `acquisition` - acquisition\n* `improvement` - improvement\n* `disposal_cost` - disposal_cost\n* `disposal` - disposal"
      },
      "BooksGeneralLedger": {
        "type": "object",
        "description": "The general ledger, one account after the other.",
        "properties": {
          "base_currency": {
            "type": "string",
            "readOnly": true,
            "description": "The currency of every `*_base_minor` amount: the base currency of the books."
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksLedgerAccount"
            },
            "readOnly": true
          }
        },
        "required": [
          "accounts",
          "base_currency"
        ]
      },
      "BooksIncomeStatement": {
        "type": "object",
        "description": "The income statement of a period, in the base currency.",
        "properties": {
          "schema": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksReportSchema"
              }
            ],
            "readOnly": true
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "compare_from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "compare_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "simplified": {
            "type": "boolean",
            "readOnly": true
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksStatementRow"
            },
            "readOnly": true
          },
          "result_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "The profit (positive) or the loss (negative) of the period."
          },
          "compare_result_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The same for the comparison period; null without one."
          },
          "unmapped_accounts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "readOnly": true,
            "description": "The codes of accounts with a balance and no line of the scheme."
          },
          "from": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "to": {
            "type": "string",
            "format": "date",
            "readOnly": true
          }
        },
        "required": [
          "compare_from",
          "compare_result_minor",
          "compare_to",
          "currency",
          "from",
          "result_minor",
          "rows",
          "schema",
          "simplified",
          "to",
          "unmapped_accounts"
        ]
      },
      "BooksInvoice": {
        "type": "object",
        "description": "An invoice with the header facts of its current revision.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "direction": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceDirectionEnum"
              }
            ],
            "readOnly": true
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceKindEnum"
              }
            ],
            "readOnly": true
          },
          "sign": {
            "type": "integer",
            "readOnly": true,
            "description": "1, or -1 for a credit note."
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceStateEnum"
              }
            ],
            "readOnly": true
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "party_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "party_name": {
            "type": "string",
            "readOnly": true
          },
          "corrects_invoice_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The invoice a credit note corrects.",
            "maxLength": 26,
            "minLength": 26
          },
          "origin": {
            "type": "string",
            "readOnly": true,
            "description": "Who created it (`human`, `import`, ...)."
          },
          "issued_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "cancelled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "cancel_reason": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "reference_number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "An issued sales invoice: its Estonian reference number (viitenumber), the 7-3-1 check digit last. Null for every other invoice."
          },
          "external_source": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "An imported sales invoice: the source of its external number series (`stripe`, `manual`, ...). Null for every other invoice."
          },
          "revision_id": {
            "type": "string",
            "readOnly": true,
            "description": "The current revision.",
            "maxLength": 26,
            "minLength": 26
          },
          "revision_no": {
            "type": "integer",
            "readOnly": true
          },
          "invoice_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "supply_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "net_minor": {
            "type": "integer",
            "readOnly": true
          },
          "tax_minor": {
            "type": "integer",
            "readOnly": true
          },
          "gross_minor": {
            "type": "integer",
            "readOnly": true
          },
          "prepaid_minor": {
            "type": "integer",
            "readOnly": true
          },
          "rounding_minor": {
            "type": "integer",
            "readOnly": true
          },
          "amount_due_minor": {
            "type": "integer",
            "readOnly": true
          },
          "base_gross_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The gross amount in the base currency; null until the rate is known.",
            "x-oscarai-money": {
              "currency": "base_currency"
            }
          },
          "base_currency": {
            "type": "string",
            "readOnly": true,
            "description": "The currency of every `*_base_minor` amount: the base currency of the books."
          },
          "needs_review": {
            "type": "boolean",
            "readOnly": true
          },
          "review_note": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "open_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "What is still open of the posted invoice, in its currency: 0 when settled; null while not posted."
          },
          "settlement_state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceSettlementStateEnum"
              }
            ],
            "readOnly": true,
            "description": "`unposted`, `unpaid`, `part_paid`, `paid`, or `overdue`: unpaid or part paid, due before today."
          },
          "posted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "When the current revision was posted to the ledger; null while not posted."
          }
        },
        "required": [
          "amount_due_minor",
          "base_currency",
          "base_gross_minor",
          "cancel_reason",
          "cancelled_at",
          "corrects_invoice_id",
          "created_at",
          "currency",
          "direction",
          "due_date",
          "external_source",
          "gross_minor",
          "id",
          "invoice_date",
          "issued_at",
          "kind",
          "needs_review",
          "net_minor",
          "number",
          "open_minor",
          "origin",
          "party_id",
          "party_name",
          "posted_at",
          "prepaid_minor",
          "reference_number",
          "review_note",
          "revision_id",
          "revision_no",
          "rounding_minor",
          "settlement_state",
          "sign",
          "state",
          "supply_date",
          "tax_minor"
        ],
        "x-oscarai-cli": {
          "title": "number",
          "columns": [
            "number",
            "party_name",
            "invoice_date",
            "due_date",
            "gross_minor",
            "settlement_state"
          ],
          "wide": [
            "direction",
            "kind",
            "state",
            "open_minor",
            "reference_number",
            "id"
          ],
          "status": {
            "field": "settlement_state",
            "roles": {
              "paid": "ok",
              "part_paid": "warn",
              "unpaid": "warn",
              "overdue": "bad",
              "unposted": "muted"
            }
          },
          "hidden": [
            "sign",
            "origin"
          ]
        }
      },
      "BooksInvoiceAllocation": {
        "type": "object",
        "description": "An active allocation that settles a line of the invoice: a payment, a refund, a credit note.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksAllocationKindEnum"
              }
            ],
            "readOnly": true
          },
          "origin": {
            "type": "string",
            "readOnly": true,
            "description": "Who allocated it: `human`, `matcher`, `import` or `migration`."
          },
          "item_currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "item_minor": {
            "type": "integer",
            "readOnly": true
          },
          "counter_currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "counter_minor": {
            "type": "integer",
            "readOnly": true
          },
          "effective_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "bank_transaction_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The bank transaction of the other side; null when the other side is not a bank line (a credit note).",
            "maxLength": 26,
            "minLength": 26
          }
        },
        "required": [
          "bank_transaction_id",
          "counter_currency",
          "counter_minor",
          "created_at",
          "effective_date",
          "id",
          "item_currency",
          "item_minor",
          "kind",
          "origin"
        ]
      },
      "BooksInvoiceBaseVat": {
        "type": "object",
        "description": "The VAT of a foreign-currency invoice in the base currency (KMS § 37 (7) p 10, EE-VAT-026).",
        "properties": {
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "tax_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "The VAT in minor units of the base currency."
          },
          "rates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksInvoiceBaseVatRate"
            },
            "readOnly": true
          },
          "rate": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceBaseVatExchangeRate"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true
          },
          "frozen": {
            "type": "boolean",
            "readOnly": true,
            "description": "True once the issue froze the rate; a draft shows the rate it would take today."
          }
        },
        "required": [
          "currency",
          "frozen",
          "rate",
          "rates",
          "tax_minor"
        ]
      },
      "BooksInvoiceBaseVatExchangeRate": {
        "type": "object",
        "description": "The exchange rate the VAT in the base currency was converted at.",
        "properties": {
          "value": {
            "type": "string",
            "readOnly": true,
            "description": "A decimal string: how many units of `quote` one unit of `base` buys."
          },
          "base": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "quote": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "rate_source": {
            "type": "string",
            "readOnly": true,
            "description": "`ecb`, `market`, `bank` or `manual`."
          }
        },
        "required": [
          "base",
          "date",
          "quote",
          "rate_source",
          "value"
        ]
      },
      "BooksInvoiceBaseVatRate": {
        "type": "object",
        "description": "The VAT of one rate, in the base currency.",
        "properties": {
          "vat_rate_bps": {
            "type": "integer",
            "readOnly": true,
            "description": "The VAT rate in basis points."
          },
          "tax_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "The VAT of the rate in minor units of the base currency."
          }
        },
        "required": [
          "tax_minor",
          "vat_rate_bps"
        ]
      },
      "BooksInvoiceDetail": {
        "type": "object",
        "description": "An invoice with its current revision, its history, its entries and its settlement.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "direction": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceDirectionEnum"
              }
            ],
            "readOnly": true
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceKindEnum"
              }
            ],
            "readOnly": true
          },
          "sign": {
            "type": "integer",
            "readOnly": true,
            "description": "1, or -1 for a credit note."
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceStateEnum"
              }
            ],
            "readOnly": true
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "party_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "party_name": {
            "type": "string",
            "readOnly": true
          },
          "corrects_invoice_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The invoice a credit note corrects.",
            "maxLength": 26,
            "minLength": 26
          },
          "origin": {
            "type": "string",
            "readOnly": true,
            "description": "Who created it (`human`, `import`, ...)."
          },
          "issued_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "cancelled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "cancel_reason": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "reference_number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "An issued sales invoice: its Estonian reference number (viitenumber), the 7-3-1 check digit last. Null for every other invoice."
          },
          "external_source": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "An imported sales invoice: the source of its external number series (`stripe`, `manual`, ...). Null for every other invoice."
          },
          "revision_id": {
            "type": "string",
            "readOnly": true,
            "description": "The current revision.",
            "maxLength": 26,
            "minLength": 26
          },
          "revision_no": {
            "type": "integer",
            "readOnly": true
          },
          "invoice_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "supply_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "net_minor": {
            "type": "integer",
            "readOnly": true
          },
          "tax_minor": {
            "type": "integer",
            "readOnly": true
          },
          "gross_minor": {
            "type": "integer",
            "readOnly": true
          },
          "prepaid_minor": {
            "type": "integer",
            "readOnly": true
          },
          "rounding_minor": {
            "type": "integer",
            "readOnly": true
          },
          "amount_due_minor": {
            "type": "integer",
            "readOnly": true
          },
          "base_gross_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The gross amount in the base currency; null until the rate is known.",
            "x-oscarai-money": {
              "currency": "base_currency"
            }
          },
          "base_currency": {
            "type": "string",
            "readOnly": true,
            "description": "The currency of every `*_base_minor` amount: the base currency of the books."
          },
          "needs_review": {
            "type": "boolean",
            "readOnly": true
          },
          "review_note": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "open_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "What is still open of the posted invoice, in its currency: 0 when settled; null while not posted."
          },
          "settlement_state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceSettlementStateEnum"
              }
            ],
            "readOnly": true,
            "description": "`unposted`, `unpaid`, `part_paid`, `paid`, or `overdue`: unpaid or part paid, due before today."
          },
          "posted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "When the current revision was posted to the ledger; null while not posted."
          },
          "revision": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceRevision"
              }
            ],
            "readOnly": true
          },
          "revisions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksInvoiceRevisionSummary"
            },
            "readOnly": true
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksInvoiceEntry"
            },
            "readOnly": true
          },
          "settlement": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksSettlement"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true
          },
          "allocations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksInvoiceAllocation"
            },
            "readOnly": true
          }
        },
        "required": [
          "allocations",
          "amount_due_minor",
          "base_currency",
          "base_gross_minor",
          "cancel_reason",
          "cancelled_at",
          "corrects_invoice_id",
          "created_at",
          "currency",
          "direction",
          "due_date",
          "entries",
          "external_source",
          "gross_minor",
          "id",
          "invoice_date",
          "issued_at",
          "kind",
          "needs_review",
          "net_minor",
          "number",
          "open_minor",
          "origin",
          "party_id",
          "party_name",
          "posted_at",
          "prepaid_minor",
          "reference_number",
          "review_note",
          "revision",
          "revision_id",
          "revision_no",
          "revisions",
          "rounding_minor",
          "settlement",
          "settlement_state",
          "sign",
          "state",
          "supply_date",
          "tax_minor"
        ],
        "x-oscarai-cli": {
          "title": "number",
          "columns": [
            "number",
            "party_name",
            "invoice_date",
            "due_date",
            "gross_minor",
            "settlement_state"
          ],
          "wide": [
            "direction",
            "kind",
            "state",
            "open_minor",
            "reference_number",
            "id"
          ],
          "status": {
            "field": "settlement_state",
            "roles": {
              "paid": "ok",
              "part_paid": "warn",
              "unpaid": "warn",
              "overdue": "bad",
              "unposted": "muted"
            }
          },
          "hidden": [
            "sign",
            "origin"
          ]
        }
      },
      "BooksInvoiceDirectionEnum": {
        "enum": [
          "purchase",
          "sales"
        ],
        "type": "string",
        "description": "* `purchase` - purchase\n* `sales` - sales"
      },
      "BooksInvoiceDocument": {
        "type": "object",
        "description": "A document attached to an invoice revision.",
        "properties": {
          "document_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "role": {
            "type": "string",
            "readOnly": true,
            "description": "`original`, ..."
          },
          "filename": {
            "type": "string",
            "readOnly": true
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksDocumentKindEnum"
              }
            ],
            "readOnly": true
          },
          "file_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The sqid of the stored file (`files/{file_id}/`), or null when none is stored."
          },
          "download_url": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The API path that gives a short-lived URL of the bytes (`files/{file_id}/download/`), or null."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Where the stored file came from: `email` (the invoice inbox), `upload` (a person), `api` (an API key or an app connected through OAuth), `import` (a migration or a Stripe import), `generated` (made by Oscar) or `other`. More values may come. Null when no file is stored."
          }
        },
        "required": [
          "document_id",
          "download_url",
          "file_id",
          "filename",
          "kind",
          "role",
          "source"
        ]
      },
      "BooksInvoiceEntry": {
        "type": "object",
        "description": "A journal entry posted from a revision of an invoice.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "revision_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "journal": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksJournalEnum"
              }
            ],
            "readOnly": true
          },
          "entry_no": {
            "type": "integer",
            "readOnly": true
          },
          "economic_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "source_role": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksEntrySourceRoleEnum"
              }
            ],
            "readOnly": true
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksEntryStateEnum"
              }
            ],
            "readOnly": true
          }
        },
        "required": [
          "economic_date",
          "entry_no",
          "id",
          "journal",
          "revision_id",
          "source_role",
          "state"
        ]
      },
      "BooksInvoiceKindEnum": {
        "enum": [
          "invoice",
          "receipt",
          "credit_note",
          "prepayment"
        ],
        "type": "string",
        "description": "* `invoice` - invoice\n* `receipt` - receipt\n* `credit_note` - credit_note\n* `prepayment` - prepayment"
      },
      "BooksInvoiceLine": {
        "type": "object",
        "description": "One line of an invoice revision, in the revision's currency.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "line_no": {
            "type": "integer",
            "readOnly": true
          },
          "kind": {
            "type": "string",
            "readOnly": true,
            "description": "`item`, `vat_summary`, ..."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "quantity": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "A decimal string."
          },
          "unit": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "unit_price_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The unit price in whole minor units; null on an item line whose price has a fraction of a minor unit."
          },
          "unit_price": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The unit price in major units, a decimal string of at most 6 decimals without trailing zeros (`150.334`); null on a line without a price."
          },
          "allowance_minor": {
            "type": "integer",
            "readOnly": true
          },
          "charge_minor": {
            "type": "integer",
            "readOnly": true
          },
          "net_minor": {
            "type": "integer",
            "readOnly": true
          },
          "vat_code": {
            "type": "string",
            "readOnly": true
          },
          "vat_rate_bps": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The VAT rate in basis points (2400 is 24 percent)."
          },
          "tax_minor": {
            "type": "integer",
            "readOnly": true
          },
          "gross_minor": {
            "type": "integer",
            "readOnly": true
          },
          "account_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "account_code": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "expense_role": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "deductible_bps": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "business_use_bps": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "fixed_asset": {
            "type": [
              "boolean",
              "null"
            ],
            "readOnly": true,
            "description": "A purchase line: whether it buys a fixed asset (KMD row 5.2) as the line set it; null takes it from the account."
          },
          "fixed_asset_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The asset of the fixed asset register this line buys, improves or sells.",
            "maxLength": 26,
            "minLength": 26
          },
          "fixed_asset_component_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The component of that asset.",
            "maxLength": 26,
            "minLength": 26
          },
          "fixed_asset_link": {
            "readOnly": true,
            "description": "`acquisition`, `improvement` or `disposal_cost` on a purchase; `disposal` on a sale.\n\n* `acquisition` - acquisition\n* `improvement` - improvement\n* `disposal_cost` - disposal_cost\n* `disposal` - disposal",
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksFixedAssetLinkEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          }
        },
        "required": [
          "account_code",
          "account_id",
          "allowance_minor",
          "business_use_bps",
          "charge_minor",
          "deductible_bps",
          "description",
          "expense_role",
          "fixed_asset",
          "fixed_asset_component_id",
          "fixed_asset_id",
          "fixed_asset_link",
          "gross_minor",
          "id",
          "kind",
          "line_no",
          "net_minor",
          "quantity",
          "tax_minor",
          "unit",
          "unit_price",
          "unit_price_minor",
          "vat_code",
          "vat_rate_bps"
        ],
        "x-oscarai-cli": {
          "columns": [
            "description",
            "vat_code",
            "net_minor",
            "tax_minor",
            "gross_minor",
            "account_code"
          ],
          "wide": [
            "line_no",
            "kind",
            "quantity",
            "unit_price",
            "vat_rate_bps"
          ]
        }
      },
      "BooksInvoicePage": {
        "type": "object",
        "description": "One page of BooksInvoice items, and the cursor of the next page.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksInvoice"
            },
            "readOnly": true
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Send it back as `cursor` for the next page; null on the last page."
          }
        },
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "BooksInvoiceRevision": {
        "type": "object",
        "description": "The current revision of an invoice, with its lines and documents.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "revision_no": {
            "type": "integer",
            "readOnly": true
          },
          "state": {
            "type": "string",
            "readOnly": true,
            "description": "`current` or `superseded`."
          },
          "party_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "party_name_raw": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The party name as the source gave it."
          },
          "invoice_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "supply_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "service_from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "service_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "net_minor": {
            "type": "integer",
            "readOnly": true
          },
          "tax_minor": {
            "type": "integer",
            "readOnly": true
          },
          "gross_minor": {
            "type": "integer",
            "readOnly": true
          },
          "prepaid_minor": {
            "type": "integer",
            "readOnly": true
          },
          "rounding_minor": {
            "type": "integer",
            "readOnly": true
          },
          "amount_due_minor": {
            "type": "integer",
            "readOnly": true
          },
          "base_gross_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "base_currency": {
            "type": "string",
            "readOnly": true,
            "description": "The currency of every `*_base_minor` amount: the base currency of the books."
          },
          "exchange_rate_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "fx_rate_source": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "vat_code_source": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "supplier_vat_number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "buyer_vat_number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "seller_snapshot": {
            "readOnly": true,
            "description": "The seller as the document named it, or null."
          },
          "buyer_snapshot": {
            "readOnly": true,
            "description": "The buyer as the document named it, or null."
          },
          "source_payload": {
            "readOnly": true,
            "description": "The payload the invoice was recorded from, or null."
          },
          "needs_review": {
            "type": "boolean",
            "readOnly": true
          },
          "review_note": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "customer_note": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "An own sales invoice: the note printed for the customer."
          },
          "prices_include_vat": {
            "type": "boolean",
            "readOnly": true,
            "description": "An own sales invoice: the unit prices of the item lines include VAT; the books computed each net."
          },
          "language": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "An own sales invoice: the language of its document, `et` or `en`; null when unset."
          },
          "base_vat": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceBaseVat"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true,
            "description": "The VAT in the base currency of a revision in another currency that charges VAT; null otherwise, and for a draft while no rate is known."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "actor_id": {
            "type": "string",
            "readOnly": true,
            "description": "The core actor who recorded the revision.",
            "maxLength": 26,
            "minLength": 26
          },
          "command_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksInvoiceLine"
            },
            "readOnly": true
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksInvoiceDocument"
            },
            "readOnly": true
          }
        },
        "required": [
          "actor_id",
          "amount_due_minor",
          "base_currency",
          "base_gross_minor",
          "base_vat",
          "buyer_snapshot",
          "buyer_vat_number",
          "command_id",
          "created_at",
          "currency",
          "customer_note",
          "documents",
          "due_date",
          "exchange_rate_id",
          "fx_rate_source",
          "gross_minor",
          "id",
          "invoice_date",
          "language",
          "lines",
          "needs_review",
          "net_minor",
          "party_id",
          "party_name_raw",
          "prepaid_minor",
          "prices_include_vat",
          "reason",
          "review_note",
          "revision_no",
          "rounding_minor",
          "seller_snapshot",
          "service_from",
          "service_to",
          "source_payload",
          "state",
          "supplier_vat_number",
          "supply_date",
          "tax_minor",
          "vat_code_source"
        ],
        "x-oscarai-cli": {
          "hidden": [
            "state",
            "source_payload"
          ]
        }
      },
      "BooksInvoiceRevisionSummary": {
        "type": "object",
        "description": "One revision in the history of an invoice.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "revision_no": {
            "type": "integer",
            "readOnly": true
          },
          "state": {
            "type": "string",
            "readOnly": true
          },
          "invoice_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "gross_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "In the currency of that revision."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "created_at",
          "gross_minor",
          "id",
          "invoice_date",
          "reason",
          "revision_no",
          "state"
        ]
      },
      "BooksInvoiceSettlementStateEnum": {
        "type": "string",
        "enum": [
          "unposted",
          "unpaid",
          "part_paid",
          "paid",
          "overdue"
        ]
      },
      "BooksInvoiceStateEnum": {
        "enum": [
          "recorded",
          "issued",
          "posted",
          "cancelled",
          "void"
        ],
        "type": "string",
        "description": "* `recorded` - recorded\n* `issued` - issued\n* `posted` - posted\n* `cancelled` - cancelled\n* `void` - void"
      },
      "BooksJournalEnum": {
        "enum": [
          "purchases",
          "sales",
          "bank",
          "general",
          "opening",
          "closing"
        ],
        "type": "string",
        "description": "* `purchases` - purchases\n* `sales` - sales\n* `bank` - bank\n* `general` - general\n* `opening` - opening\n* `closing` - closing"
      },
      "BooksLedgerAccount": {
        "type": "object",
        "description": "One account of the general ledger with its lines.",
        "properties": {
          "account_code": {
            "type": "string",
            "readOnly": true
          },
          "account_name": {
            "type": "string",
            "readOnly": true
          },
          "account_name_en": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The English name of the account; null when it has none."
          },
          "opening_base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "closing_base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksLedgerLine"
            },
            "readOnly": true
          }
        },
        "required": [
          "account_code",
          "account_name",
          "account_name_en",
          "closing_base_minor",
          "lines",
          "opening_base_minor"
        ]
      },
      "BooksLedgerLine": {
        "type": "object",
        "description": "One line of the general ledger, with the running balance of its account.",
        "properties": {
          "account_code": {
            "type": "string",
            "readOnly": true
          },
          "economic_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "journal": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksJournalEnum"
              }
            ],
            "readOnly": true
          },
          "entry_no": {
            "type": "integer",
            "readOnly": true
          },
          "entry_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "entry_state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksEntryStateEnum"
              }
            ],
            "readOnly": true
          },
          "line_no": {
            "type": "integer",
            "readOnly": true
          },
          "party_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "amount_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "Signed, debit positive, in `currency`."
          },
          "base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "running_base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "memo": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          }
        },
        "required": [
          "account_code",
          "amount_minor",
          "base_minor",
          "currency",
          "economic_date",
          "entry_id",
          "entry_no",
          "entry_state",
          "journal",
          "line_no",
          "memo",
          "party_id",
          "running_base_minor"
        ],
        "x-oscarai-cli": {
          "title": "entry_no",
          "columns": [
            "economic_date",
            "journal",
            "entry_no",
            "memo",
            "amount_minor",
            "running_base_minor"
          ],
          "wide": [
            "base_minor",
            "entry_state",
            "line_no",
            "account_code",
            "entry_id"
          ]
        }
      },
      "BooksMoneyIn": {
        "type": "object",
        "description": "The money-in classification that judges a bank transaction.",
        "properties": {
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksMoneyInKindEnum"
              }
            ],
            "readOnly": true
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "refund_invoice_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "refund_bank_transaction_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "created_at",
          "kind",
          "reason",
          "refund_bank_transaction_id",
          "refund_invoice_id"
        ]
      },
      "BooksMoneyInKindEnum": {
        "enum": [
          "refund",
          "intercompany",
          "owner",
          "tax_refund",
          "grant",
          "loan"
        ],
        "type": "string",
        "description": "* `refund` - refund\n* `intercompany` - intercompany\n* `owner` - owner\n* `tax_refund` - tax_refund\n* `grant` - grant\n* `loan` - loan"
      },
      "BooksNormalSideEnum": {
        "enum": [
          "debit",
          "credit"
        ],
        "type": "string",
        "description": "* `debit` - debit\n* `credit` - credit"
      },
      "BooksOpenItem": {
        "type": "object",
        "description": "An open-item line with its residual.",
        "properties": {
          "line_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "entry_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "account_code": {
            "type": "string",
            "readOnly": true
          },
          "control_kind": {
            "readOnly": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksControlKindEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "party_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "party_name": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "side": {
            "type": "string",
            "readOnly": true,
            "description": "`debit` or `credit`: the side the item sits on."
          },
          "amount_minor": {
            "type": "integer",
            "readOnly": true
          },
          "base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "residual_minor": {
            "type": "integer",
            "readOnly": true
          },
          "residual_base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "economic_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "invoice_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "invoice_number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The number of the invoice of the item; null without one, or for a draft."
          },
          "bank_transaction_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "days_overdue": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "Days past the due date at the as-of date; 0 or less when not due; null without one."
          },
          "aging_bucket": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksAgingBucketEnum"
              }
            ],
            "readOnly": true,
            "description": "The aging at the as-of date.\n\n* `no_due_date` - no_due_date\n* `not_due` - not_due\n* `1_30` - 1_30\n* `31_60` - 31_60\n* `61_90` - 61_90\n* `over_90` - over_90"
          }
        },
        "required": [
          "account_code",
          "aging_bucket",
          "amount_minor",
          "bank_transaction_id",
          "base_minor",
          "control_kind",
          "currency",
          "days_overdue",
          "due_date",
          "economic_date",
          "entry_id",
          "invoice_id",
          "invoice_number",
          "line_id",
          "party_id",
          "party_name",
          "residual_base_minor",
          "residual_minor",
          "side"
        ],
        "x-oscarai-cli": {
          "title": "party_name",
          "columns": [
            "invoice_number",
            "party_name",
            "due_date",
            "residual_minor",
            "days_overdue",
            "aging_bucket"
          ],
          "wide": [
            "account_code",
            "control_kind",
            "economic_date",
            "invoice_id",
            "bank_transaction_id",
            "residual_base_minor"
          ],
          "status": {
            "field": "aging_bucket",
            "roles": {
              "no_due_date": "muted",
              "not_due": "ok",
              "1_30": "warn",
              "31_60": "bad",
              "61_90": "bad",
              "over_90": "bad"
            }
          }
        }
      },
      "BooksOpenItems": {
        "type": "object",
        "description": "Every open-item line with a residual, as of a date, with its aging.",
        "properties": {
          "as_of": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "base_currency": {
            "type": "string",
            "readOnly": true,
            "description": "The currency of every `*_base_minor` amount: the base currency of the books."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksOpenItem"
            },
            "readOnly": true
          }
        },
        "required": [
          "as_of",
          "base_currency",
          "items"
        ]
      },
      "BooksParty": {
        "type": "object",
        "description": "A party: a supplier, a customer, an authority, ...",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "name_key": {
            "type": "string",
            "readOnly": true,
            "description": "The cleaned matching key of the name."
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksPartyKindEnum"
              }
            ],
            "readOnly": true
          },
          "country": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "vat_area": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "`domestic`, `eu`, `non_eu`."
          },
          "vat_area_source": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "vat_number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "vies_checked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "reg_code": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "expects_document": {
            "type": "boolean",
            "readOnly": true
          },
          "is_confirmed": {
            "type": "boolean",
            "readOnly": true
          },
          "merged_into_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The party this one was merged into.",
            "maxLength": 26,
            "minLength": 26
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "external_key": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The key of the party in another system, for example a Stripe customer."
          },
          "private_persons": {
            "type": "boolean",
            "readOnly": true,
            "description": "The party pools private persons (card buyers): the KMD INF annex leaves it out."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The postal address printed on an invoice, one or more lines."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The email address of the party."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The phone number of the party."
          },
          "roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PartyRoleEnum"
            },
            "readOnly": true,
            "description": "What the party is to the company: `supplier` when its kind is supplier or it has a purchase invoice (or an open purchase draft), `customer` when its kind is customer or it has a sales invoice. Void invoices do not count. Empty for a party of another kind with no invoice."
          }
        },
        "required": [
          "address",
          "country",
          "created_at",
          "email",
          "expects_document",
          "external_key",
          "id",
          "is_confirmed",
          "kind",
          "merged_into_id",
          "name",
          "name_key",
          "notes",
          "phone",
          "private_persons",
          "reg_code",
          "roles",
          "vat_area",
          "vat_area_source",
          "vat_number",
          "vies_checked_at"
        ],
        "x-oscarai-cli": {
          "title": "name",
          "columns": [
            "name",
            "kind",
            "reg_code",
            "vat_number",
            "country"
          ],
          "wide": [
            "vat_area",
            "is_confirmed",
            "id"
          ]
        }
      },
      "BooksPartyDefaults": {
        "type": "object",
        "description": "The defaults the books apply to a party's invoices.",
        "properties": {
          "expense_role": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "vat_code": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "payment_days": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "language": {
            "readOnly": true,
            "description": "The language a new own sales invoice to the party starts in; null: no preference.\n\n* `et` - et\n* `en` - en",
            "oneOf": [
              {
                "$ref": "#/components/schemas/KycLanguageEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          }
        },
        "required": [
          "currency",
          "expense_role",
          "language",
          "payment_days",
          "vat_code"
        ]
      },
      "BooksPartyDetail": {
        "type": "object",
        "description": "A party with its defaults.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "name_key": {
            "type": "string",
            "readOnly": true,
            "description": "The cleaned matching key of the name."
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksPartyKindEnum"
              }
            ],
            "readOnly": true
          },
          "country": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "vat_area": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "`domestic`, `eu`, `non_eu`."
          },
          "vat_area_source": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "vat_number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "vies_checked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "reg_code": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "expects_document": {
            "type": "boolean",
            "readOnly": true
          },
          "is_confirmed": {
            "type": "boolean",
            "readOnly": true
          },
          "merged_into_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The party this one was merged into.",
            "maxLength": 26,
            "minLength": 26
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "external_key": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The key of the party in another system, for example a Stripe customer."
          },
          "private_persons": {
            "type": "boolean",
            "readOnly": true,
            "description": "The party pools private persons (card buyers): the KMD INF annex leaves it out."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The postal address printed on an invoice, one or more lines."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The email address of the party."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The phone number of the party."
          },
          "roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PartyRoleEnum"
            },
            "readOnly": true,
            "description": "What the party is to the company: `supplier` when its kind is supplier or it has a purchase invoice (or an open purchase draft), `customer` when its kind is customer or it has a sales invoice. Void invoices do not count. Empty for a party of another kind with no invoice."
          },
          "defaults": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksPartyDefaults"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true
          }
        },
        "required": [
          "address",
          "country",
          "created_at",
          "defaults",
          "email",
          "expects_document",
          "external_key",
          "id",
          "is_confirmed",
          "kind",
          "merged_into_id",
          "name",
          "name_key",
          "notes",
          "phone",
          "private_persons",
          "reg_code",
          "roles",
          "vat_area",
          "vat_area_source",
          "vat_number",
          "vies_checked_at"
        ],
        "x-oscarai-cli": {
          "title": "name",
          "columns": [
            "name",
            "kind",
            "reg_code",
            "vat_number",
            "country"
          ],
          "wide": [
            "vat_area",
            "is_confirmed",
            "id"
          ]
        }
      },
      "BooksPartyKindEnum": {
        "enum": [
          "supplier",
          "customer",
          "employee",
          "authority",
          "group_company",
          "other"
        ],
        "type": "string",
        "description": "* `supplier` - supplier\n* `customer` - customer\n* `employee` - employee\n* `authority` - authority\n* `group_company` - group_company\n* `other` - other"
      },
      "BooksPartyPage": {
        "type": "object",
        "description": "One page of BooksParty items, and the cursor of the next page.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksParty"
            },
            "readOnly": true
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Send it back as `cursor` for the next page; null on the last page."
          }
        },
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "BooksPartySourceEnum": {
        "enum": [
          "alias",
          "human"
        ],
        "type": "string",
        "description": "* `alias` - alias\n* `human` - human"
      },
      "BooksPeriod": {
        "type": "object",
        "description": "An accounting period and its fiscal year.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "fiscal_year_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "fiscal_year_label": {
            "type": "string",
            "readOnly": true
          },
          "fiscal_year_state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksFiscalYearStateEnum"
              }
            ],
            "readOnly": true
          },
          "code": {
            "type": "string",
            "readOnly": true,
            "description": "`2026-03`."
          },
          "start_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksPeriodStateEnum"
              }
            ],
            "readOnly": true
          },
          "locked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "locked_reason": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "close_generation": {
            "type": "integer",
            "readOnly": true
          }
        },
        "required": [
          "close_generation",
          "code",
          "end_date",
          "fiscal_year_id",
          "fiscal_year_label",
          "fiscal_year_state",
          "id",
          "locked_at",
          "locked_reason",
          "start_date",
          "state"
        ],
        "x-oscarai-cli": {
          "title": "code",
          "columns": [
            "code",
            "start_date",
            "end_date",
            "state",
            "fiscal_year_label"
          ],
          "wide": [
            "locked_at",
            "locked_reason",
            "id"
          ],
          "status": {
            "field": "state",
            "roles": {
              "open": "ok",
              "soft_closed": "warn",
              "locked": "muted"
            }
          }
        }
      },
      "BooksPeriodPage": {
        "type": "object",
        "description": "One page of BooksPeriod items, and the cursor of the next page.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksPeriod"
            },
            "readOnly": true
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Send it back as `cursor` for the next page; null on the last page."
          }
        },
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "BooksPeriodStateEnum": {
        "enum": [
          "open",
          "soft_closed",
          "locked"
        ],
        "type": "string",
        "description": "* `open` - open\n* `soft_closed` - soft_closed\n* `locked` - locked"
      },
      "BooksProblem": {
        "type": "object",
        "description": "An RFC 9457 problem details body (section 11.5).",
        "properties": {
          "type": {
            "type": "string",
            "readOnly": true,
            "description": "A URL that names the problem."
          },
          "title": {
            "type": "string",
            "readOnly": true
          },
          "status": {
            "type": "integer",
            "readOnly": true
          },
          "code": {
            "type": "string",
            "readOnly": true,
            "description": "Stable and machine-readable; for a core error, the core's code."
          },
          "detail": {
            "type": "string",
            "readOnly": true
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksProblemFieldError"
            },
            "readOnly": true
          }
        },
        "required": [
          "code",
          "detail",
          "errors",
          "status",
          "title",
          "type"
        ]
      },
      "BooksProblemFieldError": {
        "type": "object",
        "description": "One invalid field of a validation problem.",
        "properties": {
          "field": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The field or query parameter, dotted for nested fields; null for the whole request."
          },
          "code": {
            "type": "string",
            "readOnly": true
          },
          "detail": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "code",
          "detail",
          "field"
        ]
      },
      "BooksReportSchema": {
        "type": "object",
        "description": "The reporting schema a statement was drawn from.",
        "properties": {
          "key": {
            "type": "string",
            "readOnly": true
          },
          "version": {
            "type": "string",
            "readOnly": true
          },
          "jurisdiction": {
            "type": "string",
            "readOnly": true,
            "description": "The country of the scheme (`EE`)."
          },
          "kind": {
            "type": "string",
            "readOnly": true,
            "description": "`balance_sheet` or `income_statement`."
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "content_hash": {
            "type": "string",
            "readOnly": true,
            "description": "The SHA-256 of the schema, so a report names the exact scheme it used."
          }
        },
        "required": [
          "content_hash",
          "jurisdiction",
          "key",
          "kind",
          "name",
          "version"
        ]
      },
      "BooksReviewStateEnum": {
        "enum": [
          "provisional",
          "verified"
        ],
        "type": "string",
        "description": "* `provisional` - provisional\n* `verified` - verified"
      },
      "BooksSettlement": {
        "type": "object",
        "description": "How far an invoice is settled. `paid` and `credited` are derived, never stored.",
        "properties": {
          "invoice_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "direction": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceDirectionEnum"
              }
            ],
            "readOnly": true
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceKindEnum"
              }
            ],
            "readOnly": true
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksInvoiceStateEnum"
              }
            ],
            "readOnly": true
          },
          "party_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "maxLength": 3,
            "minLength": 3
          },
          "gross_minor": {
            "type": "integer",
            "readOnly": true
          },
          "residual_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "What is still open; null while the invoice is not posted."
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksSettlementStatusEnum"
              }
            ],
            "readOnly": true
          },
          "paid": {
            "type": "boolean",
            "readOnly": true,
            "description": "Settled to zero through cash-backed allocations."
          },
          "credited": {
            "type": "boolean",
            "readOnly": true,
            "description": "A posted credit note names this invoice."
          },
          "written_off": {
            "type": "boolean",
            "readOnly": true,
            "description": "Settled with a write-off: settled but not paid."
          }
        },
        "required": [
          "credited",
          "currency",
          "direction",
          "gross_minor",
          "invoice_id",
          "kind",
          "number",
          "paid",
          "party_id",
          "residual_minor",
          "state",
          "status",
          "written_off"
        ]
      },
      "BooksSettlementStatusEnum": {
        "enum": [
          "open",
          "part_settled",
          "settled",
          "unposted"
        ],
        "type": "string",
        "description": "* `open` - open\n* `part_settled` - part_settled\n* `settled` - settled\n* `unposted` - unposted"
      },
      "BooksStatementAccount": {
        "type": "object",
        "description": "One account inside a line of a statement.",
        "properties": {
          "account_code": {
            "type": "string",
            "readOnly": true
          },
          "account_name": {
            "type": "string",
            "readOnly": true
          },
          "account_name_en": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "amount_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "In minor units of the base currency."
          },
          "compare_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The amount at the comparison date or period; null without one."
          }
        },
        "required": [
          "account_code",
          "account_name",
          "account_name_en",
          "amount_minor",
          "compare_minor"
        ]
      },
      "BooksStatementRow": {
        "type": "object",
        "description": "One row of a statement: a heading, a line or a total.",
        "properties": {
          "code": {
            "type": "string",
            "readOnly": true
          },
          "label": {
            "type": "string",
            "readOnly": true
          },
          "label_et": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The Estonian label."
          },
          "level": {
            "type": "integer",
            "readOnly": true,
            "description": "The depth of the row, 0 at the top."
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksStatementRowKindEnum"
              }
            ],
            "readOnly": true,
            "description": "`heading` has no amount.\n\n* `heading` - heading\n* `line` - line\n* `total` - total"
          },
          "amount_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "In minor units of the base currency; null on a heading."
          },
          "compare_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "The amount at the comparison date or period; null without one."
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksStatementAccount"
            },
            "readOnly": true,
            "description": "Empty on a heading, a total and in the simplified view."
          }
        },
        "required": [
          "accounts",
          "amount_minor",
          "code",
          "compare_minor",
          "kind",
          "label",
          "label_et",
          "level"
        ]
      },
      "BooksStatementRowKindEnum": {
        "enum": [
          "heading",
          "line",
          "total"
        ],
        "type": "string",
        "description": "* `heading` - heading\n* `line` - line\n* `total` - total"
      },
      "BooksTransferMatch": {
        "type": "object",
        "description": "The match of the two legs of an internal transfer.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "out_transaction_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "in_transaction_id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "residue_base_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "base_currency": {
            "type": "string",
            "readOnly": true,
            "description": "The currency of every `*_base_minor` amount: the base currency of the books."
          },
          "accounting_event_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          }
        },
        "required": [
          "accounting_event_id",
          "base_currency",
          "id",
          "in_transaction_id",
          "out_transaction_id",
          "residue_base_minor"
        ]
      },
      "BooksTrialBalance": {
        "type": "object",
        "description": "The trial balance of a range, in the base currency.",
        "properties": {
          "base_currency": {
            "type": "string",
            "readOnly": true,
            "description": "The currency of every `*_base_minor` amount: the base currency of the books."
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksTrialBalanceRow"
            },
            "readOnly": true
          },
          "total_debit_base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "total_credit_base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "balanced": {
            "type": "boolean",
            "readOnly": true
          },
          "from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "to": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          }
        },
        "required": [
          "balanced",
          "base_currency",
          "from",
          "rows",
          "to",
          "total_credit_base_minor",
          "total_debit_base_minor"
        ]
      },
      "BooksTrialBalanceRow": {
        "type": "object",
        "description": "One account of the trial balance, in the base currency.",
        "properties": {
          "account_code": {
            "type": "string",
            "readOnly": true
          },
          "account_name": {
            "type": "string",
            "readOnly": true
          },
          "account_name_en": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The English name of the account; null when it has none."
          },
          "account_type": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksAccountTypeEnum"
              }
            ],
            "readOnly": true
          },
          "opening_base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "debit_base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "credit_base_minor": {
            "type": "integer",
            "readOnly": true
          },
          "closing_base_minor": {
            "type": "integer",
            "readOnly": true
          }
        },
        "required": [
          "account_code",
          "account_name",
          "account_name_en",
          "account_type",
          "closing_base_minor",
          "credit_base_minor",
          "debit_base_minor",
          "opening_base_minor"
        ],
        "x-oscarai-cli": {
          "title": "account_code",
          "columns": [
            "account_code",
            "account_name",
            "opening_base_minor",
            "debit_base_minor",
            "credit_base_minor",
            "closing_base_minor"
          ],
          "wide": [
            "account_type",
            "account_name_en"
          ]
        }
      },
      "BooksVatCode": {
        "type": "object",
        "description": "A VAT code with its rates.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "code": {
            "type": "string",
            "readOnly": true,
            "description": "`EE-SAL-STD`."
          },
          "name": {
            "type": "string",
            "readOnly": true,
            "description": "The name in English."
          },
          "name_et": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "The name in Estonian; null when the code has none (show `name`)."
          },
          "country": {
            "type": "string",
            "readOnly": true
          },
          "direction": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksVatCodeDirectionEnum"
              }
            ],
            "readOnly": true
          },
          "treatment": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksVatTreatmentEnum"
              }
            ],
            "readOnly": true
          },
          "self_assess": {
            "type": "boolean",
            "readOnly": true
          },
          "deductible_bps": {
            "type": "integer",
            "readOnly": true
          },
          "exigibility": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksVatExigibilityEnum"
              }
            ],
            "readOnly": true
          },
          "ec_sales": {
            "type": "boolean",
            "readOnly": true
          },
          "requires_party_vat": {
            "type": "boolean",
            "readOnly": true
          },
          "review_state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksReviewStateEnum"
              }
            ],
            "readOnly": true
          },
          "exempt_category": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "An exempt code: `real_estate`, `insurance`, `financial` (counted in the VAT registration turnover) or `other` (not counted); null when not classified (counted)."
          },
          "active": {
            "type": "boolean",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "rates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksVatRate"
            },
            "readOnly": true
          }
        },
        "required": [
          "active",
          "code",
          "country",
          "created_at",
          "deductible_bps",
          "direction",
          "ec_sales",
          "exempt_category",
          "exigibility",
          "id",
          "name",
          "name_et",
          "rates",
          "requires_party_vat",
          "review_state",
          "self_assess",
          "treatment"
        ],
        "x-oscarai-cli": {
          "title": "code",
          "columns": [
            "code",
            "name",
            "direction",
            "treatment",
            "deductible_bps",
            "active"
          ],
          "wide": [
            "country",
            "self_assess",
            "ec_sales",
            "review_state",
            "id"
          ]
        }
      },
      "BooksVatCodeDirectionEnum": {
        "enum": [
          "purchase",
          "sales",
          "both"
        ],
        "type": "string",
        "description": "* `purchase` - purchase\n* `sales` - sales\n* `both` - both"
      },
      "BooksVatCodePage": {
        "type": "object",
        "description": "One page of BooksVatCode items, and the cursor of the next page.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksVatCode"
            },
            "readOnly": true
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true,
            "description": "Send it back as `cursor` for the next page; null on the last page."
          }
        },
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "BooksVatExigibilityEnum": {
        "enum": [
          "invoice",
          "payment"
        ],
        "type": "string",
        "description": "* `invoice` - invoice\n* `payment` - payment"
      },
      "BooksVatPreview": {
        "type": "object",
        "description": "What preparing the VAT return of a period would write, without writing it.",
        "properties": {
          "form": {
            "type": "string",
            "readOnly": true
          },
          "form_version": {
            "type": "string",
            "readOnly": true
          },
          "period_from": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "period_to": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "boxes": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            },
            "readOnly": true,
            "description": "Box to amount in minor units of the base currency.",
            "x-oscarai-money": {
              "currency": "base_currency"
            }
          },
          "base_currency": {
            "type": "string",
            "readOnly": true,
            "description": "The currency of every `*_base_minor` amount: the base currency of the books."
          },
          "recognitions": {
            "type": "integer",
            "readOnly": true,
            "description": "The VAT recognitions the return would include."
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "The deadline of the return of the period: the 20th of the next month, moved to the next working day after a weekend or a public holiday. Null when the period is not one calendar month."
          }
        },
        "required": [
          "base_currency",
          "boxes",
          "form",
          "form_version",
          "period_from",
          "period_to",
          "recognitions"
        ]
      },
      "BooksVatRate": {
        "type": "object",
        "description": "A rate of a VAT code over a range of dates.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "maxLength": 26,
            "minLength": 26
          },
          "valid_from": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "valid_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "rate_bps": {
            "type": "integer",
            "readOnly": true,
            "description": "The rate in basis points: 2400 is 24 percent."
          },
          "review_state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksReviewStateEnum"
              }
            ],
            "readOnly": true
          }
        },
        "required": [
          "id",
          "rate_bps",
          "review_state",
          "valid_from",
          "valid_to"
        ]
      },
      "BooksVatTreatmentEnum": {
        "enum": [
          "standard",
          "reduced",
          "zero",
          "exempt",
          "out_of_scope",
          "rc_eu_services",
          "rc_eu_goods",
          "rc_domestic",
          "rc_non_eu",
          "foreign_vat",
          "oss",
          "unknown"
        ],
        "type": "string",
        "description": "* `standard` - standard\n* `reduced` - reduced\n* `zero` - zero\n* `exempt` - exempt\n* `out_of_scope` - out_of_scope\n* `rc_eu_services` - rc_eu_services\n* `rc_eu_goods` - rc_eu_goods\n* `rc_domestic` - rc_domestic\n* `rc_non_eu` - rc_non_eu\n* `foreign_vat` - foreign_vat\n* `oss` - oss\n* `unknown` - unknown"
      },
      "CancelInvoiceBodyRequest": {
        "type": "object",
        "description": "`cancel_invoice`: withdraw an issued sales invoice or a posted purchase invoice; the number is kept, a posted entry is reversed.",
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          }
        },
        "required": [
          "reason"
        ]
      },
      "CommandOutcome": {
        "type": "object",
        "description": "The core's `CommandOutcome`: what one command did.\n\nA repeat with the same `Idempotency-Key` and the same body returns the\nstored outcome with `replayed` true.",
        "properties": {
          "command": {
            "type": "string",
            "readOnly": true
          },
          "command_id": {
            "type": "string",
            "readOnly": true,
            "description": "The core id of the command, a ULID."
          },
          "commit_seq": {
            "type": "integer",
            "readOnly": true,
            "description": "The commit sequence of the file after it."
          },
          "replayed": {
            "type": "boolean",
            "readOnly": true
          },
          "result": {
            "readOnly": true,
            "description": "The command's result: the ids it created, and more."
          }
        },
        "required": [
          "command",
          "command_id",
          "commit_seq",
          "replayed",
          "result"
        ]
      },
      "Company": {
        "type": "object",
        "description": "A company as the API shows it. `core_company_id` is null until provisioning chose it.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "organization_id": {
            "type": "string",
            "description": "The sqid of the company's organization, without loading it.",
            "readOnly": true
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "registry_code": {
            "type": "string",
            "readOnly": true
          },
          "vat_number": {
            "type": "string",
            "readOnly": true,
            "description": "The VAT number of the latest VAT registration by date. It changes only through `POST vat-registrations` (`record_vat_registration`)."
          },
          "vat_status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/VatStatusEnum"
              }
            ],
            "readOnly": true,
            "description": "The status of the latest VAT registration by date. The books apply the status by date: `GET vat-registration/`.\n\n* `registered` - VAT-registered\n* `limited` - Limited taxable person\n* `unregistered` - Not VAT-registered"
          },
          "vat_status_from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true,
            "description": "The first day of `vat_status`; null for the status at creation."
          },
          "legal_form": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LegalFormEnum"
              }
            ],
            "readOnly": true
          },
          "files_tsd_monthly": {
            "type": "boolean",
            "readOnly": true,
            "description": "The accountant set that the company files a TSD every month. False: the TSD reminder of a month comes only when the books show payroll, a dividend payment or a distribution tax in it. Changed with `PATCH /api/companies/{company_id}/`."
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CompanyStateEnum"
              }
            ],
            "readOnly": true
          },
          "core_company_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "base_currency": {
            "type": "string",
            "description": "The base currency of the books (ISO 4217): every amount without its own currency is in it.",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "base_currency",
          "core_company_id",
          "created_at",
          "files_tsd_monthly",
          "id",
          "legal_form",
          "name",
          "organization_id",
          "registry_code",
          "state",
          "updated_at",
          "vat_number",
          "vat_status",
          "vat_status_from"
        ],
        "x-oscarai-cli": {
          "title": "name",
          "columns": [
            "name",
            "registry_code",
            "legal_form",
            "vat_status",
            "state"
          ],
          "wide": [
            "vat_number",
            "base_currency",
            "organization_id",
            "id"
          ],
          "status": {
            "field": "state",
            "roles": {
              "ready": "ok",
              "provisioning": "warn",
              "failed": "bad",
              "deleted": "muted"
            }
          }
        }
      },
      "CompanyDetail": {
        "type": "object",
        "description": "A company with the caller's role and effective permissions in it. Needs `principal` in the context.\n\nThe frontend shows or hides each action from `permissions`; it never\ncomputes permissions itself.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "organization_id": {
            "type": "string",
            "description": "The sqid of the company's organization, without loading it.",
            "readOnly": true
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "registry_code": {
            "type": "string",
            "readOnly": true
          },
          "vat_number": {
            "type": "string",
            "readOnly": true,
            "description": "The VAT number of the latest VAT registration by date. It changes only through `POST vat-registrations` (`record_vat_registration`)."
          },
          "vat_status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/VatStatusEnum"
              }
            ],
            "readOnly": true,
            "description": "The status of the latest VAT registration by date. The books apply the status by date: `GET vat-registration/`.\n\n* `registered` - VAT-registered\n* `limited` - Limited taxable person\n* `unregistered` - Not VAT-registered"
          },
          "vat_status_from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true,
            "description": "The first day of `vat_status`; null for the status at creation."
          },
          "legal_form": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LegalFormEnum"
              }
            ],
            "readOnly": true
          },
          "files_tsd_monthly": {
            "type": "boolean",
            "readOnly": true,
            "description": "The accountant set that the company files a TSD every month. False: the TSD reminder of a month comes only when the books show payroll, a dividend payment or a distribution tax in it. Changed with `PATCH /api/companies/{company_id}/`."
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CompanyStateEnum"
              }
            ],
            "readOnly": true
          },
          "core_company_id": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "base_currency": {
            "type": "string",
            "description": "The base currency of the books (ISO 4217): every amount without its own currency is in it.",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "role": {
            "readOnly": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/RoleEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "permissions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PermissionEnum"
            },
            "readOnly": true
          },
          "view_as": {
            "readOnly": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/RoleEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "status": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CompanyStatus"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true
          },
          "refresh_pending": {
            "type": "boolean",
            "description": "True while a rebuild of the status counts is queued or running: a change was made that the counts may not show yet. Read again until it is false.",
            "readOnly": true
          }
        },
        "required": [
          "base_currency",
          "core_company_id",
          "created_at",
          "files_tsd_monthly",
          "id",
          "legal_form",
          "name",
          "organization_id",
          "permissions",
          "refresh_pending",
          "registry_code",
          "role",
          "state",
          "status",
          "updated_at",
          "vat_number",
          "vat_status",
          "vat_status_from",
          "view_as"
        ],
        "x-oscarai-cli": {
          "title": "name",
          "columns": [
            "name",
            "registry_code",
            "legal_form",
            "vat_status",
            "state"
          ],
          "wide": [
            "vat_number",
            "base_currency",
            "organization_id",
            "id"
          ],
          "status": {
            "field": "state",
            "roles": {
              "ready": "ok",
              "provisioning": "warn",
              "failed": "bad",
              "deleted": "muted"
            }
          }
        }
      },
      "CompanyStateEnum": {
        "enum": [
          "provisioning",
          "ready",
          "failed",
          "deleted"
        ],
        "type": "string",
        "description": "* `provisioning` - Provisioning\n* `ready` - Ready\n* `failed` - Failed\n* `deleted` - Data deleted"
      },
      "CompanyStatus": {
        "type": "object",
        "description": "The status counts of a company, as the last refresh left them (`books.models.CompanyStatus`).",
        "properties": {
          "bank_lines_to_classify": {
            "type": "integer",
            "readOnly": true
          },
          "payments_to_explain": {
            "type": "integer",
            "readOnly": true,
            "description": "Money out still open that no uploaded file explains."
          },
          "documents_to_book": {
            "type": "integer",
            "readOnly": true,
            "description": "Uploaded invoices and receipts nothing in the books refers to, recorded purchase invoices not posted, and open drafts."
          },
          "pending_proposals": {
            "type": "integer",
            "readOnly": true
          },
          "open_periods": {
            "type": "integer",
            "readOnly": true
          },
          "vat_returns_due": {
            "type": "integer",
            "readOnly": true
          },
          "next_vat_due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true,
            "description": "The due date of the next VAT return (KMD): the 20th of the next month, moved to the next working day after a weekend or a public holiday."
          },
          "last_bank_import_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "overdue_receivables": {
            "type": "integer",
            "readOnly": true
          },
          "overdue_receivables_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "The residual of the overdue receivables in the base currency, in cents."
          },
          "refreshed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "refresh_error": {
            "type": "string",
            "readOnly": true,
            "description": "Why the last refresh failed; empty when it did not."
          }
        },
        "required": [
          "bank_lines_to_classify",
          "documents_to_book",
          "last_bank_import_at",
          "next_vat_due_date",
          "open_periods",
          "overdue_receivables",
          "overdue_receivables_minor",
          "payments_to_explain",
          "pending_proposals",
          "refresh_error",
          "refreshed_at",
          "vat_returns_due"
        ]
      },
      "CreatePartyOutcome": {
        "type": "object",
        "description": "The `CommandOutcome` of `create_party`, with its result.",
        "properties": {
          "command": {
            "type": "string",
            "readOnly": true
          },
          "command_id": {
            "type": "string",
            "readOnly": true,
            "description": "The core id of the command, a ULID."
          },
          "commit_seq": {
            "type": "integer",
            "readOnly": true,
            "description": "The commit sequence of the file after it."
          },
          "replayed": {
            "type": "boolean",
            "readOnly": true
          },
          "result": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CreatePartyResult"
              }
            ],
            "readOnly": true
          }
        },
        "required": [
          "command",
          "command_id",
          "commit_seq",
          "replayed",
          "result"
        ]
      },
      "CreatePartyPayloadRequest": {
        "type": "object",
        "description": "`create_party`: a customer, a supplier or another counterparty. A manual `vat_area` is a human judgement.",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          },
          "kind": {
            "$ref": "#/components/schemas/BooksPartyKindEnum"
          },
          "country": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "vat_area": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "vat_number": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "reg_code": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "expects_document": {
            "type": "boolean",
            "description": "Default true."
          },
          "is_confirmed": {
            "type": "boolean"
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "external_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "The key of the party in another system, for example `stripe:acct_…:cus_…`. Unique; with it, a party with the same name is allowed.",
            "maxLength": 2000
          },
          "private_persons": {
            "type": "boolean",
            "description": "The party pools private persons (card buyers): the KMD INF annex leaves it out. No registry code. Default false."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The postal address printed on an invoice, one or more lines; the country is `country`. At most 500 characters.",
            "maxLength": 500
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email address of the party. Trimmed; blank is null. At most 254 characters, no whitespace, and exactly one `@` with text on both sides, else 400 `invalid_payload`.",
            "maxLength": 254
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "The phone number of the party. Trimmed; blank is null. At most 40 characters: digits, spaces and `+ - ( ) .`, with at least 5 digits, else 400 `invalid_payload`.",
            "maxLength": 40
          }
        },
        "required": [
          "kind",
          "name"
        ]
      },
      "CreatePartyResult": {
        "type": "object",
        "description": "The result of `create_party`.",
        "properties": {
          "vat_area": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "party_id": {
            "type": "string",
            "readOnly": true
          },
          "name_key": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "name_key",
          "party_id",
          "vat_area"
        ]
      },
      "DraftStateEnum": {
        "enum": [
          "open",
          "recorded",
          "discarded",
          "duplicate"
        ],
        "type": "string",
        "description": "* `open` - Open\n* `recorded` - Recorded\n* `discarded` - Discarded\n* `duplicate` - Duplicate"
      },
      "Employee": {
        "type": "object",
        "description": "An employee of the company, with the facts of the newest employment. The personal code is masked.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "personal_code": {
            "type": "string",
            "description": "The masked personal code: `*******` and 4 digits.",
            "readOnly": true
          },
          "birth_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "citizenship": {
            "type": "string"
          },
          "iban": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "basic_exemption": {
            "$ref": "#/components/schemas/BasicExemptionEnum"
          },
          "basic_exemption_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "pension_rate": {
            "$ref": "#/components/schemas/PensionRateEnum"
          },
          "source": {
            "$ref": "#/components/schemas/EmployeeSourceEnum"
          },
          "employment_type": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The type of the newest employment.",
            "readOnly": true
          },
          "start_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "end_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "status": {
            "readOnly": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/EmploymentStatusEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "registered_outside": {
            "type": "boolean",
            "description": "Whether TÖR shows an employment of the person, or a change of one, not made through OscarAI.",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "basic_exemption",
          "basic_exemption_minor",
          "birth_date",
          "citizenship",
          "created_at",
          "email",
          "employment_type",
          "end_date",
          "first_name",
          "iban",
          "id",
          "last_name",
          "pension_rate",
          "personal_code",
          "registered_outside",
          "source",
          "start_date",
          "status"
        ],
        "x-oscarai-cli": {
          "title": "last_name",
          "columns": [
            "last_name",
            "first_name",
            "personal_code",
            "employment_type",
            "start_date",
            "status"
          ],
          "wide": [
            "end_date",
            "source",
            "registered_outside",
            "id"
          ],
          "status": {
            "field": "status",
            "roles": {
              "registered": "ok",
              "submitted": "warn",
              "approved": "warn",
              "draft": "muted",
              "rejected": "bad",
              "ended": "muted"
            }
          }
        }
      },
      "EmployeeDetail": {
        "type": "object",
        "description": "An employee with every employment and its absences.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "personal_code": {
            "type": "string",
            "description": "The masked personal code: `*******` and 4 digits.",
            "readOnly": true
          },
          "birth_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "citizenship": {
            "type": "string"
          },
          "iban": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "basic_exemption": {
            "$ref": "#/components/schemas/BasicExemptionEnum"
          },
          "basic_exemption_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "pension_rate": {
            "$ref": "#/components/schemas/PensionRateEnum"
          },
          "source": {
            "$ref": "#/components/schemas/EmployeeSourceEnum"
          },
          "employment_type": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The type of the newest employment.",
            "readOnly": true
          },
          "start_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "end_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "status": {
            "readOnly": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/EmploymentStatusEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "registered_outside": {
            "type": "boolean",
            "description": "Whether TÖR shows an employment of the person, or a change of one, not made through OscarAI.",
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "employments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Employment"
            },
            "readOnly": true
          },
          "absences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Absence"
            },
            "readOnly": true
          }
        },
        "required": [
          "absences",
          "basic_exemption",
          "basic_exemption_minor",
          "birth_date",
          "citizenship",
          "created_at",
          "email",
          "employment_type",
          "employments",
          "end_date",
          "first_name",
          "iban",
          "id",
          "last_name",
          "pension_rate",
          "personal_code",
          "registered_outside",
          "source",
          "start_date",
          "status"
        ],
        "x-oscarai-cli": {
          "title": "last_name",
          "columns": [
            "last_name",
            "first_name",
            "personal_code",
            "employment_type",
            "start_date",
            "status"
          ],
          "wide": [
            "end_date",
            "source",
            "registered_outside",
            "id"
          ],
          "status": {
            "field": "status",
            "roles": {
              "registered": "ok",
              "submitted": "warn",
              "approved": "warn",
              "draft": "muted",
              "rejected": "bad",
              "ended": "muted"
            }
          }
        }
      },
      "EmployeeInputRequest": {
        "type": "object",
        "description": "The person of a new employee, or the changed fields of an employee.",
        "properties": {
          "first_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "last_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "personal_code": {
            "type": "string",
            "minLength": 1,
            "description": "The Estonian personal code: a new employee only. Sealed, never returned.",
            "maxLength": 11
          },
          "birth_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "citizenship": {
            "type": "string",
            "maxLength": 2
          },
          "iban": {
            "type": "string",
            "maxLength": 34
          },
          "email": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "basic_exemption": {
            "$ref": "#/components/schemas/BasicExemptionEnum"
          },
          "basic_exemption_minor": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "pension_rate": {
            "$ref": "#/components/schemas/PensionRateEnum"
          }
        }
      },
      "EmployeeSourceEnum": {
        "enum": [
          "oscar",
          "tor_external"
        ],
        "type": "string",
        "description": "* `oscar` - OscarAI\n* `tor_external` - Registered outside OscarAI"
      },
      "EmployeeSubmissionKindEnum": {
        "enum": [
          "new_employee",
          "new_employment",
          "change",
          "suspension",
          "end"
        ],
        "type": "string",
        "description": "* `new_employee` - New employee\n* `new_employment` - New employment\n* `change` - Change\n* `suspension` - Suspension\n* `end` - End"
      },
      "EmployeeSubmissionStatusEnum": {
        "enum": [
          "submitted",
          "approved",
          "registered",
          "applied",
          "rejected"
        ],
        "type": "string",
        "description": "* `submitted` - Submitted\n* `approved` - Approved\n* `registered` - Registered\n* `applied` - Applied\n* `rejected` - Rejected"
      },
      "Employment": {
        "type": "object",
        "description": "One employment as TÖR records it, with the status of the workflow. A 601 entry has no rate or workplace.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "toot_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "TÖR's id of the employment; null until registered."
          },
          "employment_type": {
            "type": "integer",
            "description": "The TÖR type: 1 employment contract, 600 services contract, 601 board member, 501 unpaid work."
          },
          "employment_type_name": {
            "type": "string"
          },
          "start_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "end_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "end_reason_code": {
            "type": "string"
          },
          "work_time_rate": {
            "type": [
              "string",
              "null"
            ],
            "format": "decimal",
            "pattern": "^-?\\d{0,1}(?:\\.\\d{0,2})?$"
          },
          "occupation_code": {
            "type": "string"
          },
          "workplace_address_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "contract_ref": {
            "type": "string"
          },
          "gross_salary_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The monthly contract gross, in cents."
          },
          "board_fee_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The monthly board member fee, in cents."
          },
          "currency": {
            "type": "string"
          },
          "suspensions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Suspension"
            }
          },
          "tor_state_code": {
            "type": "string"
          },
          "tor_state_name": {
            "type": "string"
          },
          "tor_seen_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "source": {
            "$ref": "#/components/schemas/EmployeeSourceEnum"
          },
          "status": {
            "$ref": "#/components/schemas/EmploymentStatusEnum"
          },
          "registered_outside": {
            "type": "boolean",
            "description": "TÖR shows something of it not made through OscarAI."
          }
        },
        "required": [
          "board_fee_minor",
          "contract_ref",
          "currency",
          "employment_type",
          "employment_type_name",
          "end_date",
          "end_reason_code",
          "gross_salary_minor",
          "id",
          "occupation_code",
          "registered_outside",
          "source",
          "start_date",
          "status",
          "suspensions",
          "toot_id",
          "tor_seen_at",
          "tor_state_code",
          "tor_state_name",
          "work_time_rate",
          "workplace_address_id"
        ],
        "x-oscarai-cli": {
          "title": "employment_type",
          "columns": [
            "employment_type",
            "start_date",
            "end_date",
            "status",
            "source",
            "toot_id"
          ],
          "wide": [
            "work_time_rate",
            "occupation_code",
            "gross_salary_minor",
            "board_fee_minor",
            "id"
          ],
          "status": {
            "field": "status",
            "roles": {
              "registered": "ok",
              "submitted": "warn",
              "approved": "warn",
              "draft": "muted",
              "rejected": "bad",
              "ended": "muted"
            }
          }
        }
      },
      "EmploymentInputRequest": {
        "type": "object",
        "description": "The employment of a start, or the changed fields of an employment.",
        "properties": {
          "employment_type": {
            "type": "integer",
            "minimum": 1,
            "description": "The TÖR type: 1 employment contract, 600 services contract, 601 board member, 501 unpaid work."
          },
          "start_date": {
            "type": "string",
            "format": "date"
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "A fixed term: the last day, given with a start."
          },
          "work_time_rate": {
            "type": "string",
            "format": "decimal",
            "pattern": "^-?\\d{0,1}(?:\\.\\d{0,2})?$",
            "description": "0.01 to 1.00. Required for type 1."
          },
          "occupation_code": {
            "type": "string",
            "description": "The occupation code of Statistics Estonia.",
            "maxLength": 10
          },
          "workplace_address_id": {
            "type": "integer",
            "minimum": 1,
            "description": "The ADS address id (ADR_ID) of the workplace building."
          },
          "contract_ref": {
            "type": "string",
            "maxLength": 50
          },
          "gross_salary_minor": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "board_fee_minor": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          }
        }
      },
      "EmploymentStatusEnum": {
        "enum": [
          "draft",
          "submitted",
          "approved",
          "registered",
          "rejected",
          "ended",
          "cancelled"
        ],
        "type": "string",
        "description": "* `draft` - Draft\n* `submitted` - Submitted\n* `approved` - Approved\n* `registered` - Registered\n* `rejected` - Rejected\n* `ended` - Ended\n* `cancelled` - Cancelled in TÖR"
      },
      "EndInputRequest": {
        "type": "object",
        "description": "The end of an employment.",
        "properties": {
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "The last day of the employment."
          },
          "reason_code": {
            "type": "integer",
            "minimum": 1,
            "description": "The end reason code of the TLP classifier."
          }
        },
        "required": [
          "end_date",
          "reason_code"
        ]
      },
      "ForwardingConfirmation": {
        "type": "object",
        "description": "The newest Gmail forwarding confirmation that oscarai forwarded to its requester. Never the code or the link.",
        "properties": {
          "requesting_address": {
            "type": "string",
            "description": "The Gmail address that asked to forward."
          },
          "status": {
            "$ref": "#/components/schemas/ForwardingConfirmationStatusEnum"
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "forwarding_works": {
            "type": "boolean",
            "description": "A mail forwarded by the requesting address has arrived since the confirmation was sent."
          }
        },
        "required": [
          "forwarding_works",
          "requesting_address",
          "sent_at",
          "status"
        ]
      },
      "ForwardingConfirmationStatusEnum": {
        "enum": [
          "sent"
        ],
        "type": "string",
        "description": "* `sent` - sent"
      },
      "HistoryMonth": {
        "type": "object",
        "description": "One month of the pay history the average pay is taken from.",
        "properties": {
          "month": {
            "type": "string",
            "description": "YYYY-MM",
            "pattern": "^\\d{4}-(0[1-9]|1[0-2])$"
          },
          "wages_minor": {
            "type": "integer",
            "maximum": 100000000000,
            "minimum": 0,
            "format": "int64"
          },
          "days": {
            "type": "integer",
            "maximum": 31,
            "minimum": 0
          }
        },
        "required": [
          "days",
          "month",
          "wages_minor"
        ]
      },
      "InboundEmail": {
        "type": "object",
        "description": "One mail the inbox received, and what came of it.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "description": "The sqid of the mail."
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          },
          "sender": {
            "type": "string"
          },
          "forwarded_by": {
            "type": "string",
            "description": "The member's address that forwarded the mail through a Gmail filter, empty when none did. Set only for an address whose Gmail forwarding confirmation oscarai verified and forwarded."
          },
          "subject": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/InboundEmailStatusEnum"
          },
          "outcome": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OutcomeEnum"
              },
              {
                "$ref": "#/components/schemas/BlankEnum"
              }
            ]
          },
          "unknown_sender": {
            "type": "boolean",
            "description": "Neither the sender nor the address that forwarded it is a member.",
            "readOnly": true
          },
          "not_authenticated": {
            "type": "boolean",
            "description": "The DMARC check failed.",
            "readOnly": true
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboundEmailFile"
            },
            "readOnly": true,
            "description": "The files the mail made (the PDFs kept and the rendered body), each with its draft."
          },
          "raw_message_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sqid of the raw message file, kept as evidence.",
            "readOnly": true
          },
          "skipped_attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SkippedAttachment"
            },
            "readOnly": true
          }
        },
        "required": [
          "files",
          "forwarded_by",
          "id",
          "not_authenticated",
          "outcome",
          "raw_message_id",
          "received_at",
          "sender",
          "skipped_attachments",
          "status",
          "subject",
          "unknown_sender"
        ]
      },
      "InboundEmailFile": {
        "type": "object",
        "description": "A file a mail made: a PDF kept or the rendered body, and the draft its extraction opened.",
        "properties": {
          "id": {
            "type": "string",
            "description": "The sqid of the file."
          },
          "filename": {
            "type": "string",
            "description": "The file name, as the mail gave it."
          },
          "draft_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sqid of the newest draft of the file, in any state (open, recorded, discarded or duplicate), or null when the extraction opened none."
          }
        },
        "required": [
          "draft_id",
          "filename",
          "id"
        ]
      },
      "InboundEmailFileRoleEnum": {
        "type": "string",
        "enum": [
          "attachment",
          "rendered_body",
          "copy",
          "supporting"
        ]
      },
      "InboundEmailStatusEnum": {
        "enum": [
          "received",
          "processing",
          "done",
          "failed",
          "ignored"
        ],
        "type": "string",
        "description": "* `received` - Received\n* `processing` - Processing\n* `done` - Done\n* `failed` - Failed\n* `ignored` - Ignored"
      },
      "Inbox": {
        "type": "object",
        "description": "The invoice inbox of a company: its private address and what came in.",
        "properties": {
          "address": {
            "type": "string",
            "format": "email",
            "description": "The private forwarding address of the company."
          },
          "address_created_at": {
            "type": "string",
            "format": "date-time"
          },
          "counts": {
            "allOf": [
              {
                "$ref": "#/components/schemas/InboxCounts"
              }
            ],
            "description": "The mails of the last 30 days."
          },
          "gmail_filter_query": {
            "type": "string",
            "description": "The search string for a Gmail filter: known suppliers, or invoice words with an attachment."
          },
          "gmail_filter_query_broad": {
            "type": "string",
            "description": "The search string that forwards every mail with a PDF."
          },
          "forwarding_confirmation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ForwardingConfirmation"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "address",
          "address_created_at",
          "counts",
          "forwarding_confirmation",
          "gmail_filter_query",
          "gmail_filter_query_broad"
        ]
      },
      "InboxCounts": {
        "type": "object",
        "description": "The mails of the last 30 days.",
        "properties": {
          "received": {
            "type": "integer"
          },
          "documents": {
            "type": "integer",
            "description": "The mails that made at least one file."
          },
          "not_an_invoice": {
            "type": "integer",
            "description": "The mails whose every PDF and body were not invoices."
          },
          "failed": {
            "type": "integer"
          }
        },
        "required": [
          "documents",
          "failed",
          "not_an_invoice",
          "received"
        ]
      },
      "InboxOrigin": {
        "type": "object",
        "description": "Where a file came from when it came from the invoice inbox: the mail, its checks and the two flags.",
        "properties": {
          "sender": {
            "type": "string",
            "description": "The From address of the mail."
          },
          "subject": {
            "type": "string"
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          },
          "spf": {
            "allOf": [
              {
                "$ref": "#/components/schemas/MailAuthResultEnum"
              }
            ],
            "description": "The SPF result of the mail, as Resend reports it.\n\n* `pass` - pass\n* `fail` - fail\n* `gray` - gray\n* `processing_failed` - processing_failed\n* `unknown` - unknown"
          },
          "dkim": {
            "$ref": "#/components/schemas/MailAuthResultEnum"
          },
          "dmarc": {
            "$ref": "#/components/schemas/MailAuthResultEnum"
          },
          "forwarded_by": {
            "type": "string",
            "description": "The member's address that forwarded the mail through a Gmail filter, empty when none did."
          },
          "unknown_sender": {
            "type": "boolean",
            "description": "Neither the sender nor the address that forwarded it is a member of the organization."
          },
          "not_authenticated": {
            "type": "boolean",
            "description": "The DMARC check of the mail failed."
          }
        },
        "required": [
          "dkim",
          "dmarc",
          "forwarded_by",
          "not_authenticated",
          "received_at",
          "sender",
          "spf",
          "subject",
          "unknown_sender"
        ]
      },
      "InvoiceDocumentRequest": {
        "type": "object",
        "description": "A document linked to an invoice revision.",
        "properties": {
          "document_id": {
            "type": "string",
            "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$",
            "minLength": 1,
            "maxLength": 26
          },
          "role": {
            "type": "string",
            "description": "`original` (the default) or `supporting`. An own sales invoice takes no `original`: its original is the PDF Oscar issues, so a document on a sales draft is `supporting`.",
            "maxLength": 2000
          }
        },
        "required": [
          "document_id"
        ]
      },
      "InvoiceLineRequest": {
        "type": "object",
        "description": "One line of an invoice revision. A manual `vat_code` is a human judgement.",
        "properties": {
          "kind": {
            "type": "string",
            "description": "Default `vat_summary`.",
            "maxLength": 2000
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "quantity": {
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "format": "decimal",
                "pattern": "^-?\\d+(\\.\\d+)?$",
                "maxLength": 2000
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "unit": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "unit_price_minor": {
            "type": [
              "integer",
              "null"
            ],
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64",
            "description": "The unit price in whole minor units. `unit_price` also takes a fraction of a minor unit."
          },
          "unit_price": {
            "description": "The unit price in major units, a decimal string of at most 6 decimals (`150.334`). The books compute the net as quantity x unit price, rounded half up to the minor unit. With `unit_price_minor` too, both must name the same price.",
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "format": "decimal",
                "pattern": "^-?\\d+(\\.\\d{1,6})?$",
                "maxLength": 40
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "allowance_minor": {
            "type": "integer",
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "charge_minor": {
            "type": "integer",
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "net_minor": {
            "type": [
              "integer",
              "null"
            ],
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "vat_code": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "vat_rate_bps": {
            "type": [
              "integer",
              "null"
            ],
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "tax_minor": {
            "type": [
              "integer",
              "null"
            ],
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "account_code": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "expense_role": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "deductible_bps": {
            "type": "integer",
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64",
            "description": "Default 10000."
          },
          "business_use_bps": {
            "type": "integer",
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64",
            "description": "Default 10000."
          },
          "fixed_asset": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "A purchase line only: true or false overrides whether it buys a fixed asset (KMD row 5.2). Null takes it from the account."
          },
          "fixed_asset_id": {
            "description": "The asset of the fixed asset register this line buys, improves or sells. The link decides the account of the line; a line that names another account is refused.",
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$",
                "minLength": 26,
                "maxLength": 26
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "fixed_asset_component_id": {
            "description": "A component of that asset; default the main component. Needs `fixed_asset_id`.",
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$",
                "minLength": 26,
                "maxLength": 26
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "fixed_asset_link": {
            "description": "`acquisition` (default for a planned asset) or `improvement` (default for an asset in use) or `disposal_cost` on a purchase; `disposal` on a sale. Needs `fixed_asset_id`.\n\n* `acquisition` - acquisition\n* `improvement` - improvement\n* `disposal_cost` - disposal_cost\n* `disposal` - disposal",
            "oneOf": [
              {
                "$ref": "#/components/schemas/BooksFixedAssetLinkEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          }
        }
      },
      "InvoiceRevisionRequest": {
        "type": "object",
        "description": "The content of an invoice: one revision. A chosen `exchange_rate_id` is a human judgement.",
        "properties": {
          "party_name_raw": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "invoice_date": {
            "type": "string",
            "format": "date",
            "minLength": 1
          },
          "supply_date": {
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "due_date": {
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "service_from": {
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "service_to": {
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "currency": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          },
          "net_minor": {
            "type": [
              "integer",
              "null"
            ],
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "tax_minor": {
            "type": [
              "integer",
              "null"
            ],
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "gross_minor": {
            "type": [
              "integer",
              "null"
            ],
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "prepaid_minor": {
            "type": "integer",
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "rounding_minor": {
            "type": "integer",
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64"
          },
          "exchange_rate_id": {
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$",
                "minLength": 26,
                "maxLength": 26
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "vat_code_source": {
            "type": "string",
            "description": "Default `derived`.",
            "maxLength": 2000
          },
          "supplier_vat_number": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "buyer_vat_number": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "source_payload": {
            "oneOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "needs_review": {
            "type": "boolean"
          },
          "review_note": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "received_date": {
            "description": "A purchase invoice: the day it was received. It dates the input VAT when the return of the tax point month was filed before.",
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "base_tax_minor": {
            "type": [
              "integer",
              "null"
            ],
            "maximum": 9223372036854776000,
            "minimum": -9223372036854776000,
            "format": "int64",
            "description": "A foreign-currency purchase invoice: the VAT in euro it prints, deducted as printed."
          },
          "customer_note": {
            "type": [
              "string",
              "null"
            ],
            "description": "An own sales invoice: a note printed for the customer, at most 2000 characters.",
            "maxLength": 2000
          },
          "prices_include_vat": {
            "type": "boolean",
            "description": "An own sales invoice: the unit prices, discounts and charges of the item lines include VAT. The books compute the net and the VAT of each line, so the total is the sum of the gross amounts. Every line is an `item` without `net_minor` or `tax_minor`. Default false."
          },
          "language": {
            "description": "An own sales invoice: the language of its document. Null: Estonian for a buyer in Estonia, else English.\n\n* `et` - et\n* `en` - en",
            "oneOf": [
              {
                "$ref": "#/components/schemas/KycLanguageEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceLineRequest"
            }
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceDocumentRequest"
            }
          }
        },
        "required": [
          "currency",
          "invoice_date",
          "lines"
        ]
      },
      "IssueInvoiceBodyRequest": {
        "type": "object",
        "description": "`issue_invoice`: number a sales invoice and freeze it.",
        "properties": {
          "number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Only under a `free` numbering policy.",
            "maxLength": 2000
          },
          "seller_snapshot": {
            "oneOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "buyer_snapshot": {
            "oneOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "seller_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The seller's postal address frozen into the seller snapshot. Without it the API takes the company's address from the Business Register. A VAT-registered company issues no invoice without the seller's and the buyer's address: 400 `seller_address_missing` or `buyer_address_missing` (EE-VAT-020).",
            "maxLength": 500
          }
        }
      },
      "IssueInvoiceOutcome": {
        "type": "object",
        "description": "The `CommandOutcome` of `issue_invoice`, with its result.",
        "properties": {
          "command": {
            "type": "string",
            "readOnly": true
          },
          "command_id": {
            "type": "string",
            "readOnly": true,
            "description": "The core id of the command, a ULID."
          },
          "commit_seq": {
            "type": "integer",
            "readOnly": true,
            "description": "The commit sequence of the file after it."
          },
          "replayed": {
            "type": "boolean",
            "readOnly": true
          },
          "result": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueInvoiceResult"
              }
            ],
            "readOnly": true
          }
        },
        "required": [
          "command",
          "command_id",
          "commit_seq",
          "replayed",
          "result"
        ]
      },
      "IssueInvoiceResult": {
        "type": "object",
        "description": "The result of `issue_invoice`.",
        "properties": {
          "number": {
            "type": "string",
            "readOnly": true
          },
          "reference_number": {
            "type": "string",
            "readOnly": true,
            "description": "The Estonian reference number (viitenumber) the payer quotes."
          },
          "invoice_id": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "invoice_id",
          "number",
          "reference_number"
        ]
      },
      "KycLanguageEnum": {
        "enum": [
          "et",
          "en"
        ],
        "type": "string",
        "description": "* `et` - et\n* `en` - en"
      },
      "LegalFormEnum": {
        "enum": [
          "ou",
          "as",
          "fie",
          "mtu",
          "sa",
          "tu",
          "uu",
          "other"
        ],
        "type": "string",
        "description": "* `ou` - Osaühing (OÜ)\n* `as` - Aktsiaselts (AS)\n* `fie` - Füüsilisest isikust ettevõtja (FIE)\n* `mtu` - Mittetulundusühing (MTÜ)\n* `sa` - Sihtasutus (SA)\n* `tu` - Täisühing (TÜ)\n* `uu` - Usaldusühing (UÜ)\n* `other` - Other"
      },
      "MailAuthResultEnum": {
        "enum": [
          "pass",
          "fail",
          "gray",
          "processing_failed",
          "unknown"
        ],
        "type": "string",
        "description": "* `pass` - pass\n* `fail` - fail\n* `gray` - gray\n* `processing_failed` - processing_failed\n* `unknown` - unknown"
      },
      "Me": {
        "type": "object",
        "description": "`GET /api/me/`: the user, the credential, and the organizations and companies the caller can see.",
        "properties": {
          "user": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MeUser"
              },
              {
                "type": "null"
              }
            ],
            "description": "The session user, or the creator of the API key or OAuth grant."
          },
          "has_totp": {
            "type": "boolean"
          },
          "staff_mfa_required": {
            "type": "boolean",
            "description": "True when the user is firm staff but this session did not pass a second factor (TOTP or a passkey): every staff power is off, and the firm API answers 403 mfa_required, until the user logs in with one."
          },
          "email_verified": {
            "type": "boolean"
          },
          "credential": {
            "$ref": "#/components/schemas/MeCredential"
          },
          "organizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MeOrganization"
            }
          },
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MeCompany"
            }
          },
          "features": {
            "$ref": "#/components/schemas/MeFeatures"
          },
          "cli_min_version": {
            "type": "string",
            "description": "The oldest version of the oscar CLI that may run the onboarding (semver). An older CLI asks the user to update first. Always returned; optional in the schema, so a client keeps working against a server older than the field."
          }
        },
        "required": [
          "companies",
          "credential",
          "email_verified",
          "features",
          "has_totp",
          "organizations",
          "staff_mfa_required",
          "user"
        ]
      },
      "MeCompany": {
        "type": "object",
        "description": "A company the caller can see.",
        "properties": {
          "id": {
            "type": "string"
          },
          "organization_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "registry_code": {
            "type": "string"
          },
          "vat_number": {
            "type": "string"
          },
          "legal_form": {
            "$ref": "#/components/schemas/LegalFormEnum"
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CompanyStateEnum"
              }
            ],
            "description": "Only a `ready` company has books.\n\n* `provisioning` - Provisioning\n* `ready` - Ready\n* `failed` - Failed\n* `deleted` - Data deleted"
          }
        },
        "required": [
          "id",
          "legal_form",
          "name",
          "organization_id",
          "registry_code",
          "state",
          "vat_number"
        ],
        "x-oscarai-cli": {
          "title": "name",
          "columns": [
            "name",
            "registry_code",
            "legal_form",
            "state"
          ],
          "wide": [
            "vat_number",
            "organization_id",
            "id"
          ],
          "status": {
            "field": "state",
            "roles": {
              "ready": "ok",
              "provisioning": "warn",
              "failed": "bad",
              "deleted": "muted"
            }
          }
        }
      },
      "MeCredential": {
        "type": "object",
        "description": "How the call was authenticated.",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/MeCredentialKindEnum"
          },
          "scopes": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The scopes of an API key or an OAuth token; null for a session, which is not narrowed."
          },
          "staff_key": {
            "type": "boolean",
            "description": "True for a staff API key: a key of no organization that acts as owner in every organization, made in the admin by a superuser. `user` is then its creator."
          }
        },
        "required": [
          "kind",
          "scopes",
          "staff_key"
        ]
      },
      "MeCredentialKindEnum": {
        "enum": [
          "session",
          "api_key",
          "oauth"
        ],
        "type": "string",
        "description": "* `session` - session\n* `api_key` - api_key\n* `oauth` - oauth"
      },
      "MeFeatures": {
        "type": "object",
        "description": "The features this deployment turns on. The frontend hides what is off.",
        "properties": {
          "agent": {
            "type": "boolean",
            "description": "The AI agent. Off, every agent endpoint answers 404 agent_disabled."
          },
          "inbox": {
            "type": "boolean",
            "description": "The invoice inbox, a forwarding address for each company. Off, its endpoints answer 409 inbox_disabled."
          },
          "employees": {
            "type": "boolean",
            "description": "The employee register and its sync with TÖR. Off, its endpoints answer 409 employees_disabled."
          },
          "payroll": {
            "type": "boolean",
            "description": "Payroll and the payroll tax returns (TSD). Off, their endpoints answer 409 payroll_disabled."
          },
          "kmd_submission": {
            "type": "boolean",
            "description": "The VAT return (KMD) is sent to the tax authority over X-tee. Off, the KMD submit answers 503 kmd_submission_disabled: download the file and upload it in e-MTA."
          }
        },
        "required": [
          "agent",
          "employees",
          "inbox"
        ]
      },
      "MeOrganization": {
        "type": "object",
        "description": "An organization the caller can see, with its role there.",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "role": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RoleEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "is_member": {
            "type": "boolean",
            "description": "False for staff who see the organization without a membership."
          }
        },
        "required": [
          "id",
          "is_member",
          "name",
          "role"
        ]
      },
      "MeUser": {
        "type": "object",
        "description": "The user behind the call.",
        "properties": {
          "id": {
            "type": "string",
            "description": "The sqid of the user."
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string"
          },
          "is_staff": {
            "type": "boolean",
            "description": "Firm staff: sees every organization as owner."
          },
          "ui_mode": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UiModeEnum"
              }
            ],
            "description": "The mode of the client dashboard the user chose: simple or advanced.\n\n* `simple` - Simple\n* `advanced` - Advanced"
          }
        },
        "required": [
          "email",
          "id",
          "is_staff",
          "name",
          "ui_mode"
        ]
      },
      "NetPayment": {
        "type": "object",
        "description": "A payment of an employee's net pay: an allocation in the books.",
        "properties": {
          "id": {
            "type": "string",
            "description": "The allocation in the books."
          },
          "state": {
            "type": "string"
          },
          "effective_date": {
            "type": "string",
            "format": "date",
            "description": "The bank date."
          },
          "amount_minor": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "bank_transaction_id": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "amount_minor",
          "bank_transaction_id",
          "currency",
          "effective_date",
          "id",
          "state"
        ]
      },
      "NullEnum": {
        "type": "null"
      },
      "Organization": {
        "type": "object",
        "description": "An organization, with the caller's role and effective permissions in it, and its companies.\n\nNeeds the caller's `principal` in the serializer context.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "role": {
            "readOnly": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/RoleEnum"
              },
              {
                "$ref": "#/components/schemas/NullEnum"
              }
            ]
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "readOnly": true
          },
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Company"
            },
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "companies",
          "created_at",
          "id",
          "name",
          "permissions",
          "role",
          "updated_at"
        ]
      },
      "OutcomeEnum": {
        "enum": [
          "documents",
          "body_rendered",
          "no_document",
          "not_an_invoice",
          "forwarding_confirmation",
          "forwarding_confirmation_unverified",
          "unknown_address",
          "revoked_address",
          "too_large"
        ],
        "type": "string",
        "description": "* `` - None yet\n* `documents` - Documents\n* `body_rendered` - Body rendered\n* `no_document` - No document\n* `not_an_invoice` - Not an invoice\n* `forwarding_confirmation` - Forwarding confirmation\n* `forwarding_confirmation_unverified` - Unverified forwarding confirmation\n* `unknown_address` - Unknown address\n* `revoked_address` - Revoked address\n* `too_large` - Too large"
      },
      "PaginatedCompanyList": {
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Company"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PaginatedEmployeeList": {
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Employee"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PaginatedInboundEmailList": {
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboundEmail"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PaginatedOrganizationList": {
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Organization"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PaginatedPayRunList": {
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PayRun"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PaginatedStoredDocumentList": {
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoredDocument"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PaginatedSubmissionList": {
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Submission"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PartyRoleEnum": {
        "enum": [
          "supplier",
          "customer"
        ],
        "type": "string",
        "description": "* `supplier` - supplier\n* `customer` - customer"
      },
      "PayRun": {
        "type": "object",
        "description": "A pay run: the month, the status, the totals.",
        "properties": {
          "id": {
            "type": "string"
          },
          "month": {
            "type": "string",
            "description": "YYYY-MM"
          },
          "payday": {
            "type": "string",
            "format": "date"
          },
          "status": {
            "$ref": "#/components/schemas/PayRunStatusEnum"
          },
          "currency": {
            "type": "string"
          },
          "employee_count": {
            "type": "integer"
          },
          "gross_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "net_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "withheld_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "employer_tax_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "expense_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "open_net_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Posted: the net pay not paid yet."
          },
          "calculation_error": {
            "type": "string",
            "description": "A draft: why the calculation of the books failed."
          },
          "pay_run_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Posted: the pay run in the books."
          },
          "approved_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "posted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "approved_at",
          "calculation_error",
          "currency",
          "employee_count",
          "employer_tax_minor",
          "expense_minor",
          "gross_minor",
          "id",
          "month",
          "net_minor",
          "open_net_minor",
          "pay_run_id",
          "payday",
          "posted_at",
          "status",
          "withheld_minor"
        ],
        "x-oscarai-cli": {
          "title": "month",
          "columns": [
            "month",
            "status",
            "payday",
            "employee_count",
            "net_minor",
            "open_net_minor"
          ],
          "wide": [
            "gross_minor",
            "employer_tax_minor",
            "expense_minor",
            "id"
          ],
          "status": {
            "field": "status",
            "roles": {
              "posted": "ok",
              "approved": "warn",
              "draft": "muted"
            }
          }
        }
      },
      "PayRunDetail": {
        "type": "object",
        "description": "A pay run with every employee.",
        "properties": {
          "id": {
            "type": "string"
          },
          "month": {
            "type": "string",
            "description": "YYYY-MM"
          },
          "payday": {
            "type": "string",
            "format": "date"
          },
          "status": {
            "$ref": "#/components/schemas/PayRunStatusEnum"
          },
          "currency": {
            "type": "string"
          },
          "employee_count": {
            "type": "integer"
          },
          "gross_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "net_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "withheld_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "employer_tax_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "expense_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "open_net_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Posted: the net pay not paid yet."
          },
          "calculation_error": {
            "type": "string",
            "description": "A draft: why the calculation of the books failed."
          },
          "pay_run_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Posted: the pay run in the books."
          },
          "approved_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "posted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "employees": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PayRunEmployee"
            }
          }
        },
        "required": [
          "approved_at",
          "calculation_error",
          "currency",
          "employee_count",
          "employees",
          "employer_tax_minor",
          "expense_minor",
          "gross_minor",
          "id",
          "month",
          "net_minor",
          "open_net_minor",
          "pay_run_id",
          "payday",
          "posted_at",
          "status",
          "withheld_minor"
        ],
        "x-oscarai-cli": {
          "title": "month",
          "columns": [
            "month",
            "status",
            "payday",
            "employee_count",
            "net_minor",
            "open_net_minor"
          ],
          "wide": [
            "gross_minor",
            "employer_tax_minor",
            "expense_minor",
            "id"
          ],
          "status": {
            "field": "status",
            "roles": {
              "posted": "ok",
              "approved": "warn",
              "draft": "muted"
            }
          }
        }
      },
      "PayRunEmployee": {
        "type": "object",
        "description": "One employee of a pay run: the inputs, and once posted the result, the open net pay and its payments.",
        "properties": {
          "id": {
            "type": "string"
          },
          "employee_id": {
            "type": "string"
          },
          "employee_name": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "salary_minor": {
            "type": "integer"
          },
          "bonus_minor": {
            "type": "integer"
          },
          "board_fee_minor": {
            "type": "integer"
          },
          "fringe_benefit_minor": {
            "type": "integer"
          },
          "fringe_benefit_code": {
            "type": "string",
            "description": "The TSD annex 4 code of the fringe benefits."
          },
          "holiday_days": {
            "type": "integer"
          },
          "sick_leaves": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SickLeave"
            }
          },
          "pay_history": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/HistoryMonth"
            },
            "description": "The pay history staff gave; null: taken from the posted runs."
          },
          "pension_rate_bps": {
            "type": "integer"
          },
          "basic_exemption": {
            "$ref": "#/components/schemas/BasicExemptionEnum"
          },
          "basic_exemption_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "social_tax_minimum": {
            "$ref": "#/components/schemas/SocialTaxMinimumEnum"
          },
          "social_tax_minimum_days": {
            "type": [
              "integer",
              "null"
            ]
          },
          "unemployment_insurance_employee": {
            "type": "boolean"
          },
          "gross_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Posted: the gross pay of the month."
          },
          "net_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Posted: the net pay."
          },
          "open_net_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Posted: the net pay not paid yet."
          },
          "payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NetPayment"
            }
          }
        },
        "required": [
          "basic_exemption",
          "basic_exemption_minor",
          "board_fee_minor",
          "bonus_minor",
          "currency",
          "employee_id",
          "employee_name",
          "fringe_benefit_code",
          "fringe_benefit_minor",
          "gross_minor",
          "holiday_days",
          "id",
          "net_minor",
          "open_net_minor",
          "pay_history",
          "payments",
          "pension_rate_bps",
          "salary_minor",
          "sick_leaves",
          "social_tax_minimum",
          "social_tax_minimum_days",
          "unemployment_insurance_employee"
        ]
      },
      "PayRunStatusEnum": {
        "enum": [
          "draft",
          "approved",
          "posting",
          "posted"
        ],
        "type": "string",
        "description": "* `draft` - Draft\n* `approved` - Approved\n* `posting` - Posting\n* `posted` - Posted"
      },
      "PensionRateEnum": {
        "enum": [
          "none",
          "2",
          "4",
          "6"
        ],
        "type": "string",
        "description": "* `none` - None\n* `2` - 2 percent\n* `4` - 4 percent\n* `6` - 6 percent"
      },
      "PermissionEnum": {
        "enum": [
          "organization.read",
          "members.read",
          "api_keys.read",
          "audit.read",
          "books.read",
          "documents.read",
          "payments.read",
          "organization.manage",
          "members.manage",
          "api_keys.manage",
          "companies.create",
          "books.setup",
          "parties.write",
          "documents.write",
          "bank.import",
          "bank.classify",
          "bank.connect",
          "invoices.write",
          "invoices.issue",
          "invoices.post_purchase",
          "invoices.void",
          "allocations.write",
          "reconciliation.decide",
          "events.write",
          "periods.close",
          "periods.reopen",
          "vat.prepare",
          "vat.file",
          "payments.manage",
          "employees.submit",
          "agent.use"
        ],
        "type": "string",
        "description": "* `organization.read` - organization.read\n* `members.read` - members.read\n* `api_keys.read` - api_keys.read\n* `audit.read` - audit.read\n* `books.read` - books.read\n* `documents.read` - documents.read\n* `payments.read` - payments.read\n* `organization.manage` - organization.manage\n* `members.manage` - members.manage\n* `api_keys.manage` - api_keys.manage\n* `companies.create` - companies.create\n* `books.setup` - books.setup\n* `parties.write` - parties.write\n* `documents.write` - documents.write\n* `bank.import` - bank.import\n* `bank.classify` - bank.classify\n* `bank.connect` - bank.connect\n* `invoices.write` - invoices.write\n* `invoices.issue` - invoices.issue\n* `invoices.post_purchase` - invoices.post_purchase\n* `invoices.void` - invoices.void\n* `allocations.write` - allocations.write\n* `reconciliation.decide` - reconciliation.decide\n* `events.write` - events.write\n* `periods.close` - periods.close\n* `periods.reopen` - periods.reopen\n* `vat.prepare` - vat.prepare\n* `vat.file` - vat.file\n* `payments.manage` - payments.manage\n* `employees.submit` - employees.submit\n* `agent.use` - agent.use"
      },
      "Problem": {
        "type": "object",
        "description": "An RFC 9457 problem details body (section 11.5).",
        "properties": {
          "type": {
            "type": "string",
            "readOnly": true
          },
          "title": {
            "type": "string",
            "readOnly": true
          },
          "status": {
            "type": "integer",
            "readOnly": true
          },
          "code": {
            "type": "string",
            "readOnly": true
          },
          "detail": {
            "type": "string",
            "readOnly": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {}
            },
            "readOnly": true
          }
        },
        "required": [
          "code",
          "detail",
          "errors",
          "status",
          "title",
          "type"
        ]
      },
      "RecordInvoiceOutcome": {
        "type": "object",
        "description": "The `CommandOutcome` of `record_invoice`, with its result.",
        "properties": {
          "command": {
            "type": "string",
            "readOnly": true
          },
          "command_id": {
            "type": "string",
            "readOnly": true,
            "description": "The core id of the command, a ULID."
          },
          "commit_seq": {
            "type": "integer",
            "readOnly": true,
            "description": "The commit sequence of the file after it."
          },
          "replayed": {
            "type": "boolean",
            "readOnly": true
          },
          "result": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RecordInvoiceResult"
              }
            ],
            "readOnly": true
          }
        },
        "required": [
          "command",
          "command_id",
          "commit_seq",
          "replayed",
          "result"
        ]
      },
      "RecordInvoicePayloadRequest": {
        "type": "object",
        "description": "`record_invoice`: a draft sales or purchase invoice.",
        "properties": {
          "direction": {
            "type": "string",
            "minLength": 1,
            "description": "`sales` or `purchase`.",
            "maxLength": 2000
          },
          "kind": {
            "type": "string",
            "description": "Default `invoice`.",
            "maxLength": 2000
          },
          "party_id": {
            "type": "string",
            "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$",
            "minLength": 1,
            "maxLength": 26
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "corrects_invoice_id": {
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$",
                "minLength": 26,
                "maxLength": 26
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "origin": {
            "type": "string",
            "description": "Default `human`.",
            "maxLength": 2000
          },
          "revision": {
            "$ref": "#/components/schemas/InvoiceRevisionRequest"
          }
        },
        "required": [
          "direction",
          "party_id",
          "revision"
        ]
      },
      "RecordInvoiceResult": {
        "type": "object",
        "description": "The result of `record_invoice`.",
        "properties": {
          "line_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "readOnly": true
          },
          "invoice_id": {
            "type": "string",
            "readOnly": true
          },
          "revision_id": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "invoice_id",
          "line_ids",
          "revision_id"
        ]
      },
      "ReviseInvoiceBodyRequest": {
        "type": "object",
        "description": "`revise_invoice`: a new revision of an invoice.",
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          },
          "party_id": {
            "oneOf": [
              {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$",
                "minLength": 26,
                "maxLength": 26
              },
              {
                "type": "string",
                "maxLength": 0
              }
            ]
          },
          "revision": {
            "$ref": "#/components/schemas/InvoiceRevisionRequest"
          }
        },
        "required": [
          "reason",
          "revision"
        ]
      },
      "RoleEnum": {
        "enum": [
          "owner",
          "member",
          "viewer"
        ],
        "type": "string",
        "description": "* `owner` - Owner\n* `member` - Member\n* `viewer` - Viewer"
      },
      "SickLeave": {
        "type": "object",
        "description": "The days of one sick leave the run pays, counted from the first day of the leave (day 1).",
        "properties": {
          "from_day": {
            "type": "integer",
            "maximum": 366,
            "minimum": 1
          },
          "to_day": {
            "type": "integer",
            "maximum": 366,
            "minimum": 1
          }
        },
        "required": [
          "from_day",
          "to_day"
        ]
      },
      "SkippedAttachment": {
        "type": "object",
        "description": "An attachment that was not kept. Its bytes were never stored.",
        "properties": {
          "filename": {
            "type": "string"
          },
          "size": {
            "type": [
              "integer",
              "null"
            ]
          },
          "reason": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SkippedAttachmentReasonEnum"
              }
            ],
            "description": "Why it was not kept. `too_many`: the mail had more attachments than the inbox reads. `not_an_invoice`: the judge of the file, or the grouping of the mail, read it as no invoice.\n\n* `not_an_invoice` - not_an_invoice\n* `not_pdf` - not_pdf\n* `too_large` - too_large\n* `too_many` - too_many"
          }
        },
        "required": [
          "filename",
          "reason",
          "size"
        ]
      },
      "SkippedAttachmentReasonEnum": {
        "enum": [
          "not_an_invoice",
          "not_pdf",
          "too_large",
          "too_many"
        ],
        "type": "string",
        "description": "* `not_an_invoice` - not_an_invoice\n* `not_pdf` - not_pdf\n* `too_large` - too_large\n* `too_many` - too_many"
      },
      "SocialTaxMinimumEnum": {
        "enum": [
          "full",
          "prorated",
          "none"
        ],
        "type": "string",
        "description": "* `full` - The whole minimum\n* `prorated` - In proportion to the days\n* `none` - None"
      },
      "StoredDocument": {
        "type": "object",
        "description": "A stored file of a company, as the API shows it. The storage name never leaves the server.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true,
            "description": "The sqid of the file."
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksDocumentKindEnum"
              }
            ],
            "readOnly": true
          },
          "name": {
            "type": "string",
            "readOnly": true
          },
          "content_type": {
            "type": "string",
            "readOnly": true
          },
          "size_bytes": {
            "type": "integer",
            "readOnly": true
          },
          "sha256": {
            "type": "string",
            "readOnly": true
          },
          "received_on": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "core_document_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The ULID of the document in the books.",
            "readOnly": true
          },
          "bank_transaction_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The core ULIDs of the bank transactions this file explains.",
            "readOnly": true
          },
          "uploaded_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sqid of the user who uploaded the file.",
            "readOnly": true
          },
          "origin": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InboxOrigin"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true,
            "description": "The mail the file came from, when it came from the invoice inbox; null for an upload."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "bank_transaction_ids",
          "content_type",
          "core_document_id",
          "created_at",
          "id",
          "kind",
          "name",
          "origin",
          "received_on",
          "sha256",
          "size_bytes",
          "uploaded_by"
        ],
        "x-oscarai-cli": {
          "title": "name",
          "columns": [
            "name",
            "kind",
            "received_on",
            "size_bytes",
            "content_type"
          ],
          "wide": [
            "origin",
            "uploaded_by",
            "created_at",
            "id"
          ]
        }
      },
      "Submission": {
        "type": "object",
        "description": "A submission and its review: the client reads its status, and the reason of a refusal.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "kind": {
            "$ref": "#/components/schemas/EmployeeSubmissionKindEnum"
          },
          "status": {
            "$ref": "#/components/schemas/EmployeeSubmissionStatusEnum"
          },
          "event_date": {
            "type": "string",
            "format": "date"
          },
          "employee_id": {
            "type": "string",
            "description": "The employee of the submission.",
            "readOnly": true
          },
          "employee_name": {
            "type": "string",
            "description": "The name of the employee.",
            "readOnly": true
          },
          "employment_id": {
            "type": "string",
            "readOnly": true
          },
          "data": {
            "description": "The submitted values by field name. Never a personal code."
          },
          "submitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "submitted_by_staff": {
            "type": "boolean"
          },
          "reviewed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "review_reason": {
            "type": "string",
            "description": "Why staff rejected it."
          },
          "toot_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "TÖR's id of the employment, once registered.",
            "readOnly": true
          },
          "tor_messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TorMessage"
            },
            "description": "The messages of TÖR on a refused event."
          },
          "tor_error_code": {
            "type": "string",
            "description": "Why the last send to TÖR did not finish; empty when it did."
          },
          "registered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "data",
          "employee_id",
          "employee_name",
          "employment_id",
          "event_date",
          "id",
          "kind",
          "registered_at",
          "review_reason",
          "reviewed_at",
          "status",
          "submitted_at",
          "submitted_by_staff",
          "toot_id",
          "tor_error_code",
          "tor_messages"
        ],
        "x-oscarai-cli": {
          "title": "kind",
          "columns": [
            "kind",
            "status",
            "event_date",
            "employee_name",
            "submitted_at",
            "review_reason"
          ],
          "wide": [
            "employment_id",
            "tor_error_code",
            "reviewed_at",
            "id"
          ],
          "status": {
            "field": "status",
            "roles": {
              "registered": "ok",
              "applied": "ok",
              "submitted": "warn",
              "approved": "warn",
              "rejected": "bad"
            }
          }
        }
      },
      "SubmissionRequestRequest": {
        "type": "object",
        "description": "A new employee, a new employment, a change, a suspension or an end, for staff to review.",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/EmployeeSubmissionKindEnum"
          },
          "employee_id": {
            "type": "string",
            "minLength": 1,
            "description": "A new employment: the employee."
          },
          "employment_id": {
            "type": "string",
            "minLength": 1,
            "description": "A change, a suspension, an end: the employment."
          },
          "employee": {
            "$ref": "#/components/schemas/EmployeeInputRequest"
          },
          "employment": {
            "$ref": "#/components/schemas/EmploymentInputRequest"
          },
          "suspension": {
            "$ref": "#/components/schemas/SuspensionInputRequest"
          },
          "end": {
            "$ref": "#/components/schemas/EndInputRequest"
          },
          "event_date": {
            "type": "string",
            "format": "date",
            "description": "A change: the day it applies from. Default today."
          }
        },
        "required": [
          "kind"
        ]
      },
      "Suspension": {
        "type": "object",
        "description": "One suspension of an employment, as TÖR holds it.",
        "properties": {
          "suspension_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "start": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "reason_code": {
            "type": "string"
          },
          "reason_name": {
            "type": "string"
          }
        },
        "required": [
          "end",
          "reason_code",
          "reason_name",
          "start",
          "suspension_id"
        ]
      },
      "SuspensionInputRequest": {
        "type": "object",
        "description": "A suspension of an employment.",
        "properties": {
          "start_date": {
            "type": "string",
            "format": "date"
          },
          "reason_code": {
            "type": "integer",
            "minimum": 1,
            "description": "The suspension reason code of TÖR."
          },
          "end_date": {
            "type": "string",
            "format": "date"
          },
          "first_start_date": {
            "type": "string",
            "format": "date",
            "description": "When an existing suspension is changed: its first day as TÖR holds it."
          }
        },
        "required": [
          "reason_code",
          "start_date"
        ]
      },
      "TaxAccountAccessStatusEnum": {
        "enum": [
          "never",
          "ok",
          "rights_missing",
          "failed"
        ],
        "type": "string",
        "description": "* `never` - Never refreshed\n* `ok` - OK\n* `rights_missing` - Rights missing\n* `failed` - Failed"
      },
      "TaxAccountBalance": {
        "type": "object",
        "description": "The tax account of the company at EMTA, from the stored copy of the last successful refresh.",
        "properties": {
          "access_status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TaxAccountAccessStatusEnum"
              }
            ],
            "readOnly": true,
            "description": "How the last refresh went: `ok`; `rights_missing`, the company has not granted `ACCOUNTING_XROAD` to OscarAI in e-MTA; `failed`; `never`, no refresh yet.\n\n* `never` - Never refreshed\n* `ok` - OK\n* `rights_missing` - Rights missing\n* `failed` - Failed"
          },
          "access_error_code": {
            "type": "string",
            "readOnly": true,
            "description": "The code of the last failure; empty when ok."
          },
          "last_attempt_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "last_success_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "as_of": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "When the stored copy was read from EMTA; null before the first read."
          },
          "request_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true,
            "description": "The day of the balance at EMTA."
          },
          "total": {
            "type": [
              "string",
              "null"
            ],
            "format": "decimal",
            "pattern": "^-?\\d{0,16}(?:\\.\\d{0,2})?$",
            "readOnly": true,
            "description": "The balance of the claims. Above zero: the company owes it."
          },
          "interest": {
            "type": [
              "string",
              "null"
            ],
            "format": "decimal",
            "pattern": "^-?\\d{0,16}(?:\\.\\d{0,2})?$",
            "readOnly": true,
            "description": "The interest on the taxes not paid in time."
          },
          "prepayment_balance": {
            "type": [
              "string",
              "null"
            ],
            "format": "decimal",
            "pattern": "^-?\\d{0,16}(?:\\.\\d{0,2})?$",
            "readOnly": true,
            "description": "The balance of the prepayment account (E)."
          },
          "account_balances": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "format": "decimal",
              "pattern": "^-?\\d{0,16}(?:\\.\\d{0,2})?$"
            },
            "readOnly": true,
            "description": "The balance of each account by its EMTA code (E: the prepayment account)."
          },
          "claims": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxAccountClaim"
            },
            "readOnly": true
          },
          "notices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxAccountNotice"
            },
            "readOnly": true
          },
          "refresh_pending": {
            "type": "boolean",
            "readOnly": true,
            "description": "A refresh is queued or running."
          }
        },
        "required": [
          "access_error_code",
          "access_status",
          "account_balances",
          "as_of",
          "claims",
          "interest",
          "last_attempt_at",
          "last_success_at",
          "notices",
          "prepayment_balance",
          "refresh_pending",
          "request_date",
          "total"
        ],
        "x-oscarai-cli": {
          "title": "access_status",
          "columns": [
            "as_of",
            "access_status",
            "total",
            "interest",
            "prepayment_balance"
          ],
          "wide": [
            "request_date",
            "last_success_at",
            "last_attempt_at",
            "access_error_code"
          ],
          "status": {
            "field": "access_status",
            "roles": {
              "ok": "ok",
              "never": "muted",
              "rights_missing": "warn",
              "failed": "bad"
            }
          }
        }
      },
      "TaxAccountClaim": {
        "type": "object",
        "description": "One open claim of the tax account (`balanceOfClaimTypes`).",
        "properties": {
          "claim_type_code": {
            "type": "string",
            "readOnly": true,
            "description": "EMTA's claim type, for example `KM` (VAT)."
          },
          "tax_period_code": {
            "type": "string",
            "readOnly": true
          },
          "document_nr": {
            "type": "string",
            "readOnly": true
          },
          "document_type_code": {
            "type": "string",
            "readOnly": true,
            "description": "`KMD` or `TSD`, as EMTA names it."
          },
          "claim_identifier": {
            "type": "string",
            "readOnly": true
          },
          "balance": {
            "type": [
              "string",
              "null"
            ],
            "format": "decimal",
            "pattern": "^-?\\d{0,16}(?:\\.\\d{0,2})?$",
            "readOnly": true,
            "description": "The balance of the claim. Above zero: the company owes it."
          },
          "tax_period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true,
            "description": "The due date, from the stored movements of the claim; null when unknown."
          }
        },
        "required": [
          "balance",
          "claim_identifier",
          "claim_type_code",
          "document_nr",
          "document_type_code",
          "due_date",
          "tax_period_code",
          "tax_period_end"
        ],
        "x-oscarai-cli": {
          "title": "tax_period_code",
          "columns": [
            "tax_period_code",
            "claim_type_code",
            "document_type_code",
            "balance",
            "due_date"
          ],
          "wide": [
            "document_nr",
            "claim_identifier",
            "tax_period_end"
          ]
        }
      },
      "TaxAccountNotice": {
        "type": "object",
        "description": "A notice for the client: a tax debt, or a claim due within 7 days.",
        "properties": {
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TaxAccountNoticeKindEnum"
              }
            ],
            "readOnly": true
          },
          "amount": {
            "type": "string",
            "format": "decimal",
            "pattern": "^-?\\d{0,16}(?:\\.\\d{0,2})?$",
            "readOnly": true
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true
          },
          "claim_type_code": {
            "type": "string",
            "readOnly": true,
            "description": "Empty for a debt."
          },
          "tax_period_code": {
            "type": "string",
            "readOnly": true
          },
          "document_nr": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "amount",
          "claim_type_code",
          "document_nr",
          "due_date",
          "kind",
          "tax_period_code"
        ],
        "x-oscarai-cli": {
          "title": "kind",
          "columns": [
            "kind",
            "amount",
            "due_date",
            "claim_type_code",
            "tax_period_code"
          ],
          "wide": [
            "document_nr"
          ]
        }
      },
      "TaxAccountNoticeKindEnum": {
        "enum": [
          "debt",
          "claim_due_soon"
        ],
        "type": "string",
        "description": "* `debt` - Debt\n* `claim_due_soon` - Claim due soon"
      },
      "TorMessage": {
        "type": "object",
        "description": "A message of TÖR on a refused event, personal codes masked.",
        "properties": {
          "type": {
            "type": "string",
            "description": "`E` an error, `W` a warning."
          },
          "field": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "description",
          "field",
          "type"
        ]
      },
      "UiModeEnum": {
        "enum": [
          "simple",
          "advanced"
        ],
        "type": "string",
        "description": "* `simple` - Simple\n* `advanced` - Advanced"
      },
      "UploadRequest": {
        "type": "object",
        "description": "The multipart body of an upload.",
        "properties": {
          "file": {
            "type": "string",
            "format": "binary"
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BooksDocumentKindEnum"
              }
            ],
            "default": "other"
          },
          "received_on": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "bank_transaction_id": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "description": "The core ULID of the bank transaction this file explains (a receipt for a payment).",
            "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
          },
          "auto_process": {
            "type": "boolean",
            "default": false,
            "description": "The batch import. Every upload of an invoice, receipt or credit note is recorded and posted without a person when the extraction is confident and the company switch `invoice_auto_book` is on, and the reconciliation matcher links it to its bank line; `auto_process` also refuses the upload without `invoices.write` (403) and a file the extraction does not read: only a PDF of kind invoice, receipt or credit note (409 `not_extractable` otherwise). The post needs `invoices.post_purchase`. A draft that is not confident waits for a person. Follow it with `GET extractions/?file=`."
          }
        },
        "required": [
          "file"
        ]
      },
      "VatStatusEnum": {
        "enum": [
          "registered",
          "limited",
          "unregistered"
        ],
        "type": "string",
        "description": "* `registered` - VAT-registered\n* `limited` - Limited taxable person\n* `unregistered` - Not VAT-registered"
      }
    },
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An organization API key: `Authorization: Bearer osk_live_...`."
      },
      "cookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "sessionid"
      },
      "oauth2": {
        "type": "oauth2",
        "description": "An OAuth 2.1 access token (PKCE S256), bound to one organization.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "/oauth/authorize",
            "tokenUrl": "/oauth/token",
            "refreshUrl": "/oauth/token",
            "scopes": {
              "read": "Read the books",
              "write": "Change the books"
            }
          }
        }
      }
    }
  }
}
