把 shipping 侧 inventory/receipt 词根迁到 onhand/inbound,29 张表与 枚举/权限/前端/i18n 同步改名;在手与入站报表配置及文件改由 freight_rpa 持有,发货与调拨仅按 source_code 消费;ORM 类加 FreightRpa 前缀, 上传动作改为 freight_rpa_upload。含类名与上传动作改名规格文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
66 lines
2.9 KiB
Python
66 lines
2.9 KiB
Python
"""
|
|
tests/test_line_closure_export.py
|
|
|
|
用途:验证滚动导出资格对已结案行的剔除(含"有库存的结案行也不导出"边缘场景)。
|
|
依赖:pytest、reservation_service、fulfillment_workflow、核验/预约模型、行级履约决定。
|
|
逻辑:两行均有可用预约,结案其一后,导出资格集合只保留未结案行。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from decimal import Decimal
|
|
|
|
from app import db
|
|
from app.models import (
|
|
ShippingOnhandVerification,
|
|
ShippingOnhandVerificationLine,
|
|
ShippingReservation,
|
|
)
|
|
from app.services.shipping_notice.fulfillment_workflow import exportable_snapshot_line_ids
|
|
from app.services.shipping_notice.reservation_service import current_available_snapshot_line_ids
|
|
from tests.test_effective_order_view import _seed_frozen_order
|
|
from tests.test_line_closure_fulfillment import _seed_close_decision
|
|
|
|
|
|
def _seed_available_reservations(fixture):
|
|
"""两行各建一条 available 预约 + 一轮 completed 核验。"""
|
|
verification = ShippingOnhandVerification(task_id=fixture.order.id, status='completed')
|
|
db.session.add(verification)
|
|
db.session.flush()
|
|
for index, snap_line in enumerate(fixture.snap_lines):
|
|
reservation = ShippingReservation(
|
|
task_id=fixture.order.id, snapshot_line_id=snap_line.id,
|
|
reservation_id=f'RSV-CLOSE-{index}', po_number_normalized='PO-CLOSE',
|
|
part_number=snap_line.part_number, required_qty=Decimal('10'), status='available',
|
|
)
|
|
db.session.add(reservation)
|
|
db.session.flush()
|
|
db.session.add(ShippingOnhandVerificationLine(
|
|
verification_id=verification.id, reservation_id=reservation.id,
|
|
required_qty=Decimal('10'), available_qty=Decimal('10'), status='available',
|
|
))
|
|
db.session.flush()
|
|
|
|
|
|
def test_closed_line_with_inventory_is_not_exportable(app):
|
|
"""结案行即使库存充足、核验 available 也不得进入导出资格集合。"""
|
|
with app.app_context():
|
|
fixture = _seed_frozen_order()
|
|
_seed_available_reservations(fixture)
|
|
_seed_close_decision(fixture, 1)
|
|
_verification, available = current_available_snapshot_line_ids(
|
|
fixture.order, closed_snapshot_line_ids={int(fixture.snap_lines[1].id)},
|
|
)
|
|
# 断言:仅未结案的第 0 行可导出。
|
|
assert available == {int(fixture.snap_lines[0].id)}
|
|
|
|
|
|
def test_exportable_snapshot_line_ids_excludes_closed(app):
|
|
"""滚动导出入口(exportable_snapshot_line_ids)自动剔除结案行。"""
|
|
with app.app_context():
|
|
fixture = _seed_frozen_order()
|
|
_seed_available_reservations(fixture)
|
|
_seed_close_decision(fixture, 1)
|
|
# 断言:导出集合不含结案行(该行预约仍 available,验证 closed 过滤优先)。
|
|
assert exportable_snapshot_line_ids(fixture.order) == {int(fixture.snap_lines[0].id)}
|