wes4m / zatca-xml-js

An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in TypeScript.
MIT License
67 stars 56 forks source link
invoice phase-1 phase-2 saudi tax typescript xml zatca

v0.1.9 (experimental)



An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in TypeScript.

Read the documentation PDFs or Systems Developers for more details.

[![GitHub license](https://badgen.net/github/license/wes4m/zatca-xml-js?v=0.1.0)](https://github.com/wes4m/zatca-xml-js/blob/main/LICENSE)

Check out Invoicen

Dependencies

If you plan on using the built in EGS module to generate keys, and CSR. The EGS module in the package is dependent on OpenSSL being installed in the system it's running on. It's being used to generate an ECDSA key pair using the secp256k1 curve. also to generate and sign a CSR.

All other parts of the package will work fine without OpenSSL. (meaning it supports react-native and other frameworks)

Supports

All tha main futures required to on-board a new EGS. Create, sign, and report a simplified tax invoice are currently supported.

Installation

npm install zatca-xml-js

Usage

View full example at examples

import {
    EGS, EGSUnitInfo,
    ZATCASimplifiedTaxInvoice,
} from "zatca-xml-js";

// New Invoice and EGS Unit
const invoice: ZATCASimplifiedTaxInvoice = {/*...*/};
const egsunit: EGSUnitInfo = {/*...*/};

// Init EGS unit
const egs = new EGS(egsunit);
// New Keys & CSR for the EGS
await egs.generateNewKeysAndCSR(false, "solution_name");
// Issue a new compliance cert for the EGS
const compliance_rid = await egs.issueComplianceCertificate("123345");
// Sign invoice
const {signed_invoice_string, invoice_hash} = egs.signInvoice(invoice);
// Check invoice compliance
await egs.checkInvoiceCompliance(signed_invoice_string, invoice_hash);
// Issue production certificate
await egs.issueProductionCertificate(compliance_rid);
// Report invoice
await egs.reportInvoice(signed_invoice_string, invoice_hash);

Implementation

Notice of Non-Affiliation and Disclaimer

zatca-xml-js is not affiliated, associated, authorized, endorsed by, or in any way officially connected with ZATCA (Zakat, Tax and Customs Authority), or any of its subsidiaries or its affiliates. The official ZATCA website can be found at https://zatca.gov.sa.

Contribution

All contributions are appreciated.

Roadmap

I'm not planning on supporting Tax Invoices (Not simplified ones). If any one wants to tackle that part.