fix - warehouse of quota stat in pos deviec complete - v2

This commit is contained in:
2025-11-26 17:39:46 +03:30
parent 64d5912a74
commit a4bfa46e5d
8 changed files with 38 additions and 33 deletions

View File

@@ -201,11 +201,13 @@ class InventoryQuotaSaleTransactionSerializer(serializers.ModelSerializer):
gov_product = item_data.pop('gov_product', None)
free_product = item_data.pop('free_product', None)
distribution_id = item_data.pop('quota_distribution')
distribution = QuotaDistribution.objects.filter(
id=item_data.pop('quota_distribution')
id=distribution_id
).first() if 'quota_distribution' in item_data.keys() else None
quota_stat = OrganizationQuotaStats.objects.get(id=item_data.pop('quota_stat'))
quota_stat_id = item_data.pop('quota_stat')
quota_stat = OrganizationQuotaStats.objects.get(id=quota_stat_id)
# create item for transaction
item = warehouse_models.InventoryQuotaSaleItem.objects.create(
@@ -223,7 +225,7 @@ class InventoryQuotaSaleTransactionSerializer(serializers.ModelSerializer):
total_price += item.total_price
# IF WE DO NOT HAVE DISTRIBUTION, THEN IT IS A FREE PRODUCT TRANSACTION
if 'quota_distribution' and 'quota_stat' in item_data.keys():
if distribution_id and quota_stat_id in item_data.keys():
# create extra sale for distribution
create_extra_sale(transaction=transaction, sale_item=item)