diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html
index db3f73a8..80e35914 100644
--- a/datacenterlight/templates/datacenterlight/order_detail.html
+++ b/datacenterlight/templates/datacenterlight/order_detail.html
@@ -126,21 +126,25 @@
{% if vm.vat > 0 %}
- {% trans "Subtotal" %}
+ {% trans "Price" %}
{{vm.price|floatformat:2|intcomma}} CHF
+ {% if vm.discount.amount > 0 %}
+
+ {%trans "Discount" as discount_name %}
+ {{ vm.discount.name|default:discount_name }}
+ - {{ vm.discount.amount }} CHF
+
+ {% endif %}
+
+ {% trans "Subtotal" %}
+ {{vm.price - vm.discount.amount|floatformat:2|intcomma}} CHF
+
{% trans "VAT for" %} {{vm.vat_country}} ({{vm.vat_percent}}%) :
{{vm.vat|floatformat:2|intcomma}} CHF
{% endif %}
- {% if vm.discount.amount > 0 %}
-
- {%trans "Discount" as discount_name %}
- {{ vm.discount.name|default:discount_name }}
- - {{ vm.discount.amount }} CHF
-
- {% endif %}
diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py
index f47905a5..2705143c 100644
--- a/utils/hosting_utils.py
+++ b/utils/hosting_utils.py
@@ -104,15 +104,17 @@ def get_vm_price_for_given_vat(cpu, memory, ssd_size, hdd_size=0,
(decimal.Decimal(hdd_size) * pricing.hdd_unit_price)
)
- vat = price * decimal.Decimal(vat_rate) * decimal.Decimal(0.01)
+ discount_name = pricing.discount_name
+ discount_amount = round(float(pricing.discount_amount), 2)
+ vat = (price - discount_amount) * decimal.Decimal(vat_rate) * decimal.Decimal(0.01)
vat_percent = vat_rate
cents = decimal.Decimal('.01')
price = price.quantize(cents, decimal.ROUND_HALF_UP)
vat = vat.quantize(cents, decimal.ROUND_HALF_UP)
discount = {
- 'name': pricing.discount_name,
- 'amount': round(float(pricing.discount_amount), 2)
+ 'name': discount_name,
+ 'amount': discount_amount
}
return (round(float(price), 2), round(float(vat), 2),
round(float(vat_percent), 2), discount)