Skip to content

Instantly share code, notes, and snippets.

@klement97
Created January 3, 2021 16:25
Show Gist options
  • Save klement97/ba52b146473ca28c846abd2b9ee8a40a to your computer and use it in GitHub Desktop.
Save klement97/ba52b146473ca28c846abd2b9ee8a40a to your computer and use it in GitHub Desktop.
@property
def total_price(self) -> Decimal:
"""
Total price is sum of the following:
- Pizza total price
- Size price
- Sum of toppings
"""
price = self.pizza.total_price + self.size.price
for topping in self.extra_toppings.all():
price += topping.price
return price
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment