From 8b71fe3b941cf38d9ab16a9c4cf47628c86f367d Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Tue, 2 Dec 2025 17:12:16 +0330 Subject: [PATCH] fix - bug of stat type in quota stat service --- apps/product/services/quota_stat_service.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/product/services/quota_stat_service.py b/apps/product/services/quota_stat_service.py index 63b7f5d..4b332da 100644 --- a/apps/product/services/quota_stat_service.py +++ b/apps/product/services/quota_stat_service.py @@ -59,11 +59,14 @@ class QuotaStatsService: assigner_stat, created = OrganizationQuotaStats.objects.get_or_create( organization=assigner, quota=quota, - stat_type='distribution' ) - assigner_stat.remaining_amount -= distribution.weight - assigner_stat.total_distributed += distribution.weight - assigner_stat.save() + if created: + assigner_stat.stat_type = 'distribution' + 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(