diff --git a/shop/models.py b/shop/models.py index 05b2785f..b07b83c0 100644 --- a/shop/models.py +++ b/shop/models.py @@ -72,6 +72,14 @@ class Order(CreatedUpdatedModel): @property def subtotal(self): + return self.total - self.vat + + @property + def vat(self): + return (self.total/100)*25 + + @property + def total(self): return self.products.aggregate( sum=Sum( models.F('orderproductrelation__product__price') * @@ -80,14 +88,6 @@ class Order(CreatedUpdatedModel): ) )['sum'] - @property - def vat(self): - return (self.subtotal/100)*25 - - @property - def total(self): - return self.subtotal + self.vat - class ProductCategory(CreatedUpdatedModel, UUIDModel): class Meta: