diff --git a/inventory-backend/app/services/inbound/product_service.py b/inventory-backend/app/services/inbound/product_service.py index bdaf8f9..235e4c3 100644 --- a/inventory-backend/app/services/inbound/product_service.py +++ b/inventory-backend/app/services/inbound/product_service.py @@ -171,6 +171,7 @@ class ProductInboundService: production_time_range=time_range, raw_material_cost=raw_cost, manual_cost=unit_total_cost, + total_price=total_price, quality_status=data.get('quality_status', '合格'), product_photo=json.dumps(photo_list), quality_report_link=json.dumps(quality_list), @@ -230,6 +231,11 @@ class ProductInboundService: stock.stock_quantity = float(stock.stock_quantity) + diff stock.available_quantity = float(stock.available_quantity) + diff + # 计算总成本 + if 'unit_total_cost' in data or 'in_quantity' in data: + qty = float(data.get('in_quantity', stock.in_quantity or 1)) + stock.total_price = float(stock.manual_cost or 0) * qty + if 'production_start_time' in data or 'production_end_time' in data: old_range = stock.production_time_range or " ~ " parts = old_range.split(' ~ ')