DEV Community

chathuranga basnayaka
chathuranga basnayaka

Posted on

ZATCA e-invoices in euros or dollars: converting the VAT to riyals with the SAMA rate

A Saudi company invoicing a German customer in euros hits the same question every time: the invoice is in EUR, but which riyal figure goes where, and at what rate?

The short version: issue the invoice in euros if you like, but the VAT amount has to appear in riyals, converted at the Saudi Central Bank (SAMA) rate for the date the tax became due. ZATCA's e-invoicing format has no field for the exchange rate, so your system has to get the conversion right and be able to show its working later.

What the rules say

  • VAT Implementing Regulations, currency conversion. An amount in a currency other than the riyal is converted to riyals at the daily rate prescribed by the Saudi Central Bank on the date the tax becomes due.
  • Article 53 of the Implementing Regulations. A tax invoice must show the amount of tax payable in SAR.
  • GCC Unified VAT Agreement. An invoice can be issued in any currency, provided the tax is stated in local currency at the official rate on the tax due date.
  • ZATCA XML implementation standard. Every invoice carries a tax currency code (rule BR-KSA-68), that code must be SAR (BR-KSA-EN16931-02), and the invoice total VAT amount must be given in that currency (BR-53).

Nothing in the XML says "rate used: 4.11393". The riyal VAT total is just a number in the file. If a reviewer asks how you got it, the answer lives in your own records.

A worked example

An invoice dated 25 November 2026, where the tax is due on that date:

Line EUR
Consulting services 12,000.00
VAT at 15% 1,800.00
Total 13,800.00

SAMA's table dated 2026-11-25 gives EUR → SAR 4.11393.

  • VAT in riyals: 1,800.00 × 4.11393 = 7,405.074, so SAR 7,405.07
  • If you also show the total in riyals: 13,800.00 × 4.11393 = SAR 56,772.23

Convert the VAT amount itself and round once, to two decimals. Don't convert the net amount, round it, then apply 15% in riyals: that can land a halala away from the figure above, and the two VAT totals in the file would no longer agree.

Where the numbers go in the XML

ZATCA invoices are UBL 2.1. For a euro invoice the relevant parts look like this (trimmed):

<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
<cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>

<!-- VAT in the invoice currency, with the breakdown -->
<cac:TaxTotal>
  <cbc:TaxAmount currencyID="EUR">1800.00</cbc:TaxAmount>
  <cac:TaxSubtotal>
    <cbc:TaxableAmount currencyID="EUR">12000.00</cbc:TaxableAmount>
    <cbc:TaxAmount currencyID="EUR">1800.00</cbc:TaxAmount>
    <cac:TaxCategory>
      <cbc:ID>S</cbc:ID>
      <cbc:Percent>15.00</cbc:Percent>
      <cac:TaxScheme><cbc:ID>VAT</cbc:ID></cac:TaxScheme>
    </cac:TaxCategory>
  </cac:TaxSubtotal>
</cac:TaxTotal>

<!-- VAT total in the tax currency (BR-53) -->
<cac:TaxTotal>
  <cbc:TaxAmount currencyID="SAR">7405.07</cbc:TaxAmount>
</cac:TaxTotal>
Enter fullscreen mode Exit fullscreen mode

The second TaxTotal is the one people miss. It holds only the riyal amount, and it's where the converted figure goes.

Code: convert, round, and keep the evidence

import os, requests
from decimal import Decimal, ROUND_HALF_UP

KEY = os.environ["ALLRATES_KEY"]

def sama_rate(currency: str, date: str) -> dict:
    r = requests.get(
        f"https://allratestoday.com/api/v1/central-bank/sama/{date}",
        params={"source": currency, "target": "SAR"},
        headers={"Authorization": f"Bearer {KEY}"},
        timeout=10,
    )
    r.raise_for_status()
    return r.json()

def vat_in_sar(vat_amount: str, currency: str, tax_due_date: str) -> dict:
    data = sama_rate(currency, tax_due_date)
    rate = Decimal(str(data["rate"]))
    sar = (Decimal(vat_amount) * rate).quantize(Decimal("0.01"), ROUND_HALF_UP)
    # Store all of this with the invoice. It is your only record of the rate.
    return {
        "vat_sar": str(sar),
        "rate": str(rate),
        "rate_date": data["rate_date"],
        "source": "Saudi Central Bank (SAMA), via allratestoday.com",
    }

print(vat_in_sar("1800.00", "EUR", "2026-11-25"))
# {'vat_sar': '7405.07', 'rate': '4.11393', 'rate_date': '2026-11-25', ...}
Enter fullscreen mode Exit fullscreen mode

The dated endpoint is on paid plans; today's table (/api/v1/central-bank/sama/latest) works on the free key. SAMA dates a table for every day of the week, so a Friday or Saturday invoice still gets a row for its own date.

Things that trip people up

  • Dollar invoices still need riyal VAT. The rate never moves (3.75), but the XML still needs the SAR tax total.
  • The tax due date isn't always the invoice date. For advance payments and some continuous supplies the tax point differs. Convert at the rate for the date the tax became due, not the date you happened to raise the document.
  • Today's table lands in the evening. An invoice issued at 9am Riyadh time can't use a table that doesn't exist yet. Decide your policy (hold, or issue and true-up) and apply it every time.
  • Credit notes. Use the rate from the original invoice, so the reversal nets to zero in riyals.

None of this is tax advice, and your adviser has the final word on the tax due date for each kind of supply. But getting the rate source and the rounding right in code removes most of the back-and-forth.

More on the SAMA table and its history: Saudi Central Bank exchange rate API.

Top comments (0)