{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ordogrid/json-schema/ordogrid-receipt-create-schema.json",
  "title": "ReceiptCreate",
  "description": "Supply either client_id or inline client. Omit number for automatic company numbering. Unknown fields are rejected.",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ordogrid-openapi.json#/components/schemas/ReceiptCreate",
  "additionalProperties": false,
  "allOf": [
    {
      "oneOf": [
        {
          "not": {
            "required": [
              "client"
            ]
          },
          "required": [
            "client_id"
          ]
        },
        {
          "not": {
            "required": [
              "client_id"
            ]
          },
          "required": [
            "client"
          ]
        }
      ]
    }
  ],
  "properties": {
    "attachments": {
      "items": {
        "$ref": "#/$defs/InlineFile"
      },
      "type": "array"
    },
    "client": {
      "$ref": "#/$defs/ParticipantInput"
    },
    "client_id": {
      "pattern": "^[a-fA-F0-9]{24}$",
      "type": "string"
    },
    "communication": {
      "type": "string"
    },
    "currency": {
      "type": "string"
    },
    "due_date": {
      "description": "ISO-8601 date or datetime.",
      "type": [
        "string",
        "null"
      ]
    },
    "external_id": {
      "description": "Durable company/integration document identity. Required for crash/key-rotation recovery guarantees.",
      "maxLength": 200,
      "type": "string"
    },
    "global_discount": {
      "$ref": "#/$defs/DiscountInput"
    },
    "issue_date": {
      "description": "ISO-8601 date or datetime.",
      "type": [
        "string",
        "null"
      ]
    },
    "items": {
      "items": {
        "$ref": "#/$defs/DocumentItemInput"
      },
      "minItems": 1,
      "type": "array"
    },
    "note": {
      "type": "string"
    },
    "number": {
      "type": "string"
    },
    "payment_date": {
      "description": "ISO-8601 date or datetime.",
      "type": [
        "string",
        "null"
      ]
    },
    "payment_method": {
      "description": "Receipts only.",
      "type": "string"
    },
    "pdf": {
      "allOf": [
        {
          "$ref": "#/$defs/InlineFile"
        }
      ],
      "description": "Your own rendering of this document. It replaces the PDF we would have generated, so it is what gets archived, e-mailed and attached to a Peppol transmission. The structured fields still drive the UBL."
    },
    "prices_include_vat": {
      "type": "boolean"
    },
    "purchase_order": {
      "type": "string"
    },
    "supplier": {
      "anyOf": [
        {
          "$ref": "#/$defs/ParticipantInput"
        },
        {
          "type": "null"
        }
      ]
    },
    "transaction_reference": {
      "description": "Receipts only.",
      "type": "string"
    }
  },
  "required": [
    "items",
    "currency"
  ],
  "type": "object",
  "$defs": {
    "AddressInput": {
      "additionalProperties": false,
      "properties": {
        "city": {
          "minLength": 1,
          "type": "string"
        },
        "country": {
          "description": "ISO 3166-1 alpha-2 code, e.g. BE. A country name in French, Dutch, English or German is accepted and stored as its code; an unknown country is a 400 INVALID_COUNTRY.",
          "minLength": 1,
          "type": "string"
        },
        "postal_code": {
          "minLength": 1,
          "type": "string"
        },
        "street": {
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "street",
        "city",
        "postal_code",
        "country"
      ],
      "type": "object"
    },
    "DiscountInput": {
      "additionalProperties": false,
      "properties": {
        "amount_basis": {
          "default": "net",
          "description": "Basis of a fixed discount; existing inputs default to net.",
          "enum": [
            "net",
            "gross"
          ],
          "type": "string"
        },
        "type": {
          "default": "percentage",
          "enum": [
            "percentage",
            "fixed"
          ],
          "type": "string"
        },
        "value": {
          "description": "Exact decimal values may be strings. Non-negative; percentages at most 100.",
          "type": [
            "number",
            "string"
          ]
        }
      },
      "required": [
        "value"
      ],
      "type": "object"
    },
    "DocumentItemInput": {
      "additionalProperties": false,
      "anyOf": [
        {
          "properties": {
            "vat_rate": {
              "type": [
                "number",
                "string"
              ]
            }
          },
          "required": [
            "vat_rate"
          ]
        },
        {
          "properties": {
            "vat_type": {
              "type": "string"
            }
          },
          "required": [
            "vat_type"
          ]
        }
      ],
      "properties": {
        "description": {
          "type": "string"
        },
        "discount": {
          "$ref": "#/$defs/DiscountInput"
        },
        "margin_scheme": {
          "$ref": "#/$defs/MarginScheme"
        },
        "price_basis": {
          "default": "net",
          "enum": [
            "net",
            "gross"
          ],
          "type": "string"
        },
        "quantity": {
          "type": [
            "number",
            "string"
          ]
        },
        "source_unit_price": {
          "description": "Exact entered price in price_basis. Gross prices are authoritative; unit_price remains the compatible net price.",
          "type": "string"
        },
        "unit": {
          "description": "UN/ECE code, e.g. C62 (piece).",
          "type": [
            "string",
            "null"
          ]
        },
        "unit_price": {
          "type": [
            "number",
            "string"
          ]
        },
        "vat_rate": {
          "description": "Decimal tax rate. Either vat_rate or vat_type must be non-null.",
          "type": [
            "number",
            "string",
            "null"
          ]
        },
        "vat_type": {
          "enum": [
            "standard",
            "exempt",
            "exempt_art44",
            "reverse_charge",
            "cocontractant",
            "intracommunity",
            "zero_rated",
            "export",
            "margin",
            null
          ],
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "description",
        "quantity",
        "unit_price"
      ],
      "type": "object"
    },
    "InlineFile": {
      "description": "A file sent inline. Maximum 5MB decoded.",
      "properties": {
        "content_base64": {
          "contentEncoding": "base64",
          "minLength": 1,
          "type": "string"
        },
        "filename": {
          "type": "string"
        },
        "mime_type": {
          "type": "string"
        }
      },
      "required": [
        "filename",
        "content_base64"
      ],
      "type": "object"
    },
    "MarginScheme": {
      "additionalProperties": false,
      "properties": {
        "jurisdiction": {
          "const": "BE"
        },
        "profile": {
          "const": "peppol_bis_billing_3"
        },
        "purchase_price": {
          "description": "Non-negative purchase price; at most two decimal places for the supported EUR profile.",
          "oneOf": [
            {
              "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
              "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
              "type": "string"
            },
            {
              "type": "number"
            }
          ]
        },
        "purchase_reference": {
          "maxLength": 128,
          "minLength": 1,
          "type": "string"
        },
        "scheme": {
          "const": "second_hand_goods"
        },
        "supplier_status": {
          "const": "private_person"
        },
        "tax_rate": {
          "description": "Supported rate is exactly 21. Decimal strings such as 21, 21.0 and 21.00 are accepted.",
          "oneOf": [
            {
              "const": 21
            },
            {
              "type": "string"
            }
          ]
        }
      },
      "required": [
        "scheme",
        "jurisdiction",
        "profile",
        "purchase_price",
        "purchase_reference",
        "supplier_status",
        "tax_rate"
      ],
      "type": "object"
    },
    "ParticipantInput": {
      "additionalProperties": false,
      "properties": {
        "address": {
          "anyOf": [
            {
              "$ref": "#/$defs/AddressInput"
            },
            {
              "type": "null"
            }
          ]
        },
        "bic": {
          "type": [
            "string",
            "null"
          ]
        },
        "email": {
          "type": [
            "string",
            "null"
          ]
        },
        "iban": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "minLength": 1,
          "type": "string"
        },
        "phone": {
          "type": [
            "string",
            "null"
          ]
        },
        "vat_number": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    }
  }
}