do not crap out when no tickets exist

This commit is contained in:
Thomas Steen Rasmussen 2021-08-01 17:43:53 +02:00
parent b5dd97e935
commit 929cde010e
1 changed files with 4 additions and 3 deletions

View File

@ -231,7 +231,8 @@ class ShopTicketStatsDetailView(CampViewMixin, OrgaTeamPermissionMixin, ListView
context["total_income"] += product.total_income
context["total_cost"] += product.total_cost
context["total_profit"] += product.total_profit
context["average_price"] = round(
context["total_income"] / context["total_units"], 2
)
if context["total_income"] and context["total_units"]:
context["average_price"] = round(
context["total_income"] / context["total_units"], 2
)
return context