feat(shipping-notice): 收料异动解析配置闭环与按需触发FK违例修复
- 收料单元 schedule_run_id 改可空,修复按需触发 FK 违例 - 收料配置绑定已发布异动解析规则(校验/回显/审计快照) - 预检未绑异动规则 fail-closed,不再徒劳触发 RPA - 标准异动字段目录只读接口;解析规则用途切换与批号映射表单(四语言) - movement 解析规则可发布(跳过订单匹配键校验);站点启停门禁仅限库存站点页签 - 只读映射卡三列布局修复
This commit is contained in:
1 parent
ab57ab3b1f
commit
20835dcfc0
28 files changed
+987
-73
No files matched your search
@@ -281,3 +281,42 @@ def test_sample_analysis_rejects_invalid_file(app, tmp_path):
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
inventory_structure_analysis.create_sample_upload(upload, actor_id=None)
|
||||
assert exc_info.value.code == 'SHIPPING.INVENTORY_STRUCTURE_ANALYSIS_INVALID'
|
||||
|
||||
|
||||
def test_profile_draft_purpose_passthrough_creates_movement_profile(app, tmp_path):
|
||||
"""purpose='movement' 必须透传到解析规则:异动草稿不依赖库存字段目录与匹配键。"""
|
||||
app.config['SHIPPING_NOTICE_STORAGE_ROOT'] = str(tmp_path / 'shipping')
|
||||
with app.app_context():
|
||||
analysis = inventory_structure_analysis.create_sample_upload(_inventory_upload(), actor_id=None)
|
||||
# 关键断言:movement 映射直接用定死领域字段码作键,不需要订单匹配键。
|
||||
profile = inventory_structure_analysis.create_profile_draft(analysis['id'], {
|
||||
'profile_code': 'MOVE_STD', 'display_name': '收料异动标准', 'purpose': 'movement',
|
||||
'sheet_name': 'Inventory', 'header_row_index': 3,
|
||||
'field_mapping': {'doc_no': 'Supplier Sku', 'material_code': 'Reservation ID',
|
||||
'quantity': 'Qty Available', 'movement_date': 'Warehouse ID'},
|
||||
'match_keys': None,
|
||||
}, actor_id=None)
|
||||
assert profile['purpose'] == 'movement'
|
||||
assert profile['definition']['match_keys'] == []
|
||||
assert set(profile['definition']['field_mapping']) == {'doc_no', 'material_code', 'quantity', 'movement_date'}
|
||||
|
||||
|
||||
def test_publish_movement_profile_skips_order_match_key_contract(app, tmp_path):
|
||||
"""发布 movement 规则不需要订单匹配键:其端点契约是定死异动字段,不是订单 Schema。"""
|
||||
from app.services.shipping_notice import inventory_parsing_profile
|
||||
|
||||
app.config['SHIPPING_NOTICE_STORAGE_ROOT'] = str(tmp_path / 'shipping')
|
||||
with app.app_context():
|
||||
analysis = inventory_structure_analysis.create_sample_upload(_inventory_upload(), actor_id=None)
|
||||
profile = inventory_structure_analysis.create_profile_draft(analysis['id'], {
|
||||
'profile_code': 'MOVE_PUB', 'display_name': '收料异动发布', 'purpose': 'movement',
|
||||
'sheet_name': 'Inventory', 'header_row_index': 3,
|
||||
'field_mapping': {'doc_no': 'Supplier Sku', 'material_code': 'Reservation ID',
|
||||
'quantity': 'Qty Available', 'movement_date': 'Warehouse ID'},
|
||||
'match_keys': None,
|
||||
}, actor_id=None)
|
||||
# 关键断言:movement 草稿必须能直接发布(有样本证据即可),match_keys 为空是合法契约。
|
||||
published = inventory_parsing_profile.publish(profile['id'], actor_id=None)
|
||||
assert published['status'] == 'published'
|
||||
assert published['checksum']
|
||||
assert published['definition']['match_keys'] == []
|
||||
Reference in new issue
Block a user