From 353c9b4147e98e6378a0e241b8a68e1df7ca28ec Mon Sep 17 00:00:00 2001 From: Martin Gross Date: Mon, 12 Sep 2022 12:48:58 +0200 Subject: [PATCH] VAT: Transmit the country code of the normalized VAT-ID instead of the user provided one --- src/pretix/base/services/tax.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pretix/base/services/tax.py b/src/pretix/base/services/tax.py index 5ae1b8810b..f12f583b42 100644 --- a/src/pretix/base/services/tax.py +++ b/src/pretix/base/services/tax.py @@ -109,6 +109,9 @@ def _validate_vat_id_EU(vat_id, country_code): if not re.match(vat_moss.id.ID_PATTERNS[cc_to_vat_prefix(country_code)]['regex'], number): raise VATIDFinalError(error_messages['invalid']) + # We are relying on the country code of the normalized VAT-ID and not the user/InvoiceAddress-provided + # VAT-ID, since Django and the EU have different ideas of which country is using which country code. + # For example: For django and most people, Greece is GR. However, the VAT-service expects EL. payload = """ @@ -119,7 +122,7 @@ def _validate_vat_id_EU(vat_id, country_code): - """.strip() % (country_code, number) + """.strip() % (vat_id[:2], number) try: response = requests.post(