diff --git a/backend/models.py b/backend/models.py index 6c2bf698..db6aec5f 100644 --- a/backend/models.py +++ b/backend/models.py @@ -349,11 +349,11 @@ def get_to_details(self) -> tuple[str, dict[str, str]]: "company": self.client_company, } - def get_subtotal(self): + def get_subtotal(self) -> Decimal: subtotal = 0 for item in self.items.all(): subtotal += item.get_total_price() - return round(subtotal, 2) + return Decimal(round(subtotal, 2)) def get_tax(self, amount: float = 0.00) -> float: amount = amount or self.get_subtotal() @@ -368,8 +368,8 @@ def get_percentage_amount(self, subtotal: float = 0.00) -> Decimal: return round(total * (self.discount_percentage / 100), 2) return Decimal(0) - def get_total_price(self): - total = self.get_subtotal() or 0.00 + def get_total_price(self) -> Decimal: + total = self.get_subtotal() or Decimal(0) total -= self.get_percentage_amount() @@ -382,7 +382,7 @@ def get_total_price(self): else: total -= self.get_tax(total) - return round(total, 2) + return Decimal(round(total, 2)) def has_access(self, user: User) -> bool: if not user.is_authenticated: