From eff9b7878cc57cee1fb159475cc0415f0fb7baec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Thu, 23 Nov 2023 16:00:16 -0300 Subject: [PATCH] =?UTF-8?q?Custo=20total=20deve=20ser=20somat=C3=B3ria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/eventos/admin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py index cf0bc08..1419014 100644 --- a/sigi/apps/eventos/admin.py +++ b/sigi/apps/eventos/admin.py @@ -1051,13 +1051,14 @@ class EventoAdmin(AsciifyQParameter, CartExportReportMixin, admin.ModelAdmin): my_decimal_field = models.DecimalField(max_digits=14, decimal_places=2) queryset = super().get_queryset(request) return queryset.annotate( - custo_total=(F("equipe__qtde_diarias") * F("equipe__valor_diaria")) - + F("equipe__total_passagens"), + custo_total=Sum( + (F("equipe__qtde_diarias") * F("equipe__valor_diaria")) + + F("equipe__total_passagens") + ), custo_participante=Cast( Case( When(total_participantes__lte=0, then=None), default=F("custo_total") / F("total_participantes"), - output_field=my_decimal_field, ), output_field=my_decimal_field, ),