feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-06 10:18:37 +08:00
1 parent 3a9fbac2fc
commit d2b3d74def
571 files changed
+78064 -24681

No files matched your search

@@ -0,0 +1,65 @@
"""
backend/tests/test_shipping_projection_cross_surface.py
用途:跨面一致性契约——15 阶顺序、OT stage 同步与密度窗口共享同一投影真相。
依赖:progress_audit_contract、order_task_service、frontend progressWindow 对齐的 BE 语义。
逻辑:阶段码集合一致;sync_order_task_processing_state 写入的 stage 必须属于
SHIPPING_PROCESSING_STAGES;inventory_source_resolving 在 waiting_review 之前。
"""
from __future__ import annotations
from app import db
from app.models import ShippingNotice, ShippingOrderTask
from app.services.shipping_notice.order_task_service import sync_order_task_processing_state
from app.services.shipping_notice.progress_audit_contract import (
EML_ONLY_PROCESSING_STAGES,
SHIPPING_PROCESSING_STAGES,
)
def test_fifteen_stages_inventory_source_before_review():
"""库存源解析必须排在人工复核与建单之前(跨面共用同一有序元组)。"""
stages = list(SHIPPING_PROCESSING_STAGES)
assert len(stages) == 15
assert stages.index('inventory_source_resolving') < stages.index('waiting_review')
assert stages.index('waiting_review') < stages.index('order_creating')
assert stages.index('inventory_matching') < stages.index('excel_generating')
assert 'email_parsing' in EML_ONLY_PROCESSING_STAGES
assert 'email_adjudicating' in EML_ONLY_PROCESSING_STAGES
def test_sync_order_task_stage_must_be_processing_stage(app):
"""任务工作台与对话投影均读 OT.stage;写入值必须是冻结的 15 阶之一。"""
with app.app_context():
notice = ShippingNotice(
task_no='SN-CROSS-SURFACE-001',
source_type='manual',
process_status='matched',
po_number='PO-CROSS-001',
order_lines_migration_status='pending',
)
db.session.add(notice)
db.session.flush()
order_task = ShippingOrderTask(
task_no='OT-CROSS-SURFACE-001',
user_id=1,
shipping_notice_id=int(notice.id),
stage='waiting_review',
status='waiting_review',
progress_version=1,
)
db.session.add(order_task)
db.session.flush()
sync_order_task_processing_state(
order_task,
stage='inventory_matching',
status='processing',
)
db.session.commit()
refreshed = db.session.get(ShippingOrderTask, order_task.id)
assert refreshed.stage == 'inventory_matching'
assert refreshed.stage in SHIPPING_PROCESSING_STAGES
assert int(refreshed.progress_version or 0) >= 2