import - distributioin stat type for distribution tab

This commit is contained in:
2025-12-09 11:28:06 +03:30
parent f4958e657e
commit 9aef4967c7
4 changed files with 107 additions and 31 deletions

View File

@@ -410,12 +410,23 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, QuotaDashboardService, viewsets
dashboard of all quotas & their information
"""
search_fields = [
"quota__registerer_organization__name",
"quota__quota_id",
"quota__product__name",
"quota__sale_type",
"quota__sale_unit__unit",
"quota__group",
"quota__creator_info",
]
org = get_organization_by_user(request.user)
query_param = self.request.query_params # noqa
# filter by date
start_date = query_param.get('start') if 'start' in query_param.keys() else None
end_date = query_param.get('end') if 'end' in query_param.keys() else None
query_string = query_param.get('search') if 'search' in query_param.keys() else None
# filter by quota is close or open
is_closed = True if 'is_closed' in query_param.keys() else False
@@ -428,7 +439,16 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, QuotaDashboardService, viewsets
products = {f'{stat.quota.product.name}': stat.quota.product.id for stat in org_quota_stat}
dashboard_data_by_product = self.get_dashboard_by_product(self, org, products)
dashboard_data_by_product = self.get_dashboard_by_product(
self,
org,
products,
start_date=start_date,
end_date=end_date,
search_fields=search_fields,
quota_is_closed=is_closed,
query_string=query_string
)
return Response(dashboard_data_by_product)