From 6405e123ffbf1b16b05b04ba9b8d9d6a0174069f Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 29 Jun 2015 13:51:37 +0100 Subject: [PATCH 1/2] Added estimated VAT, as per issue #71 --- RIGS/rigboard.py | 2 ++ RIGS/templates/RIGS/item_table.html | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 050e0eda..269cbdb5 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -47,6 +47,8 @@ class EventCreate(generic.CreateView): def get_context_data(self, **kwargs): context = super(EventCreate, self).get_context_data(**kwargs) context['edit'] = True + context['new'] = True + context['currentVAT'] = models.VatRate.objects.current_rate() form = context['form'] if re.search('"-\d+"', form['items_json'].value()): diff --git a/RIGS/templates/RIGS/item_table.html b/RIGS/templates/RIGS/item_table.html index 199f92c3..cac7e0ba 100644 --- a/RIGS/templates/RIGS/item_table.html +++ b/RIGS/templates/RIGS/item_table.html @@ -29,8 +29,13 @@ £ {{object.sum_total|default:0|floatformat:2}} - VAT @ - {{object.vat_rate.as_percent|floatformat|default:"TBD"}}% + {% if new %} + VAT @ + {{currentVAT.as_percent|floatformat}}% (TBC) + {% else %} + VAT @ + {{object.vat_rate.as_percent|floatformat|default:"TBD"}}% + {% endif %} £ {{object.vat|default:0|floatformat:2}} From 0dd5a1d931d787f14c3984930710064eadaae525 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 19 Jul 2015 16:14:40 +0100 Subject: [PATCH 2/2] Removed unnecessary variable & updated test --- RIGS/rigboard.py | 1 - RIGS/templates/RIGS/item_table.html | 2 +- RIGS/test_functional.py | 8 +++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 269cbdb5..cdbd2865 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -47,7 +47,6 @@ class EventCreate(generic.CreateView): def get_context_data(self, **kwargs): context = super(EventCreate, self).get_context_data(**kwargs) context['edit'] = True - context['new'] = True context['currentVAT'] = models.VatRate.objects.current_rate() form = context['form'] diff --git a/RIGS/templates/RIGS/item_table.html b/RIGS/templates/RIGS/item_table.html index cac7e0ba..0c652daf 100644 --- a/RIGS/templates/RIGS/item_table.html +++ b/RIGS/templates/RIGS/item_table.html @@ -29,7 +29,7 @@ £ {{object.sum_total|default:0|floatformat:2}} - {% if new %} + {% if not object.pk %} VAT @ {{currentVAT.as_percent|floatformat}}% (TBC) {% else %} diff --git a/RIGS/test_functional.py b/RIGS/test_functional.py index c9b5c906..dfb5a5da 100644 --- a/RIGS/test_functional.py +++ b/RIGS/test_functional.py @@ -143,6 +143,8 @@ class EventTest(LiveServerTestCase): self.profile.set_password("EventTestPassword") self.profile.save() + self.vatrate = models.VatRate.objects.create(start_at='2014-03-05',rate=0.20,comment='test1') + self.browser = webdriver.Firefox() os.environ['RECAPTCHA_TESTING'] = 'True' @@ -375,9 +377,9 @@ class EventTest(LiveServerTestCase): # Check totals self.assertEqual("47.90", self.browser.find_element_by_id('sumtotal').text) - self.assertIn("TBD%", self.browser.find_element_by_id('vat-rate').text) - self.assertEqual("0.00", self.browser.find_element_by_id('vat').text) - self.assertEqual("47.90", self.browser.find_element_by_id('total').text) + self.assertIn("(TBC)", self.browser.find_element_by_id('vat-rate').text) + self.assertEqual("9.58", self.browser.find_element_by_id('vat').text) + self.assertEqual("57.48", self.browser.find_element_by_id('total').text) # Attempt to save - missing title save.click()