add: add new feature for order and product

This commit is contained in:
behruz-dev
2025-09-15 14:49:43 +05:00
parent e3ab844250
commit d5e75dc6b2

View File

@@ -19,6 +19,7 @@ class OrderItemCreateSerializer(serializers.Serializer):
if not product: if not product:
raise serializers.ValidationError("Product not found") raise serializers.ValidationError("Product not found")
data['product'] = product data['product'] = product
product.quantity_left -= round(data['quantity'] / product.min_quantity)
data['price'] = round((data['quantity'] / product.min_quantity) * product.price) data['price'] = round((data['quantity'] / product.min_quantity) * product.price)
return data return data