discount option added to calculator
This commit is contained in:
parent
4d2d337651
commit
f8dc2c6bbe
18 changed files with 554 additions and 476 deletions
|
|
@ -37,7 +37,6 @@ class DCLSectionPlugin(CMSPluginBase):
|
|||
'DCLSectionIconPluginModel',
|
||||
]
|
||||
for child in instance.child_plugin_instances:
|
||||
print(child.__dict__)
|
||||
if child.__class__.__name__ in right_children:
|
||||
context['children_to_side'].append(child)
|
||||
elif child.plugin_type == 'DCLCalculatorPlugin':
|
||||
|
|
|
|||
25
datacenterlight/migrations/0022_auto_20180506_1950.py
Normal file
25
datacenterlight/migrations/0022_auto_20180506_1950.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2018-05-06 14:20
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('datacenterlight', '0021_cmsintegration_calculator_placeholder'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='vmpricing',
|
||||
name='discount_amount',
|
||||
field=models.DecimalField(decimal_places=2, default=0, max_digits=4),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='vmpricing',
|
||||
name='discount_name',
|
||||
field=models.CharField(blank=True, max_length=255, null=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -34,6 +34,10 @@ class VMPricing(models.Model):
|
|||
hdd_unit_price = models.DecimalField(
|
||||
max_digits=7, decimal_places=6, default=0
|
||||
)
|
||||
discount_name = models.CharField(max_length=255, null=True, blank=True)
|
||||
discount_amount = models.DecimalField(
|
||||
max_digits=4, decimal_places=2, default=0
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.name + ' => ' + ' - '.join([
|
||||
|
|
@ -42,8 +46,12 @@ class VMPricing(models.Model):
|
|||
'{}/GB SSD'.format(self.ssd_unit_price.normalize()),
|
||||
'{}/GB HDD'.format(self.hdd_unit_price.normalize()),
|
||||
'{}% VAT'.format(self.vat_percentage.normalize())
|
||||
if not self.vat_inclusive else 'VAT-Incl', ]
|
||||
)
|
||||
if not self.vat_inclusive else 'VAT-Incl',
|
||||
'{} {}'.format(
|
||||
self.discount_amount if self.discount_amount else '',
|
||||
self.discount_name if self.discount_name else 'Discount'
|
||||
),
|
||||
])
|
||||
|
||||
@classmethod
|
||||
def get_vm_pricing_by_name(cls, name):
|
||||
|
|
|
|||
|
|
@ -150,3 +150,12 @@ footer .dcl-link-separator::before {
|
|||
border-radius: 100%;
|
||||
background: #777;
|
||||
}
|
||||
|
||||
.mb-0 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.thin-hr {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
|
@ -180,9 +180,13 @@
|
|||
if(typeof window.ssdUnitPrice === 'undefined'){
|
||||
window.ssdUnitPrice = 0.6;
|
||||
}
|
||||
if(typeof window.discountAmount === 'undefined'){
|
||||
window.discountAmount = 0;
|
||||
}
|
||||
var total = (cardPricing['cpu'].value * window.coresUnitPrice) +
|
||||
(cardPricing['ram'].value * window.ramUnitPrice) +
|
||||
(cardPricing['storage'].value * window.ssdUnitPrice);
|
||||
(cardPricing['storage'].value * window.ssdUnitPrice) -
|
||||
window.discountAmount;
|
||||
total = parseFloat(total.toFixed(2));
|
||||
$("#total").text(total);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
window.ramUnitPrice = {{vm_pricing.ram_unit_price|default:0}};
|
||||
window.ssdUnitPrice = {{vm_pricing.ssd_unit_price|default:0}};
|
||||
window.hddUnitPrice = {{vm_pricing.hdd_unit_price|default:0}};
|
||||
window.discountAmount = {{vm_pricing.discount_amount|default:0}};
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
|
|
@ -19,11 +20,15 @@
|
|||
<div class="price">
|
||||
<span id="total"></span>
|
||||
<span>CHF/{% trans "month" %}</span>
|
||||
{% if vm_pricing.vat_inclusive %}
|
||||
<div class="price-text">
|
||||
<p>{% trans "VAT included" %}</p>
|
||||
<p>
|
||||
{% if vm_pricing.vat_inclusive %}{% trans "VAT included" %} <br>{% endif %}
|
||||
{% if vm_pricing.discount_amount %}
|
||||
{% trans "Discount" as discount_name %}
|
||||
{{ vm_pricing.discount_amount }} CHF <strong>{{ vm_pricing.discount_name|default:discount_name }}</strong> included
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="descriptions">
|
||||
<div class="description form-group">
|
||||
|
|
|
|||
|
|
@ -78,7 +78,24 @@
|
|||
<hr>
|
||||
<p>{% trans "Configuration"%} <strong class="pull-right">{{request.session.template.name}}</strong></p>
|
||||
<hr>
|
||||
<p class="last-p"><strong>{%trans "Total" %}</strong> <small>({% if vm_pricing.vat_inclusive %}{%trans "including VAT" %}{% else %}{%trans "excluding VAT" %}{% endif %})</small> <strong class="pull-right">{{request.session.specs.price|intcomma}} CHF/{% trans "Month" %}</strong></p>
|
||||
<p>
|
||||
<strong>{%trans "Total" %}</strong>
|
||||
<small>
|
||||
({% if vm_pricing.vat_inclusive %}{%trans "including VAT" %}{% else %}{%trans "excluding VAT" %}{% endif %})
|
||||
</small>
|
||||
<strong class="pull-right">{{request.session.specs.price|intcomma}} CHF/{% trans "Month" %}</strong>
|
||||
</p>
|
||||
<hr>
|
||||
{% if vm_pricing.discount_amount %}
|
||||
<p class="mb-0">
|
||||
{%trans "Discount" as discount_name %}
|
||||
<strong>{{ vm_pricing.discount_name|default:discount_name }}</strong>
|
||||
<strong class="pull-right text-primary">- {{ vm_pricing.discount_amount }} CHF/{% trans "Month" %}</strong>
|
||||
</p>
|
||||
<p>
|
||||
({% trans "Will be applied at checkout" %})
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@
|
|||
<span>{% trans "Disk space" %}: </span>
|
||||
<span class="pull-right">{{vm.disk_size|intcomma}} GB</span>
|
||||
</p>
|
||||
<hr>
|
||||
{% if vm.vat > 0 %}
|
||||
<p>
|
||||
<strong>{% trans "Subtotal" %}: </strong>
|
||||
|
|
@ -75,6 +76,13 @@
|
|||
<span class="pull-right">{{vm.vat|floatformat:2|intcomma}} CHF</span>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if vm_pricing.discount_amount %}
|
||||
<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>
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
<strong>{% trans "Total" %}</strong>
|
||||
<span class="pull-right">{{vm.total_price|floatformat:2|intcomma}} CHF</span>
|
||||
|
|
|
|||
|
|
@ -387,7 +387,10 @@ class OrderConfirmationView(DetailView):
|
|||
'billing_address_data': (
|
||||
request.session.get('billing_address_data')
|
||||
),
|
||||
'cms_integration': get_cms_integration('default')
|
||||
'cms_integration': get_cms_integration('default'),
|
||||
'vm_pricing': VMPricing.get_vm_pricing_by_name(
|
||||
self.request.session['specs']['pricing_name']
|
||||
),
|
||||
}
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue