fix - distribution add calcualte remaining/ditributed weight on quota stat

This commit is contained in:
2025-11-17 12:27:51 +03:30
parent 78ddd9cdeb
commit 7886c19c58

View File

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