BR-KSA-61 Warning — the invoice is accepted

Previous invoice hash (PIH) missing from the invoice

Field KSA-13 is absent from the XML entirely. How this differs from BR-KSA-26, how to add the field, and the value the first invoice takes.

The message text as the Authority sends it in English, unedited

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. 1
    Add the block with the correct identifier

    The invoice must contain a cac:AdditionalDocumentReference with <cbc:ID>PIH</cbc:ID>, holding a cac:Attachment and inside it a <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain"> carrying the hash in Base64.

  2. 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? +
In the Authority specification it is classified as a warning, meaning the invoice may be accepted with a warning rather than rejected. Do not build on that: a chain with no hashes means you cannot prove the sequence of your invoices under audit.
How does the hash relate to the invoice counter (ICV)? +
Both prove sequence, from two angles: the counter is an increasing number that says this is invoice number N, and the hash ties the content of an invoice to the content of the one before it. See BR-KSA-33.
You fixed this one — now avoid the next

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

← All ZATCA error codes