From f6dc90fb287a1536b82d208208ec19a9e7ca578e Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 30 Oct 2020 22:33:44 +0100 Subject: [PATCH] Show message and cart after tax rate has changed --- src/pretix/base/services/cart.py | 1 + src/pretix/presale/checkoutflow.py | 7 ++++++- .../templates/pretixpresale/event/checkout_base.html | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pretix/base/services/cart.py b/src/pretix/base/services/cart.py index 9485526058..65ebe23d63 100644 --- a/src/pretix/base/services/cart.py +++ b/src/pretix/base/services/cart.py @@ -1063,6 +1063,7 @@ def update_tax_rates(event: Event, cart_id: str, invoice_address: InvoiceAddress if pos.tax_rate != rate: current_net = pos.price - pos.tax_value new_gross = pos.item.tax(current_net, base_price_is='net', invoice_address=invoice_address).gross + totaldiff += new_gross - pos.price pos.price = new_gross pos.includes_tax = rate != Decimal('0.00') pos.override_tax_rate = rate diff --git a/src/pretix/presale/checkoutflow.py b/src/pretix/presale/checkoutflow.py index 8336e8d65e..a561bb7b56 100644 --- a/src/pretix/presale/checkoutflow.py +++ b/src/pretix/presale/checkoutflow.py @@ -554,11 +554,16 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep): addr = self.invoice_form.save() self.cart_session['invoice_address'] = addr.pk - update_tax_rates( + diff = update_tax_rates( event=request.event, cart_id=get_or_create_cart_id(request), invoice_address=self.invoice_form.instance ) + if abs(diff) > Decimal('0.001'): + messages.info(request, _('Due to thec invoice address you entered, we need to apply a different tax ' + 'rate to your purchase and the price of the products in your cart has ' + 'changed accordingly.')) + return redirect(self.get_next_url(request) + '?open_cart=true') return redirect(self.get_next_url(request)) diff --git a/src/pretix/presale/templates/pretixpresale/event/checkout_base.html b/src/pretix/presale/templates/pretixpresale/event/checkout_base.html index 90b4742796..4b785a9acd 100644 --- a/src/pretix/presale/templates/pretixpresale/event/checkout_base.html +++ b/src/pretix/presale/templates/pretixpresale/event/checkout_base.html @@ -3,7 +3,7 @@ {% load bootstrap3 %} {% block title %}{% trans "Checkout" %}{% endblock %} {% block content %} -
+