diff --git a/Changelog b/Changelog index 17efb793..7f68ac8b 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,15 @@ +2.7.3: 2019-12-18 + * Bugfix: Swiss VAT being wrongly added to non-EU customers +2.7.2: 2019-12-17 + * Add vat rates for AD, TK and IS + * Improve billing address' string representation + Notes for deployment: + - Import the newly added vat rates into db + ``` + ./manage.py import_vat_rates vat_rates.csv + ``` +2.7.1: 2019-12-14 + * feature: Add management command to list active VM customers (MR!723) 2.7: 2019-12-9 * feature: EU VAT for new subscriptions (MR!721) Notes for deployment: diff --git a/datacenterlight/management/commands/all_customers.py b/datacenterlight/management/commands/all_customers.py new file mode 100644 index 00000000..adbd8552 --- /dev/null +++ b/datacenterlight/management/commands/all_customers.py @@ -0,0 +1,41 @@ +import logging + +from django.core.management.base import BaseCommand + +from hosting.models import ( + HostingOrder, VMDetail +) +from membership.models import CustomUser + +logger = logging.getLogger(__name__) + + +class Command(BaseCommand): + help = '''Dumps the email addresses of all customers who have a VM''' + + def add_arguments(self, parser): + parser.add_argument('-a', '--all_registered', action='store_true', + help='All registered users') + + def handle(self, *args, **options): + all_registered = options['all_registered'] + all_customers_set = set() + if all_registered: + all_customers = CustomUser.objects.filter( + is_admin=False, validated=True + ) + for customer in all_customers: + all_customers_set.add(customer.email) + else: + all_hosting_orders = HostingOrder.objects.filter() + running_vm_details = VMDetail.objects.filter(terminated_at=None) + running_vm_ids = [rvm.vm_id for rvm in running_vm_details] + for order in all_hosting_orders: + if order.vm_id in running_vm_ids: + all_customers_set.add(order.customer.user.email) + for cu in all_customers_set: + print(cu) + if all_registered: + print("All registered users = %s" % len(all_customers_set)) + else: + print("Total active customers = %s" % len(all_customers_set)) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 8ed0b794..952fa47f 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -619,6 +619,7 @@ class OrderConfirmationView(DetailView, FormView): vm_specs["vat_country"] = user_vat_country vm_specs["discount"] = discount vm_specs["total_price"] = round(price + vat - discount['amount'], 2) + request.session['specs'] = vm_specs context.update({ 'vm': vm_specs, diff --git a/utils/models.py b/utils/models.py index c969a60c..8cd529e0 100644 --- a/utils/models.py +++ b/utils/models.py @@ -20,7 +20,10 @@ class BaseBillingAddress(models.Model): class BillingAddress(BaseBillingAddress): def __str__(self): - return self.street_address + return "%s, %s, %s, %s, %s" % ( + self.cardholder_name, self.street_address, self.city, + self.postal_code, self.country + ) class UserBillingAddress(BaseBillingAddress): @@ -28,7 +31,10 @@ class UserBillingAddress(BaseBillingAddress): current = models.BooleanField(default=True) def __str__(self): - return self.street_address + return "%s, %s, %s, %s, %s" % ( + self.cardholder_name, self.street_address, self.city, + self.postal_code, self.country + ) def to_dict(self): return { diff --git a/vat_rates.csv b/vat_rates.csv index 4a3ec440..74422f48 100644 --- a/vat_rates.csv +++ b/vat_rates.csv @@ -316,3 +316,6 @@ IM",GBP,0.1,standard, 2019-11-15,,FR,EUR,0.2,standard,France standard VAT (added manually) 2019-11-15,,GR,EUR,0.24,standard,Greece standard VAT (added manually) 2019-11-15,,GB,EUR,0.2,standard,UK standard VAT (added manually) +2019-12-17,,AD,EUR,0.045,standard,Andorra standard VAT (added manually) +2019-12-17,,TK,EUR,0.18,standard,Turkey standard VAT (added manually) +2019-12-17,,IS,EUR,0.24,standard,Iceland standard VAT (added manually)