Question about PIH

@Ankit_Tiwari , PIH should be from the invoice hash we get when we generate invoice request from requestGenerator(),
var invoiceapiReq = invoiceRequest.GenerateRequest(signedXmlDocument);
the above method returns invoicehash,uuid and base64 of invoice. Should we use this hash for the subsequent invoice during singing of the subsequent invoice xml ? or do we need to use the hash of the final invoice hash which we receive after clearance , we get after calling this api “https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/invoices/clearance/single”;

your response is highly appreciated.Thankyou

@Mausoof Clearance by ZATCA doesnt change the “hash” of invoice. For PIH, you should use the hash which is “digestvalue” of immediately preceding document irrespective of whether that document was Accepted / Rejected / standard invoice / simplified invoice / debit note / credit note.

1 Like

Dear @Ankit_Tiwari ,

Thank you for the response. I have a query regarding the invoices/clearance/single endpoint. As per the documentation in sandbox integration, the request body includes:

{
“invoiceHash”: “f+0WCqnPkInI+eL9G3LAry12fTPf+toC9UX07F4fI+s=”,
“uuid”: “8d487816-70b8-4ade-a618-9d620b73814a”,
“invoice”: “PD94bWwgdmVyc2…”
} The response we receive is as follows:
{
“invoiceHash”: “P3/QfnGR7eMON/LM8Vpiz6nCqrt5+msixDhj84Fo6Ww=”,
“status”: “Cleared”,
“clearedInvoice”: “PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVn…”
}

It is observed that the invoiceHash in the response differs from the one in the request. Could you please clarify which invoiceHash should be considered as the PIH for further processing? This clarification will help ensure accurate implementation.

Thank you for your assistance!

Dear @Mausoof the hash in “DigestValue” doesn’t change even after clearance. Please look for DigestValue in request and response. PIH is based on the DigestValue, Clearance or rejection doesnt change DigestValue and therefore it doesnt have impact on PIH sequence.

1 Like

Thank you for the clarification; the confusion is almost resolved. However, I have one remaining doubt. If I generate an invoice XML and sign it using the previous invoice hash, I will get a new invoice hash in the DigestValue. Suppose I do not submit this particular invoice for clearance and instead create a new invoice. In this case, can I use the DigestValue of the previous invoice hash, which has not been submitted for clearance, to sign the new invoice XML?