Add exclude_vat_calculations field and add VAT only when this is set to False

This commit is contained in:
PCoder 2020-07-21 21:54:54 +05:30
parent 18c494dfd7
commit 050309a68e

View file

@ -82,15 +82,22 @@ class GenericProduct(AssignPermissionsMixin, models.Model):
product_subscription_interval = models.CharField( product_subscription_interval = models.CharField(
max_length=10, default="month", max_length=10, default="month",
help_text="Choose between `year` and `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): def __str__(self):
return self.product_name return self.product_name
def get_actual_price(self, vat_rate=None): def get_actual_price(self, vat_rate=None):
VAT = vat_rate if vat_rate is not None else self.product_vat if self.exclude_vat_calculations:
return round( return round(float(self.product_price), 2)
float(self.product_price) + float(self.product_price) * float(VAT), 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): class HostingOrder(AssignPermissionsMixin, models.Model):