Galaxy DigiLabsSoftware Engineering, AI Automation & Digital Platforms

Case Study

Compliance & Accounting2026

From Engine Selection to Compliant E-Invoices in Production

ZATCA e-invoicing demands UBL 2.1 XML, ECDSA signing and the clearance flow. We selected a pure-Python engine over the Java alternatives and built the signing, XML and clearance pipeline inside the business system.

A business required to meet ZATCA Phase 2

Outcome

E-invoices generated, signed and cleared from inside the system in production — with the engine chosen for maintainability, not just compliance.

Business Context

The business operates in a jurisdiction where Phase 2 e-invoicing is mandatory. Invoices were already generated by the ERP layer; they now had to leave the system as compliant signed XML.

Technical Challenge

XML structure compliance, clearance semantics for different invoice types, and keeping signing key handling inside the system without scattering it across modules.

Implemented Solution

Generate the UBL 2.1 XML, sign it with ECDSA using the CSID, and route it through the clearance API where required — all from the existing invoice flow.

Verified Outcome

E-invoices generated, signed and cleared from inside the system in production — with the engine chosen for maintainability, not just compliance.

Confidentiality and evidence note

Case studies are written from available project evidence and may anonymize client-identifying details. Exact metrics are omitted unless they are verified and approved for publication.

Problem

A business system had to produce ZATCA-compliant e-invoices: UBL 2.1 XML structure, ECDSA signing and, for the relevant transactions, clearance through the ZATCA API. This is a compliance pipeline, not a print setting.

Business Context

The business operates in a jurisdiction where Phase 2 e-invoicing is mandatory. Invoices were already generated by the ERP layer; they now had to leave the system as compliant signed XML.

Constraints

  • Compliant UBL 2.1 XML structure with correct tax data.
  • ECDSA signing with the provisioned certificate (CSID).
  • Clearance flow for transactions that require it.
  • The engine must live inside the business system and stay maintainable.

Analysis

The signing engine candidates divided by language and licensing. The Java options were heavier; a pure-Python engine (MIT-licensed) matched the stack, the team and the requirement to keep the pipeline inside the app.

Architecture

The engine is a set of Python modules inside the business app: invoice XML generation, tax data generation, initial and final invoice signing, clearance utilities and decoding. The system calls them at the right state in the invoice lifecycle.

Solution

Generate the UBL 2.1 XML, sign it with ECDSA using the CSID, and route it through the clearance API where required — all from the existing invoice flow.

Technology

  • Pure-Python signing engine (zatca_bev, MIT)
  • UBL 2.1 XML generation
  • ECDSA signing + CSID
  • ZATCA clearance utilities
  • Inside the ERP app (erpgalaxy)

Implementation

The engine files were integrated into the app's ZATCA module and wired to the invoice lifecycle, then verified against real invoices in production.

Challenges

XML structure compliance, clearance semantics for different invoice types, and keeping signing key handling inside the system without scattering it across modules.

Outcome

Compliant, signed, cleared e-invoices now leave the system directly — the invoice the business already knows is the invoice the authority accepts.

Lessons

Select compliance engines for maintainability and fit, not just headline features. A pure-Python, well-licensed engine that lives inside the system beats a heavier integration you cannot understand.

Future Improvements

Phase 2 edge-case coverage (credit notes, and the additional fields for simplified vs. standard invoices) and monitoring on clearance failures.

Technology

Python ECDSAUBL 2.1 XMLCSIDZATCA clearance API

Start With the Problem

Tell Us What's Not Working.

You don't need to know which framework, platform or technology you need. Start by explaining the problem - we'll design the system around it.

hello@galaxydigilabs.com