Merge pull request #204

fix(api): re-order transactions from newest to oldest
This commit is contained in:
Herculino Trotta
2025-03-08 23:23:25 -03:00
committed by GitHub
3 changed files with 12 additions and 10 deletions

View File

@@ -176,7 +176,7 @@ class TransactionSerializer(serializers.ModelSerializer):
] ]
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(**kwargs) super().__init__(*args, **kwargs)
self.fields["account_id"].queryset = Account.objects.all() self.fields["account_id"].queryset = Account.objects.all()

View File

@@ -20,6 +20,8 @@ class AccountViewSet(viewsets.ModelViewSet):
pagination_class = CustomPageNumberPagination pagination_class = CustomPageNumberPagination
def get_queryset(self): def get_queryset(self):
return Account.objects.all().select_related( return (
"group", "currency", "exchange_currency" Account.objects.all()
.order_by("id")
.select_related("group", "currency", "exchange_currency")
) )

View File

@@ -38,7 +38,7 @@ class TransactionViewSet(viewsets.ModelViewSet):
return self.update(request, *args, **kwargs) return self.update(request, *args, **kwargs)
def get_queryset(self): def get_queryset(self):
return Transaction.objects.all().order_by("id") return Transaction.objects.all().order_by("-id")
class TransactionCategoryViewSet(viewsets.ModelViewSet): class TransactionCategoryViewSet(viewsets.ModelViewSet):
@@ -51,7 +51,7 @@ class TransactionCategoryViewSet(viewsets.ModelViewSet):
class TransactionTagViewSet(viewsets.ModelViewSet): class TransactionTagViewSet(viewsets.ModelViewSet):
queryset = TransactionTag.objects.all().order_by("id") queryset = TransactionTag.objects.all()
serializer_class = TransactionTagSerializer serializer_class = TransactionTagSerializer
pagination_class = CustomPageNumberPagination pagination_class = CustomPageNumberPagination
@@ -60,7 +60,7 @@ class TransactionTagViewSet(viewsets.ModelViewSet):
class TransactionEntityViewSet(viewsets.ModelViewSet): class TransactionEntityViewSet(viewsets.ModelViewSet):
queryset = TransactionEntity.objects.all().order_by("id") queryset = TransactionEntity.objects.all()
serializer_class = TransactionEntitySerializer serializer_class = TransactionEntitySerializer
pagination_class = CustomPageNumberPagination pagination_class = CustomPageNumberPagination
@@ -69,18 +69,18 @@ class TransactionEntityViewSet(viewsets.ModelViewSet):
class InstallmentPlanViewSet(viewsets.ModelViewSet): class InstallmentPlanViewSet(viewsets.ModelViewSet):
queryset = InstallmentPlan.objects.all().order_by("id") queryset = InstallmentPlan.objects.all()
serializer_class = InstallmentPlanSerializer serializer_class = InstallmentPlanSerializer
pagination_class = CustomPageNumberPagination pagination_class = CustomPageNumberPagination
def get_queryset(self): def get_queryset(self):
return InstallmentPlan.objects.all().order_by("id") return InstallmentPlan.objects.all().order_by("-id")
class RecurringTransactionViewSet(viewsets.ModelViewSet): class RecurringTransactionViewSet(viewsets.ModelViewSet):
queryset = RecurringTransaction.objects.all().order_by("id") queryset = RecurringTransaction.objects.all()
serializer_class = RecurringTransactionSerializer serializer_class = RecurringTransactionSerializer
pagination_class = CustomPageNumberPagination pagination_class = CustomPageNumberPagination
def get_queryset(self): def get_queryset(self):
return RecurringTransaction.objects.all().order_by("id") return RecurringTransaction.objects.all().order_by("-id")