Fix: Schema would show the full price for happy hour products

This commit is contained in:
Amritanshu Agrawal 2023-08-07 17:43:09 +05:30
parent 05302c4291
commit f1ef578eae
1 changed files with 2 additions and 4 deletions

View File

@ -55,11 +55,9 @@ class Inventory(BaseModel):
@model_validator(mode="after")
def calculate_amount(self) -> "Inventory":
price = 0 if self.is_happy_hour else self.price
self.amount = round(
Decimal(
(self.price or Decimal(0)) * self.quantity * (1 - self.discount) * (1 + (self.tax_rate or Decimal(0)))
),
2,
Decimal(price * self.quantity * (1 - self.discount) * (1 + (self.tax_rate or Decimal(0)))), 2
)
return self