Skip to content

Monitoring and daily checks ​

What to watch ​

SignalWhereHealthy
Invoices in REJECTED, FAILED, MANUAL_REVIEWzatca_invoices.processing_status0, or handled within a day
B2C invoices close to the deadlineInvoiceReportingDeadlineAtRisk eventNever fires
Unresolved CRITICAL errorszatca_errors (severity = critical, resolved_at null)0
Dead-lettered outbox messageszatca_outbox.dead_lettered_at not null0
Outbox lagOldest unprocessed zatca_outbox.available_atSeconds
Device certificatesphp artisan zatca:devicesNo EXPIRED, renewals planned
Hash chainszatca:chain:verify (daily)Exit code 0
Audit logzatca:audit:verifyExit code 0

Example queries:

sql
-- invoices that need a human
SELECT public_id, workflow, invoice_number, processing_status, updated_at
FROM zatca_invoices
WHERE processing_status IN ('REJECTED', 'FAILED', 'MANUAL_REVIEW')
ORDER BY updated_at;

-- most frequent errors this week
SELECT code, COUNT(*) FROM zatca_errors
WHERE created_at > NOW() - INTERVAL 7 DAY GROUP BY code ORDER BY 2 DESC;

Built-in checks ​

CommandPurpose
zatca:chain:verify [--device=] [--deep]Counters contiguous, each PIH equals the previous hash, counter head matches. --deep also re-hashes every stored XML
zatca:deadlines:checkFire deadline alerts, mark breaches
zatca:reconcileRe-queue work whose queue message was lost
zatca:audit:verifyDetect modified or deleted audit entries
zatca:devicesDevice status and certificate expiry

All run on the scheduler; you can also run them by hand. A failing zatca:chain:verify is a serious incident: stop issuing on that device and investigate before continuing.

Errors ​

Every error is stored with a category (json_validation, business_rule, xml_generation, certificate, signing, authentication, api_connection, zatca_rejection, queue, database, sequence, …), a severity, the ZATCA code and message, and whether it was resolved. Similar errors are grouped in zatca_error_groups with a count, so one bad template that rejects 500 invoices shows up as one group.

Logs ​

The package logs to your default log channel. Logs never contain private keys, CSID secrets, OTPs or full invoice XML. zatca_submission_attempts stores the hash and UUID instead of the signed XML, and ZATCA's response with sensitive values removed.

Dashboard ​

A web dashboard (invoice lists, filters, error groups, devices, actions) is planned for milestone M7. Until then use the commands above, the tables and the events.

Not affiliated with or endorsed by ZATCA. Verify regulatory requirements with ZATCA and your tax advisor.