feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
1 parent
260465b72d
commit
1b6483a4ea
466 files changed
+32115
-33796
No files matched your search
@@ -16,7 +16,11 @@ import pytest
|
||||
from app.services.shipping_notice.document_layout.xfa_acroform import XfaAcroformField
|
||||
from app.services.shipping_notice.document_layout.xfa_dataset import parse_xfa_datasets
|
||||
from app.services.shipping_notice.document_layout.xfa_profile_extraction import extract_xfa_profile
|
||||
from app.services.shipping_notice.document_layout.xfa_validation import validate_xfa_extraction
|
||||
from app.services.shipping_notice.document_layout.xfa_validation import (
|
||||
_line_amount_failures,
|
||||
_normalize_comparable,
|
||||
validate_xfa_extraction,
|
||||
)
|
||||
from tests.test_shipping_xfa_helpers import load_datasets_fixture
|
||||
from tests.test_shipping_xfa_profile_extraction import _raw_profile, _schema_definition
|
||||
|
||||
@@ -103,6 +107,43 @@ def test_line_amount_formula_failure():
|
||||
assert 'xfa_business_validation_failed' in result.reason_codes
|
||||
|
||||
|
||||
def test_current_schema_amount_aliases_do_not_implicitly_split_composite_prices():
|
||||
"""交叉校验不得把未显式拆分的 NETPR 复合展示值当作单价。"""
|
||||
assert _normalize_comparable('898.72 / 1') == '898.72 / 1'
|
||||
assert _line_amount_failures([{
|
||||
'qty': '30',
|
||||
'unit_price': '898.72',
|
||||
'price_unit': '1',
|
||||
'line_amount_with_tax': '26,961.60',
|
||||
}]) == []
|
||||
|
||||
|
||||
def test_line_amount_formula_never_uses_price_unit_as_an_implicit_divisor():
|
||||
"""金额公式只使用数量、单价和金额;price_unit 不能成为后端特殊除数。"""
|
||||
assert _line_amount_failures([{
|
||||
'qty': '30',
|
||||
'unit_price': '898.72',
|
||||
'line_amount_with_tax': '26,961.60',
|
||||
}]) == []
|
||||
|
||||
# 即使原始行残留同名值,未注册字段也不能作为后台隐式除数。
|
||||
assert _line_amount_failures([{
|
||||
'qty': '30',
|
||||
'unit_price': '898.72',
|
||||
'price_unit': 'not-a-number',
|
||||
'line_amount_with_tax': '26,961.60',
|
||||
}]) == []
|
||||
|
||||
# 即使 Schema 中存在同名字段,通用金额公式也不得按字段名切换为除法。
|
||||
failures = _line_amount_failures([{
|
||||
'qty': '10',
|
||||
'unit_price': '20',
|
||||
'price_unit': '10',
|
||||
'line_amount_with_tax': '20',
|
||||
}])
|
||||
assert failures and failures[0]['reason'] == 'amount_mismatch'
|
||||
|
||||
|
||||
def test_header_total_vs_line_sum_failure():
|
||||
"""关键断言:Header 总金额与明细合计不一致 → business_validation_failed。"""
|
||||
raw_profile, analysis, extraction = _extract_ok()
|
||||
@@ -177,6 +218,61 @@ def test_acroform_display_format_difference_is_ok(monkeypatch):
|
||||
assert result.cross_check_summary['acroform_status'] == 'matched'
|
||||
|
||||
|
||||
def test_acroform_composite_value_requires_an_explicit_split_binding(monkeypatch):
|
||||
"""复合 Widget 只有明确 split_rule_ref 才可跳过原文对账。"""
|
||||
raw_profile, analysis, extraction = _extract_ok()
|
||||
raw_profile['definition']['split_rules'] = []
|
||||
price_binding = next(
|
||||
item for item in raw_profile['definition']['bindings']
|
||||
if item['field_code'] == 'unit_price'
|
||||
)
|
||||
price_binding.pop('split_rule_ref', None)
|
||||
# 运行期模型只信 binding 明确引用;清除引用后使用直取值以暴露不一致。
|
||||
for row in extraction.rows:
|
||||
for field in row.get('fields') or []:
|
||||
if field.get('field_code') == 'unit_price':
|
||||
field['value'] = '898.72'
|
||||
|
||||
monkeypatch.setattr(
|
||||
'app.services.shipping_notice.document_layout.xfa_validation.read_acroform_fields',
|
||||
lambda _pdf: [XfaAcroformField('NETPR', 'NETPR', '898.72 / 1', '898.72 / 1')],
|
||||
)
|
||||
result = validate_xfa_extraction(
|
||||
raw_profile=raw_profile,
|
||||
dataset_analysis=analysis,
|
||||
extraction=extraction,
|
||||
pdf_bytes=b'%PDF-fake',
|
||||
)
|
||||
|
||||
assert result.passed is False
|
||||
assert 'xfa_acroform_mismatch' in result.reason_codes
|
||||
|
||||
|
||||
def test_acroform_english_month_date_matches_normalized_dataset_date(monkeypatch):
|
||||
"""AcroForm 的英文月名日期与 datasets ISO 日期一致时不得误判为冲突。"""
|
||||
raw_profile, analysis, extraction = _extract_ok()
|
||||
|
||||
def _fake_acroform(_pdf_bytes):
|
||||
return [
|
||||
XfaAcroformField('EINDT', 'EINDT', '14-Jul-2026', '14***6'),
|
||||
]
|
||||
|
||||
monkeypatch.setattr(
|
||||
'app.services.shipping_notice.document_layout.xfa_validation.read_acroform_fields',
|
||||
_fake_acroform,
|
||||
)
|
||||
result = validate_xfa_extraction(
|
||||
raw_profile=raw_profile,
|
||||
dataset_analysis=analysis,
|
||||
extraction=extraction,
|
||||
pdf_bytes=b'%PDF-fake',
|
||||
)
|
||||
|
||||
# 关键断言:只覆盖一个字段应为 partial,而不是格式假冲突导致 mismatched。
|
||||
assert result.passed is True
|
||||
assert result.cross_check_summary['acroform_status'] == 'partial'
|
||||
|
||||
|
||||
def test_acroform_empty_fields_is_unavailable(monkeypatch):
|
||||
"""关键断言:PDF 有调用但无 AcroForm Fields → unavailable,不得记 matched。"""
|
||||
raw_profile, analysis, extraction = _extract_ok()
|
||||
|
||||
Reference in new issue
Block a user