fix - bug of stat type in quota stat service

This commit is contained in:
2025-12-02 17:12:16 +03:30
parent 7f9f1ca1ea
commit 8b71fe3b94

View File

@@ -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(