Understanding of PIH and ICV

I am trying to understand about ICV and PIH. Is this order correct according to latest ZATCA phase 2 guidelines?

Document ICV PIH Status
Inv 1 1 0 Accepted :white_check_mark:
Inv 2 2 hash(Inv 1) Rejected :cross_mark:
Inv 3 3 hash(Inv 1) Accepted :white_check_mark:
CN 1 4 hash(Inv 3) Accepted :white_check_mark:
Inv 2 (fixed) 2 hash(Inv 3) Accepted :white_check_mark:
CN 2 5 hash(Inv 2 fixed) Accepted :white_check_mark:
DN 1 6 hash(CN 2) Accepted :white_check_mark:
Inv 4 7 hash(DN 1) Accepted :white_check_mark:
CN 3 8 hash(Inv 4) Rejected :cross_mark:
Inv 5 9 hash(Inv 4) Accepted :white_check_mark:
CN 3 (fixed) 8 hash(Inv 5) Accepted :white_check_mark:
DN 2 10 hash(CN 3 fixed) Accepted :white_check_mark:

Dear @hariomojha please note that ICV and PIH sequence continues per CSID irrespective of the type of document and irrespective of acceptance status of the document. Simply put, every new document you generate should take the hash value from immediately preceding document and increment ICV by 1 based on immediately preceding document irrespective of type and status.

Consider below:

Document ICV PIH Status
Inv 1 1 Equivalent of 0 (value is provided within Data Dictionary) Accepted :white_check_mark:
Inv 2 2 hash(Inv 1) Rejected :cross_mark:
Inv 3 3 hash(Inv 2) Accepted :white_check_mark:
CN 1 4 hash(Inv 3) Accepted :white_check_mark:
Inv 2 (fixed) 5 hash**(CN 1)** Accepted :white_check_mark:
CN 2 6 hash(Inv 2 fixed) Accepted :white_check_mark:
DN 1 7 hash(CN 2) Accepted :white_check_mark:
Inv 4 8 hash(DN 1) Accepted :white_check_mark:
CN 3 9 hash(Inv 4) Rejected :cross_mark:
Inv 5 10 hash(CN 3) Accepted :white_check_mark:
CN 3 (fixed) 11 hash(Inv 5) Accepted :white_check_mark:
DN 2 12 hash(CN 3 fixed) Accepted :white_check_mark:
2 Likes

Thank you @Ankit.K.Tiwari for the clarification. Can you please help with one more scenario

1. Inv A (not sent yet)

ICV = 11

PIH = hash(Inv 10)

Status = not submitted to ZATCA

2. Inv B (created after Inv A, sent first)

ICV = 12

PIH = hash(Inv A)

Status = sent to ZATCA → Accepted / Rejected

3. Later user try to send Inv A (ICV = 11) with PIH = hash(Inv 10)

@hariomojha the sequence must be maintained at the time of generating invoices. Once generated, you can send invoices to ZATCA in any order for example out of invoices 1,2,3,4,5.. you can send invoice 5 first, then 3 then 2 and so on. Sending invoices to ZATCA can be in any order as long as generation was sequential.