This e-invoice reader decodes the QR code printed on invoices issued in Saudi Arabia, or the XML file a supplier sends, and lays out the invoice data as cards: seller, VAT number, date, total and VAT. It then checks each field: the VAT number format, that the total equals the amount before VAT plus the VAT, that the VAT comes to about 15%, and that the date is valid. It is built for the purchasing accountant who receives a supplier invoice and wants to be sure of its figures before booking it.
How reading an e-invoice QR code works
The QR code on an invoice holds Base64 text. Decoded, it becomes a TLV sequence: for each field, one byte for the tag, one for the length of the value, then the value. Tags 1 to 5 are the seller name, the seller VAT number, the date and time, the total including VAT and the VAT, according to the ZATCA FAQ. From the total and the VAT the reader works out the amount before VAT and the rate:
Net = Total − VAT · Rate = VAT ÷ Net
Checking a tax invoice: what the reader tests
| Check | In the QR code | In an XML file |
|---|---|---|
| Base64 format, TLV structure and field lengths | Yes | For the embedded code |
| VAT number has 15 digits starting and ending with 3 | Yes | Yes |
| Date is valid and not after today | Yes | Yes |
| Total = amount before VAT + VAT | VAT smaller than total | Yes, plus the line total |
| VAT is 15% of the amount before it | Yes | Yes |
| Phase: 5 tags, or 9 with signature | Yes | Signature present |
| Embedded code matches the file's amounts | — | Yes |
| Digital signature and stamp, and registration with ZATCA | Not checked here | |
The standard VAT rate in Saudi Arabia is 15%, but a rate that differs from it does not always mean the invoice is wrong: it may include an exempt or zero-rated line. That is why the result says Review rather than Error.
Reading an e-invoice from an XML file
A phase 2 invoice is an XML file in UBL 2.1 format, and the PDF copy the buyer sees is rendered from it. Open the file in the XML file tab or paste its content, and the reader pulls out the invoice number, its unique identifier (UUID), its type from the name attribute of InvoiceTypeCode (01 standard, 02 simplified), the seller name and VAT number, the amounts from LegalMonetaryTotal and TaxTotal, and the invoice lines. It then adds up the line nets and compares them with the totals, and decodes the QR code embedded in the file to match it against the amounts. The element paths follow the ZATCA XML implementation standard.
E-invoice QR code scanner from an image or a phone
The Read the code from an image button reads the code from a photo or screenshot if your browser supports code reading, as Chrome on Android and most recent desktop browsers do. If it does not, scan the code with your phone camera or any QR reader, copy the text it shows and paste it into the field. The image never leaves your device either way. The reader does not open PDF files directly, so take a screenshot of the code in the PDF.
Errors that reading an invoice QR code reveals
- A VAT number one digit short, or one that does not start and end with 3.
- The total in the code is before VAT instead of after it, so the VAT rate shows far above 15%.
- The code holds a web link instead of Base64, so no data can be read from it.
- The seller name length was counted in characters rather than bytes, so the name appears cut off or the fields run into each other.
- An XML file whose embedded code no longer matches the file's own amounts after the invoice was edited.
What to do after the check
If every check passes, book the invoice in your purchases. If the VAT number or the amounts show Error, send the invoice back to the supplier and ask for a corrected one before you claim its VAT on your return. Download the report as a PDF to file with the invoice or send to the supplier, and you can check the supplier's VAT number with ZATCA's verification service. To check a VAT number on its own, use the VAT number checker. To generate a code to compare against, use the ZATCA QR code generator.
When supplier invoices run into the dozens each month
Checking an invoice by hand works while there are only a few. Once supplier invoices arrive every day, what matters is that each one is booked once across purchasing, inventory and the accounts, and that its VAT matches your return. At Microtec we offer businesses in the Kingdom an ERP accounting system that brings purchasing, sales, inventory and finance together, and our solutions are approved by the Zakat, Tax and Customs Authority. Book supplier invoices in it as they arrive during the trial.