From 28de7545b12689265bb3d7b9260546a8cc46905d Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Tue, 29 Oct 2024 15:05:39 -0300 Subject: [PATCH] feat: improve transaction ordering on calendar --- app/apps/calendar_view/utils/calendar.py | 7 ++++++- app/apps/calendar_view/views.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/apps/calendar_view/utils/calendar.py b/app/apps/calendar_view/utils/calendar.py index ffdfb9c..fe1bfeb 100644 --- a/app/apps/calendar_view/utils/calendar.py +++ b/app/apps/calendar_view/utils/calendar.py @@ -37,7 +37,12 @@ def get_transactions_by_day(year, month): # Get all transactions for the month transactions = Transaction.objects.filter( date__year=year, date__month=month - ).order_by("date") + ).order_by( + "date", + "-type", + "-is_paid", + "id", + ) # Calculate padding days needed padding_days = first_day.weekday() # Monday is 0, Sunday is 6 diff --git a/app/apps/calendar_view/views.py b/app/apps/calendar_view/views.py index a38f050..80bcf8e 100644 --- a/app/apps/calendar_view/views.py +++ b/app/apps/calendar_view/views.py @@ -66,7 +66,12 @@ def calendar_list(request, month: int, year: int): @require_http_methods(["GET"]) def calendar_transactions_list(request, day: int, month: int, year: int): date = datetime.date(year=year, month=month, day=day) - transactions = Transaction.objects.filter(date=date) + transactions = Transaction.objects.filter(date=date).order_by( + "date", + "-type", + "-is_paid", + "id", + ) return render( request,