add: add filters

This commit is contained in:
behruz-dev
2025-10-01 17:54:49 +05:00
parent 17bdb625ea
commit 729ea67660

View File

@@ -71,8 +71,16 @@ class CashTransactionStatisticsApiView(views.APIView):
def get(self, request):
cash_transaction_ids = request.query_params.getlist('cash_transaction')
start_date = request.query_params.get('start_date')
end_date = request.query_params.get('end_date')
project_ids = request.query_params.getlist('project_ids')
if cash_transaction_ids:
queryset = CashTransaction.objects.filter(id__in=cash_transaction_ids)
if start_date and end_date:
queryset = CashTransaction.objects.filter(created_at__range=(start_date, end_date))
if project_ids:
queryset = CashTransaction.objects.filter(projects__id__in=project_ids)
else:
queryset = CashTransaction.objects.all()
res = queryset.aggregate(