{% extends "base.html" %} {% block title %}{{ t('ZATCA e-invoicing') }}{% endblock %} {% block content %}

{{ t('ZATCA e-invoicing') }}

{{ t('Fatoora phase 2: invoices of Saudi branches are signed, given a QR code and cleared or reported to ZATCA.') }}

{% if counts.pending %}
{% endif %}
{{ t('Cleared (B2B)') }}
{{ counts.cleared or 0 }}
{{ t('Reported (B2C)') }}
{{ counts.reported or 0 }}
{{ t('Waiting to be sent') }}
{{ counts.pending or 0 }}
{{ t('Rejected') }}
{{ counts.rejected or 0 }}

{{ t('Environment') }}

{{ t('Sandbox: ZATCA developer portal, OTP 123345, nothing is legally issued. Simulation: test with your real VAT number. Production: live invoices. Each environment needs its own onboarding.') }}
{{ t('Written into the certificate request.') }}

{{ t('How it works') }}

1. {{ t('Branch details') }}{{ t('VAT number, CR number and the national address (building number, street, district, city, postal code) of each Saudi branch.') }}
2. {{ t('Onboard') }}{{ t('Get a one-time password (OTP) in the Fatoora portal and enter it here. Lubwise creates the keys, passes the compliance checks and receives the certificate.') }}
3. {{ t('Invoice as usual') }}{{ t('Posting signs the invoice. B2B invoices are cleared by ZATCA at once; B2C invoices and POS receipts are reported within 24 hours.') }}
4. {{ t('Corrections') }}{{ t('An e-invoice cannot be changed or reset. Issue a credit note or debit note; they are e-invoiced the same way.') }}
{% for br in branches %}{% set b = br.b %}

{{ b.code }} — {{ nm(b) }}

{% if b.zatca_enabled %}{{ t('E-invoicing on') }}{% elif not br.saudi %}{{ t('Not a Saudi branch') }}{% else %}{{ t('E-invoicing off') }}{% endif %}
{% if br.saudi %}
{{ t('Empty = the company CR number.') }}
{% if br.problems %}
{{ icon('alert') }}{{ t('Still needed') }}: {{ br.problems|join('; ') }}
{% endif %}

{{ t('E-invoicing units') }}

{{ t('Each unit has its own certificate and invoice counter. The branch unit signs back-office invoices and, unless a register has its own, POS receipts.') }}

{% for u in br.units %} {% else %}{% endfor %}
{{ t('Unit') }}{{ t('Status') }}{{ t('Invoices signed') }}{{ t('Certificate valid until') }}
{{ u.name }}
{{ u.serial }}
{% if u.state == 'active' %}{{ t('Active') }}{% elif u.state == 'compliance' %}{{ t('Compliance checks') }}{% else %}{{ t('Not onboarded') }}{% endif %} {% if u.last_error %}
{{ u.last_error }}
{% endif %}
{{ u.icv }}{{ u.cert_expiry or '—' }} {% if u.state != 'active' %}
{% else %}
{% endif %}
{{ t('No unit yet.') }}
{% if br.registers %}{% endif %}
{% else %}

{{ t('ZATCA e-invoicing applies to branches in Saudi Arabia (SAR).') }}

{% endif %}
{% endfor %}

{{ t('VAT categories') }}

{{ t('Zero-rated, exempt and out-of-scope sales must state the reason ZATCA accepts.') }}

{% for tx in taxes %}{% set cat = tx.zatca_category or ('S' if tx.rate > 0 else 'Z') %} {% endfor %}
{{ t('Tax') }}{{ t('Rate %') }}{{ t('Category') }}{{ t('Exemption reason') }}
{{ nm(tx) }}{{ '%g' % tx.rate }}

{{ t('E-invoices') }}

{% for k, l in [('attention', 'Needs attention'), ('cleared', 'Cleared'), ('reported', 'Reported'), ('all', 'All')] %} {{ t(l) }}{% endfor %}
{% for d in docs %} {% else %}{% endfor %}
{{ t('Document') }}{{ t('Type') }}{{ t('Unit') }}{{ t('Signed at') }}{{ t('Total') }}{{ t('Status') }}
{{ d.number }} {{ t('Standard (B2B)') if d.subtype == 'standard' else t('Simplified (B2C)') }} · {{ t({'invoice': 'Invoice', 'credit': 'Credit Note', 'debit': 'Debit Note', 'prepayment': 'Advance invoice'}[d.doc_type]) }} {{ d.unit_name }}{{ d.issued_at|replace('T', ' ') }}{{ d.total|money(d.currency) }} {% set st = {'cleared': 'st-posted', 'reported': 'st-posted', 'pending': 'st-warn', 'rejected': 'st-cancelled'}[d.status] %}{{ t(d.status|capitalize) }} {% if d.msgs.errors %}
{{ d.msgs.errors|join('; ') }}
{% endif %} {% if d.warnings %}{{ d.warnings }} {{ t('warning(s)') }}{% endif %}
XML {% if d.status == 'pending' %}
{% endif %}
{{ t('Nothing here.') }}
{% endblock %}