Browse Source

Custo total deve ser somatória

pull/169/head
Sesóstris Vieira 1 year ago
parent
commit
eff9b7878c
  1. 7
      sigi/apps/eventos/admin.py

7
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) my_decimal_field = models.DecimalField(max_digits=14, decimal_places=2)
queryset = super().get_queryset(request) queryset = super().get_queryset(request)
return queryset.annotate( return queryset.annotate(
custo_total=(F("equipe__qtde_diarias") * F("equipe__valor_diaria")) custo_total=Sum(
+ F("equipe__total_passagens"), (F("equipe__qtde_diarias") * F("equipe__valor_diaria"))
+ F("equipe__total_passagens")
),
custo_participante=Cast( custo_participante=Cast(
Case( Case(
When(total_participantes__lte=0, then=None), When(total_participantes__lte=0, then=None),
default=F("custo_total") / F("total_participantes"), default=F("custo_total") / F("total_participantes"),
output_field=my_decimal_field,
), ),
output_field=my_decimal_field, output_field=my_decimal_field,
), ),

Loading…
Cancel
Save