Fix the way we calculate VAT and final VM price
1. Get the VM's pricing from its config and VMPricing 2. Compute and apply discount if any 3. Apply VAT on the discounted amount from 2
This commit is contained in:
parent
ef0e3b76fa
commit
484bd53bd2
5 changed files with 60 additions and 61 deletions
|
|
@ -98,22 +98,26 @@
|
|||
{% if vm.vat > 0 or vm.discount.amount > 0 %}
|
||||
<div class="col-sm-6">
|
||||
<div class="subtotal-price">
|
||||
{% if vm.vat > 0 %}
|
||||
<p>
|
||||
<strong class="text-lg">{% trans "Subtotal" %} </strong>
|
||||
<strong class="pull-right">{{vm.price|floatformat:2|intcomma}} CHF</strong>
|
||||
</p>
|
||||
<p>
|
||||
<small>{% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%) </small>
|
||||
<strong class="pull-right">{{vm.vat|floatformat:2|intcomma}} CHF</strong>
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
<strong>{% trans "Subtotal" %} </strong>
|
||||
<strong class="pull-right">{{vm.price|floatformat:2|intcomma}} CHF</strong>
|
||||
</p>
|
||||
{% if vm.discount.amount > 0 %}
|
||||
<p class="text-primary">
|
||||
{%trans "Discount" as discount_name %}
|
||||
<strong>{{ vm.discount.name|default:discount_name }} </strong>
|
||||
<strong class="pull-right">- {{ vm.discount.amount }} CHF</strong>
|
||||
</p>
|
||||
<p>
|
||||
<small>{% trans "Subtotal after discount" %}</small>
|
||||
<strong class="pull-right">{{vm.total_after_discount|floatformat:2|intcomma}} CHF</strong>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if vm.vat > 0 %}
|
||||
<p>
|
||||
<small>{% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%) </small>
|
||||
<strong class="pull-right">{{vm.vat|floatformat:2|intcomma}} CHF</strong>
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ class IndexView(CreateView):
|
|||
)
|
||||
return HttpResponseRedirect(referer_url + "#order_form")
|
||||
|
||||
price, vat, vat_percent, discount = get_vm_price_with_vat(
|
||||
vm_price_dict = get_vm_price_with_vat(
|
||||
cpu=cores,
|
||||
memory=memory,
|
||||
ssd_size=storage,
|
||||
|
|
@ -193,13 +193,9 @@ class IndexView(CreateView):
|
|||
'cpu': cores,
|
||||
'memory': memory,
|
||||
'disk_size': storage,
|
||||
'price': price,
|
||||
'vat': vat,
|
||||
'vat_percent': vat_percent,
|
||||
'discount': discount,
|
||||
'total_price': round(price + vat - discount['amount'], 2),
|
||||
'pricing_name': vm_pricing_name
|
||||
}
|
||||
specs.update(vm_price_dict)
|
||||
request.session['specs'] = specs
|
||||
request.session['template'] = template_data
|
||||
return HttpResponseRedirect(reverse('datacenterlight:payment'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue