fix - remaining dist weight in dist dashboard

This commit is contained in:
2025-12-10 15:55:41 +03:30
parent 553339de34
commit b8a563b4b0

View File

@@ -3,6 +3,7 @@ from django.db.models import Sum, Count, Q
from django.db.models.functions import Coalesce
from apps.authentication.models import Organization
from apps.authentication.services.service import get_all_org_child
from apps.core.services.filter.search import DynamicSearchService
from apps.product.models import OrganizationQuotaStats, QuotaDistribution, Quota
@@ -21,6 +22,10 @@ class QuotaDashboardService:
distribution_number = 0
base_filter = {} # filter queries
# child organizations
org_child = get_all_org_child(org)
org_child.append(org)
if product_id:
base_filter['quota__product_id'] = product_id
@@ -45,6 +50,7 @@ class QuotaDashboardService:
Q(registerer_organization=org) |
Q(assigned_organizations=org)
).distinct('id'),
organization__in=org_child,
stat_type='distribution',
**base_filter
)