fatoora-rs
An unofficial open-source toolkit for everything you'd need for ZATCA (Zakat, Tax and Customs Authority of Saudi Arabia) Phase 1 and 2 compliant e-invoicing
...with bindings and support for many programming languages (coming soon lol).
...and also built in Rust btw
fatoora-rsis in active early development. While the core functionality is usable, the public API is still evolving and may change as the project matures. We strive to maintain good test coverage and stability, but users should be aware that some rough edges may remain. Feedback and contributions are especially welcome at this stage.
Disclaimer:
fatoora-rs 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.
Documentation
WIP
Features
Everything done by the official ZATCA SDK
- CSR Generation
- Invoice Signing (All invoice types)
- Validation (UBL only for now)
- QR Generation
- API Requests
But we do it faster and better e.g. ~190x faster invoice hashing than ZATCA's SDK (see bench/)
Dependencies
XML parsing/manipulation is done internally with libxml2, so you might need to install it if you haven't already see here for relevant instructions.
Usage/Examples
Rust
use EnvironmentType;
use CsrProperties;
let props = parse_csr_config?;
let = props.build_with_rng?;
let csr_pem = csr.to_pem?;
let key_pem = key.to_pkcs8_pem?;
CLI
Rust
use InvoiceSigner;
let cert_pem = read_to_string?;
let key_pem = read_to_string?;
let signer = from_pem?;
let xml = read_to_string?;
let signed_xml = signer.sign_xml?;
CLI
Rust
use Config;
use validate_xml_invoice_from_file;
let config = new;
validate_xml_invoice_from_file?;
CLI
Rust
use parse_signed_invoice_xml;
let xml = read_to_string?;
let signed = parse_signed_invoice_xml?;
let qr = signed.qr_code;
CLI
Rust
use invoice_hash_base64;
use Parser;
let xml = read_to_string?;
let doc = default.parse_string?;
let hash = invoice_hash_base64?;
CLI
Rust
use parse_signed_invoice_xml;
let xml = read_to_string?;
let signed = parse_signed_invoice_xml?;
let payload = json!;
CLI
Contributing
Contributions are always welcome!
- Open issues for discussion before implementing any big features
- Add relevant tests and make sure there are no formatting issues
Network tests
Live API tests run by default with the rest of the test suite.
Set SKIP_ZATCA_LIVE_API=1 to disable them locally or in CI.
Roadmap
- Increase test coverage to 100% (Inshallah)
- Add the full validation suite (not only UBL schema)
- Expand bindings to other languages (subject to demand)
- PDF invoice generation