{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Ledger1099ReconciliationRequest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "tax_year",
    "jurisdiction",
    "ledger_basis",
    "ledger",
    "form_summaries",
    "mapping_policy"
  ],
  "properties": {
    "tax_year": {
      "const": 2026
    },
    "jurisdiction": {
      "const": "US-federal"
    },
    "ledger_basis": {
      "type": "string",
      "enum": [
        "gross_sales",
        "net_settlement"
      ]
    },
    "ledger": {
      "type": "array",
      "maxItems": 10000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "row_id",
          "vendor_id",
          "payment_date",
          "amount_cents",
          "channel"
        ],
        "properties": {
          "row_id": {
            "type": "string",
            "pattern": "^lr_[a-z0-9_]{1,47}$"
          },
          "vendor_id": {
            "type": "string",
            "pattern": "^v_[a-z0-9_]{1,47}$"
          },
          "payment_date": {
            "type": "string",
            "pattern": "^2026-[0-9]{2}-[0-9]{2}$"
          },
          "amount_cents": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9000000000000000
          },
          "channel": {
            "type": "string",
            "enum": [
              "payment_card",
              "third_party_network"
            ]
          }
        }
      }
    },
    "form_summaries": {
      "type": "array",
      "minItems": 1,
      "maxItems": 1000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "document_id",
          "vendor_id",
          "form_type",
          "box",
          "amount_cents",
          "correction_status"
        ],
        "properties": {
          "document_id": {
            "type": "string",
            "pattern": "^d_[a-z0-9_]{1,47}$"
          },
          "vendor_id": {
            "type": "string",
            "pattern": "^v_[a-z0-9_]{1,47}$"
          },
          "form_type": {
            "const": "1099-K"
          },
          "box": {
            "const": "1a"
          },
          "amount_cents": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9000000000000000
          },
          "correction_status": {
            "type": "string",
            "enum": [
              "original",
              "corrected",
              "superseded"
            ]
          }
        }
      }
    },
    "mapping_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "policy_id",
        "version",
        "comparison_mode",
        "channels",
        "allowed_adjustment_types"
      ],
      "properties": {
        "policy_id": {
          "type": "string",
          "pattern": "^pol_[a-z0-9_]{1,47}$"
        },
        "version": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+$"
        },
        "comparison_mode": {
          "type": "string",
          "enum": [
            "gross_to_gross",
            "net_to_gross_with_explicit_adjustments"
          ]
        },
        "channels": {
          "type": "array",
          "minItems": 1,
          "maxItems": 2,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "enum": [
              "payment_card",
              "third_party_network"
            ]
          }
        },
        "allowed_adjustment_types": {
          "type": "array",
          "maxItems": 7,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "enum": [
              "cash_equivalent",
              "credit",
              "discount",
              "fee",
              "other_explicit",
              "refund",
              "shipping"
            ]
          }
        }
      }
    },
    "adjustments": {
      "type": "array",
      "maxItems": 1000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "adjustment_id",
          "vendor_id",
          "type",
          "amount_cents",
          "direction",
          "source_ref"
        ],
        "properties": {
          "adjustment_id": {
            "type": "string",
            "pattern": "^adj_[a-z0-9_]{1,47}$"
          },
          "vendor_id": {
            "type": "string",
            "pattern": "^v_[a-z0-9_]{1,47}$"
          },
          "type": {
            "type": "string",
            "enum": [
              "cash_equivalent",
              "credit",
              "discount",
              "fee",
              "other_explicit",
              "refund",
              "shipping"
            ]
          },
          "amount_cents": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9000000000000000
          },
          "direction": {
            "type": "string",
            "enum": [
              "add_to_ledger_for_form_compare",
              "subtract_from_ledger_for_form_compare"
            ]
          },
          "source_ref": {
            "type": "string",
            "pattern": "^src_[a-z0-9_]{1,47}$"
          }
        }
      }
    },
    "tolerance_cents": {
      "type": "integer",
      "minimum": 0,
      "maximum": 1000000
    }
  }
}
