迁移合同费用通用附件
1、删除旧费用附件 API、CRUD、模型和专用前端面板,统一改用通用附件能力。 2、调整合同费用接口为 study_id 语义,并补充合同、凭证、发票等附件类型的权限映射。 3、将合同费用新建和编辑改为抽屉流程,详情页与列表页复用同一编辑组件。 4、补充数据库迁移、附件列表、合同费用抽屉和权限场景测试,覆盖旧权限移除与新流程。
This commit is contained in:
@@ -4,17 +4,49 @@ from datetime import date
|
||||
from decimal import Decimal
|
||||
import uuid
|
||||
|
||||
from starlette.requests import Request
|
||||
|
||||
from app.api.v1 import fees_contracts
|
||||
from app.models.contract_fee import ContractFee
|
||||
from app.schemas.contract_fee import ContractFeeCreate, ContractFeeRead, ContractFeeUpdate
|
||||
|
||||
|
||||
def _request_with_query(query: str) -> Request:
|
||||
return Request(
|
||||
{
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"path": "/api/v1/fees/contracts",
|
||||
"query_string": query.encode(),
|
||||
"headers": [],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_contract_fee_list_query_accepts_legacy_project_params():
|
||||
"""合同费用列表应兼容旧 projectId/centerId 查询参数。"""
|
||||
study_id = uuid.uuid4()
|
||||
center_id = uuid.uuid4()
|
||||
resolver = getattr(fees_contracts, "_resolve_contract_fee_list_query", None)
|
||||
|
||||
assert resolver is not None
|
||||
resolved_study_id, resolved_center_id = resolver(
|
||||
_request_with_query(f"projectId={study_id}¢erId={center_id}"),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
|
||||
assert resolved_study_id == study_id
|
||||
assert resolved_center_id == center_id
|
||||
|
||||
|
||||
def test_contract_fee_schema_includes_contract_basic_fields():
|
||||
"""合同费用应包含合同基础信息字段。"""
|
||||
project_id = uuid.uuid4()
|
||||
study_id = uuid.uuid4()
|
||||
center_id = uuid.uuid4()
|
||||
|
||||
payload = ContractFeeCreate(
|
||||
project_id=project_id,
|
||||
study_id=study_id,
|
||||
center_id=center_id,
|
||||
contract_no="CT-001",
|
||||
signed_date=date(2026, 5, 27),
|
||||
@@ -28,6 +60,8 @@ def test_contract_fee_schema_includes_contract_basic_fields():
|
||||
assert payload.signed_date == date(2026, 5, 27)
|
||||
assert payload.currency == "CNY"
|
||||
assert payload.remark == "首版合同"
|
||||
assert payload.study_id == study_id
|
||||
assert "project_id" not in ContractFeeCreate.model_fields
|
||||
|
||||
update_payload = ContractFeeUpdate(contract_no="CT-002", currency="USD", remark="变更合同信息")
|
||||
assert update_payload.model_dump(exclude_unset=True) == {
|
||||
@@ -38,6 +72,8 @@ def test_contract_fee_schema_includes_contract_basic_fields():
|
||||
|
||||
for field in ("contract_no", "signed_date", "currency", "remark"):
|
||||
assert field in ContractFeeRead.model_fields
|
||||
assert "study_id" in ContractFeeRead.model_fields
|
||||
assert "project_id" not in ContractFeeRead.model_fields
|
||||
|
||||
|
||||
def test_contract_fee_model_includes_contract_basic_columns():
|
||||
|
||||
Reference in New Issue
Block a user