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"),