From 5383a8b77c21be3a72c2f0a633cc2ff6404ac89e Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 28 May 2018 16:23:34 +0200 Subject: [PATCH] Fix custom taxation without invoice addresses --- src/pretix/base/models/tax.py | 25 ++++++++++--------- .../pretixcontrol/event/tax_edit.html | 1 + 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/pretix/base/models/tax.py b/src/pretix/base/models/tax.py index 871a3695cc..13a7d9b8ee 100644 --- a/src/pretix/base/models/tax.py +++ b/src/pretix/base/models/tax.py @@ -160,18 +160,19 @@ class TaxRule(LoggedModel): def get_matching_rule(self, invoice_address): rules = json.loads(self.custom_rules) - for r in rules: - if r['country'] == 'EU' and str(invoice_address.country) not in EU_COUNTRIES: - continue - if r['country'] not in ('ZZ', 'EU') and r['country'] != str(invoice_address.country): - continue - if r['address_type'] == 'individual' and invoice_address.is_business: - continue - if r['address_type'] in ('business', 'business_vat_id') and not invoice_address.is_business: - continue - if r['address_type'] == 'business_vat_id' and (not invoice_address.vat_id or not invoice_address.vat_id_validated): - continue - return r + if invoice_address: + for r in rules: + if r['country'] == 'EU' and str(invoice_address.country) not in EU_COUNTRIES: + continue + if r['country'] not in ('ZZ', 'EU') and r['country'] != str(invoice_address.country): + continue + if r['address_type'] == 'individual' and invoice_address.is_business: + continue + if r['address_type'] in ('business', 'business_vat_id') and not invoice_address.is_business: + continue + if r['address_type'] == 'business_vat_id' and (not invoice_address.vat_id or not invoice_address.vat_id_validated): + continue + return r return {'action': 'vat'} def is_reverse_charge(self, invoice_address): diff --git a/src/pretix/control/templates/pretixcontrol/event/tax_edit.html b/src/pretix/control/templates/pretixcontrol/event/tax_edit.html index b886838e16..39fd12da9a 100644 --- a/src/pretix/control/templates/pretixcontrol/event/tax_edit.html +++ b/src/pretix/control/templates/pretixcontrol/event/tax_edit.html @@ -51,6 +51,7 @@ checked in order and once the first rule matches the order, it will be used and all further rules will be ignored. If no rule matches, tax will be charged. {% endblocktrans %} + {% trans "All of these rules will only apply if an invoice address is set." %}