"""绩效核算的请求/响应模型(M3 ④)。""" from datetime import date, datetime from decimal import Decimal from pydantic import BaseModel, ConfigDict, Field from app.core.response import PageQuery class LedgerQuery(PageQuery): """台账列表查询条件。""" settlement_month: str | None = Field(default=None, max_length=7, description="归属月 YYYY-MM") personnel_id: int | None = Field(default=None, ge=1, description="归属人员筛选") business_id: int | None = Field(default=None, ge=1, description="业务筛选") is_active: int | None = Field(default=None, ge=0, le=1, description="生效标记筛选") calc_type: int | None = Field(default=None, ge=1, le=2, description="核算类型筛选") class LedgerOut(BaseModel): """台账行响应(金额/比例一律 str)。""" model_config = ConfigDict(from_attributes=True) id: int receipt_id: int | None = None calc_version: int is_active: int calc_type: int business_id: int business_no: str personnel_id: int personnel_name: str role_code: str customer_type: str product_category: str ship_date: date | None = None receipt_date: date payment_days: int | None = None rate_text: str converted_profit: Decimal | None = None performance_amount: Decimal | None = None barter_applied: int weight_r: int | None = None payment_weight: Decimal | None = None payable_amount: Decimal | None = None settlement_month: str is_probation: int missing_cost: int snapshot_json: dict | None = None settlement_id: int | None = None calc_reason: str | None = None create_time: datetime class CalcReceiptOut(BaseModel): """单笔核算结果:台账行 + 重复计提标记(核算粒度 #25 一期口径)。""" ledger: LedgerOut #: True=该业务此前已核算过,本笔回款仅登记进度、未重复计提(#25 一期口径) repeated: bool = False