fix - connect fields of distribution with org quota stat

This commit is contained in:
2025-11-22 15:36:48 +03:30
parent 97e4f30b98
commit 2d21d7d207

View File

@@ -94,6 +94,16 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
""" Custom output of serializer """
representation = super().to_representation(instance)
# get org quota stat detail
quotas_stat_amount = instance.quota.quota_amount_by_org(instance.assigned_organization)
representation['remaining_weight'] = quotas_stat_amount['remaining_weight']
representation['distributed'] = quotas_stat_amount['quota_distributed']
representation['warehouse_entry'] = quotas_stat_amount['inventory_received']
representation['warehouse_balance'] = quotas_stat_amount['inventory_entry_balance']
representation['been_sold'] = quotas_stat_amount['been_sold']
if instance.quota:
representation['quota'] = QuotaSerializer(instance.quota).data