Skip to main content
BR-KSA-61ErrorZATCA Phase 2 UBL 2.1implemented

Previous Invoice Hash (PIH) Element Mandatory (KSA-13)

Every Phase 2 invoice must contain an AdditionalDocumentReference with cbc:ID='PIH' carrying the previous invoice hash.

Scope
Hash Chain & Security
Applicable Invoice Types
Standard (B2B), Simplified (B2C), Credit Note, Debit Note
Catalog Version
v1.0.0 (2026-11-23)
Target XPath
/Invoice/cac:AdditionalDocumentReference[cbc:ID='PIH']/cac:Attachment/cbc:EmbeddedDocumentBinaryObject

Typical Reason for Failure

First invoice from a newly onboarded POS skips the PIH node instead of hashing '0'.

Invalid Synthetic Example

Before (Fails)xml
<!-- Missing PIH AdditionalDocumentReference -->

Corrected Synthetic Example

After (Fixed)xml
<cac:AdditionalDocumentReference><cbc:ID>PIH</cbc:ID><cac:Attachment><cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==</cbc:EmbeddedDocumentBinaryObject></cac:Attachment></cac:AdditionalDocumentReference>

Explanation of the Fix

Always include PIH; use Base64(SHA256('0')) for ICV=1.

Official Source Reference

ZATCA Electronic Invoice XML Implementation Standard (Phase 2)

Open official specification

Related Rules

Test your invoice against BR-KSA-61 now

Browser quick check; raw XML is never stored.

Open Validator