fix: adjust product service to use manual_cost instead of unit_total_cost

Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
dxc
2026-03-02 11:57:14 +08:00
parent bcd39729f8
commit 7f19867139

View File

@ -170,8 +170,7 @@ class ProductInboundService:
production_manager=data.get('production_manager'), production_manager=data.get('production_manager'),
production_time_range=time_range, production_time_range=time_range,
raw_material_cost=raw_cost, raw_material_cost=raw_cost,
manual_cost=manual_cost, manual_cost=unit_total_cost,
unit_total_cost=unit_total_cost,
total_price=total_price, total_price=total_price,
quality_status=data.get('quality_status', '合格'), quality_status=data.get('quality_status', '合格'),
product_photo=json.dumps(photo_list), product_photo=json.dumps(photo_list),
@ -223,7 +222,7 @@ class ProductInboundService:
if 'sale_price' in data: stock.sale_price = float(data['sale_price']) if 'sale_price' in data: stock.sale_price = float(data['sale_price'])
if 'raw_material_cost' in data: stock.raw_material_cost = float(data['raw_material_cost']) if 'raw_material_cost' in data: stock.raw_material_cost = float(data['raw_material_cost'])
if 'unit_total_cost' in data: stock.unit_total_cost = float(data['unit_total_cost']) if 'unit_total_cost' in data: stock.manual_cost = float(data['unit_total_cost'])
if 'in_quantity' in data: if 'in_quantity' in data:
new_qty = float(data['in_quantity']) new_qty = float(data['in_quantity'])
@ -234,7 +233,7 @@ class ProductInboundService:
if 'unit_total_cost' in data or 'in_quantity' in data: if 'unit_total_cost' in data or 'in_quantity' in data:
qty = float(data.get('in_quantity', stock.in_quantity or 1)) qty = float(data.get('in_quantity', stock.in_quantity or 1))
stock.total_price = float(stock.unit_total_cost or 0) * qty stock.total_price = float(stock.manual_cost or 0) * qty
if 'production_start_time' in data or 'production_end_time' in data: if 'production_start_time' in data or 'production_end_time' in data:
old_range = stock.production_time_range or " ~ " old_range = stock.production_time_range or " ~ "
@ -322,7 +321,9 @@ class ProductInboundService:
items = [] items = []
for item in current_items: for item in current_items:
items.append(item.to_dict()) item_dict = item.to_dict()
item_dict['unit_total_cost'] = float(item.manual_cost or 0)
items.append(item_dict)
return {"total": pagination.total, "items": items} return {"total": pagination.total, "items": items}
except: except:
traceback.print_exc() traceback.print_exc()