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(