feat(shipping_notice): 支持无 PO 表头的邮件分配表解析并锁定 STP 进行中的草稿

邮件分配表在无 PO 表头时,若已映射料号或预约号仍解析行以供
merge mpn_fallback,二者皆无才整表跳过;STP 等待入队/排队/执行
期间拒绝草稿内容写入并从可用动作中剥离 edit_draft/validate,
会话摘要与工作台同源认活跃 STP Job 以避免误判为待人工。
This commit is contained in:
hugo committed 2026-09-16 10:00:19 +08:00
1 parent f77f267091
commit 2841f4a598
18 files changed
+1050 -73

No files matched your search

@@ -620,6 +620,43 @@ def test_email_supplement_requires_frozen_schema_alias_for_order_headers():
assert result == {'version': 'email-supplement.v1', 'rows': [], 'issues': ['email_supplement_po_header_missing']}
def test_email_supplement_parses_without_po_when_mpn_and_reservation_present():
"""无 PO 表头但有 MPN + External reservation ID 时仍须产出补充行(本单回归)。"""
html = '''<table><tr>
<th>MPN</th><th>Source type</th><th>External reservation ID</th>
</tr><tr>
<td>D4-A08AR12000002</td><td>VMI-SIN</td><td>3000092917</td>
</tr></table>'''
supplement = parse_email_allocation_tables(
content_hash='j' * 64, html_tables=[html], schema_definition=SCHEMA,
)
assert len(supplement['rows']) == 1
assert supplement['rows'][0]['part_number'] == 'D4-A08AR12000002'
assert supplement['rows'][0]['reservation_id'] == '3000092917'
assert supplement['rows'][0]['inventory_source_hint'] == 'VMI-SIN'
assert 'email_supplement_po_header_missing' in supplement['issues']
merged = merge_email_supplements(
orders=[_order()],
supplements_by_intake={1: {**supplement, 'document_id': 44}},
schema_definition=SCHEMA,
)[0]
assert _value(merged['lines'][0]['fields'], 'reservation') == '3000092917'
assert _value(merged['lines'][0]['fields'], 'source') == 'VMI-SIN'
assert merged['_hxops_email_supplement_relation'] == 'mpn_fallback'
def test_email_supplement_still_skips_table_without_po_or_part_or_reservation():
"""无 PO 且无料号/预约号可映射列时仍整表跳过,避免无身份噪声行。"""
result = parse_email_allocation_tables(
content_hash='k' * 64,
schema_definition=SCHEMA,
html_tables=['''<table><tr><th>Location ID</th><th>Supplier code</th></tr>
<tr><td>941.76</td><td>0000000100</td></tr></table>'''],
)
assert result['rows'] == []
assert 'email_supplement_po_header_missing' in result['issues']
def test_email_supplement_inventec_po_date_two_digit_year_keeps_source_location():
"""Inventec 分配表 PO Date=12-Jun-26 时仍须保留 Source Location / 预约号。