# Question about PIH

**URL:** <https://zatca1.discourse.group/t/question-about-pih/2647>\
**Category:** Clearance and Reporting\
**Created:** [August 27, 2024, 12:13pm UTC](https://zatca1.discourse.group/t/question-about-pih/2647 "2024-08-27T12:13:32Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Mausoof](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@Mausoof](https://zatca1.discourse.group/u/Mausoof)\
**Post date:** [December 20, 2024, 6:28am UTC](https://zatca1.discourse.group/t/question-about-pih/2647/21 "2024-12-20T06:28:34Z")

</div>

@Ankit.K.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](https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/invoices/clearance/single)”;

your response is highly appreciated.Thankyou

---

<div class="post-metadata">

**Author:** ![Ankit.K.Tiwari](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@Ankit.K.Tiwari](https://zatca1.discourse.group/u/Ankit.K.Tiwari)\
**Post date:** [December 22, 2024, 8:43am UTC](https://zatca1.discourse.group/t/question-about-pih/2647/22 "2024-12-22T08:43:03Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Mausoof](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@Mausoof](https://zatca1.discourse.group/u/Mausoof)\
**Post date:** [December 22, 2024, 9:54am UTC](https://zatca1.discourse.group/t/question-about-pih/2647/23 "2024-12-22T09:54:52Z")

</div>

Dear @Ankit.K.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!

---

<div class="post-metadata">

**Author:** ![Ankit.K.Tiwari](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@Ankit.K.Tiwari](https://zatca1.discourse.group/u/Ankit.K.Tiwari)\
**Post date:** [December 24, 2024, 9:40am UTC](https://zatca1.discourse.group/t/question-about-pih/2647/24 "2024-12-24T09:40:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mausoof](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@Mausoof](https://zatca1.discourse.group/u/Mausoof)\
**Post date:** [December 28, 2024, 11:16am UTC](https://zatca1.discourse.group/t/question-about-pih/2647/25 "2024-12-28T11:16:50Z")

</div>

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?

[Previous page](https://zatca1.discourse.group/t/question-about-pih/2647.md?page=1)
