discount name in templates
This commit is contained in:
parent
2ff8c25034
commit
eeed9b2e72
5 changed files with 15 additions and 11 deletions
|
@ -79,8 +79,8 @@
|
|||
{% if vm.discount > 0 %}
|
||||
<p class="text-primary">
|
||||
{%trans "Discount" as discount_name %}
|
||||
<span>{{ vm_pricing.discount_name|default:discount_name }}: </span>
|
||||
<span class="pull-right">- {{ vm_pricing.discount_amount }} CHF</span>
|
||||
<span>{{ vm.discount.name|default:discount_name }}: </span>
|
||||
<span class="pull-right">- {{ discount.amount }} CHF</span>
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
|
|
|
@ -172,7 +172,7 @@ class IndexView(CreateView):
|
|||
'vat': vat,
|
||||
'vat_percent': vat_percent,
|
||||
'discount': discount,
|
||||
'total_price': price + vat - discount,
|
||||
'total_price': price + vat - discount.amount,
|
||||
'pricing_name': vm_pricing_name
|
||||
}
|
||||
request.session['specs'] = specs
|
||||
|
|
|
@ -138,11 +138,11 @@
|
|||
<span class="pull-right">{{vm.vat|floatformat:2|intcomma}} CHF</span>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if vm_pricing.discount_amount %}
|
||||
{% if vm.discount > 0 %}
|
||||
<p class="text-primary">
|
||||
{%trans "Discount" as discount_name %}
|
||||
<span>{{ vm_pricing.discount_name|default:discount_name }}: </span>
|
||||
<span class="pull-right">- {{ vm_pricing.discount_amount }} CHF</span>
|
||||
<span>{{ vm.discount.name|default:discount_name }}: </span>
|
||||
<span class="pull-right">- {{ discount.amount }} CHF</span>
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
|
|
|
@ -764,7 +764,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
|
|||
context['vm']['price'] = price
|
||||
context['vm']['discount'] = discount
|
||||
context['vm']['vat_percent'] = vat_percent
|
||||
context['vm']['total_price'] = price + vat - discount
|
||||
context['vm']['total_price'] = price + vat - discount.amount
|
||||
context['subscription_end_date'] = vm_detail.end_date()
|
||||
except VMDetail.DoesNotExist:
|
||||
try:
|
||||
|
@ -784,7 +784,8 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
|
|||
context['vm']['price'] = price
|
||||
context['vm']['discount'] = discount
|
||||
context['vm']['vat_percent'] = vat_percent
|
||||
context['vm']['total_price'] = price + vat - discount
|
||||
context['vm']['total_price'] = price + \
|
||||
vat - discount.amount
|
||||
except WrongIdError:
|
||||
messages.error(
|
||||
self.request,
|
||||
|
@ -1084,7 +1085,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View):
|
|||
'price': price,
|
||||
'vat': vat,
|
||||
'vat_percent': vat_percent,
|
||||
'total_price': price + vat - discount,
|
||||
'total_price': price + vat - discount.amount,
|
||||
'pricing_name': vm_pricing_name
|
||||
}
|
||||
|
||||
|
|
|
@ -123,5 +123,8 @@ def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0,
|
|||
cents = decimal.Decimal('.01')
|
||||
price = price.quantize(cents, decimal.ROUND_HALF_UP)
|
||||
vat = vat.quantize(cents, decimal.ROUND_HALF_UP)
|
||||
discount = pricing.discount_amount
|
||||
return float(price), float(vat), float(vat_percent), float(discount)
|
||||
discount = {
|
||||
'name': pricing.discount_name,
|
||||
'amount': float(pricing.discount_amount),
|
||||
}
|
||||
return float(price), float(vat), float(vat_percent), discount
|
||||
|
|
Loading…
Reference in a new issue