refactor(shipping-notice): 统一料号字段,移除过时的 SKU 相关字段,更新相关逻辑以支持新字段命名
This commit is contained in:
1 parent
dde25344ca
commit
46eb63f5bb
111 files changed
+3116
-1250
No files matched your search
@@ -90,6 +90,15 @@ def _delivery_date_for_task(task: ShippingTask) -> str:
|
||||
|
||||
|
||||
def _resolve_odm_id(task: ShippingTask) -> str:
|
||||
"""
|
||||
按订单内部料号与 Reservation 定位当前库存投影中的 ODM ID。
|
||||
|
||||
核心逻辑:订单与库存统一按 part_number + reservation_id 配对。
|
||||
Args:
|
||||
task: 已关联库存快照的发货任务。
|
||||
Returns:
|
||||
首个匹配库存行的 ODM ID;未命中时回退库存中的首个非空值。
|
||||
"""
|
||||
notice_lines = read_task_order_lines(task)
|
||||
inventory_lines = [row for row in (task.inventory_lines_json or []) if isinstance(row, dict)]
|
||||
if not inventory_lines:
|
||||
@@ -98,14 +107,14 @@ def _resolve_odm_id(task: ShippingTask) -> str:
|
||||
inv_by_key: dict[tuple[str, str], dict[str, Any]] = {}
|
||||
for row in inventory_lines:
|
||||
key = (
|
||||
str(row.get("sku") or "").strip(),
|
||||
str(row.get("part_number") or "").strip(),
|
||||
str(row.get("reservation_id") or "").strip(),
|
||||
)
|
||||
inv_by_key[key] = row
|
||||
|
||||
for line in notice_lines:
|
||||
key = (
|
||||
str(line.get("sku") or "").strip(),
|
||||
str(line.get("part_number") or "").strip(),
|
||||
str(line.get("reservation_id") or "").strip(),
|
||||
)
|
||||
matched = inv_by_key.get(key)
|
||||
@@ -155,8 +164,9 @@ def _line_currency(task: ShippingTask, line: dict[str, Any]) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def _line_vendor_part_number(line: dict[str, Any]) -> str:
|
||||
return str(line.get("vendor_part_number") or "").strip()
|
||||
def _line_part_number(line: dict[str, Any]) -> str:
|
||||
"""返回货代明细使用的内部料号。"""
|
||||
return str(line.get("part_number") or "").strip()
|
||||
|
||||
|
||||
def _clear_sheet_data_rows(ws, *, from_row: int = DATA_START_ROW) -> None:
|
||||
@@ -201,7 +211,7 @@ def _fill_pvmi_template(task: ShippingTask, path: Path) -> None:
|
||||
|
||||
detail_ws.cell(row_idx, 1).value = business_ref
|
||||
detail_ws.cell(row_idx, 2).value = line_no
|
||||
detail_ws.cell(row_idx, 4).value = _line_vendor_part_number(line)
|
||||
detail_ws.cell(row_idx, 4).value = _line_part_number(line)
|
||||
detail_ws.cell(row_idx, 5).value = qty if qty is not None else ""
|
||||
detail_ws.cell(row_idx, 7).value = _line_po_number(task, line)
|
||||
detail_ws.cell(row_idx, 10).value = amount if amount is not None else ""
|
||||
@@ -217,7 +227,7 @@ def _row_values(task: ShippingTask, line: dict | None) -> list:
|
||||
task.customer_code or "",
|
||||
task.ship_to or "",
|
||||
task.required_date or "",
|
||||
line.get("sku") or "",
|
||||
line.get("part_number") or "",
|
||||
line.get("qty") or "",
|
||||
line.get("uom") or "EA",
|
||||
line.get("remark") or "",
|
||||
|
||||
Reference in new issue
Block a user