{
 "type": "object",
 "properties": {
  "invoice_number": {
   "type": "string"
  },
  "issue_date": {
   "type": "string"
  },
  "due_date": {
   "type": "string"
  },
  "delivery_date": {
   "type": "string"
  },
  "service_period_start": {
   "type": "string"
  },
  "service_period_end": {
   "type": "string"
  },
  "invoice_type": {
   "type": "string",
   "description": "380 invoice, 381 credit note"
  },
  "currency": {
   "type": "string"
  },
  "buyer_reference": {
   "type": "string"
  },
  "order_reference": {
   "type": "string"
  },
  "seller": {
   "$ref": "#/$defs/party"
  },
  "buyer": {
   "$ref": "#/$defs/party"
  },
  "lines": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "description": {
      "type": "string"
     },
     "quantity": {
      "type": "number"
     },
     "unit": {
      "type": "string"
     },
     "unit_code": {
      "type": "string",
      "description": "UNECE Rec 20: C62 piece, HUR hour, DAY, MON month, ANN year, KGM, MTR, LTR"
     },
     "discount_amount": {
      "type": "number"
     },
     "unit_price": {
      "type": "number"
     },
     "net_amount": {
      "type": "number"
     },
     "vat_rate": {
      "type": "number"
     }
    }
   }
  },
  "vat_breakdown": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "rate": {
      "type": "number"
     },
     "taxable_amount": {
      "type": "number"
     },
     "vat_amount": {
      "type": "number"
     },
     "category": {
      "type": "string"
     }
    }
   }
  },
  "allowances_charges": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "is_charge": {
      "type": "boolean"
     },
     "amount": {
      "type": "number"
     },
     "vat_rate": {
      "type": "number"
     },
     "reason": {
      "type": "string"
     }
    }
   }
  },
  "total_net": {
   "type": "number"
  },
  "prepaid_amount": {
   "type": "number"
  },
  "total_vat": {
   "type": "number"
  },
  "total_gross": {
   "type": "number"
  },
  "amount_due": {
   "type": "number"
  },
  "payment": {
   "type": "object",
   "properties": {
    "iban": {
     "type": "string"
    },
    "bic": {
     "type": "string"
    },
    "account_name": {
     "type": "string"
    },
    "payment_reference": {
     "type": "string"
    },
    "terms": {
     "type": "string"
    }
   }
  }
 },
 "$defs": {
  "party": {
   "type": "object",
   "properties": {
    "name": {
     "type": "string"
    },
    "street": {
     "type": "string"
    },
    "postcode": {
     "type": "string"
    },
    "city": {
     "type": "string"
    },
    "country": {
     "type": "string",
     "description": "ISO 3166-1 alpha-2"
    },
    "vat_id": {
     "type": "string"
    },
    "tax_number": {
     "type": "string"
    },
    "email": {
     "type": "string"
    }
   }
  }
 },
 "required": [
  "invoice_number",
  "issue_date",
  "currency",
  "seller",
  "buyer",
  "total_gross"
 ]
}