From 050309a68e62c1db3a22330388f5b09abc100be4 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 21 Jul 2020 21:54:54 +0530 Subject: [PATCH] Add exclude_vat_calculations field and add VAT only when this is set to False --- hosting/models.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hosting/models.py b/hosting/models.py index 67c55aa2..1061cf54 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -82,15 +82,22 @@ class GenericProduct(AssignPermissionsMixin, models.Model): product_subscription_interval = models.CharField( max_length=10, default="month", help_text="Choose between `year` and `month`") + exclude_vat_calculations = models.BooleanField( + default=False, + help_text="When checked VAT calculations are excluded for this product" + ) def __str__(self): return self.product_name def get_actual_price(self, vat_rate=None): - VAT = vat_rate if vat_rate is not None else self.product_vat - return round( - float(self.product_price) + float(self.product_price) * float(VAT), 2 - ) + if self.exclude_vat_calculations: + return round(float(self.product_price), 2) + else: + VAT = vat_rate if vat_rate is not None else self.product_vat + return round( + float(self.product_price) + float(self.product_price) * float(VAT), 2 + ) class HostingOrder(AssignPermissionsMixin, models.Model):