- settlement_service:generate(确认回款口径 #8 策略点=有效台账行按回款日 归月、经理聚合 #12 暂口径基数不含经理个人户、月结 uk 一行一月、草稿/ 驳回可重生成、已审定/待审 400)→ submit(审批开关分流,关=自动通过即 锁定、开=待财务复核)→ approval_service.act 扩 order_type=2/3 钩子 (通过=mark_locked/调整单生效;驳回=回草稿/作废,延迟导入防循环) - 锁定拦截:回款新增写路径校验回款月已审定 400(比需求「提示」取硬, 一期安全侧;M2 已核算禁改防线先于其生效) - 调整单:新建(TZ 单号,开关分流自动通过留痕/走审批)+ 列表 - schemas settlement:金额 Decimal 声明(str 声明遇 Decimal 入参拒绝) - 测试 6 例:生成回填/无记录 400/已审定重生成 400/关自动锁定/锁定后回款 禁改/开两节点流转至锁定(finance→leader) Co-Authored-By: Claude Code <noreply@anthropic.com>
91 lines
2.4 KiB
Python
91 lines
2.4 KiB
Python
"""月度结算的请求/响应模型(M3 ④)。"""
|
||
|
||
import re
|
||
from datetime import datetime
|
||
from decimal import Decimal
|
||
|
||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||
|
||
from app.core.response import PageQuery
|
||
|
||
_MONTH_RE = re.compile(r"^\d{4}-\d{2}$")
|
||
|
||
|
||
def _check_month(value: str) -> str:
|
||
"""月份格式 YYYY-MM(settlement_month 全表唯一的维度)。"""
|
||
if not _MONTH_RE.match(value):
|
||
raise ValueError("月份格式须为 YYYY-MM")
|
||
return value
|
||
|
||
|
||
class SettlementGenerateIn(BaseModel):
|
||
"""月结生成入参。"""
|
||
|
||
month: str = Field(description="结算月份 YYYY-MM")
|
||
|
||
@field_validator("month")
|
||
@classmethod
|
||
def _v_month(cls, value: str) -> str:
|
||
return _check_month(value)
|
||
|
||
|
||
class SettlementQuery(PageQuery):
|
||
"""月结列表查询。"""
|
||
|
||
status: int | None = Field(default=None, ge=1, le=4, description="状态筛选")
|
||
|
||
|
||
class SettlementItemOut(BaseModel):
|
||
"""月结明细行。"""
|
||
|
||
model_config = ConfigDict(from_attributes=True)
|
||
|
||
id: int
|
||
personnel_id: int
|
||
personnel_name: str
|
||
role_code: str
|
||
calc_type: int
|
||
performance_sum: Decimal
|
||
payable_sum: Decimal
|
||
basic_amount: Decimal | None = None
|
||
salary_mode: str | None = None
|
||
net_amount: Decimal | None = None
|
||
is_probation: int
|
||
probation_note: str | None = None
|
||
|
||
|
||
class SettlementOut(BaseModel):
|
||
"""月结头表响应。"""
|
||
|
||
model_config = ConfigDict(from_attributes=True)
|
||
|
||
id: int
|
||
settlement_month: str
|
||
status: int
|
||
total_performance: Decimal | None = None
|
||
total_payable: Decimal | None = None
|
||
person_count: int
|
||
approval_order_no: str | None = None
|
||
submitter_name: str
|
||
locked_at: datetime | datetime | None = None
|
||
locked_by: str | None = None
|
||
create_time: datetime
|
||
|
||
|
||
class SettlementDetailOut(SettlementOut):
|
||
"""月结详情:附明细。"""
|
||
|
||
items: list[SettlementItemOut] = Field(default_factory=list)
|
||
|
||
|
||
class AdjustmentCreateIn(BaseModel):
|
||
"""调整单创建入参(金额恒正,方向表达补发/扣减)。"""
|
||
|
||
model_config = ConfigDict(str_strip_whitespace=True)
|
||
|
||
settlement_month: str = Field(description="调整月份 YYYY-MM")
|
||
personnel_id: int = Field(ge=1, description="调整人员ID")
|
||
direction: int = Field(ge=1, le=2, description="1补发 2扣减")
|
||
amount: str = Field(description="金额(元,两位小数)")
|
||
reason: str = Field(min_length=1, max_length=255, description="扣补说明")
|