# Validate EInvoice PIH \[Failed\] and B2B invoice calculate hash

**URL:** <https://zatca1.discourse.group/t/validate-einvoice-pih-failed-and-b2b-invoice-calculate-hash/5099>\
**Category:** Clearance and Reporting\
**Created:** [January 11, 2025, 10:14pm UTC](https://zatca1.discourse.group/t/validate-einvoice-pih-failed-and-b2b-invoice-calculate-hash/5099 "2025-01-11T22:14:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmad1](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@ahmad1](https://zatca1.discourse.group/u/ahmad1)\
**Post date:** [January 11, 2025, 10:14pm UTC](https://zatca1.discourse.group/t/validate-einvoice-pih-failed-and-b2b-invoice-calculate-hash/5099/1 "2025-01-11T22:14:45Z")

</div>

aslam alekm  
I use Fatoora sdk .net , all invoices are cleared and reported , but when i check the xml invoice by validate SDk CLI i always get the error Validate EInvoice PIH [Failed]

> Blockquote

Validate XSD [Success]  
Validate EN Schematrons [Success]  
Validate KSA Schematrons [Success]  
Validate QR Code [Success]  
Validate EInvoice Signature [Success]  
Validate EInvoice PIH [Failed]  
Errors:  
\*\*\*\* [Error] CODE: KSA-13, MESSAGE : PIH is inValid  
Overall status [Failed]

> Blockquote

and also please tell me if that the steps is right after clearance status i decode the return cleared invoice and do generateHash CLI for it and uses this result hash as PIH for the next invoice is that right , or not need to do that and uses the hash that generated and send as payload for request , please explain that for me  
and what about this Error for PIH even i start with ZERO hash in a first B2C invoice and for example sign it and uses the generatedHash for this sign invoice as PIH in the next invoice i get this ERROR  
thank you

---

<div class="post-metadata">

**Author:** ![salmanDEV](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@salmanDEV](https://zatca1.discourse.group/u/salmanDEV)\
**Post date:** [January 12, 2025, 11:49am UTC](https://zatca1.discourse.group/t/validate-einvoice-pih-failed-and-b2b-invoice-calculate-hash/5099/2 "2025-01-12T11:49:32Z")

</div>

Invoice Hash that you should in payload is the Current Invoice Hash  
and this Hash Use to Generate the Next Invoice XML as PIH (pervious Invoice Hash )

---

<div class="post-metadata">

**Author:** ![ahmad1](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@ahmad1](https://zatca1.discourse.group/u/ahmad1)\
**Post date:** [January 12, 2025, 12:41pm UTC](https://zatca1.discourse.group/t/validate-einvoice-pih-failed-and-b2b-invoice-calculate-hash/5099/3 "2025-01-12T12:41:49Z")

</div>

thank you brother , so i will use the hash that it payload with invoice even it is for invoice without sign  
and also why i got this PIH error after the create XML invoice , although if i create the second xml and sign it for reporting just i validate it i get this error  
thank you for replying brother

---

<div class="post-metadata">

**Author:** ![sergei.shishov](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sergei.shishov](https://zatca1.discourse.group/u/sergei.shishov)\
**Post date:** [January 17, 2025, 6:40am UTC](https://zatca1.discourse.group/t/validate-einvoice-pih-failed-and-b2b-invoice-calculate-hash/5099/4 "2025-01-17T06:40:30Z")

</div>

Hi @ahmad1 , please read the documentation,

CIH (current invoice hash) is used for current invoice and in PIH (previous invoice hash) you should enter a value from previous document (reported). If you do not have previous document (you did not report anything yet), then you have to use special value indicated in documentation representing `"0"` value.

I would recommend you to read the documentation and understand this logic, as it is making the chain of your documents reported by 1 device. “0” → inv1 → inv2 → inv3 → …

Best regards,  
Sergei
