Skip to content

Commit

Permalink
fix: Fixed user not able to view invoice if it had a total price of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
TreyWW committed Apr 1, 2024
1 parent 543a021 commit aa43cc1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand All @@ -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:
Expand Down

0 comments on commit aa43cc1

Please sign in to comment.