fix(T+): 补齐指导成本与读取服务保护
补充业务详情指导成本入口、来源版本和历史封存保护,接入月份锁并完善权限复核。 同步接入读取服务运行状态到页面,补充前端控制、回归测试和服务端只读连接授权校验。 定向隔离测试:89 项通过,1 条既有 Starlette 弃用警告。
This commit is contained in:
1 parent
68e70fd6e2
commit
b8920c0d28
17 files changed
+375
-47
No files matched your search
@@ -1,5 +1,6 @@
|
||||
"""来源业务的人工分类资料。"""
|
||||
|
||||
from decimal import Decimal, InvalidOperation
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
||||
@@ -29,6 +30,28 @@ class SourcePriceConfirmIn(BaseModel):
|
||||
return self
|
||||
|
||||
|
||||
class GuidanceConfirmIn(BaseModel):
|
||||
"""从业务发货明细登记对应发货月份的单位指导成本。"""
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
shipment_item_id: int = Field(ge=1)
|
||||
amount: str = Field(min_length=1, max_length=32)
|
||||
evidence: str = Field(min_length=1, max_length=500)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_values(self):
|
||||
self.evidence = self.evidence.strip()
|
||||
if not self.evidence:
|
||||
raise ValueError("核对依据不能为空")
|
||||
try:
|
||||
value = Decimal(self.amount)
|
||||
except (InvalidOperation, TypeError, ValueError):
|
||||
raise ValueError("指导成本必须为有效数字") from None
|
||||
if not value.is_finite() or value < 0 or value.as_tuple().exponent < -4:
|
||||
raise ValueError("指导成本最多保留4位小数且不能为负数")
|
||||
return self
|
||||
|
||||
|
||||
class SourceProductCategory(BaseModel):
|
||||
product_id: int = Field(ge=1)
|
||||
category: Literal["municipal_water", "rail_transit"]
|
||||
|
||||
Reference in new issue
Block a user