fix - compare weight in distribution with parent or none

This commit is contained in:
2025-11-04 14:49:05 +03:30
parent 82e8c4f9fb
commit 03bd9e3c0e
2 changed files with 17 additions and 1 deletions

View File

@@ -65,7 +65,10 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
if total + amount > quota.quota_weight:
raise QuotaWeightException()
else:
if parent_distribution.weight + amount > parent_distribution.weight:
children_total = parent_distribution.children.all().aggregate(
total=models.Sum('weight')
)['total'] or 0
if children_total + amount > parent_distribution.weight:
raise QuotaWeightException()
if self.instance: