feat(freight-rpa): 库存/收料改名在手/入站,报表归属RPA,类名统一FreightRpa
把 shipping 侧 inventory/receipt 词根迁到 onhand/inbound,29 张表与 枚举/权限/前端/i18n 同步改名;在手与入站报表配置及文件改由 freight_rpa 持有,发货与调拨仅按 source_code 消费;ORM 类加 FreightRpa 前缀, 上传动作改为 freight_rpa_upload。含类名与上传动作改名规格文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
ffc0d4a430
commit
39fe3c05f2
453 files changed
+17945
-8646
No files matched your search
@@ -13,8 +13,8 @@ tests/test_shipping_notice_ui_state.py
|
||||
from app import db
|
||||
from app.core.auth.jwt import issue_local_access_token
|
||||
from app.models import (
|
||||
ShippingInventoryCandidateLine, ShippingInventoryCandidateSet, ShippingInventoryCandidateSource,
|
||||
ShippingNotice, ShippingNoticeLine, ShippingNoticeLineInventoryMatch,
|
||||
ShippingOnhandCandidateLine, ShippingOnhandCandidateSet, ShippingOnhandCandidateSource,
|
||||
ShippingNotice, ShippingNoticeLine, ShippingNoticeLineOnhandMatch,
|
||||
ShippingOrderSnapshot, ShippingOrderSnapshotLine, ShippingOrderTask, User,
|
||||
)
|
||||
from app.services.shipping_notice.constants import (
|
||||
@@ -102,7 +102,7 @@ def test_unified_action_shape_contains_gate_version_fields():
|
||||
"lock_version": 7,
|
||||
"current_gate": {"evaluation_version": 3},
|
||||
"primary_action": {
|
||||
"code": "retry_inventory_matching",
|
||||
"code": "retry_onhand_matching",
|
||||
"label": "重新匹配",
|
||||
"dispatch": "mutation",
|
||||
},
|
||||
@@ -300,7 +300,7 @@ def test_task_ui_state_formal_gate_overrides_stale_task_fields(app) -> None:
|
||||
db.session.add(task)
|
||||
db.session.flush()
|
||||
execution = ensure_execution_for_workflow_version(task_id=task.id, actor_type='system')
|
||||
execution.current_gate_code = 'inventory_matching'
|
||||
execution.current_gate_code = 'onhand_matching'
|
||||
db.session.flush()
|
||||
|
||||
state = build_task_ui_state(task)
|
||||
@@ -382,11 +382,11 @@ def test_build_task_ui_state_queries_process_gate_once(app, monkeypatch) -> None
|
||||
def _fake_gate(_task):
|
||||
calls['n'] += 1
|
||||
return {
|
||||
'current_gate_code': 'inventory_sufficiency',
|
||||
'current_gate_code': 'onhand_sufficiency',
|
||||
'status': 'blocked',
|
||||
'lifecycle_stage': 'fulfillment_prep',
|
||||
'current_blocking_gate': {
|
||||
'gate_code': 'inventory_sufficiency',
|
||||
'gate_code': 'onhand_sufficiency',
|
||||
'status': 'blocked_manual',
|
||||
},
|
||||
'primary_action': None,
|
||||
@@ -555,18 +555,18 @@ def test_stp_facts_candidates_frozen_projected(app) -> None:
|
||||
)
|
||||
db.session.add(task)
|
||||
db.session.flush()
|
||||
candidate_set = ShippingInventoryCandidateSet(
|
||||
candidate_set = ShippingOnhandCandidateSet(
|
||||
task_id=task.id, set_version=1, lifecycle_status='frozen', input_fingerprint='a' * 64,
|
||||
)
|
||||
db.session.add(candidate_set)
|
||||
db.session.flush()
|
||||
db.session.add_all([
|
||||
ShippingInventoryCandidateSource(
|
||||
ShippingOnhandCandidateSource(
|
||||
candidate_set_id=candidate_set.id, source_code=code, candidate_order=index,
|
||||
)
|
||||
for index, code in enumerate(['DBS_DUB', 'DBS_RTM'], start=1)
|
||||
])
|
||||
db.session.add(ShippingInventoryCandidateLine(
|
||||
db.session.add(ShippingOnhandCandidateLine(
|
||||
candidate_set_id=candidate_set.id, line_no=1, source_codes_json=['DBS_DUB', 'DBS_RTM'],
|
||||
))
|
||||
task.active_inventory_candidate_set_id = candidate_set.id
|
||||
@@ -585,7 +585,7 @@ def test_stp_facts_projects_line_resolutions(app) -> None:
|
||||
db.session.add(user)
|
||||
db.session.flush()
|
||||
task = ShippingOrderTask(
|
||||
task_no='OT-UI-STP-LINES', user_id=user.id, stage='inventory_matching',
|
||||
task_no='OT-UI-STP-LINES', user_id=user.id, stage='onhand_matching',
|
||||
)
|
||||
db.session.add(task)
|
||||
db.session.flush()
|
||||
@@ -602,11 +602,11 @@ def test_stp_facts_projects_line_resolutions(app) -> None:
|
||||
)
|
||||
db.session.add(snapshot_line)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id, snapshot_line_id=snapshot_line.id, line_no=1, line_index=0,
|
||||
match_result='matched', inventory_status='ready', required_qty='10', available_qty='10',
|
||||
match_result='matched', onhand_status='ready', required_qty='10', available_qty='10',
|
||||
matched_qty='10', shortage_qty='0', reservation_id='3000092917', part_number='PN-1',
|
||||
inventory_source_code='DBS_DUB', matched_file_no='INV-1', is_current=True,
|
||||
source_code='DBS_DUB', matched_file_no='INV-1', is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
@@ -651,7 +651,7 @@ def test_stage_context_prefers_current_structured_inventory_match(app) -> None:
|
||||
user = User(username='ui-structured-match', email='ui-structured-match@example.com')
|
||||
db.session.add(user)
|
||||
db.session.flush()
|
||||
task = ShippingOrderTask(task_no='OT-UI-STRUCTURED-MATCH', user_id=user.id, stage='inventory_matching')
|
||||
task = ShippingOrderTask(task_no='OT-UI-STRUCTURED-MATCH', user_id=user.id, stage='onhand_matching')
|
||||
db.session.add(task)
|
||||
db.session.flush()
|
||||
snapshot = ShippingOrderSnapshot(
|
||||
@@ -667,20 +667,20 @@ def test_stage_context_prefers_current_structured_inventory_match(app) -> None:
|
||||
)
|
||||
db.session.add(snapshot_line)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id,
|
||||
snapshot_line_id=snapshot_line.id,
|
||||
line_no=1,
|
||||
line_index=0,
|
||||
match_result="matched",
|
||||
inventory_status="ready",
|
||||
onhand_status="ready",
|
||||
required_qty="10",
|
||||
available_qty="7",
|
||||
matched_qty="7",
|
||||
shortage_qty="3",
|
||||
reservation_id="RSV-1",
|
||||
part_number="PN-1",
|
||||
inventory_source_code="DBS_DUB",
|
||||
source_code="DBS_DUB",
|
||||
is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
@@ -703,22 +703,22 @@ def test_stage_context_prefers_current_structured_inventory_match(app) -> None:
|
||||
# §1.5 明细按钮:短缺 → close_unfulfillable / release_inventory_shortage + retry 两动作。
|
||||
assert line["is_shortage"] is True
|
||||
assert line["user_line_status"] == "shortage"
|
||||
assert set(line["line_allowed_actions"]) == {"close_unfulfillable", "release_inventory_shortage"}
|
||||
assert "retry_inventory_preparation" in line["inventory_allowed_actions"]
|
||||
assert set(line["line_allowed_actions"]) == {"close_unfulfillable", "release_onhand_shortage"}
|
||||
assert "retry_onhand_preparation" in line["inventory_allowed_actions"]
|
||||
|
||||
|
||||
def test_stage_context_hides_inventory_actions_while_rpa_running(app) -> None:
|
||||
"""库存 RPA queued/running 时,工作台 preparation 行不得下发重试 RPA 动作。
|
||||
|
||||
与 Case 投影同源:inventory_rpa_is_running 在行循环外算一次;运行中 actions 为空。
|
||||
与 Case 投影同源:onhand_rpa_is_running 在行循环外算一次;运行中 actions 为空。
|
||||
"""
|
||||
from app.models import ShippingTaskInventoryRpaAttempt
|
||||
from app.models import FreightRpaOnhandTaskAttempt
|
||||
|
||||
with app.app_context():
|
||||
user = User(username='ui-rpa-running', email='ui-rpa-running@example.com')
|
||||
db.session.add(user)
|
||||
db.session.flush()
|
||||
task = ShippingOrderTask(task_no='OT-UI-RPA-RUNNING', user_id=user.id, stage='inventory_matching')
|
||||
task = ShippingOrderTask(task_no='OT-UI-RPA-RUNNING', user_id=user.id, stage='onhand_matching')
|
||||
db.session.add(task)
|
||||
db.session.flush()
|
||||
snapshot = ShippingOrderSnapshot(
|
||||
@@ -734,23 +734,23 @@ def test_stage_context_hides_inventory_actions_while_rpa_running(app) -> None:
|
||||
)
|
||||
db.session.add(snapshot_line)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id,
|
||||
snapshot_line_id=snapshot_line.id,
|
||||
line_no=1,
|
||||
line_index=0,
|
||||
match_result='matched',
|
||||
inventory_status='ready',
|
||||
onhand_status='ready',
|
||||
required_qty='10',
|
||||
available_qty='7',
|
||||
matched_qty='7',
|
||||
shortage_qty='3',
|
||||
reservation_id='RSV-RPA',
|
||||
part_number='PN-RPA',
|
||||
inventory_source_code='DBS_DUB',
|
||||
source_code='DBS_DUB',
|
||||
is_current=True,
|
||||
))
|
||||
db.session.add(ShippingTaskInventoryRpaAttempt(
|
||||
db.session.add(FreightRpaOnhandTaskAttempt(
|
||||
task_no=task.task_no,
|
||||
source_code='DBS_DUB',
|
||||
attempt_no=1,
|
||||
@@ -769,7 +769,7 @@ def test_stage_context_hides_inventory_actions_while_rpa_running(app) -> None:
|
||||
def test_stage_context_preparation_projects_source_ambiguity_and_lock(app, monkeypatch) -> None:
|
||||
"""行级 source_conflict 与候选源只读 Match;Excel 未生成时下发 source_options。"""
|
||||
monkeypatch.setattr(
|
||||
'app.services.shipping_notice.inventory_source_repository.list_database_inventory_sources',
|
||||
'app.services.shipping_notice.onhand_source_repository.list_database_inventory_sources',
|
||||
lambda enabled_only=True: [
|
||||
{'source_code': 'src_a', 'display_name': 'Source A'},
|
||||
{'source_code': 'SRC_B', 'display_name': ''},
|
||||
@@ -779,7 +779,7 @@ def test_stage_context_preparation_projects_source_ambiguity_and_lock(app, monke
|
||||
user = User(username='ui-source-ambiguity', email='ui-source-ambiguity@example.com')
|
||||
db.session.add(user)
|
||||
db.session.flush()
|
||||
task = ShippingOrderTask(task_no='OT-UI-SOURCE-AMBIG', user_id=user.id, stage='inventory_matching')
|
||||
task = ShippingOrderTask(task_no='OT-UI-SOURCE-AMBIG', user_id=user.id, stage='onhand_matching')
|
||||
db.session.add(task)
|
||||
db.session.flush()
|
||||
snapshot = ShippingOrderSnapshot(
|
||||
@@ -792,9 +792,9 @@ def test_stage_context_preparation_projects_source_ambiguity_and_lock(app, monke
|
||||
line = ShippingOrderSnapshotLine(snapshot_id=snapshot.id, position=0, line_no=1, field_values_json={})
|
||||
db.session.add(line)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id, snapshot_line_id=line.id, line_no=1, line_index=0,
|
||||
match_result='source_conflict', inventory_status='source_conflict',
|
||||
match_result='source_conflict', onhand_status='source_conflict',
|
||||
allowed_source_codes_snapshot=['SRC_A', 'SRC_B'], is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
@@ -820,15 +820,15 @@ def test_stage_context_projects_selected_source_without_backfilling_match_source
|
||||
part_number='PN-SEL',
|
||||
qty='2',
|
||||
)
|
||||
candidate_set = ShippingInventoryCandidateSet(
|
||||
candidate_set = ShippingOnhandCandidateSet(
|
||||
task_id=task.id, set_version=1, lifecycle_status='frozen', input_fingerprint='b' * 64,
|
||||
)
|
||||
db.session.add(candidate_set)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingInventoryCandidateSource(
|
||||
db.session.add(ShippingOnhandCandidateSource(
|
||||
candidate_set_id=candidate_set.id, source_code='DSV360_AWSSG', candidate_order=1,
|
||||
))
|
||||
db.session.add(ShippingInventoryCandidateLine(
|
||||
db.session.add(ShippingOnhandCandidateLine(
|
||||
candidate_set_id=candidate_set.id, line_no=1, source_codes_json=['DSV360_AWSSG'],
|
||||
))
|
||||
task.active_inventory_candidate_set_id = candidate_set.id
|
||||
@@ -858,23 +858,23 @@ def test_stage_context_notice_resolves_ot_match_and_selected_source(app) -> None
|
||||
part_number='PN-NOTICE',
|
||||
qty='3',
|
||||
)
|
||||
candidate_set = ShippingInventoryCandidateSet(
|
||||
candidate_set = ShippingOnhandCandidateSet(
|
||||
task_id=task.id, set_version=1, lifecycle_status='frozen', input_fingerprint='c' * 64,
|
||||
)
|
||||
db.session.add(candidate_set)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingInventoryCandidateSource(
|
||||
db.session.add(ShippingOnhandCandidateSource(
|
||||
candidate_set_id=candidate_set.id, source_code='DSV360_AWSSG', candidate_order=1,
|
||||
))
|
||||
db.session.add(ShippingInventoryCandidateLine(
|
||||
db.session.add(ShippingOnhandCandidateLine(
|
||||
candidate_set_id=candidate_set.id, line_no=1, source_codes_json=['DSV360_AWSSG'],
|
||||
))
|
||||
task.active_inventory_candidate_set_id = candidate_set.id
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id, snapshot_line_id=line.id, line_no=1, line_index=0,
|
||||
match_result='matched', inventory_status='ready', required_qty='3', available_qty='3',
|
||||
match_result='matched', onhand_status='ready', required_qty='3', available_qty='3',
|
||||
matched_qty='3', shortage_qty='0', reservation_id='RSV-NOTICE', part_number='PN-NOTICE',
|
||||
inventory_source_code='DSV360_AWSSG', matched_file_no='INV-NOTICE', is_current=True,
|
||||
source_code='DSV360_AWSSG', matched_file_no='INV-NOTICE', is_current=True,
|
||||
))
|
||||
notice = ShippingNotice(
|
||||
task_no='SN-UI-NOTICE-RESOLVE',
|
||||
@@ -934,12 +934,12 @@ def test_preparation_lines_carry_part_available_qty(app) -> None:
|
||||
qty="8",
|
||||
)
|
||||
# 行 Match 事实:required '8'、part_available_qty='9'(允许源内、忽略预约号与单位的料号总可用量)。
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id, snapshot_line_id=line.id, line_no=1, line_index=0,
|
||||
match_result="matched", inventory_status="ready", required_qty="8",
|
||||
match_result="matched", onhand_status="ready", required_qty="8",
|
||||
available_qty="9", matched_qty="9", shortage_qty="0", part_available_qty="9",
|
||||
reservation_id="RSV-PART-AVAIL", part_number="PN-PART-AVAIL",
|
||||
inventory_source_code="DBS_DUB", is_current=True,
|
||||
source_code="DBS_DUB", is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
@@ -951,8 +951,8 @@ def test_preparation_lines_carry_part_available_qty(app) -> None:
|
||||
|
||||
def test_resolve_task_inventory_download_requires_current_task_link(app, tmp_path) -> None:
|
||||
"""库存文件下载只能读取当前任务 active link 指向的托管文件,禁止按库存源或订单猜测文件。"""
|
||||
from app.models import ShippingInventoryFile, ShippingTaskInventoryLink
|
||||
from app.services.shipping_notice.inventory_file_store import resolve_task_inventory_download
|
||||
from app.models import FreightRpaOnhandReportFile, ShippingTaskOnhandLink
|
||||
from app.services.shipping_notice.onhand_file_store import resolve_task_inventory_download
|
||||
|
||||
with app.app_context():
|
||||
inventory_path = tmp_path / "task-inventory.xlsx"
|
||||
@@ -960,8 +960,8 @@ def test_resolve_task_inventory_download_requires_current_task_link(app, tmp_pat
|
||||
task = ShippingOrderTask(
|
||||
task_no="OT-UI-INVENTORY-DOWNLOAD", user_id=1, source_type="direct_pdf",
|
||||
)
|
||||
inventory_file = ShippingInventoryFile(
|
||||
inventory_file_no="SIF-UI-DOWNLOAD",
|
||||
inventory_file = FreightRpaOnhandReportFile(
|
||||
onhand_file_no="SIF-UI-DOWNLOAD",
|
||||
storage_path=str(inventory_path),
|
||||
source_file_name="task-inventory.xlsx",
|
||||
snapshot_status="ready",
|
||||
@@ -972,9 +972,9 @@ def test_resolve_task_inventory_download_requires_current_task_link(app, tmp_pat
|
||||
# 未建立 task link 时不得因为文件存在而放行下载。
|
||||
assert resolve_task_inventory_download(task) is None
|
||||
|
||||
db.session.add(ShippingTaskInventoryLink(
|
||||
db.session.add(ShippingTaskOnhandLink(
|
||||
task_id=task.id,
|
||||
inventory_file_id=inventory_file.id,
|
||||
onhand_file_id=inventory_file.id,
|
||||
is_active=True,
|
||||
access_mode="readonly",
|
||||
))
|
||||
@@ -988,7 +988,7 @@ def test_resolve_task_inventory_download_requires_current_task_link(app, tmp_pat
|
||||
|
||||
def test_workspace_inventory_download_requires_owned_active_file(app, client, tmp_path) -> None:
|
||||
"""库存下载路由只能返回当前用户任务的 active link 文件,不能泄漏其他任务或无关联文件。"""
|
||||
from app.models import ShippingInventoryFile, ShippingTaskInventoryLink
|
||||
from app.models import FreightRpaOnhandReportFile, ShippingTaskOnhandLink
|
||||
|
||||
with app.app_context():
|
||||
owner = User(username='inventory-download-owner', email='inventory-download-owner@example.com')
|
||||
@@ -999,17 +999,17 @@ def test_workspace_inventory_download_requires_owned_active_file(app, client, tm
|
||||
inventory_path.write_bytes(b'inventory-download-content')
|
||||
task = ShippingOrderTask(task_no='OT-INVENTORY-DOWNLOAD-API', user_id=owner.id, source_type='direct_pdf')
|
||||
no_file_task = ShippingOrderTask(task_no='OT-INVENTORY-DOWNLOAD-NONE', user_id=owner.id, source_type='direct_pdf')
|
||||
inventory_file = ShippingInventoryFile(
|
||||
inventory_file_no='SIF-INVENTORY-DOWNLOAD-API',
|
||||
inventory_file = FreightRpaOnhandReportFile(
|
||||
onhand_file_no='SIF-INVENTORY-DOWNLOAD-API',
|
||||
storage_path=str(inventory_path),
|
||||
source_file_name='inventory-download.xlsx',
|
||||
snapshot_status='ready',
|
||||
)
|
||||
db.session.add_all([task, no_file_task, inventory_file])
|
||||
db.session.flush()
|
||||
db.session.add(ShippingTaskInventoryLink(
|
||||
db.session.add(ShippingTaskOnhandLink(
|
||||
task_id=task.id,
|
||||
inventory_file_id=inventory_file.id,
|
||||
onhand_file_id=inventory_file.id,
|
||||
is_active=True,
|
||||
access_mode='readonly',
|
||||
))
|
||||
@@ -1026,14 +1026,14 @@ def test_workspace_inventory_download_requires_owned_active_file(app, client, tm
|
||||
# 无 active link 和非归属用户均固定为 404,避免按来源或订单号探测库存文件。
|
||||
missing = client.get('/api/workspace/shipping-tasks/OT-INVENTORY-DOWNLOAD-NONE/inventory-file', headers=owner_headers)
|
||||
assert missing.status_code == 404
|
||||
assert missing.get_json()['error']['code'] == 'SHIPPING.TASK_INVENTORY_FILE_NOT_FOUND'
|
||||
assert missing.get_json()['error']['code'] == 'SHIPPING.TASK_ONHAND_FILE_NOT_FOUND'
|
||||
forbidden = client.get('/api/workspace/shipping-tasks/OT-INVENTORY-DOWNLOAD-API/inventory-file', headers=other_headers)
|
||||
assert forbidden.status_code == 404
|
||||
|
||||
|
||||
def test_workspace_line_inventory_download_requires_current_line_reference(app, client, tmp_path) -> None:
|
||||
"""行内下载只能读取当前匹配事实引用的库存文件,不能按文件号探测同任务其他来源。"""
|
||||
from app.models import ShippingInventoryFile, ShippingNoticeLineInventoryMatch
|
||||
from app.models import FreightRpaOnhandReportFile, ShippingNoticeLineOnhandMatch
|
||||
|
||||
with app.app_context():
|
||||
owner = User(username='line-inventory-download-owner', email='line-inventory-download-owner@example.com')
|
||||
@@ -1046,20 +1046,20 @@ def test_workspace_line_inventory_download_requires_current_line_reference(app,
|
||||
task, snapshot_line = _frozen_task_with_line(
|
||||
task_no='OT-LINE-INVENTORY-DOWNLOAD', user_id=owner.id,
|
||||
)
|
||||
allowed_file = ShippingInventoryFile(
|
||||
inventory_file_no='SIF-LINE-CRANE', storage_path=str(allowed_path),
|
||||
allowed_file = FreightRpaOnhandReportFile(
|
||||
onhand_file_no='SIF-LINE-CRANE', storage_path=str(allowed_path),
|
||||
source_file_name='crane.xlsx', source_code='CRANE', snapshot_status='ready',
|
||||
)
|
||||
denied_file = ShippingInventoryFile(
|
||||
inventory_file_no='SIF-LINE-DBS', storage_path=str(denied_path),
|
||||
denied_file = FreightRpaOnhandReportFile(
|
||||
onhand_file_no='SIF-LINE-DBS', storage_path=str(denied_path),
|
||||
source_file_name='dbs.xlsx', source_code='DBS', snapshot_status='ready',
|
||||
)
|
||||
db.session.add_all([task, allowed_file, denied_file])
|
||||
db.session.flush()
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id, snapshot_line_id=snapshot_line.id, line_no=1, line_index=0,
|
||||
inventory_snapshot_id=allowed_file.id, matched_file_no=allowed_file.inventory_file_no,
|
||||
inventory_source_code='CRANE', match_result='not_found', inventory_status='ready', is_current=True,
|
||||
onhand_snapshot_id=allowed_file.id, matched_file_no=allowed_file.onhand_file_no,
|
||||
source_code='CRANE', match_result='not_found', onhand_status='ready', is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
headers = {'Authorization': f'Bearer {issue_local_access_token(owner)}'}
|
||||
@@ -1088,19 +1088,19 @@ def test_stage_context_keeps_legacy_evidence_when_structured_row_is_partial(app)
|
||||
part_number="PN-LEGACY",
|
||||
qty="10",
|
||||
)
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id,
|
||||
snapshot_line_id=snapshot_line.id,
|
||||
line_no=1,
|
||||
line_index=0,
|
||||
match_result="matched",
|
||||
inventory_status="ready",
|
||||
onhand_status="ready",
|
||||
required_qty="10",
|
||||
available_qty="8",
|
||||
shortage_qty="2",
|
||||
reservation_id="RSV-LEGACY",
|
||||
part_number="PN-LEGACY",
|
||||
inventory_source_code="DBS_DUB",
|
||||
source_code="DBS_DUB",
|
||||
is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
@@ -1125,19 +1125,19 @@ def test_task_detail_endpoint_returns_preparation_stage_context(app, monkeypatch
|
||||
part_number="PN-DETAIL",
|
||||
qty="2",
|
||||
)
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id,
|
||||
snapshot_line_id=snapshot_line.id,
|
||||
line_no=1,
|
||||
line_index=0,
|
||||
match_result="matched",
|
||||
inventory_status="ready",
|
||||
onhand_status="ready",
|
||||
required_qty="2",
|
||||
available_qty="2",
|
||||
shortage_qty="0",
|
||||
reservation_id="RSV-DETAIL",
|
||||
part_number="PN-DETAIL",
|
||||
inventory_source_code="DBS_DUB",
|
||||
source_code="DBS_DUB",
|
||||
is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
@@ -1160,9 +1160,9 @@ def test_stp_facts_multi_source_excel_block_legacy_payload(app) -> None:
|
||||
task, snapshot_line = _frozen_task_with_line(
|
||||
task_no="OT-UI-STP-MULTI", reservation_id="RSV-MULTI", part_number="PN-MULTI", qty="1",
|
||||
)
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id, snapshot_line_id=snapshot_line.id, line_no=1, line_index=0,
|
||||
match_result='source_conflict', inventory_status='source_conflict',
|
||||
match_result='source_conflict', onhand_status='source_conflict',
|
||||
allowed_source_codes_snapshot=['DBS_DUB', 'DBS_RTM'], is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
@@ -1233,7 +1233,7 @@ def test_stage_context_line_actions_without_match_rows(app) -> None:
|
||||
"""正式 OT 无匹配行时,preparation.lines 仍须下发明细库存重试动作。
|
||||
|
||||
断言:has_formal_ot 不得用 current_match_rows 判定;无 match 时 fact 兜底 preparing,
|
||||
inventory_allowed_actions 含 retry_inventory_preparation。
|
||||
inventory_allowed_actions 含 retry_onhand_preparation。
|
||||
"""
|
||||
with app.app_context():
|
||||
user = User(username='ui-no-match-actions', email='ui-no-match-actions@example.com')
|
||||
@@ -1253,7 +1253,7 @@ def test_stage_context_line_actions_without_match_rows(app) -> None:
|
||||
assert len(preparation["lines"]) == 1
|
||||
line = preparation["lines"][0]
|
||||
# 关键断言:无 Match 行时明细仍可点「重试库存准备」,不得因 has_formal_ot=False 空动作。
|
||||
assert "retry_inventory_preparation" in line["inventory_allowed_actions"]
|
||||
assert "retry_onhand_preparation" in line["inventory_allowed_actions"]
|
||||
assert "close_unfulfillable" in line["line_allowed_actions"]
|
||||
|
||||
|
||||
@@ -1286,15 +1286,15 @@ def test_stage_context_preparation_projects_shortage_release_template_fields(app
|
||||
"""短缺行必须按库存源发货模板投影人工补录字段,禁止 fail-closed 空列表。"""
|
||||
from app.models import (
|
||||
ShippingExcelTemplate,
|
||||
ShippingInventoryField,
|
||||
ShippingInventorySource,
|
||||
FreightRpaOnhandField,
|
||||
FreightRpaSource,
|
||||
ShippingOrderSchema,
|
||||
ShippingOrderSchemaVersion,
|
||||
)
|
||||
|
||||
with app.app_context():
|
||||
location = ShippingInventoryField.query.filter_by(field_code='location').one()
|
||||
source = ShippingInventorySource.query.filter_by(source_code='DSV360_AWSDU').one()
|
||||
location = FreightRpaOnhandField.query.filter_by(field_code='location').one()
|
||||
source = FreightRpaSource.query.filter_by(source_code='DSV360_AWSDU').one()
|
||||
template = db.session.get(ShippingExcelTemplate, int(source.excel_template_id))
|
||||
assert template is not None
|
||||
template.definition_json = {
|
||||
@@ -1325,7 +1325,7 @@ def test_stage_context_preparation_projects_shortage_release_template_fields(app
|
||||
task = ShippingOrderTask(
|
||||
task_no='OT-UI-RELEASE-FIELDS',
|
||||
user_id=user.id,
|
||||
stage='inventory_matching',
|
||||
stage='onhand_matching',
|
||||
)
|
||||
db.session.add(task)
|
||||
db.session.flush()
|
||||
@@ -1351,21 +1351,21 @@ def test_stage_context_preparation_projects_shortage_release_template_fields(app
|
||||
db.session.add(snapshot_line)
|
||||
db.session.flush()
|
||||
# 无库存快照时模板库存字段全部人工补录;源码必须能解析到 published 发货模板。
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
db.session.add(ShippingNoticeLineOnhandMatch(
|
||||
task_id=task.id,
|
||||
snapshot_line_id=snapshot_line.id,
|
||||
line_no=1,
|
||||
line_index=0,
|
||||
match_result='not_found',
|
||||
inventory_status='ready',
|
||||
onhand_status='ready',
|
||||
required_qty='10',
|
||||
available_qty='0',
|
||||
matched_qty='0',
|
||||
shortage_qty='10',
|
||||
reservation_id='RSV-RELEASE',
|
||||
part_number='PN-RELEASE',
|
||||
inventory_source_code='DSV360_AWSDU',
|
||||
inventory_snapshot_id=None,
|
||||
source_code='DSV360_AWSDU',
|
||||
onhand_snapshot_id=None,
|
||||
is_current=True,
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
Reference in new issue
Block a user