Previous invoice hash (KSA-13) must exist in an invoice.
What does this mean?
The difference between this code and BR-KSA-26 is small and important: there the value is present but wrongly formatted, here the field is missing altogether. The Authority looks for the cac:AdditionalDocumentReference block whose identifier is PIH and does not find it.
Why does it happen?
Ordered from the most common to the least — your cause is most likely the first or the second.
- The XML template has no PIH block at all — common in systems built from a Phase 1 example and upgraded later.
-
The block is there but its
<cbc:EmbeddedDocumentBinaryObject>is empty. -
The block identifier written in lower case as
pih, or under a different name; the identifier is case sensitive. - Dropping the block deliberately on the first invoice because there is no previous invoice — which is wrong: the first invoice has a fixed value.
How to fix it
2 steps, then send the invoice again.
-
1
Add the block with the correct identifier
The invoice must contain a
cac:AdditionalDocumentReferencewith<cbc:ID>PIH</cbc:ID>, holding acac:Attachmentand inside it a<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">carrying the hash in Base64. -
2
Put the fixed value on the first invoice
The value for the first invoice is the Base64 hash of the character 0 — see BR-KSA-26 for the full string. Do not leave the field empty and do not remove it.
This code does not block acceptance, so the invoice you have is compliant. Correct the data so the warnings disappear from future invoices.
Does ZATCA Tools prevent it?
Yes. The field is built automatically on every invoice ZATCA Tools issues, and the first invoice takes the fixed value without any action from you.
Related codes
Frequently asked questions
Is this code a warning or an error? +
How does the hash relate to the invoice counter (ICV)? +
ZATCA Tools builds the signature, the PIH, the counter and the encoding for you, and validates your data before it is sent. Completely free for now, and no credit card.
Start for free