feat(shipping-notice): 新增订单行与字段冲突管理功能,支持字段冲突查询与解决

This commit is contained in:
hugo committed 2026-07-16 13:03:11 +08:00
1 parent 4fbaed2b4c
commit 9da0481fc3
74 files changed
+4861 -375

No files matched your search

+33 -14
View File
@@ -716,22 +716,41 @@ def test_match_inventory_requires_reservation_id(app, client):
assert task is not None
task.lines_json = [{"sku": "A001", "qty": 1, "uom": "EA"}]
db.session.commit()
client.post(
"/api/shipping-notice/tools/ensure_inventory",
headers=headers,
json={
from app.services.shipping_notice.inventory_workflow import (
ensure_inventory as ensure_inventory_service,
parse_inventory as parse_inventory_service,
upload_inventory_file as upload_inventory_file_service,
)
from io import BytesIO
from werkzeug.datastructures import FileStorage
direct_data = ensure_inventory_service({
"task_id": task_id,
"inventory_lines": [{"sku": "A001", "reservation_id": "R-1", "available_qty": 10}],
},
)
match_res = client.post(
"/api/shipping-notice/tools/match_inventory",
headers=headers,
json={"task_id": task_id},
)
data = match_res.get_json()
assert data["status"] == "needs_human"
assert data.get("checkpoint") == "rsv_req"
})
assert direct_data["status"] == "needs_human", direct_data
assert direct_data.get("checkpoint") == "rsv_req"
assert not task.inventory_lines_json
parse_data = parse_inventory_service({
"task_id": task_id,
"inventory_lines": [{"sku": "A001", "reservation_id": "R-1", "available_qty": 10}],
})
assert parse_data["status"] == "needs_human"
assert parse_data.get("checkpoint") == "rsv_req"
assert not task.inventory_lines_json
upload_data = upload_inventory_file_service(
task_id,
FileStorage(stream=BytesIO(b"sku,qty\nA001,1"), filename="inventory.csv"),
)
assert upload_data["status"] == "needs_human"
assert upload_data.get("checkpoint") == "rsv_req"
from app.services.shipping_notice.fulfillment_workflow import match_inventory as match_inventory_service
match_data = match_inventory_service({"task_id": task_id})
assert match_data["status"] == "needs_human"
assert match_data.get("checkpoint") == "rsv_req"
def test_correct_inventory_mapping_resets_to_inference(app, client, tmp_path):