From fe3fa73cfcf1ae6dc7c5b358770e0833e5f36b6d Mon Sep 17 00:00:00 2001 From: Sebastien Renard Date: Mon, 7 Oct 2024 10:26:56 +0200 Subject: [PATCH] filter out condition with no timesheet to avoid null date --- people/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/people/views.py b/people/views.py index b7afa7dc..827fac41 100644 --- a/people/views.py +++ b/people/views.py @@ -291,9 +291,9 @@ def value_repr(self): value=max_mission_per_month_qs["id__count"], link=max_mission_per_month_link)) - max_monthly_daily_rate = FinancialCondition.objects.filter(mission__lead__state="WON", consultant=consultant).annotate( - month=TruncMonth("mission__timesheet__working_date")).values("month").annotate(Avg("daily_rate")).order_by( - "-daily_rate__avg").first() + max_monthly_daily_rate = FinancialCondition.objects.filter(mission__lead__state="WON", consultant=consultant) \ + .exclude(mission__timesheet__working_date=None).annotate(month=TruncMonth("mission__timesheet__working_date")) \ + .values("month").annotate(Avg("daily_rate")).order_by("-daily_rate__avg").first() if max_monthly_daily_rate: achievements.append(Achievement(key="MAX_MONTHLY_DAILY_RATE", name=_("Max monthly daily rate (%s)") % max_monthly_daily_rate["month"].strftime("%m/%Y"),