{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Q04 settlement input schema",
  "description": "Strict input shape. Blank templates are preparation scaffolds, not runnable inputs.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "matter_id",
    "currency",
    "gross_cents",
    "approved_lines",
    "draft_lines",
    "draft_net_cents"
  ],
  "properties": {
    "matter_id": {
      "type": "string",
      "minLength": 1
    },
    "currency": {
      "type": "string",
      "minLength": 1
    },
    "gross_cents": {
      "type": "integer",
      "minimum": 0
    },
    "approved_lines": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "line_id",
          "category",
          "amount_cents",
          "source_ref",
          "approved_by",
          "status"
        ],
        "properties": {
          "line_id": {
            "type": "string",
            "minLength": 1
          },
          "category": {
            "type": "string",
            "enum": [
              "fee",
              "cost",
              "lien",
              "reserve",
              "other"
            ]
          },
          "amount_cents": {
            "type": "integer",
            "minimum": 0
          },
          "source_ref": {
            "type": "string"
          },
          "approved_by": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "approved",
              "unresolved"
            ]
          }
        }
      }
    },
    "draft_lines": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "line_id",
          "amount_cents"
        ],
        "properties": {
          "line_id": {
            "type": "string",
            "minLength": 1
          },
          "amount_cents": {
            "type": "integer",
            "minimum": 0
          }
        }
      }
    },
    "draft_net_cents": {
      "type": "integer"
    }
  }
}
