Previous invoice hash (PIH)
The base64 hash of the previous document from the same device, linking documents into a chain.
Each document carries the fingerprint of the one before it, so deleting or altering a document breaks the chain. BR-KSA-61 requires the field and BR-KSA-26 sets the method: remove the UBLExtensions block, the QR reference block and the cac:Signature block, canonicalize with C14N11, hash with SHA-256, encode in base64.
The first document of a device's chain has no predecessor and carries a fixed value from the standard: NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==, the base64 of the hexadecimal SHA-256 of the character "0".
Rejected documents stay in the chain: the technical guidelines say the platform records their hashes, so the next document must point to the rejected one, not to the one before it. There is no need to wait for clearance before issuing the next document, since ZATCA's stamp does not change the hash.
| Identifier | KSA-13 |
|---|---|
| Path in the document | /Invoice/cac:AdditionalDocumentReference[cbc:ID='PIH']/cac:Attachment/cbc:EmbeddedDocumentBinaryObject |
| Cardinality | 0..1 |
| Data type | Binary (base64) |
| Applies to | Standard tax invoice and Simplified tax invoice |
In JooDax
BuiltEach unit keeps the hash of its last document and writes it into the next, starting from the standard's fixed value; the unit tests check that each document carries its predecessor's hash.
crates/jdx-einvoice-sa/src/unit.rs
Applies to
| Tax invoice | Debit note | Credit note | Simplified | Simplified debit | Simplified credit |
|---|---|---|---|---|---|
| Mandatory | Mandatory | Mandatory | Mandatory | Mandatory | Mandatory |
Rules that check it
Related fields
Fields — E-invoicing in Saudi Arabia (FATOORA)
Sources
- Electronic Invoice XML Implementation Standard to the E-Invoicing resolution dated 2023-05-19 (v1.2) — ZATCA
- Electronic Invoice Data Dictionary to the E-Invoicing resolution dated 2023-05-19 (v1.2) — ZATCA
- Security Features Implementation Standards to the E-Invoicing resolution dated 2023-05-19 (v1.2) — ZATCA
- E-invoicing Detailed Technical Guidelines (vVersion 2) — ZATCA
Checked on: 4 November 2026. What concerns JooDax is taken from the programs’ own code.