PIH validation errors

Dears ,

Hope this finds you well .

I keep getting this error when validating my invoices using fatoora SDK :

[INFO] ValidationProcessorImpl - [PIH] validation result : FAILED
[ERROR] ValidationProcessorImpl - pih validation errors :
[ERROR] ValidationProcessorImpl - CODE : KSA-13, MESSAGE : PIH is inValid
[INFO] InvoiceValidationService -  *** GLOBAL VALIDATION RESULT = FAILED

I’m using the standard invoice provided in the sample folder in the SDK \Data\Samples\Standard\Invoice\Standard_Invoice.xml

I Tried modifying the PIH to 0 or to “MA==” (which is the equilivent of 0 in base64 with no luck .

Please advice .

Please note that there is a PIH text file to keep last invoice hash please check if it is there
C:\zatca-einvoicing-sdk-238-R3.3.3\Data\PIH

and for very first invoice your hash should be
NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==

where means 0 (zero)

Do i have to keep it?? If i use it as first PIH, what about Second on will be??
thanks in Advance

You need to update the PIH whenever you generate a new invoice, First Invoice PIH will be

NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==

and the hash of first invoice will be the PIH of Next invoice.
Example:
Invoice 1

Invoice Hash: ZNMSA9pKhIlUDf/Lb5JbS37HIMfYmvRy8SJS41sTKAM=
PIH : NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==

Invoice 2:
Invoice Hash : 5yfF/cx7h0oe9oESilAGXfyLHMWYJ0ASIzJAjjt9K/o=
PIH : ZNMSA9pKhIlUDf/Lb5JbS37HIMfYmvRy8SJS41sTKAM=

Invoice 3 :
Invoice Hash : 268oIbm9asXQXwmM5aDR2poh7kKqgui5BDqNQdhqS0A=
PIH : 5yfF/cx7h0oe9oESilAGXfyLHMWYJ0ASIzJAjjt9K/o=

1 Like

@Ather thanks a lot for your information, if the invoice does not have reported what about that?? should i still take next PIH??
I am facing The invoice hash API body does not match the (calculated) Hash of the XML, everytime, How to solve it, Can you help me out??

@sayedrahman
Which SDK are you using?

If invoice is rejected by ZATCA, then tax payers can fix the
errors and submit the XML just like a new invoice having its own Invoice Counter Value and Hash.

Detailed Guidelines for E-Invoicing

Page 63