Show message and cart after tax rate has changed

This commit is contained in:
Raphael Michel
2020-10-30 22:33:44 +01:00
parent 4093c1d909
commit f6dc90fb28
3 changed files with 8 additions and 2 deletions

View File

@@ -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

View File

@@ -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))

View File

@@ -3,7 +3,7 @@
{% load bootstrap3 %}
{% block title %}{% trans "Checkout" %}{% endblock %}
{% block content %}
<details class="panel panel-default cart">
<details class="panel panel-default cart" {% if "open_cart" in request.GET %}open{% endif %}>
<summary class="panel-heading">
<h3 class="panel-title">
<span>