{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/journalize-dev/json-schema/journalize-dev-balance-sheet-response-schema.json",
  "title": "BalanceSheetResponse",
  "description": "Mirrors reports.ReportResult for GET /reports/balance-sheet.\naccepted=True with a non-empty errors list is a valid, billable\nresponse (§7) — e.g. missing price directives — not a failure.",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/journalize-dev-openapi.json#/components/schemas/BalanceSheetResponse",
  "properties": {
    "accepted": {
      "type": "boolean",
      "title": "Accepted"
    },
    "doc": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/RealAccountEntry"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Doc"
    },
    "errors": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Errors"
    },
    "free_reports_remaining": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Free Reports Remaining"
    }
  },
  "type": "object",
  "required": [
    "accepted"
  ],
  "$defs": {
    "Cost": {
      "properties": {
        "number": {
          "type": "string",
          "title": "Number"
        },
        "currency": {
          "type": "string",
          "title": "Currency"
        },
        "date": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Date"
        },
        "label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Label"
        }
      },
      "type": "object",
      "required": [
        "number",
        "currency"
      ],
      "title": "Cost"
    },
    "InventoryPosition": {
      "properties": {
        "number": {
          "type": "string",
          "title": "Number"
        },
        "currency": {
          "type": "string",
          "title": "Currency"
        },
        "cost": {
          "anyOf": [
            {
              "$ref": "#/$defs/Cost"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "number",
        "currency"
      ],
      "title": "InventoryPosition"
    },
    "RealAccountEntry": {
      "properties": {
        "account": {
          "type": "string",
          "title": "Account"
        },
        "parent": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Parent"
        },
        "balance": {
          "items": {
            "$ref": "#/$defs/InventoryPosition"
          },
          "type": "array",
          "title": "Balance"
        }
      },
      "type": "object",
      "required": [
        "account"
      ],
      "title": "RealAccountEntry",
      "description": "One entry in the flat adjacency list reports._serialize_real_account()\nnow emits — was a recursive nested tree (RealAccountNode, containing a\ndict of RealAccountNode) until a real, confirmed problem: that shape\nrequires a genuinely self-referential OpenAPI schema, which x402scan's\nown API scanner (reading /openapi.json as its primary source) choked\non with \"Maximum call stack size exceeded\" — confirmed directly, not\nguessed: a naive \"fully substitute every $ref\" resolver hits actual\nunbounded recursion against a self-referential schema, since there's\nno way to inline a genuine cycle into a finite structure.\n\n`parent` is the immediate parent's full account name (None for a\ntop-level account like \"Assets\" or \"Expenses\") — an explicit\nadjacency-list pointer, even though it's technically redundant with\n`account` itself (Beancount account names are colon-separated paths,\nso the parent is always \"drop the last segment\"). Included anyway so\na consumer doesn't have to parse that convention themselves just to\nreconstruct the tree.\n\n`number` fields inside `balance` stay strings end-to-end (see module\ndocstring) — never re-parsed into a JSON float anywhere on the\nresponse path."
    }
  }
}