{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/invoicecraftly/main/json-schema/invoicecraftly-public-document-v1-schema.json",
  "title": "PublicDocumentV1",
  "x-generated": "2026-09-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/invoicecraftly-openapi.json#/components/schemas/PublicDocumentV1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "type",
    "issueDate",
    "currency",
    "seller",
    "buyer",
    "items"
  ],
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "invoice"
      ],
      "description": "Only invoice is currently supported."
    },
    "number": {
      "type": "string"
    },
    "issueDate": {
      "type": "string",
      "format": "date"
    },
    "dueDate": {
      "type": "string",
      "format": "date"
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "locale": {
      "type": "string"
    },
    "template": {
      "type": "string",
      "enum": [
        "ledger"
      ],
      "description": "Only Ledger is currently supported."
    },
    "seller": {
      "$ref": "#/$defs/Party"
    },
    "buyer": {
      "$ref": "#/$defs/Party"
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/LineItem"
      }
    },
    "payment": {
      "$ref": "#/$defs/Payment"
    },
    "notes": {
      "type": "string"
    },
    "branding": {
      "$ref": "#/$defs/Branding"
    }
  },
  "$defs": {
    "Branding": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "accentColor": {
          "type": "string",
          "pattern": "^#[0-9a-fA-F]{3,8}$"
        },
        "stampStyle": {
          "type": "string",
          "enum": [
            "round",
            "square",
            "none"
          ]
        },
        "logo": {
          "$ref": "#/$defs/Logo"
        }
      }
    },
    "LineItem": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "description",
        "quantity",
        "unitPrice",
        "taxRate"
      ],
      "properties": {
        "description": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "unitPrice": {
          "type": "number",
          "minimum": 0
        },
        "taxRate": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "taxLabel": {
          "type": "string"
        }
      }
    },
    "Logo": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "data",
        "mimeType"
      ],
      "properties": {
        "data": {
          "type": "string",
          "contentEncoding": "base64",
          "description": "Base64 image data. Decoded size is limited to 512 KiB."
        },
        "mimeType": {
          "type": "string",
          "enum": [
            "image/png",
            "image/jpeg"
          ]
        }
      }
    },
    "Party": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "addressLines"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "addressLines": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "Payment": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "bankName": {
          "type": "string"
        },
        "iban": {
          "type": "string"
        },
        "bic": {
          "type": "string"
        },
        "accountNumber": {
          "type": "string"
        },
        "routingNumber": {
          "type": "string"
        },
        "reference": {
          "type": "string"
        },
        "poNumber": {
          "type": "string"
        },
        "terms": {
          "type": "string"
        },
        "dueText": {
          "type": "string"
        },
        "qrMode": {
          "type": "string",
          "enum": [
            "",
            "contact",
            "epc",
            "paymentLink"
          ]
        }
      }
    }
  }
}