ZATCA deep dive

The complete ZATCA journey, stage by stage.

From onboarding to reconciliation — every stage dsFatoora runs on your behalf, including the pitfalls we've built specific safeguards for.

1

Onboarding & ZATCA registration

Taxpayer onboarding, CSID request, and environment setup (sandbox → simulation → production) before any invoice is generated.

2

Extracting invoice data from the ERP

dsFatoora reads invoice data at the point of posting — from SAP, D365, Oracle, Sage, Odoo, or a legacy system — via API, OData, or staging tables.

3

Determining invoice type

Standard tax invoice vs. simplified invoice, and whether it's a credit or debit note, is resolved before any XML is generated.

4

Generating ZATCA-compliant XML

Source data is mapped into the ZATCA invoice schema.

Common pitfall: Decimal precision mismatches between the ERP's stored values and ZATCA's expected precision are one of the most common failure points here.
5

Applying UBL 2.1 structure

The XML is structured to the UBL 2.1 standard ZATCA requires, including all mandatory namespaces and extensions.

6

Performing ZATCA business validations

Rules covering VAT numbers, mandatory fields, totals, and tax breakdowns are checked before submission.

Common pitfall: Rounding differences on tax totals — especially across a large number of line items — are a frequent validation rejection.
7

Generating UUID

A unique invoice identifier is generated and embedded, distinct from the ERP's own invoice number.

8

Calculating invoice hash

A cryptographic hash of the invoice content is calculated for integrity verification.

9

Managing Previous Invoice Hash (PIH)

Each invoice's hash chains to the hash of the one before it, forming an auditable, tamper-evident sequence.

Common pitfall: Out-of-order submissions (common with retry queues) can break the PIH chain if sequencing isn't enforced at the middleware level.
10

Applying cryptographic stamping

The invoice is signed using the taxpayer's cryptographic certificate.

11

Managing certificates

CSID, CCSID and PCSID lifecycle — issuance, renewal before expiry, and secure storage — is handled centrally.

12

Generating QR code information

A QR code encoding the mandatory invoice fields is generated for both B2B and B2C formats.

13

Calling ZATCA APIs

The signed invoice is submitted to the appropriate Clearance or Reporting endpoint depending on invoice type.

14

Processing ZATCA responses

Responses are parsed into accepted, accepted-with-warnings, or rejected, each routed differently.

Common pitfall: Credit notes referencing an original invoice that itself had warnings can produce confusing downstream rejections if not tracked carefully.
15

Updating invoice status in the ERP

Clearance status, QR code, and any warnings are written back to the source ERP against the original transaction.

16

Handling failures

Failures are classified — data error, connectivity error, or authority-side error — and routed to the right remediation path.

17

Implementing retry mechanisms

Exponential backoff and a dead-letter queue prevent transient failures from becoming lost invoices.

18

Preventing duplicate submissions

Idempotency keys ensure a retried submission can never be cleared twice.

19

Maintaining audit logs

Every stage is logged immutably with timestamps, satisfying both internal audit and ZATCA's own record-keeping expectations.

20

Monitoring & reconciliation

A dashboard continuously matches ERP records against ZATCA's cleared records, surfacing any gap for resolution.

Common pitfall: At high line-item volumes — large consolidated invoices with hundreds of SKUs — reconciliation timing needs to account for ZATCA's own batch-processing windows.

Jump to a known issue

  • Decimal precision (Stage 4)
  • Rounding on large line-item sets (Stage 6)
  • PIH chain sequencing (Stage 9)
  • Credit note edge cases (Stage 14)
  • High-volume reconciliation timing (Stage 20)
Talk through your ZATCA edge cases