BR-KSA-61: Every invoice needs the previous invoice hash (PIH, KSA-13)
The invoice must contain a cac:AdditionalDocumentReference with cbc:ID 'PIH' whose cac:Attachment has a non-empty cbc:EmbeddedDocumentBinaryObject with mimeCode='text/plain'.
How to fix it
Add <cac:AdditionalDocumentReference><cbc:ID>PIH</cbc:ID><cac:Attachment><cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">…</cbc:EmbeddedDocumentBinaryObject></cac:Attachment></cac:AdditionalDocumentReference> with the previous invoice's hash.
ZATCA's official text
[BR-KSA-61]-Previous invoice hash (KSA-13) must exist in an invoice.
Source: ZATCA SDK 3.4.8 · ZATCA KSA rules
Fails when (the condition ZATCA's SDK runs)
not((cac:AdditionalDocumentReference[normalize-space(cbc:ID) = 'PIH'] and exists(cac:AdditionalDocumentReference[normalize-space(cbc:ID) = 'PIH']/cac:Attachment/cbc:EmbeddedDocumentBinaryObject) and (cac:AdditionalDocumentReference[normalize-space(cbc:ID) = 'PIH']/cac:Attachment/cbc:EmbeddedDocumentBinaryObject) != '' and (cac:AdditionalDocumentReference[normalize-space(cbc:ID) = 'PIH']/cac:Attachment/cbc:EmbeddedDocumentBinaryObject[normalize-space(@mimeCode) = 'text/plain'])))
Related rules
- BR-KSA-26 · Previous invoice hash (PIH) attachment must be filled, text/plain
- BR-KSA-53 · Each line needs a line amount with VAT (KSA-12) on standard invoices
- BR-KSA-56 · Credit and debit notes must reference the original invoice (BT-25)
- BR-KSA-60 · Simplified invoices must include the cac:Signature block (KSA-15)
- BR-KSA-63 · Saudi buyer needs a full national address on standard invoices
- BR-KSA-66 · Seller postal code (BT-38) must be exactly 5 digits
Validate your invoice against ZATCA's rules
Paste the XML and see every error and warning. It runs in your browser; the invoice goes nowhere.
Validate an invoice or try Matheel