feat(shipping-notice): 新增发货通知自动上传功能与候选资格评估

- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。
- 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。
- 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。
- 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。
- 增强文档与代码注释,反映新的业务逻辑与功能要求。
This commit is contained in:
hugo committed 2026-08-02 19:26:35 +08:00
1 parent cef3d5b26a
commit 3a9fbac2fc
226 files changed
+25010 -2098

No files matched your search

+21 -1
View File
@@ -17,7 +17,10 @@ SCHEMA = {'fields': [
{'field_id': 'po', 'field_code': 'customer_po_number', 'scope': 'header', 'aliases': ['PO#', 'PO Number']},
{'field_id': 'part', 'field_code': 'part_number', 'scope': 'line', 'aliases': ['MPN', 'Part Number']},
{'field_id': 'qty', 'field_code': 'qty'},
{'field_id': 'reservation', 'field_code': 'reservation_id', 'scope': 'line', 'aliases': ['Reservation ID']},
{
'field_id': 'reservation', 'field_code': 'reservation_id', 'scope': 'line',
'aliases': ['Reservation ID', 'External reservation ID'],
},
{'field_id': 'allocation', 'field_code': 'allocation_id'},
{'field_id': 'source', 'field_code': 'inventory_source_hint', 'scope': 'line', 'aliases': ['Source Type']},
]}
@@ -63,6 +66,23 @@ def test_email_supplement_html_grid_merges_by_po_and_mpn_without_overwriting_pdf
assert merged[0]['_hxops_email_supplement_relation'] == 'po_mpn'
def test_email_supplement_external_reservation_id_alias_merges_real_mail_header():
"""真实邮件的 External reservation ID 表头必须按 Schema 别名补到订单行。"""
supplement = parse_email_allocation_tables(
content_hash='e' * 64,
html_tables=['''<table><tr><th>PO#</th><th>MPN</th><th>External reservation ID</th><th>Source Type</th><th>Allocated Qty</th></tr><tr><td>4518738152</td><td>D4-A08AR12000002</td><td>3000099143</td><td>DBS SIN</td><td>20</td></tr></table>'''],
schema_definition=SCHEMA,
)
merged = merge_email_supplements(
orders=[_order()], supplements_by_intake={1: supplement}, schema_definition=SCHEMA,
)
assert supplement['rows'][0]['reservation_id'] == '3000099143'
assert _value(merged[0]['lines'][0]['fields'], 'reservation') == '3000099143'
assert merged[0]['_hxops_email_supplement_relation'] == 'po_mpn'
def test_email_supplement_po_fallback_requires_one_reservation():
"""缺 MPN 时只有唯一 Reservation 的 PO 可广播;多 Reservation 必须复核。"""
one = {'document_id': 44, 'rows': [{'po_number': '4518738152', 'reservation_id': '2000484577', 'evidence': {}}]}