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
1 changed files with 11 additions and 4 deletions

View File

@ -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):