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:
@ -170,8 +170,7 @@ class ProductInboundService:
|
||||
production_manager=data.get('production_manager'),
|
||||
production_time_range=time_range,
|
||||
raw_material_cost=raw_cost,
|
||||
manual_cost=manual_cost,
|
||||
unit_total_cost=unit_total_cost,
|
||||
manual_cost=unit_total_cost,
|
||||
total_price=total_price,
|
||||
quality_status=data.get('quality_status', '合格'),
|
||||
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 '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:
|
||||
new_qty = float(data['in_quantity'])
|
||||
@ -234,7 +233,7 @@ class ProductInboundService:
|
||||
|
||||
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.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:
|
||||
old_range = stock.production_time_range or " ~ "
|
||||
@ -322,7 +321,9 @@ class ProductInboundService:
|
||||
|
||||
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}
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
Reference in New Issue
Block a user