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

View File

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