from pydantic import BaseModel
from typing import Optional
from datetime import datetime


class CostItem(BaseModel):
    item: str
    item_name: str
    unit: str
    unit_cost_label: str  # 吨耗单位


class CostCreate(BaseModel):
    item: str
    record_date: datetime
    shift_a: Optional[float] = 0
    shift_b: Optional[float] = 0
    unit_cost: Optional[float] = 0
    remark: Optional[str] = None


class CostUpdate(BaseModel):
    record_date: Optional[datetime] = None
    shift_a: Optional[float] = None
    shift_b: Optional[float] = None
    unit_cost: Optional[float] = None
    remark: Optional[str] = None


class CostOut(BaseModel):
    id: int
    item: str
    item_name: Optional[str] = None
    unit: Optional[str] = None
    record_date: datetime
    shift_a: Optional[float] = 0
    shift_b: Optional[float] = 0
    unit_cost: Optional[float] = 0
    remark: Optional[str] = None
    created_at: datetime

    class Config:
        from_attributes = True
