From e5fcac45bebae3b7d1c2bb2f331c39197d2cd728 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Sat, 22 Nov 2025 10:19:22 +0330 Subject: [PATCH] add - inventory entered quotas --- apps/product/web/api/v1/viewsets/quota_api.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/apps/product/web/api/v1/viewsets/quota_api.py b/apps/product/web/api/v1/viewsets/quota_api.py index 6198502..570b899 100644 --- a/apps/product/web/api/v1/viewsets/quota_api.py +++ b/apps/product/web/api/v1/viewsets/quota_api.py @@ -370,6 +370,35 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicS serializer = self.get_serializer(page, many=True, context={'org': org}) return self.get_paginated_response(serializer.data) + @action( + methods=['get'], + detail=False, + url_path='inventory_entered_quotas', + url_name='inventory_entered_quotas', + name='inventory_entered_quotas' + ) + @transaction.atomic + def active_quotas_by_inventory_entry(self, request): + """ list of organization active quotas that have inventory entries """ + + org = get_organization_by_user(request.user) + + queryset = self.filter_query( + self.get_queryset(visibility_by_org_scope=True).filter( + is_closed=False)) # return by search param or all objects + + # paginate queryset + page = self.paginate_queryset( + queryset.filter( + Q(assigned_organizations=org) | + Q(registerer_organization=org), + org_quota_stats__inventory_received__gt=0, + ).order_by('-modify_date').distinct() + ) + if page is not None: # noqa + serializer = self.get_serializer(page, many=True, context={'org': org}) + return self.get_paginated_response(serializer.data) + @action( methods=['get'], detail=False,