refactor(shipping-notice): 统一料号字段,移除过时的 SKU 相关字段,更新相关逻辑以支持新字段命名
This commit is contained in:
1 parent
dde25344ca
commit
46eb63f5bb
111 files changed
+3116
-1250
No files matched your search
@@ -30,7 +30,7 @@ def _task(**kwargs) -> ShippingTask:
|
||||
process_status=kwargs.pop('process_status', 'pending_review'),
|
||||
pending_human_reason=kwargs.pop('pending_human_reason', 'rsv_req'),
|
||||
po_number=kwargs.pop('po_number', 'PO-100'),
|
||||
lines_json=kwargs.pop('lines_json', [{'sku': 'A001', 'qty': 10}]),
|
||||
lines_json=kwargs.pop('lines_json', [{'part_number': 'A001', 'qty': 10}]),
|
||||
order_data_version=1,
|
||||
order_lines_migration_status='pending',
|
||||
**kwargs,
|
||||
@@ -52,15 +52,15 @@ def test_build_plan_fills_empty_and_conflicts_on_diff(app):
|
||||
"""空字段自动进入 fills;双方非空不同进入 conflicts。"""
|
||||
with app.app_context():
|
||||
task = _task(lines_json=[
|
||||
{'sku': 'A001', 'qty': 10, 'reservation_id': ''},
|
||||
{'sku': 'B002', 'qty': 5, 'reservation_id': '3000000001'},
|
||||
{'part_number': 'A001', 'qty': 10, 'reservation_id': ''},
|
||||
{'part_number': 'B002', 'qty': 5, 'reservation_id': '3000000001'},
|
||||
])
|
||||
plan = build_candidate_reconciliation_plan(
|
||||
task=task,
|
||||
candidate_summary={
|
||||
'lines': [
|
||||
{'sku': 'A001', 'qty': 10, 'reservation_id': '3000092917', 'hub_code': 'H1'},
|
||||
{'sku': 'B002', 'qty': 5, 'reservation_id': '3000000099'},
|
||||
{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000092917', 'inventory_source_hint': 'H1'},
|
||||
{'part_number': 'B002', 'qty': 5, 'reservation_id': '3000000099'},
|
||||
]
|
||||
},
|
||||
verified_reservation_evidence=[
|
||||
@@ -76,9 +76,9 @@ def test_build_plan_fills_empty_and_conflicts_on_diff(app):
|
||||
def test_apply_conflict_persists_field_conflict_and_blocks_gate(app):
|
||||
"""冲突落库后库存门禁应阻断。"""
|
||||
with app.app_context():
|
||||
task = _task(lines_json=[{'sku': 'A001', 'qty': 10, 'reservation_id': '3000000001'}])
|
||||
task = _task(lines_json=[{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000000001'}])
|
||||
replace_task_order_lines(task, task.lines_json, normalize=False)
|
||||
candidate = _candidate([{'sku': 'A001', 'qty': 10, 'reservation_id': '3000092917'}])
|
||||
candidate = _candidate([{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000092917'}])
|
||||
plan = build_candidate_reconciliation_plan(
|
||||
task=task,
|
||||
candidate_summary=candidate.summary_json,
|
||||
@@ -96,9 +96,9 @@ def test_apply_conflict_persists_field_conflict_and_blocks_gate(app):
|
||||
def test_resolve_conflict_writes_line_and_is_idempotent(app):
|
||||
"""解决冲突回写订单行;同幂等键可重放。"""
|
||||
with app.app_context():
|
||||
task = _task(lines_json=[{'sku': 'A001', 'qty': 10, 'reservation_id': '3000000001'}])
|
||||
task = _task(lines_json=[{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000000001'}])
|
||||
replace_task_order_lines(task, task.lines_json, normalize=False)
|
||||
candidate = _candidate([{'sku': 'A001', 'qty': 10, 'reservation_id': '3000092917'}])
|
||||
candidate = _candidate([{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000092917'}])
|
||||
plan = build_candidate_reconciliation_plan(
|
||||
task=task,
|
||||
candidate_summary=candidate.summary_json,
|
||||
@@ -137,14 +137,14 @@ def test_update_notice_line_version_mismatch(app):
|
||||
task = _task(
|
||||
process_status='parsed',
|
||||
pending_human_reason=None,
|
||||
lines_json=[{'sku': 'A001', 'qty': 10, 'reservation_id': '3000000001'}],
|
||||
lines_json=[{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000000001'}],
|
||||
)
|
||||
replace_task_order_lines(task, task.lines_json, normalize=False)
|
||||
db.session.commit()
|
||||
resp = update_notice_line({
|
||||
'task_id': task.task_no,
|
||||
'line_index': 0,
|
||||
'patch': {'hub_code': 'H9'},
|
||||
'patch': {'inventory_source_hint': 'H9'},
|
||||
'expected_order_data_version': 1,
|
||||
})
|
||||
# replace 已 bump version,再带 1 应失败;先读当前版本再测过期。
|
||||
@@ -153,7 +153,7 @@ def test_update_notice_line_version_mismatch(app):
|
||||
resp = update_notice_line({
|
||||
'task_id': task.task_no,
|
||||
'line_index': 0,
|
||||
'patch': {'hub_code': 'H8'},
|
||||
'patch': {'inventory_source_hint': 'H8'},
|
||||
'expected_order_data_version': stale,
|
||||
})
|
||||
assert resp['status'] == 'failed'
|
||||
@@ -165,13 +165,13 @@ def test_multiline_conflicts_persist_and_survive_line_replace(app):
|
||||
with app.app_context():
|
||||
app.config['SHIPPING_NOTICE_ORDER_LINES_WRITE_MODE'] = 'dual'
|
||||
task = _task(lines_json=[
|
||||
{'sku': 'A001', 'qty': 10, 'reservation_id': '3000000001'},
|
||||
{'sku': 'B002', 'qty': 5, 'reservation_id': '3000000002'},
|
||||
{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000000001'},
|
||||
{'part_number': 'B002', 'qty': 5, 'reservation_id': '3000000002'},
|
||||
])
|
||||
replace_task_order_lines(task, task.lines_json, normalize=False)
|
||||
candidate = _candidate([
|
||||
{'sku': 'A001', 'qty': 10, 'reservation_id': '3000092917'},
|
||||
{'sku': 'B002', 'qty': 5, 'reservation_id': '3000092918'},
|
||||
{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000092917'},
|
||||
{'part_number': 'B002', 'qty': 5, 'reservation_id': '3000092918'},
|
||||
])
|
||||
plan = build_candidate_reconciliation_plan(
|
||||
task=task,
|
||||
@@ -200,9 +200,9 @@ def test_multiline_conflicts_persist_and_survive_line_replace(app):
|
||||
def test_reconcile_exact_file_open_existing_auto_fill(app):
|
||||
"""安全态 exact_file 可自动补空 Reservation。"""
|
||||
with app.app_context():
|
||||
task = _task(lines_json=[{'sku': 'A001', 'qty': 10}])
|
||||
task = _task(lines_json=[{'part_number': 'A001', 'qty': 10}])
|
||||
replace_task_order_lines(task, task.lines_json, normalize=False)
|
||||
candidate = _candidate([{'sku': 'A001', 'qty': 10, 'reservation_id': '3000092917'}])
|
||||
candidate = _candidate([{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000092917'}])
|
||||
result = reconcile_exact_file_open_existing(
|
||||
task=task,
|
||||
candidate=candidate,
|
||||
|
||||
Reference in new issue
Block a user