# Saudi Arabia ZATCA Tax Invoice (UBL)

Source: https://xmlvalid.com/schemas/sa-zatca-tax-invoice

> A Saudi tax invoice (B2B) for FATOORA, checked against the UBL 2.1 schema and the rules of ZATCA's SDK: EN 16931 as ZATCA adapts it and the KSA rules.

Saudi e-invoicing (FATOORA) has been in force since 4 December 2021, when businesses started to generate and keep invoices electronically. Since 1 January 2023, its second phase connects their systems to ZATCA's FATOORA platform, in waves by revenue. Invoices are UBL 2.1 XML.
A tax invoice, usually issued by one business to another, has InvoiceTypeCode 388 (381 for a credit note, 383 for a debit note, 386 for a prepayment) with a name starting 01. ZATCA validates it against the UBL schema, a subset of the EN 16931 rules and the KSA rules (BR-KSA-\*), which override EN 16931 where they differ.

- Type: XSD + Schematron
- Version: XML Implementation Standard 1.2, SDK 3.4.6 rules
- Namespace: `urn:oasis:names:specification:ubl:schema:xsd:Invoice-2`
- Root element: `Invoice`
- Publisher: ZATCA (Zakat, Tax and Customs Authority) (GNU LGPL 3.0 (the rules)), source: https://zatca.gov.sa/en/E-Invoicing/SystemsDevelopers/Pages/E-Invoice-specifications.aspx
- Rules: [EN 16931 rules as ZATCA ships them (UBL) SDK 3.4.6](https://xmlvalid.com/rules/sets/sa-zatca-en16931)
- Rules: [ZATCA e-invoicing rules (Saudi Arabia) SDK 3.4.6](https://xmlvalid.com/rules/sets/sa-zatca)
- Validate against it: https://xmlvalid.com/validate?schema=sa-zatca-tax-invoice

## Notes

- Rules run only when the document matches the schema. Documents over 50 MB are checked against the schema only.
- The rules are the two stylesheets of ZATCA's SDK 3.4.6: its copy of the EN 16931 rules and the KSA rules (20210819\_ZATCA\_E-invoice\_Validation\_Rules), both under the LGPL.
- The schema is UBL 2.1 with one change: the certificate serial number in the signature (X509SerialNumber) is read as an integer of any length. libxml2 reads integers of up to 24 digits, and ZATCA's certificates have longer serial numbers.
- ZATCA's SDK also checks the signature, the QR code and the invoice hash; those are not checked here, and clearance happens on the FATOORA platform.
- The example is the standard tax invoice of ZATCA's SDK 3.4.6, as phive-rules keeps the SDK's samples.
