add: add filter to income-expence contract list api

This commit is contained in:
behruz-dev
2025-09-13 17:37:11 +05:00
parent f8a269a43a
commit 8d7133495a
2 changed files with 8 additions and 0 deletions

View File

@@ -43,6 +43,10 @@ class ExpenceContractListApiView(generics.GenericAPIView):
permission_classes = [HasRolePermission]
def get(self, request):
counterparty_id = request.query_params.get('counterparty')
if counterparty_id:
self.queryset = self.queryset.filter(counterparty=counterparty_id)
page = self.paginate_queryset(self.queryset)
if page is not None:
serializer = self.serializer_class(page, many=True)

View File

@@ -44,6 +44,10 @@ class IncomeContractListApiView(generics.GenericAPIView):
permission_classes = [HasRolePermission]
def get(self, request):
counterparty_id = request.query_params.get('counterparty')
if counterparty_id:
self.queryset = self.queryset.filter(counterparty=counterparty_id)
page = self.paginate_queryset(self.queryset)
if page is not None:
serializer = self.serializer_class(page, many=True)