fix inventory balanve & remaining - import provider name in device serializer

This commit is contained in:
2025-08-07 14:51:19 +03:30
parent bc8c884678
commit b6ef262c33
5 changed files with 28 additions and 1 deletions

View File

@@ -35,7 +35,13 @@ def remaining_distribution_weight(instance: QuotaDistribution):
total_children_weight = instance.children.aggregate(
total=Sum('weight')
)['total'] or 0
instance.remaining_weight = instance.weight - total_children_weight
# total warehouse inventory entry
total_entry = instance.inventory_entry.aggregate(
total=Sum('weight')
)['total'] or 0
instance.remaining_weight = instance.weight - total_children_weight - total_entry
instance.distributed = total_children_weight
instance._from_signal = True
instance.save(update_fields=['remaining_weight', 'distributed'])