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
@@ -248,6 +248,75 @@ def test_acroform_composite_value_requires_an_explicit_split_binding(monkeypatch
|
||||
assert 'xfa_acroform_mismatch' in result.reason_codes
|
||||
|
||||
|
||||
def test_acroform_skips_header_bindings_with_split_rule_ref(monkeypatch):
|
||||
"""
|
||||
表头拆分目标不得拿源 Widget 全文对账(与明细 split_rule_ref 跳过对齐)。
|
||||
关键断言:即使 datasets 侧与 AcroForm 源全文因换行不同,也不应报 bill_to_* mismatched。
|
||||
"""
|
||||
from app.services.shipping_notice.document_layout.xfa_profile_extraction import XfaExtractedField
|
||||
|
||||
raw_profile, analysis, extraction = _extract_ok()
|
||||
raw_profile['definition']['bindings'].append({
|
||||
'binding_id': 'bind-bill-customer',
|
||||
'field_id': 'f-bill-customer',
|
||||
'field_code': 'bill_to_customer',
|
||||
'scope': 'header',
|
||||
'value_binding': {
|
||||
'type': 'xfa_dataset',
|
||||
'path_id': 'path-invoiced-to',
|
||||
'data_path': '/data/HEADER/INVOICED_TO',
|
||||
},
|
||||
'visual_binding': {
|
||||
'page_no': 1,
|
||||
'normalized_bbox': {'x0': 0.0, 'y0': 0.0, 'x1': 0.02, 'y1': 0.02},
|
||||
'source': 'suggested',
|
||||
'status': 'suggested',
|
||||
'confidence': 0.0,
|
||||
},
|
||||
'split_rule_ref': {
|
||||
'rule_set_id': 'invoiced-to-v1',
|
||||
'segment_id': 'seg-bill-customer',
|
||||
},
|
||||
})
|
||||
# 模拟 STEP1 误写的源全文(修复前会按 binding_id 参与 AcroForm 对账)。
|
||||
sample_evidence = extraction.header_fields[0].evidence if extraction.header_fields else {}
|
||||
extraction.header_fields = list(extraction.header_fields) + [
|
||||
XfaExtractedField(
|
||||
mapping_id='bind-bill-customer',
|
||||
field_id='f-bill-customer',
|
||||
field_code='bill_to_customer',
|
||||
data_path='/data/HEADER/INVOICED_TO',
|
||||
raw_value='Cloud Network Technology Kft.\nBánki Donát u.1.',
|
||||
normalized_value='Cloud Network Technology Kft.\nBánki Donát u.1.',
|
||||
quote='Cloud Network Technology Kft.\nBánki Donát u.1.',
|
||||
normalizer_key='trim',
|
||||
evidence=sample_evidence,
|
||||
issues=[],
|
||||
),
|
||||
]
|
||||
|
||||
monkeypatch.setattr(
|
||||
'app.services.shipping_notice.document_layout.xfa_validation.read_acroform_fields',
|
||||
lambda _pdf: [
|
||||
XfaAcroformField(
|
||||
'INVOICED_TO',
|
||||
'INVOICED_TO',
|
||||
'Cloud Network Technology Kft.\r\nBánki Donát u.1.',
|
||||
'Cloud***u.1.',
|
||||
),
|
||||
],
|
||||
)
|
||||
result = validate_xfa_extraction(
|
||||
raw_profile=raw_profile,
|
||||
dataset_analysis=analysis,
|
||||
extraction=extraction,
|
||||
pdf_bytes=b'%PDF-fake',
|
||||
)
|
||||
mismatches = result.cross_check_summary.get('acroform_mismatches') or []
|
||||
assert not any(item.get('field_code') == 'bill_to_customer' for item in mismatches)
|
||||
assert 'xfa_acroform_mismatch' not in result.reason_codes
|
||||
|
||||
|
||||
def test_acroform_english_month_date_matches_normalized_dataset_date(monkeypatch):
|
||||
"""AcroForm 的英文月名日期与 datasets ISO 日期一致时不得误判为冲突。"""
|
||||
raw_profile, analysis, extraction = _extract_ok()
|
||||
|
||||
Reference in new issue
Block a user