x
This commit is contained in:
@@ -204,7 +204,12 @@ async def _issue_materials_for_order_creation(
|
|||||||
warehouse = await _get_default_warehouse(db_session)
|
warehouse = await _get_default_warehouse(db_session)
|
||||||
plan_items, planned_material_cost = await _build_material_plan(db_session, order)
|
plan_items, planned_material_cost = await _build_material_plan(db_session, order)
|
||||||
if not plan_items:
|
if not plan_items:
|
||||||
raise HTTPException(status_code=400, detail="销售单产品未配置物料BOM,无法自动扣减物料")
|
order.production_no = order.production_no or generate_order_no("WO")
|
||||||
|
order.production_status = "bom_missing"
|
||||||
|
order.planned_material_cost = 0
|
||||||
|
order.actual_material_cost = 0
|
||||||
|
order.status = "manufacturing"
|
||||||
|
return 0, 0, 0
|
||||||
shortage_items = [item for item in plan_items if item.shortage_quantity > 0]
|
shortage_items = [item for item in plan_items if item.shortage_quantity > 0]
|
||||||
if shortage_items:
|
if shortage_items:
|
||||||
shortage_text = ",".join([f"{item.material_name} 缺 {item.shortage_quantity}" for item in shortage_items])
|
shortage_text = ",".join([f"{item.material_name} 缺 {item.shortage_quantity}" for item in shortage_items])
|
||||||
@@ -252,7 +257,7 @@ async def _issue_materials_for_order_creation(
|
|||||||
order.production_status = "material_issued"
|
order.production_status = "material_issued"
|
||||||
order.planned_material_cost = round(float(planned_material_cost), 4)
|
order.planned_material_cost = round(float(planned_material_cost), 4)
|
||||||
order.actual_material_cost = round(float(actual_material_cost), 4)
|
order.actual_material_cost = round(float(actual_material_cost), 4)
|
||||||
order.status = "pending"
|
order.status = "manufacturing"
|
||||||
|
|
||||||
return movement_count, planned_material_cost, actual_material_cost
|
return movement_count, planned_material_cost, actual_material_cost
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -2144,17 +2144,17 @@ const InventoryView = {
|
|||||||
}))
|
}))
|
||||||
};
|
};
|
||||||
if (state.editingItem) {
|
if (state.editingItem) {
|
||||||
await apiRequest(`/api/sales-orders/${state.editingItem.id}`, {
|
const result = await apiRequest(`/api/sales-orders/${state.editingItem.id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
});
|
});
|
||||||
addNotification('销售订单更新成功', 'success');
|
addNotification(result.production_status === 'bom_missing' ? '订单已保存,但成品未配置BOM,未扣减物料' : '销售订单更新成功并已自动扣减物料', result.production_status === 'bom_missing' ? 'warning' : 'success');
|
||||||
} else {
|
} else {
|
||||||
await apiRequest('/api/sales-orders', {
|
const result = await apiRequest('/api/sales-orders', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
});
|
});
|
||||||
addNotification('销售订单创建成功并已自动扣减物料', 'success');
|
addNotification(result.production_status === 'bom_missing' ? '订单已创建,但成品未配置BOM,未扣减物料' : '销售订单创建成功并已自动扣减物料', result.production_status === 'bom_missing' ? 'warning' : 'success');
|
||||||
}
|
}
|
||||||
closeModal();
|
closeModal();
|
||||||
loadProductionOrders();
|
loadProductionOrders();
|
||||||
|
|||||||
Reference in New Issue
Block a user