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
@@ -71,10 +71,10 @@ def test_projection_fact_read_failure_is_fail_closed():
|
||||
"""关键事实读取失败时必须进入人工诊断态,不得静默返回旧动作。"""
|
||||
payload = reconcile_processing_projection_facts({
|
||||
'status': 'running',
|
||||
'stage': 'inventory_preparation',
|
||||
'stage': 'onhand_preparation',
|
||||
'source_type': 'eml',
|
||||
'projection_data_inconsistent': True,
|
||||
'available_actions': ['retry_inventory_preparation'],
|
||||
'available_actions': ['retry_onhand_preparation'],
|
||||
})
|
||||
assert payload['status'] == 'waiting_human'
|
||||
assert 'retryable' not in payload
|
||||
@@ -87,10 +87,10 @@ def test_inventory_shortage_gate_projects_a_user_visible_blocking_reason():
|
||||
"""库存缺口 Gate 不能只保留内部码而遗漏批次/工作台的统一阻塞原因。"""
|
||||
payload = apply_user_projection_fields(reconcile_processing_projection_facts({
|
||||
'status': 'blocked',
|
||||
'stage': 'inventory_matching',
|
||||
'stage': 'onhand_matching',
|
||||
'source_type': 'eml',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_sufficiency',
|
||||
'gate_code': 'onhand_sufficiency',
|
||||
'status': 'blocked_manual',
|
||||
'next_action_code': 'open_shortage_review',
|
||||
'blocking_reason_code': 'inventory_shortage_review_required',
|
||||
@@ -116,12 +116,12 @@ def test_normalize_unknown_action_codes():
|
||||
def test_stage_nodes_length_is_fifteen():
|
||||
"""stage_nodes 恒为 15 阶权威事实。"""
|
||||
nodes = build_stage_nodes(
|
||||
stage='inventory_matching',
|
||||
stage='onhand_matching',
|
||||
status='automating',
|
||||
source_type='eml',
|
||||
)
|
||||
assert len(nodes) == 15
|
||||
assert nodes[11]['stage'] == 'inventory_matching'
|
||||
assert nodes[11]['stage'] == 'onhand_matching'
|
||||
assert nodes[11]['status'] == 'running'
|
||||
assert nodes[10]['status'] == 'passed'
|
||||
assert nodes[12]['status'] == 'pending'
|
||||
@@ -130,20 +130,20 @@ def test_stage_nodes_length_is_fifteen():
|
||||
def test_invalidated_from_stage_marks_nodes_pending():
|
||||
"""BE-01:改单失效起点及之后(当前游标之前)不得再标 passed。"""
|
||||
nodes = build_stage_nodes(
|
||||
stage='inventory_matching',
|
||||
stage='onhand_matching',
|
||||
status='processing',
|
||||
source_type='eml',
|
||||
invalidated_from_stage='inventory_source_resolving',
|
||||
invalidated_from_stage='onhand_source_resolving',
|
||||
)
|
||||
# inventory_source_resolving 在当前游标之前且位于失效起点,应标 pending。
|
||||
inv_node = next(n for n in nodes if n['stage'] == 'inventory_source_resolving')
|
||||
inv_node = next(n for n in nodes if n['stage'] == 'onhand_source_resolving')
|
||||
assert inv_node['status'] == 'pending'
|
||||
waiting = next(n for n in nodes if n['stage'] == 'waiting_review')
|
||||
assert waiting['status'] == 'pending'
|
||||
# 失效起点之前仍可为 passed。
|
||||
dup_node = next(n for n in nodes if n['stage'] == 'duplicate_checking')
|
||||
assert dup_node['status'] == 'passed'
|
||||
current = next(n for n in nodes if n['stage'] == 'inventory_matching')
|
||||
current = next(n for n in nodes if n['stage'] == 'onhand_matching')
|
||||
assert current['status'] == 'running'
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ def test_artifact_gate_overrides_stale_inventory_stage_and_action():
|
||||
"""Gate 18 阻断时不得继续展示旧库存匹配阶段或 match_inventory。"""
|
||||
payload = reconcile_processing_projection_facts({
|
||||
'status': 'automating',
|
||||
'stage': 'inventory_matching',
|
||||
'stage': 'onhand_matching',
|
||||
'source_type': 'order_task',
|
||||
'shipping_notice_no': 'SN-1',
|
||||
'current_gate': {
|
||||
@@ -241,9 +241,9 @@ def test_map_notice_to_processing_status_stage_domain_mapping():
|
||||
assert map_notice_to_processing_status_stage(waiting) == ('automating', 'freight_uploading')
|
||||
|
||||
matching = SimpleNamespace(
|
||||
current_step='inventory_matching', upload_status='', match_status='matching', export_file_path=None,
|
||||
current_step='onhand_matching', upload_status='', match_status='matching', export_file_path=None,
|
||||
)
|
||||
assert map_notice_to_processing_status_stage(matching) == ('automating', 'inventory_matching')
|
||||
assert map_notice_to_processing_status_stage(matching) == ('automating', 'onhand_matching')
|
||||
|
||||
|
||||
def test_map_notice_unknown_status_fail_closed():
|
||||
@@ -270,7 +270,7 @@ def test_derive_available_actions_without_gate_fails_closed():
|
||||
|
||||
actions = derive_available_actions(
|
||||
status='blocked',
|
||||
stage='inventory_source_resolving',
|
||||
stage='onhand_source_resolving',
|
||||
gate={
|
||||
'gate_code': 'inventory_source',
|
||||
'status': 'blocked',
|
||||
@@ -300,12 +300,12 @@ def test_retryable_projection_uses_technical_failure_reason_mapping():
|
||||
"""重试兜底原因必须生成可展示的技术失败 i18n 键,而不能抛 KeyError。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'processing',
|
||||
'stage': 'inventory_preparation',
|
||||
'stage': 'onhand_preparation',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'gate_code': 'onhand_preparation',
|
||||
'status': 'blocked_retryable',
|
||||
'next_action_code': 'retry_inventory_preparation',
|
||||
'next_action_code': 'retry_onhand_preparation',
|
||||
'blocking_reason_code': 'technical_failure_present',
|
||||
},
|
||||
'available_actions': ['retry'],
|
||||
@@ -323,26 +323,26 @@ def test_inventory_snapshot_missing_projects_retryable_inventory_action():
|
||||
"""库存快照缺失属于可恢复技术阻断,用户态必须保留重试动作。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'blocked',
|
||||
'stage': 'inventory_preparation',
|
||||
'stage': 'onhand_preparation',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'gate_code': 'onhand_preparation',
|
||||
'status': 'blocked_retryable',
|
||||
'next_action_code': 'retry_inventory_preparation',
|
||||
'next_action_code': 'retry_onhand_preparation',
|
||||
'blocking_reason_code': 'inventory_snapshot_missing',
|
||||
},
|
||||
'retry_decision': {
|
||||
'retryable': True,
|
||||
'reason_code': 'inventory_snapshot_missing',
|
||||
},
|
||||
'available_actions': ['retry_inventory_preparation'],
|
||||
'available_actions': ['retry_onhand_preparation'],
|
||||
})
|
||||
|
||||
assert payload['user_status'] == 'retryable'
|
||||
assert 'retryable' not in payload
|
||||
# 主动作必须保留 Gate 原始码,前端才能提交到正确的库存准备执行器。
|
||||
assert payload['primary_action'] == {
|
||||
'code': 'retry_inventory_preparation',
|
||||
'code': 'retry_onhand_preparation',
|
||||
'i18n_key': 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryPreparation',
|
||||
'parameters': {},
|
||||
}
|
||||
@@ -352,30 +352,30 @@ def test_formal_blocked_gate_overrides_stale_preparation_running_state():
|
||||
"""正式 Gate 已阻断时,旧库存准备 waiting 不能把用户态降回系统处理中。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'processing',
|
||||
'stage': 'inventory_preparation',
|
||||
'stage': 'onhand_preparation',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'gate_code': 'onhand_preparation',
|
||||
'status': 'blocked_retryable',
|
||||
'next_action_code': 'retry_inventory_preparation',
|
||||
'next_action_code': 'retry_onhand_preparation',
|
||||
'blocking_reason_code': 'technical_failure_present',
|
||||
},
|
||||
'available_actions': ['retry_inventory_preparation'],
|
||||
'available_actions': ['retry_onhand_preparation'],
|
||||
})
|
||||
|
||||
# 关键断言:Gate 是业务裁决真相;Preparation Attempt 只能作为过程明细。
|
||||
assert payload['user_status'] == 'retryable'
|
||||
assert payload['primary_action']['code'] == 'retry_inventory_preparation'
|
||||
assert payload['primary_action']['code'] == 'retry_onhand_preparation'
|
||||
|
||||
|
||||
def test_retryable_projection_exposes_technical_failure_reason_without_retry_decision():
|
||||
"""AutoProgress 超时未生成 Retry Decision 时,工作项读取仍必须返回可翻译原因。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'blocked',
|
||||
'stage': 'inventory_preparation',
|
||||
'stage': 'onhand_preparation',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'gate_code': 'onhand_preparation',
|
||||
'status': 'blocked_retryable',
|
||||
'blocking_reason_code': 'technical_failure_present',
|
||||
},
|
||||
@@ -394,20 +394,20 @@ def test_formal_inventory_matching_retry_projects_business_i18n_key():
|
||||
"""正式 OT 的库存重试不得让页面回退展示内部 action code。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'blocked',
|
||||
'stage': 'inventory_matching',
|
||||
'stage': 'onhand_matching',
|
||||
'source_type': 'order_task',
|
||||
'shipping_notice_no': 'SN-RETRY-MATCH',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_matching',
|
||||
'gate_code': 'onhand_matching',
|
||||
'status': 'blocked_retryable',
|
||||
'next_action_code': 'retry_inventory_matching',
|
||||
'next_action_code': 'retry_onhand_matching',
|
||||
'blocking_reason_code': 'inventory_match_failed',
|
||||
},
|
||||
'available_actions': ['retry_inventory_matching'],
|
||||
'available_actions': ['retry_onhand_matching'],
|
||||
})
|
||||
|
||||
assert payload['primary_action'] == {
|
||||
'code': 'retry_inventory_matching',
|
||||
'code': 'retry_onhand_matching',
|
||||
'i18n_key': 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryMatching',
|
||||
'parameters': {},
|
||||
}
|
||||
@@ -422,28 +422,28 @@ def test_formal_inventory_gate_overrides_stale_waiting_review_compatibility_fiel
|
||||
'stage': 'waiting_review',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'gate_code': 'onhand_preparation',
|
||||
'status': 'blocked_manual',
|
||||
'next_action_code': 'retry_inventory_preparation',
|
||||
'blocking_reason_code': 'inventory_rpa_timeout',
|
||||
'next_action_code': 'retry_onhand_preparation',
|
||||
'blocking_reason_code': 'onhand_rpa_timeout',
|
||||
},
|
||||
'available_actions': ['open_order_review'],
|
||||
})
|
||||
|
||||
assert payload['status'] == 'waiting_review'
|
||||
assert payload['stage'] == 'inventory_fetching'
|
||||
assert payload['stage'] == 'onhand_fetching'
|
||||
assert 'projection_inconsistency_code' not in payload
|
||||
assert payload['available_actions'] == ['retry_inventory_preparation']
|
||||
assert payload['available_actions'] == ['retry_onhand_preparation']
|
||||
|
||||
|
||||
def test_inventory_file_missing_exposes_a_user_facing_reason_i18n_key():
|
||||
"""库存文件缺失需携带可翻译原因,批次中心不得回显内部原因码。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'blocked',
|
||||
'stage': 'inventory_preparation',
|
||||
'stage': 'onhand_preparation',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'gate_code': 'onhand_preparation',
|
||||
'status': 'blocked_manual',
|
||||
'blocking_reason_code': 'inventory_file_missing',
|
||||
},
|
||||
@@ -461,32 +461,32 @@ def test_inventory_file_empty_keeps_gate_retry_as_the_only_primary_action():
|
||||
"""库存文件缺失必须保留 Gate 重试,不得降级为线外上传或空按钮。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'processing',
|
||||
'stage': 'inventory_fetching',
|
||||
'stage': 'onhand_fetching',
|
||||
'source_type': 'order_task',
|
||||
'shipping_notice_no': 'SN-1',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'gate_code': 'onhand_preparation',
|
||||
'status': 'blocked_manual',
|
||||
'next_action_code': 'retry_inventory_preparation',
|
||||
'next_action_code': 'retry_onhand_preparation',
|
||||
'blocking_reason_code': 'inventory_file_empty',
|
||||
},
|
||||
'available_actions': ['retry_inventory_preparation'],
|
||||
'available_actions': ['retry_onhand_preparation'],
|
||||
})
|
||||
|
||||
assert payload['user_status'] == 'waiting_human'
|
||||
assert payload['primary_action'] == {
|
||||
'code': 'retry_inventory_preparation',
|
||||
'code': 'retry_onhand_preparation',
|
||||
'i18n_key': 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryPreparation',
|
||||
'parameters': {},
|
||||
}
|
||||
assert payload['available_actions'] == ['retry_inventory_preparation']
|
||||
assert payload['available_actions'] == ['retry_onhand_preparation']
|
||||
|
||||
|
||||
def test_waiting_human_reconcile_action_uses_gate_action():
|
||||
"""人工阻断的统一对账动作必须由正式 Gate 明确下发。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'waiting_review',
|
||||
'stage': 'inventory_matching',
|
||||
'stage': 'onhand_matching',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_candidates_calculated',
|
||||
'status': 'blocked',
|
||||
@@ -505,7 +505,7 @@ def test_waiting_human_without_reconcile_action_has_no_false_primary_action():
|
||||
"""未知人工阻断未提供统一对账动作时,不得凭空生成可执行主动作。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'waiting_review',
|
||||
'stage': 'inventory_matching',
|
||||
'stage': 'onhand_matching',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_candidates_calculated',
|
||||
'status': 'blocked',
|
||||
@@ -529,10 +529,10 @@ def test_in_flight_gate_projects_running_not_waiting_human():
|
||||
"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'waiting_review',
|
||||
'stage': 'inventory_preparation',
|
||||
'stage': 'onhand_preparation',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'gate_code': 'onhand_preparation',
|
||||
'status': 'waiting_external',
|
||||
},
|
||||
'available_actions': [],
|
||||
@@ -546,9 +546,9 @@ def test_apply_user_projection_fields_fail_closes_inconsistent_projection():
|
||||
"""事实读取异常即使发生在用户态计算后,也必须清空动作并进入诊断态。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'running',
|
||||
'stage': 'inventory_preparation',
|
||||
'current_gate': {'gate_code': 'inventory_preparation', 'status': 'running'},
|
||||
'available_actions': ['retry_inventory_preparation'],
|
||||
'stage': 'onhand_preparation',
|
||||
'current_gate': {'gate_code': 'onhand_preparation', 'status': 'running'},
|
||||
'available_actions': ['retry_onhand_preparation'],
|
||||
'projection_data_inconsistent': True,
|
||||
})
|
||||
|
||||
@@ -563,8 +563,8 @@ def test_inventory_milestones_are_projection_facts_not_runtime_gate_codes():
|
||||
"""四个 MVP 库存里程碑必须由正式 Gate 和结构化事实派生,不能创建 APX Gate。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'automating',
|
||||
'stage': 'inventory_matching',
|
||||
'current_gate': {'gate_code': 'inventory_matching', 'status': 'running'},
|
||||
'stage': 'onhand_matching',
|
||||
'current_gate': {'gate_code': 'onhand_matching', 'status': 'running'},
|
||||
'available_actions': [],
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user