wes4m / zatca-xml-js

An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in TypeScript.
MIT License
68 stars 58 forks source link

Worked, How do I get PIH (previous invoice hash)? #6

Closed sudo-sand closed 1 year ago

sudo-sand commented 1 year ago

I have pretty much the same example as you. When I run checkInvoiceCompliance or reportInvoice I get Request failed with status code 400.

One more question, do I store PIH in a DB or how do you get it?

wes4m commented 1 year ago

I have pretty much the same example as you. When I run checkInvoiceCompliance or reportInvoice I get Request failed with status code 400.

The 400 Failure with reportInvoice is expected. ZATCA's sandbox report API is not fully ready yet. Currently they're returning a constant production cert that does not have the ability to sign Simplified Tax Invoices. Hopefully they fix that soon.

One more question, do I store PIH in a DB or how do you get it?

Yes, you will have to store the last invoice hash as a PIH somewhere whenever you create an invoice.

sudo-sand commented 1 year ago

So, with the first phase, I have to store the xml invoices correct?

wes4m commented 1 year ago

So, with the first phase, I have to store the xml invoices correct?

ZATCA's first phase does not require you to store any XMLs. But yes, for the second phase you will need to store the invoices as a custom object and then generate an XML every time. Or just store the signed XML for each invoice.

sudo-sand commented 1 year ago

Sorry for bothering you, in the first phase, what format does the invoice take?

wes4m commented 1 year ago

Sorry for bothering you, in the first phase, what format does the invoice take?

This package is intended for phase 2. Try something like @mrsool/zatca for phase 1. Also read ZATCA Specs

sudo-sand commented 1 year ago

Thanks @wes4m for your help!