feat(shipping-notice): 完善 XFA 模板映射与订单审核流程
- 统一 XFA 数据集、字段拆分、校验及运行时解析 - 完善订单模板管理、发布检查与迁移状态 - 优化订单审核草稿、预约回退及 STP 投影缓存 - 更新前端模板编辑器、映射组件与多语言错误文案 - 补充后端与前端测试,并更新本地集成启动配置
This commit is contained in:
1 parent
43a30a7489
commit
4ec436d44c
67 files changed
+5411
-528
No files matched your search
@@ -4,6 +4,7 @@ backend/tests/test_shipping_document_profile_quality.py
|
||||
用途:验证订单文档模板的独立盲测候选、批准资格和冻结 checksum 门禁。
|
||||
依赖:Profile 服务、布局快照、模板盲测服务与测试数据库。
|
||||
逻辑:管理员固化一份独立样本真值;通过且批准后才可放行确定性自动建单。
|
||||
XFA 确认真值允许候选含 bindings 以外的视觉表头(如 bill_to)。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -42,6 +43,47 @@ def _memory_file_asset_storage(monkeypatch):
|
||||
monkeypatch.setattr(file_asset_storage_module.file_asset_storage, 'delete_object', lambda storage_key: objects.pop(storage_key, None))
|
||||
|
||||
|
||||
def test_expected_order_fields_allows_extra_visual_header_keys_for_xfa_bindings():
|
||||
"""XFA 确认:bindings 表头齐全即可;候选额外含 bill_to 等视觉框不得拒绝。"""
|
||||
binding = SimpleNamespace(
|
||||
scope='header',
|
||||
field_code='customer_po_number',
|
||||
value_binding=SimpleNamespace(path_id='po-path'),
|
||||
)
|
||||
parser = SimpleNamespace(bindings=[binding], header_mappings=[], order_field_layouts=[])
|
||||
raw = {
|
||||
'header:customer_po_number': '4510039229',
|
||||
'header:bill_to_customer': 'Cloud Network Technology Kft.',
|
||||
'header:bill_to_address': 'Bánki Donát u. 1',
|
||||
}
|
||||
|
||||
result = quality._expected_order_fields(raw, parser=parser)
|
||||
|
||||
# 关键断言:正式绑定键保留,额外视觉表头一并写入盲测真值。
|
||||
assert result == raw
|
||||
|
||||
|
||||
def test_expected_order_fields_still_requires_every_bound_header_for_xfa():
|
||||
"""XFA 确认:缺少 bindings 表头仍须拒绝,避免静默漏掉正式 path 字段。"""
|
||||
parser = SimpleNamespace(
|
||||
bindings=[
|
||||
SimpleNamespace(scope='header', field_code='customer_po_number'),
|
||||
SimpleNamespace(scope='header', field_code='currency'),
|
||||
],
|
||||
header_mappings=[],
|
||||
order_field_layouts=[],
|
||||
)
|
||||
|
||||
with pytest.raises(Exception) as caught:
|
||||
quality._expected_order_fields(
|
||||
{'header:customer_po_number': '4510039229', 'header:bill_to_customer': 'X'},
|
||||
parser=parser,
|
||||
)
|
||||
|
||||
assert getattr(caught.value, 'code', None) == 'SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_INVALID'
|
||||
assert 'header:currency' in (getattr(caught.value, 'details', {}) or {}).get('missing_keys', [])
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('actual', 'expected', 'config'),
|
||||
[
|
||||
|
||||
Reference in new issue
Block a user