The Legal Mandate: Business Continuity Under VAT Regulations
Under Article 53 of the Executive Regulations for Value Added Tax and the technical provisions of ZATCA Resolution No. 09-08-2021, tax authorities recognize that physical telecommunication infrastructure, undersea fiber lines, and cloud data centers can suffer outages.
However, Saudi tax law strictly distinguishes between unavoidable network failure (*Inqita' Al-Ittisal*) and intentional tax evasion (*Taharrub Dareebi*). To stay compliant during an outage, your software architecture must prove that no invoices were skipped, altered, or retroactively inserted while offline.
Outage Detection
ERP heartbeat detects connectivity loss with gw-fatoora.zatca.gov.sa
Local Signing & Chaining
POS signs transactions locally via secp256k1 key; increments ICV and maintains PIH chain
Customer Receipt Handoff
B2C customer receives printed slip with valid QR code; B2B invoices held in pending queue
Connection Restoration
Gateway recovers; ERP background worker initiates rate-limited asynchronous sync
Statutory Ledger Audit
Invoices clear and report to ZATCA; clearance stamps returned; audit log verified
Detailed Rules: B2C Simplified Invoicing During Outages
For retail stores, pharmacies, restaurants, and supermarkets, pausing checkout counters during an internet outage would paralyze commercial life. ZATCA engineered the Reporting Model specifically to accommodate offline environments:
1. How Offline B2C Invoicing Works Mechanically
Because the EGS Private Key resides locally on your server or POS cash register (rather than on ZATCA's cloud servers), your machine can perform 100% of the cryptographic operations offline:
2. The 24-Hour Synchronization Rule
Under statutory regulations, all Simplified Tax Invoices generated offline must be transmitted to ZATCA's reporting endpoint (/invoices/reporting/single) within 24 hours of transaction timestamp.
What If the Outage Lasts Longer Than 24 Hours?
If an internet failure exceeds 24 hours due to a documented fiber cut or telecommunications disaster, the enterprise must report the queued invoices immediately upon connection restoration. The system must preserve raw router/ISP logs proving the outage to defend against automated late-reporting penalties during tax audits.
Detailed Rules: B2B Standard Invoicing During Outages
While retail B2C invoicing can proceed seamlessly offline, business-to-business commerce faces strict legal boundaries due to the Clearance Model:
| Operational Stage | Normal Online Mode | Offline Outage Mode |
|---|---|---|
| Invoice Generation | ERP creates XML payload. | ERP creates XML payload and queues in local buffer. |
| ZATCA Verification | Real-time API call (/invoices/clearance/single). | Cannot execute. System marks status as PENDING_CLEARANCE. |
| Document Delivery to Buyer | Cleared PDF/A3 with ZATCA Cryptographic Stamp delivered. | STRICTLY PROHIBITED. Un-cleared invoice cannot be given to client. |
| Goods Dispatch Procedure | Accompanied by official cleared tax invoice. | Dispatched using Commercial Delivery Note or Goods Receipt Note. |
| Input VAT Claim by Buyer | Buyer immediately books 15% input VAT. | Buyer cannot claim input VAT until clearance is received post-restoration. |
Statutory Safeguards & Rights Protection
Mandatory protections enforced by MHRSD & Saudi Labor Law
Technical Architecture: The Resilient Offline Queue & Sync Pattern
To prevent data loss and broken cryptographic chains during network interruptions, enterprise software must implement the Transactional Outbox Pattern:
Local Billing & Network Check
POS detects offline state; writes raw transaction into local encrypted Outbox queue
Offline Signing & QR Issuance
System signs hash locally using secp256k1 key; issues customer receipt with 2D QR code
Automatic FIFO Resynchronization
Connection recovers; background worker transmits queued batches in strict sequential order
Critical Concurrency Rule: Strict Sequential Sync
When the network recovers, the background synchronization engine must process queued invoices in strict First-In, First-Out (FIFO) sequential order.
BR-KSA-51: Invalid Previous Invoice Hash across the entire backlog.Resilient Sync Script with Exponential Backoff (Node.js Reference)
The following production code illustrates how an enterprise background sync worker queues offline invoices and submits them with exponential backoff and concurrency locking:
import axios from 'axios';
interface QueuedInvoice {
id: string;
icv: number;
signedXmlBase64: string;
invoiceHash: string;
isStandardB2B: boolean;
}
class ZatcaOfflineSyncManager {
private isSyncing = false;
async processOfflineQueue(queue: QueuedInvoice[], csidAuthToken: string): Promise<void> {
if (this.isSyncing) return; // Prevent concurrent sync loops
this.isSyncing = true;
try {
// STRICT REQUIREMENT: Sort sequentially by ICV
queue.sort((a, b) => a.icv - b.icv);
for (const invoice of queue) {
let attempts = 0;
let success = false;
while (!success && attempts < 5) {
try {
const endpoint = invoice.isStandardB2B
? 'https://gw-fatoora.zatca.gov.sa/e-invoicing/core/invoices/clearance/single'
: 'https://gw-fatoora.zatca.gov.sa/e-invoicing/core/invoices/reporting/single';
const response = await axios.post(
endpoint,
{ invoice: invoice.signedXmlBase64, invoiceHash: invoice.invoiceHash },
{
headers: {
'Authorization': `Basic ${csidAuthToken}`,
'Accept-Version': 'V2',
'Content-Type': 'application/json',
},
timeout: 5000,
}
);
if (response.status === 200) {
await this.markAsSynced(invoice.id, response.data);
success = true;
}
} catch (error: any) {
attempts++;
// Exponential backoff with jitter: 2^attempts * 500ms
const delayMs = Math.pow(2, attempts) * 500 + Math.random() * 200;
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
}
if (!success) {
throw new Error(`Chain halted at ICV ${invoice.icv}: Sync failed after 5 retries.`);
}
}
} finally {
this.isSyncing = false;
}
}
private async markAsSynced(id: string, zatcaResponse: any): Promise<void> {
// Database update: Mark invoice as SYNCED with official ZATCA response
}
}Real-World Case Study: Dammam Industrial Supply Hub (14-Hour Fiber Cut)
In November 2025, road construction in the Second Industrial City of Dammam severed primary and backup optical fiber cables serving an industrial steel distributor:
* For retail cash sales (B2C), the POS terminals switched to offline mode, issuing 312 Simplified receipts with full cryptographic QR codes.
For corporate contractors (B2B), the logistics team held B2B tax invoice numbers in an atomic database queue and issued physical goods using Commercial Delivery Notes (Bayan Tasleem Goods)*.
Common Offline Sync Pitfalls & Troubleshooting
| Error Code / Symptom | Root Cause | Immediate Remediation |
|---|---|---|
| `HTTP 429 Too Many Requests` | The ERP submitted hundreds of queued invoices simultaneously in parallel threads, overwhelming rate limits. | Implement a sequential queue with a 50ms delay between API requests to smooth traffic. |
| `BR-KSA-51: Invalid Previous Hash` | A multi-threaded sync worker processed Invoice #104 before Invoice #103, breaking the sequence. | Enforce strict sequential FIFO ordering (ORDER BY icv ASC) when ingesting the outbox queue. |
| `Timestamp Out of Order` | The offline POS clock drifted backward or was manually modified during power failure. | Lock the operating system clock to a secure Network Time Protocol (NTP) daemon; prevent manual time adjustments. |
| `Database Lock Timeout` | Concurrent checkout cashiers attempted to read and update the shared PIH table simultaneously while offline. | Implement independent EGS units per register so each cash drawer maintains its own isolated hash chain. |
Frequently Asked Questions (FAQ)
Can a retail store continue selling to walk-in consumers if the internet goes down?
Yes. Retail stores issuing Simplified Tax Invoices (B2C) can continue selling offline without interruption. The local POS system cryptographically signs the invoice, generates the required QR code, and holds the document in a local buffer for reporting within 24 hours.
Can an enterprise issue a Standard B2B invoice offline during an emergency?
No. Standard B2B invoices require real-time clearance from ZATCA before they can be legally issued to corporate buyers. Delivering an un-cleared B2B invoice to a client prevents the client from deducting input VAT and constitutes a direct regulatory violation.
What should an enterprise do if an internet outage lasts for 3 days?
The enterprise must: (1) Maintain all transactions in its sequential offline database; (2) Obtain an official outage incident certificate from its Internet Service Provider (STC, Mobily, Zain); (3) Submit an emergency notification ticket through the ZATCA ERAD Portal; and (4) Transmit all queued records immediately upon connection recovery.
Does offline invoicing reset the Invoice Counter Value (ICV)?
No. The Invoice Counter Value (ICV) must continue incrementing sequentially (N + 1) regardless of whether the system is online or offline. Operating offline must never reset or interrupt the continuous numerical sequence.
How does ZATCA know if an invoice was actually generated during an offline outage?
ZATCA verifies the internal transaction timestamp against the sequential hash chain (PIH) and compares submission times with regional telecommunication logs. If the hash sequence is unbroken and matches prior transactions, the offline generation is validated.
Was this compliance guide helpful?
Your feedback helps our legal editorial team maintain authoritative KSA guidance.
Advocate High Court (Punjab Bar Council) and ATT GCC VAT Certified Specialist. Author of comprehensive regulatory commentaries on Saudi corporate law, ZATCA e-invoicing protocols, and Labor Reform Initiatives.