{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:invoice-json:invoice-v1",
  "title": "Invoice v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "vendor_name",
    "tax_id",
    "invoice_number",
    "date",
    "currency",
    "line_items",
    "subtotal",
    "tax_amount",
    "total_due",
    "discounts",
    "shipping",
    "rounding",
    "amount_paid",
    "grand_total"
  ],
  "properties": {
    "vendor_name": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 512
    },
    "tax_id": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 512
    },
    "invoice_number": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 512
    },
    "date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "currency": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^[A-Z]{3}$"
    },
    "line_items": {
      "type": "array",
      "maxItems": 1000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "desc",
          "qty",
          "unit_price",
          "total"
        ],
        "properties": {
          "desc": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2048
          },
          "qty": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
          },
          "unit_price": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
          },
          "total": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
          }
        }
      }
    },
    "subtotal": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
    },
    "tax_amount": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
    },
    "total_due": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
    },
    "discounts": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
    },
    "shipping": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
    },
    "rounding": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
    },
    "amount_paid": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
    },
    "grand_total": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$"
    }
  }
}
