From 7886c19c585242dfb0ed03be7b5774d99e246e20 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Mon, 17 Nov 2025 12:27:51 +0330 Subject: [PATCH] fix - distribution add calcualte remaining/ditributed weight on quota stat --- apps/product/services/quota_stat_service.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/product/services/quota_stat_service.py b/apps/product/services/quota_stat_service.py index 5f89f21..3b131c3 100644 --- a/apps/product/services/quota_stat_service.py +++ b/apps/product/services/quota_stat_service.py @@ -8,7 +8,6 @@ class QuotaStatsService: # origin org assigner = distribution.assigner_organization - print(assigner) # destination org assigned = distribution.assigned_organization # ================ origin ================ @@ -19,11 +18,10 @@ class QuotaStatsService: if created: assigner_stat.stat_type = 'distribution' assigner_stat.save() - print(assigner_stat.remaining_amount) - assigner_stat.remaining_amount -= distribution.weight - print(assigner_stat.remaining_amount) - assigner_stat.total_distributed += distribution.weight - assigner_stat.save() + if assigner_stat.stat_type == 'distribution': + assigner_stat.remaining_amount -= distribution.weight + assigner_stat.total_distributed += distribution.weight + assigner_stat.save() # ============== destination ================ assigned_stat, _ = OrganizationQuotaStats.objects.get_or_create( @@ -78,9 +76,10 @@ class QuotaStatsService: organization=distribution.assigner_organization, quota=quota ) - assigner_stat.remaining_amount += distribution.weight - assigner_stat.total_distributed -= distribution.weight - assigner_stat.save() + if assigner_stat.stat_type == 'distribution': + assigner_stat.remaining_amount += distribution.weight + assigner_stat.total_distributed -= distribution.weight + assigner_stat.save() # destination assigned_stat = OrganizationQuotaStats.objects.get(