From 3599f0bff46ad6d37ac407f01cc0ea38f051d09e Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 15 Nov 2019 13:11:11 +0530 Subject: [PATCH] Show VAT elegantly --- .../templates/datacenterlight/order_detail.html | 15 +++++++++++++++ datacenterlight/views.py | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 8a444bef..2aae3391 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -55,10 +55,25 @@

+ {% if generic_payment_details.vat_rate > 0 %} +

+ {% trans "Price" %}: + CHF {{generic_payment_details.amount_before_vat|floatformat:2|intcomma}} +

+

+ {% trans "VAT for" %} {{generic_payment_details.vat_country}} ({{generic_payment_details.vat_rate}}%) : + CHF {{generic_payment_details.vat_amount|floatformat:2|intcomma}} +

+

+ {% trans "Total Amount" %} : + CHF {{generic_payment_details.amount|floatformat:2|intcomma}} +

+ {% else %}

{% trans "Amount" %}: CHF {{generic_payment_details.amount|floatformat:2|intcomma}}

+ {% endif %} {% if generic_payment_details.description %}

{% trans "Description" %}: diff --git a/datacenterlight/views.py b/datacenterlight/views.py index b2e04bf6..6f7da18e 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -414,8 +414,18 @@ class PaymentOrderView(FormView): product = generic_payment_form.cleaned_data.get( 'product_name' ) + user_country_vat_rate = get_vat_rate_for_country( + address_form.cleaned_data["country"] + ) gp_details = { "product_name": product.product_name, + "vat_rate": user_country_vat_rate * 100, + "vat_amount": round( + float(product.product_price) * + user_country_vat_rate, 2), + "vat_country": address_form.cleaned_data["country"], + "amount_before_vat": round( + float(product.product_price), 2), "amount": product.get_actual_price( vat_rate=get_vat_rate_for_country( address_form.cleaned_data["country"])