{
  "$defs": {
    "Account": {
      "description": "One GL account.",
      "properties": {
        "account_type": {
          "$ref": "#/$defs/AccountTypeEnum",
          "description": "Top-level classification."
        },
        "closed": {
          "anyOf": [
            {
              "$ref": "#/$defs/IsoDate"
            },
            {
              "type": "null"
            }
          ],
          "description": "When this account was closed (rare; typically archived not closed)."
        },
        "code": {
          "description": "Account code per the basis (e.g. SKR04 `\"1200\"`, US-GAAP\n`\"1010-Cash\"`).",
          "type": "string"
        },
        "currency_scope": {
          "$ref": "#/$defs/CurrencyScope",
          "description": "Currency scope."
        },
        "datev_skr_code": {
          "description": "SKR04 / SKR03 DATEV code.",
          "type": [
            "string",
            "null"
          ]
        },
        "ifrs_taxonomy_ref": {
          "description": "IFRS Foundation taxonomy concept reference.",
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "description": "Human-readable account name.",
          "type": "string"
        },
        "normal_balance": {
          "$ref": "#/$defs/NormalBalance",
          "description": "Normal-balance side."
        },
        "note": {
          "description": "Free-form note.",
          "type": [
            "string",
            "null"
          ]
        },
        "opened": {
          "$ref": "#/$defs/IsoDate",
          "description": "When this account was opened."
        },
        "parent": {
          "description": "Parent account code for hierarchical CoAs.",
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "$ref": "#/$defs/AccountStatus",
          "description": "Status."
        },
        "xbrl_concept": {
          "description": "Qualified XBRL concept name (`us-gaap:Cash`, `ifrs-full:CashAndCashEquivalents`).",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "code",
        "name",
        "account_type",
        "normal_balance",
        "currency_scope",
        "status",
        "opened"
      ],
      "type": "object"
    },
    "AccountStatus": {
      "description": "Account-record lifecycle status.",
      "enum": [
        "active",
        "archived"
      ],
      "type": "string"
    },
    "AccountTypeEnum": {
      "description": "Top-level account classification. Contra accounts are explicit\nvariants so balance signs are unambiguous.",
      "oneOf": [
        {
          "enum": [
            "asset",
            "liability",
            "equity",
            "income",
            "expense",
            "contra_asset",
            "contra_liability",
            "contra_equity",
            "contra_income",
            "contra_expense"
          ],
          "type": "string"
        },
        {
          "const": "memo",
          "description": "Memo / off-balance-sheet line used for tracking only.",
          "type": "string"
        }
      ]
    },
    "CoaBasis": {
      "description": "Accounting basis the CoA implements.",
      "oneOf": [
        {
          "const": "skr04",
          "description": "DATEV SKR04 (industry default for DE GmbH/UG).",
          "type": "string"
        },
        {
          "const": "skr03",
          "description": "DATEV SKR03 (legacy DE small-business default).",
          "type": "string"
        },
        {
          "const": "us_gaap",
          "description": "US Generally Accepted Accounting Principles.",
          "type": "string"
        },
        {
          "const": "ifrs",
          "description": "IFRS as issued by the IASB.",
          "type": "string"
        },
        {
          "const": "hgb_pkg",
          "description": "HGB Posten-Gliederung per §§266 / §275.",
          "type": "string"
        },
        {
          "const": "frs102",
          "description": "UK FRS 102 chart.",
          "type": "string"
        },
        {
          "const": "swiss_gaap_fer",
          "description": "Swiss GAAP FER.",
          "type": "string"
        },
        {
          "const": "custom",
          "description": "Adopter-defined custom chart.",
          "type": "string"
        }
      ]
    },
    "CurrencyScope": {
      "description": "Currency scope of postings to this account.",
      "oneOf": [
        {
          "const": "functional_only",
          "description": "Postings only in the entity's functional currency.",
          "type": "string"
        },
        {
          "const": "any",
          "description": "Multi-currency postings permitted (typical for cash and FX\nrevaluation accounts).",
          "type": "string"
        }
      ]
    },
    "IsoCurrency": {
      "description": "ISO 4217 currency code.",
      "pattern": "^[A-Z]{3}$",
      "type": "string"
    },
    "IsoDate": {
      "description": "ISO 8601 date (YYYY-MM-DD).",
      "format": "date",
      "type": "string"
    },
    "NormalBalance": {
      "description": "Normal-balance side of an account.",
      "enum": [
        "debit",
        "credit"
      ],
      "type": "string"
    },
    "PathRef": {
      "description": "Path-based cross-reference relative to .corpospec/ root.\nPattern: `^[a-z0-9_-]+(/[a-z0-9_.-]+)+$`",
      "pattern": "^[a-z0-9_-]+(/[a-z0-9_.-]+)+$",
      "type": "string"
    }
  },
  "$id": "https://corpospec.com/schemas/v0.16.0/coa.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Chart-of-Accounts record per BDR 0066 §1.\n\nOne per (entity, basis) tuple. The same entity may carry multiple CoAs\nwhen running parallel books under different frameworks (e.g. HGB local\n+ IFRS for group consolidation).",
  "properties": {
    "accounts": {
      "description": "Accounts in this chart. Order is by `code` lexicographically by\nconvention.",
      "items": {
        "$ref": "#/$defs/Account"
      },
      "type": "array"
    },
    "basis": {
      "$ref": "#/$defs/CoaBasis",
      "description": "Accounting basis."
    },
    "currency": {
      "$ref": "#/$defs/IsoCurrency",
      "description": "Functional currency of the books."
    },
    "effective_from": {
      "$ref": "#/$defs/IsoDate",
      "description": "When this CoA version took effect."
    },
    "effective_to": {
      "anyOf": [
        {
          "$ref": "#/$defs/IsoDate"
        },
        {
          "type": "null"
        }
      ],
      "description": "When this CoA version was superseded."
    },
    "entity": {
      "$ref": "#/$defs/PathRef",
      "description": "The legal entity whose books this CoA serves."
    },
    "id": {
      "$ref": "#/$defs/PathRef",
      "description": "PathRef identifier, conventionally\n`financials/chart-of-accounts/<entity>-<basis>`."
    },
    "version": {
      "description": "Free-form version label (e.g. `\"DATEV-2024-Q4\"`, `\"FASB-ASC-2024\"`).",
      "type": "string"
    }
  },
  "required": [
    "id",
    "entity",
    "basis",
    "version",
    "currency",
    "effective_from",
    "accounts"
  ],
  "title": "ChartOfAccounts",
  "type": "object",
  "x-corpospec-pillar": "financials"
}