add: add filters
This commit is contained in:
@@ -71,8 +71,16 @@ class CashTransactionStatisticsApiView(views.APIView):
|
|||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
cash_transaction_ids = request.query_params.getlist('cash_transaction')
|
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:
|
if cash_transaction_ids:
|
||||||
queryset = CashTransaction.objects.filter(id__in=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:
|
else:
|
||||||
queryset = CashTransaction.objects.all()
|
queryset = CashTransaction.objects.all()
|
||||||
res = queryset.aggregate(
|
res = queryset.aggregate(
|
||||||
|
|||||||
Reference in New Issue
Block a user