From 4c621aed4b78d62f636d1535b85698c6af568187 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Thu, 14 Sep 2017 21:02:59 +0200 Subject: [PATCH] make it possible to have customorders and invoices without Danish VAT --- .../migrations/0049_auto_20170914_2034.py | 25 +++++++++++++++++++ src/shop/models.py | 12 +++++++-- src/shop/templates/pdf/custominvoice.html | 4 +++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/shop/migrations/0049_auto_20170914_2034.py diff --git a/src/shop/migrations/0049_auto_20170914_2034.py b/src/shop/migrations/0049_auto_20170914_2034.py new file mode 100644 index 00000000..fb244fbf --- /dev/null +++ b/src/shop/migrations/0049_auto_20170914_2034.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-09-14 18:34 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0048_product_ticket_type'), + ] + + operations = [ + migrations.AddField( + model_name='customorder', + name='danish_vat', + field=models.BooleanField(default=True, help_text='Danish VAT?'), + ), + migrations.AlterField( + model_name='customorder', + name='paid', + field=models.BooleanField(default=False, help_text='Check when this custom order has been paid (or if it gets cancelled out by a Credit Note)', verbose_name='Paid?'), + ), + ] diff --git a/src/shop/models.py b/src/shop/models.py index afc1cc8d..0b407cd6 100644 --- a/src/shop/models.py +++ b/src/shop/models.py @@ -41,16 +41,24 @@ class CustomOrder(CreatedUpdatedModel): paid = models.BooleanField( verbose_name=_('Paid?'), - help_text=_('Whether this custom order has been paid.'), + help_text=_('Check when this custom order has been paid (or if it gets cancelled out by a Credit Note)'), default=False, ) + danish_vat = models.BooleanField( + help_text="Danish VAT?", + default=True + ) + def __str__(self): return 'custom order id #%s' % self.pk @property def vat(self): - return Decimal(round(self.amount*Decimal(0.2), 2)) + if self.danish_vat: + return Decimal(round(self.amount*Decimal(0.2), 2)) + else: + return 0 class Order(CreatedUpdatedModel): diff --git a/src/shop/templates/pdf/custominvoice.html b/src/shop/templates/pdf/custominvoice.html index 101bc95d..f204a16a 100644 --- a/src/shop/templates/pdf/custominvoice.html +++ b/src/shop/templates/pdf/custominvoice.html @@ -34,7 +34,11 @@ + {% if invoice.customorder.danish_vat %} Danish VAT (25%) + {% else %} + No VAT + {% endif %} {{ invoice.customorder.vat|currency }}