Skip to content
E-invoicing in Saudi Arabia (FATOORA)

The previous invoice hash (PIH) and the document chain

Each document carries the hash of the one before it from the same device, so documents form a chain in which any deletion or change shows.

The controls require the issuing unit to put a hash on each document together with the hash of the previous one. If a document is deleted, the next hash no longer matches anything; if one is altered, its hash changes and the chain breaks after it.

The first document of a device's chain carries a fixed value from the standard: the base64 of the hexadecimal hash of "0". Note that this value is base64 of 64 characters of text, whereas later documents' hashes are base64 of 32 bytes.

Rejected documents are part of the chain: the platform records their hashes, so the next document points to them. Documents need not be submitted in the order they were issued, as long as each points to the one issued immediately before it.

In JooDax

Built

Each unit keeps the last document's hash and writes it into the next inside the same transaction, starting from the genesis value, which matches the standard exactly. A unit test checks that the second document carries the first one's hash.

crates/jdx-einvoice-sa/src/unit.rs

Questions and answers

If document 2 is rejected and resent after document 3, which does it point to?

The resent document points to document 3, and document 3 still points to the rejected document 2, per the technical guidelines' example.

Related pages

Related concepts

E-invoicing in Saudi Arabia (FATOORA)

Sources

  1. الضوابط والمتطلبات والمواصفات الفنية والقواعد الإجرائية اللازمة لتنفيذ أحكام لائحة الفوترة الإلكترونية (قرار المحافظ رقم 62738 وتاريخ 1443/11/23هـ) (vfile dated 20230519 (decision 62738)) — ZATCA
  2. Electronic Invoice XML Implementation Standard to the E-Invoicing resolution dated 2023-05-19 (v1.2) — ZATCA
  3. Security Features Implementation Standards to the E-Invoicing resolution dated 2023-05-19 (v1.2) — ZATCA
  4. E-invoicing Detailed Technical Guidelines (vVersion 2) — ZATCA

Checked on: 4 November 2026. What concerns JooDax is taken from the programs’ own code.