diff --git a/src/backoffice/templates/ticket_stats_detail.html b/src/backoffice/templates/ticket_stats_detail.html index d6139c64..d8c5fa39 100644 --- a/src/backoffice/templates/ticket_stats_detail.html +++ b/src/backoffice/templates/ticket_stats_detail.html @@ -51,6 +51,7 @@
+

The average price of the {{ total_units }} tickets with the ticket type {{ product_list.0.ticket_type.name }} is {{ average_price|floatformat:"2" }} DKK.

Note: This view only shows tickets, which are generated based on paid orders. Unpaid orders are not included here.

Back to Ticket Types

diff --git a/src/backoffice/views/orga.py b/src/backoffice/views/orga.py index b5d80149..d246c7a5 100644 --- a/src/backoffice/views/orga.py +++ b/src/backoffice/views/orga.py @@ -228,4 +228,7 @@ 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 + ) return context diff --git a/src/tickets/models.py b/src/tickets/models.py index 7680da51..dad743cd 100644 --- a/src/tickets/models.py +++ b/src/tickets/models.py @@ -138,6 +138,8 @@ class DiscountTicket(BaseTicket): class ShopTicket(BaseTicket): + """Why doesn't this have an FK to OrderProductRelation instead of the fk to Order?""" + order = models.ForeignKey( "shop.Order", related_name="shoptickets", on_delete=models.PROTECT )