{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://artifacts.apis.io/finisma-de/json-schema/finisma-de-invoice-schema.json",
  "title": "Invoice",
  "x-generated": "2026-11-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/finisma-de-openapi.json#/components/schemas/Invoice",
  "type": "object",
  "properties": {
    "invoiceNumber": {
      "type": "string",
      "minLength": 1,
      "maxLength": 60
    },
    "profile": {
      "type": "string",
      "enum": [
        "en16931",
        "xrechnung"
      ],
      "default": "en16931"
    },
    "documentTypeCode": {
      "type": "string",
      "default": "380"
    },
    "precedingInvoiceNumber": {
      "type": "string",
      "maxLength": 60
    },
    "precedingInvoiceDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "issueDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "dueDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "deliveryDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "deliveryCountryCode": {
      "type": "string",
      "minLength": 2,
      "maxLength": 2
    },
    "delivery": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 200
        },
        "gln": {
          "type": "string",
          "maxLength": 20
        },
        "address": {
          "type": "object",
          "properties": {
            "line1": {
              "type": "string",
              "maxLength": 150
            },
            "line2": {
              "type": "string",
              "maxLength": 150
            },
            "postalCode": {
              "type": "string",
              "maxLength": 20
            },
            "city": {
              "type": "string",
              "maxLength": 100
            },
            "countryCode": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "currency": {
      "type": "string",
      "minLength": 3,
      "maxLength": 3,
      "default": "EUR"
    },
    "buyerReference": {
      "type": "string",
      "maxLength": 80
    },
    "costCenter": {
      "type": "string",
      "maxLength": 60
    },
    "purchaseOrderReference": {
      "type": "string",
      "maxLength": 60
    },
    "contractReference": {
      "type": "string",
      "maxLength": 200
    },
    "invoicingPeriod": {
      "type": "object",
      "properties": {
        "start": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "end": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        }
      },
      "additionalProperties": false
    },
    "projectReference": {
      "type": "string",
      "maxLength": 200
    },
    "despatchAdviceRef": {
      "type": "string",
      "maxLength": 200
    },
    "receivingAdviceRef": {
      "type": "string",
      "maxLength": 200
    },
    "allowanceCharges": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "charge": {
            "type": "boolean",
            "description": "true = Zuschlag (BG-21), false = Abzug/Nachlass (BG-20)."
          },
          "amount": {
            "type": "number",
            "minimum": 0,
            "description": "BT-92/BT-99: Betrag ohne Vorzeichen. Darf fehlen, wenn percent gesetzt ist: dann gilt round2(basisAmount × percent / 100)."
          },
          "basisAmount": {
            "type": "number",
            "description": "BT-93/BT-100: Grundbetrag des Prozentsatzes. Ohne Angabe die Summe der lineNetAmount aller Positionen mit ratePercent (bei gemischten Kategorien desselben Satzes nur die mit categoryCode)."
          },
          "percent": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "BT-94/BT-101: Prozentsatz, z. B. 2 für 2 % Nachlass."
          },
          "categoryCode": {
            "type": "string",
            "maxLength": 12,
            "default": "S"
          },
          "ratePercent": {
            "type": "number",
            "description": "BT-96/BT-103: Steuersatz in Prozent. Darf beim Prozent-Eintrag ohne basisAmount fehlen, wenn alle Positionen denselben Satz haben."
          },
          "reason": {
            "type": "string",
            "maxLength": 200
          },
          "reasonCode": {
            "type": "string",
            "maxLength": 10
          }
        },
        "required": [
          "charge"
        ],
        "additionalProperties": false
      },
      "maxItems": 50
    },
    "seller": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "vatId": {
          "type": "string",
          "maxLength": 20
        },
        "gln": {
          "type": "string",
          "maxLength": 20
        },
        "registrationId": {
          "type": "string",
          "maxLength": 60,
          "description": "BT-30 (Verkäufer) / BT-47 (Käufer): Handelsregisternummer bzw. Registerkennung der Partei, z. B. \"HRB 12345, Amtsgericht München\". Nur angeben, wenn sie auf der Rechnung steht. Beim Käufer reicht sie bei Reverse Charge (Kategorie AE) statt der USt-IdNr., bei innergemeinschaftlicher Lieferung (K) nicht."
        },
        "address": {
          "type": "object",
          "properties": {
            "line1": {
              "type": "string",
              "maxLength": 150
            },
            "line2": {
              "type": "string",
              "maxLength": 150
            },
            "city": {
              "type": "string",
              "maxLength": 100
            },
            "postalCode": {
              "type": "string",
              "maxLength": 20
            },
            "countryCode": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2,
              "default": "DE"
            }
          },
          "additionalProperties": false,
          "default": {}
        },
        "contact": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "maxLength": 150
            },
            "email": {
              "type": "string",
              "maxLength": 150
            },
            "phone": {
              "type": "string",
              "maxLength": 40
            }
          },
          "additionalProperties": false
        },
        "electronicAddress": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "scheme": {
              "type": "string",
              "maxLength": 10,
              "default": "EM"
            }
          },
          "required": [
            "id"
          ],
          "additionalProperties": false
        },
        "customerAssignedId": {
          "type": "string",
          "maxLength": 100
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false
    },
    "buyer": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "vatId": {
          "type": "string",
          "maxLength": 20
        },
        "gln": {
          "type": "string",
          "maxLength": 20
        },
        "registrationId": {
          "type": "string",
          "maxLength": 60,
          "description": "BT-30 (Verkäufer) / BT-47 (Käufer): Handelsregisternummer bzw. Registerkennung der Partei, z. B. \"HRB 12345, Amtsgericht München\". Nur angeben, wenn sie auf der Rechnung steht. Beim Käufer reicht sie bei Reverse Charge (Kategorie AE) statt der USt-IdNr., bei innergemeinschaftlicher Lieferung (K) nicht."
        },
        "address": {
          "type": "object",
          "properties": {
            "line1": {
              "type": "string",
              "maxLength": 150
            },
            "line2": {
              "type": "string",
              "maxLength": 150
            },
            "city": {
              "type": "string",
              "maxLength": 100
            },
            "postalCode": {
              "type": "string",
              "maxLength": 20
            },
            "countryCode": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2,
              "default": "DE"
            }
          },
          "additionalProperties": false,
          "default": {}
        },
        "contact": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "maxLength": 150
            },
            "email": {
              "type": "string",
              "maxLength": 150
            },
            "phone": {
              "type": "string",
              "maxLength": 40
            }
          },
          "additionalProperties": false
        },
        "electronicAddress": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "scheme": {
              "type": "string",
              "maxLength": 10,
              "default": "EM"
            }
          },
          "required": [
            "id"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          },
          "quantity": {
            "type": "number"
          },
          "unitCode": {
            "type": "string",
            "maxLength": 12,
            "default": "C62"
          },
          "sellerArticleId": {
            "type": "string",
            "maxLength": 200
          },
          "buyerArticleId": {
            "type": "string",
            "maxLength": 200
          },
          "globalArticleId": {
            "type": "string",
            "maxLength": 60
          },
          "globalArticleScheme": {
            "type": "string",
            "maxLength": 10,
            "pattern": "^[0-9A-Za-z]+$"
          },
          "unitPriceNet": {
            "type": "number"
          },
          "vatRatePercent": {
            "type": "number"
          },
          "categoryCode": {
            "type": "string",
            "maxLength": 12
          },
          "allowanceCharges": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "charge": {
                  "type": "boolean",
                  "description": "true = Zuschlag (BG-28), false = Abzug/Rabatt (BG-27)."
                },
                "amount": {
                  "type": "number",
                  "minimum": 0,
                  "description": "BT-136/BT-141: Betrag ohne Vorzeichen. Darf fehlen, wenn percent gesetzt ist: dann gilt round2(basisAmount × percent / 100)."
                },
                "basisAmount": {
                  "type": "number",
                  "description": "BT-137/BT-142: Grundbetrag des Prozentsatzes. Ohne Angabe Menge × unitPriceNet der Position (je Eintrag, nicht gestaffelt)."
                },
                "percent": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100,
                  "description": "BT-138/BT-143: Prozentsatz, z. B. 10 für 10 % Rabatt."
                },
                "reason": {
                  "type": "string",
                  "maxLength": 200
                },
                "reasonCode": {
                  "type": "string",
                  "maxLength": 10
                }
              },
              "required": [
                "charge"
              ],
              "additionalProperties": false
            },
            "maxItems": 10
          },
          "lineNetAmount": {
            "type": "number"
          }
        },
        "required": [
          "name",
          "quantity",
          "unitPriceNet",
          "vatRatePercent",
          "lineNetAmount"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 500
    },
    "vatBreakdown": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ratePercent": {
            "type": "number"
          },
          "basisAmount": {
            "type": "number"
          },
          "taxAmount": {
            "type": "number"
          },
          "categoryCode": {
            "type": "string",
            "maxLength": 12,
            "default": "S"
          },
          "exemptionReason": {
            "type": "string",
            "maxLength": 500
          },
          "exemptionReasonCode": {
            "type": "string",
            "maxLength": 30
          }
        },
        "required": [
          "ratePercent",
          "basisAmount",
          "taxAmount"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 50
    },
    "totalNet": {
      "type": "number"
    },
    "totalVat": {
      "type": "number"
    },
    "totalGross": {
      "type": "number"
    },
    "paidAmount": {
      "type": "number",
      "minimum": 0
    },
    "notes": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "maxLength": 1000
          },
          {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "maxLength": 1000
              },
              "subjectCode": {
                "type": "string"
              }
            },
            "required": [
              "text"
            ],
            "additionalProperties": false
          }
        ]
      },
      "maxItems": 20
    },
    "taxCurrencyCode": {
      "type": "string",
      "minLength": 3,
      "maxLength": 3
    },
    "totalVatInTaxCurrency": {
      "type": "number"
    },
    "payee": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "gln": {
          "type": "string",
          "maxLength": 20
        },
        "registrationId": {
          "type": "string",
          "maxLength": 60
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false
    },
    "payment": {
      "type": "object",
      "properties": {
        "terms": {
          "type": "string",
          "maxLength": 1000
        },
        "iban": {
          "type": "string",
          "maxLength": 40,
          "pattern": "^[A-Za-z0-9 ]*$"
        },
        "bic": {
          "type": "string",
          "maxLength": 15,
          "pattern": "^[A-Za-z0-9 ]*$"
        },
        "reference": {
          "type": "string",
          "maxLength": 140
        },
        "meansCode": {
          "type": "string"
        },
        "mandateId": {
          "type": "string",
          "maxLength": 35
        },
        "creditorId": {
          "type": "string",
          "maxLength": 35
        },
        "debitedIban": {
          "type": "string",
          "maxLength": 40,
          "pattern": "^[A-Za-z0-9 ]*$"
        },
        "accountName": {
          "type": "string",
          "maxLength": 200
        },
        "discountPercent": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "discountDays": {
          "type": "integer",
          "minimum": 0,
          "maximum": 999
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "invoiceNumber",
    "issueDate",
    "seller",
    "buyer",
    "lines",
    "vatBreakdown",
    "totalNet",
    "totalVat",
    "totalGross"
  ],
  "additionalProperties": false
}