64dc85bd14
- inventory业务层下沉(薄路由+service orchestration模式): - customer/supplier/warehouse -> master_data_service - material_routes(价格历史/趋势/供应商关联)-> material_service - product_routes(CRUD/BOM/from-task跨模块桥接)-> product_service - dashboard_routes(首页统计/低库存预警)-> dashboard_service - inventory侧新增service回归覆盖(dashboard 2 / master_data 10 / material 10 / product 14),含跨模块桥接测试种子 - Pydantic v2弃用清零:全仓14处 class Config 全部迁移到 model_config = ConfigDict(from_attributes=True)(含 shared auth) - datetime.utcnow() 弃用清零:auth_service 3处统一改 datetime.now(timezone.utc) - 同步文档:STATUS / ROADMAP / TECH_DEBT(D12清偿)/ AGENTS 代码地图 测试基线:126 passed, 4 skipped(无deprecation warning) Co-Authored-By: Claude Code <noreply@anthropic.com>
152 lines
3.7 KiB
Python
152 lines
3.7 KiB
Python
from pydantic import BaseModel, ConfigDict, Field
|
|
from typing import Optional, List, Literal
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
|
|
|
|
TxnType = Literal["receipt", "payment"]
|
|
PartnerType = Literal["customer", "supplier"]
|
|
OrderType = Literal["sales", "purchase"]
|
|
TxnStatus = Literal["confirmed", "voided"]
|
|
|
|
|
|
class FinanceAllocationCreate(BaseModel):
|
|
order_type: OrderType
|
|
order_id: int
|
|
allocated_amount: Decimal = Field(gt=0)
|
|
|
|
|
|
class FinanceTransactionCreate(BaseModel):
|
|
amount: Decimal = Field(gt=0)
|
|
txn_date: Optional[datetime] = None
|
|
method: str = "bank"
|
|
account_name: Optional[str] = None
|
|
remark: Optional[str] = None
|
|
allocations: List[FinanceAllocationCreate]
|
|
|
|
|
|
class ReceiptCreate(FinanceTransactionCreate):
|
|
customer_id: int
|
|
|
|
|
|
class PaymentCreate(FinanceTransactionCreate):
|
|
supplier_id: int
|
|
|
|
|
|
class FinanceAllocationResponse(BaseModel):
|
|
id: int
|
|
order_type: str
|
|
order_id: int
|
|
allocated_amount: Decimal
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class FinanceTransactionResponse(BaseModel):
|
|
id: int
|
|
txn_no: str
|
|
txn_type: TxnType
|
|
partner_type: PartnerType
|
|
partner_id: int
|
|
partner_name: Optional[str] = None
|
|
amount: Decimal
|
|
txn_date: datetime
|
|
method: str
|
|
account_name: Optional[str]
|
|
status: TxnStatus
|
|
remark: Optional[str]
|
|
created_at: datetime
|
|
allocations: List[FinanceAllocationResponse] = []
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class FinanceSummaryResponse(BaseModel):
|
|
receivable_total: Decimal
|
|
payable_total: Decimal
|
|
monthly_receipt_total: Decimal
|
|
monthly_payment_total: Decimal
|
|
selected_year: int
|
|
selected_quarter: Optional[int] = None
|
|
period_label: str
|
|
period_receipt_total: Decimal = Decimal("0")
|
|
period_payment_total: Decimal = Decimal("0")
|
|
overdue_receivable_count: int = 0
|
|
overdue_payable_count: int = 0
|
|
|
|
|
|
class ReceivableItemResponse(BaseModel):
|
|
order_id: int
|
|
order_no: str
|
|
customer_id: int
|
|
customer_name: str
|
|
order_date: datetime
|
|
total_amount: Decimal
|
|
received_amount: Decimal
|
|
receivable_amount: Decimal
|
|
status: str
|
|
|
|
|
|
class PayableItemResponse(BaseModel):
|
|
order_id: int
|
|
order_no: str
|
|
supplier_id: int
|
|
supplier_name: str
|
|
order_date: datetime
|
|
total_amount: Decimal
|
|
paid_amount: Decimal
|
|
payable_amount: Decimal
|
|
status: str
|
|
|
|
|
|
class PartnerStatementItemResponse(BaseModel):
|
|
partner_id: int
|
|
partner_name: str
|
|
order_count: int
|
|
transaction_count: int
|
|
order_total: Decimal
|
|
settled_total: Decimal
|
|
transaction_total: Decimal
|
|
outstanding_total: Decimal
|
|
period_year: int
|
|
period_quarter: Optional[int] = None
|
|
|
|
|
|
class FinancePartnerStatementResponse(BaseModel):
|
|
partner_type: PartnerType
|
|
year: int
|
|
quarter: Optional[int] = None
|
|
period_label: str
|
|
order_total: Decimal
|
|
settled_total: Decimal
|
|
transaction_total: Decimal
|
|
outstanding_total: Decimal
|
|
items: List[PartnerStatementItemResponse] = []
|
|
|
|
|
|
class PartnerProductStatementItemResponse(BaseModel):
|
|
partner_id: int
|
|
partner_name: str
|
|
product_id: int
|
|
product_sku: Optional[str] = None
|
|
product_name: str
|
|
order_count: int
|
|
order_quantity: Decimal
|
|
order_amount: Decimal
|
|
settled_amount: Decimal
|
|
outstanding_amount: Decimal
|
|
period_year: int
|
|
period_quarter: Optional[int] = None
|
|
|
|
|
|
class FinancePartnerProductStatementResponse(BaseModel):
|
|
partner_type: PartnerType
|
|
year: int
|
|
quarter: Optional[int] = None
|
|
period_label: str
|
|
partner_id: Optional[int] = None
|
|
order_amount_total: Decimal
|
|
settled_amount_total: Decimal
|
|
outstanding_amount_total: Decimal
|
|
items: List[PartnerProductStatementItemResponse] = []
|