Skip to content

Commit

Permalink
fix date truncation. Use proper django function for that
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalfox committed Aug 7, 2023
1 parent 752500d commit 9e59e05
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions staffing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,6 @@ def consultant_csv_timesheet(request, consultant, days, month, missions):
@pydici_non_public
def mission_timesheet(request, mission_id):
"""Mission timesheet"""
dateTrunc = connections[Timesheet.objects.db].ops.date_trunc_sql # Shortcut to SQL date trunc function
mission = Mission.objects.get(id=mission_id)
current_month = date.today().replace(day=1) # Current month
consultants = mission.consultants()
Expand Down Expand Up @@ -1630,7 +1629,6 @@ def rates_report(request):
def missions_report(request, year=None, nature="HOLIDAYS"):
"""Reports about holidays or non-prod missions"""
data = []
dateTrunc = connections[Timesheet.objects.db].ops.date_trunc_sql # Shortcut to SQL date trunc function
month = int(get_parameter("FISCAL_YEAR_MONTH"))

timesheets = Timesheet.objects.filter(mission__nature=nature, working_date__lte=date.today())
Expand All @@ -1653,7 +1651,7 @@ def missions_report(request, year=None, nature="HOLIDAYS"):
end = date(year+1, month, 1)
timesheets = timesheets.filter(working_date__gte=start, working_date__lt=end)

timesheets =timesheets.extra(select={'month': dateTrunc("month", "working_date")})
timesheets =timesheets.annotate(month=TruncMonth("working_date"))
timesheets = timesheets.values("month", "mission__description", "consultant__name", "consultant__profil__name", "consultant__company__name").annotate(Sum("charge")).order_by("month")

for timesheet in timesheets:
Expand Down

0 comments on commit 9e59e05

Please sign in to comment.