执行中的运输计划不再随意改单;库存流水记到装卸产品明细;手工派车日历区分酸碱并记录数量。同时收紧合同附件与子表的差量保存,并清理已废弃的 bak 备份目录。 Co-authored-by: Cursor <cursoragent@cursor.com>
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
"""运输计划归属公司与合同交易主体。"""
|
|
from fastapi import HTTPException
|
|
|
|
from app.schemas.pl.plan import PlanContractLink
|
|
from app.services.pl_plan_service import (
|
|
belongs_company_trading_entity,
|
|
is_belongs_company_contract_error,
|
|
)
|
|
from app.services.pl_plan_stop_service import _resolve_stop_contracts
|
|
|
|
|
|
def test_belongs_company_maps_to_exact_trading_entity():
|
|
assert belongs_company_trading_entity("shanxia") == "安庆市山峡化工有限公司"
|
|
assert belongs_company_trading_entity("yundong") == "安徽云栋化工有限公司"
|
|
assert belongs_company_trading_entity("") == ""
|
|
assert belongs_company_trading_entity("云栋贸易") == ""
|
|
|
|
|
|
def test_empty_belongs_company_rejects_external_stop_contract():
|
|
with pytest_raises_company():
|
|
_resolve_stop_contracts(
|
|
None,
|
|
"tenant",
|
|
"cust",
|
|
"外部客户A",
|
|
[PlanContractLink(contractId="c1", contractNo="N1")],
|
|
"装货合同",
|
|
expected_supplier_name="",
|
|
)
|
|
|
|
|
|
def test_internal_stop_skips_belongs_company_contract_check():
|
|
links = _resolve_stop_contracts(
|
|
None,
|
|
"tenant",
|
|
"cust",
|
|
"安庆市山峡化工有限公司",
|
|
[PlanContractLink(contractId="c1", contractNo="N1")],
|
|
"装货合同",
|
|
expected_supplier_name="",
|
|
)
|
|
assert links == []
|
|
|
|
|
|
def test_belongs_company_contract_error_is_not_swallowed():
|
|
mismatch = HTTPException(status_code=422, detail="装货合同的交易主体与归属公司不一致")
|
|
empty = HTTPException(status_code=422, detail="请先选择归属公司")
|
|
other = HTTPException(status_code=422, detail="请为装货客户选择合同")
|
|
assert is_belongs_company_contract_error(mismatch)
|
|
assert is_belongs_company_contract_error(empty)
|
|
assert not is_belongs_company_contract_error(other)
|
|
|
|
|
|
def pytest_raises_company():
|
|
import pytest
|
|
|
|
return pytest.raises(HTTPException, match="请先选择归属公司")
|