from pydantic import BaseModel
from typing import Optional
from datetime import datetime
from app.models.plan import PlanStatus


class PlanCreate(BaseModel):
    plan_no: str
    plan_date: datetime
    shift: Optional[str] = None
    plan_quantity: int = 0
    plan_weight: float = 0
    steel_grade: Optional[str] = None
    spec_range: Optional[str] = None
    priority: int = 5
    remark: Optional[str] = None


class PlanUpdate(BaseModel):
    plan_date: Optional[datetime] = None
    shift: Optional[str] = None
    plan_quantity: Optional[int] = None
    plan_weight: Optional[float] = None
    actual_quantity: Optional[int] = None
    actual_weight: Optional[float] = None
    status: Optional[PlanStatus] = None
    priority: Optional[int] = None
    remark: Optional[str] = None


class PlanOut(BaseModel):
    id: int
    plan_no: str
    plan_date: datetime
    shift: Optional[str]
    plan_quantity: int
    plan_weight: float
    actual_quantity: int
    actual_weight: float
    status: PlanStatus
    steel_grade: Optional[str]
    spec_range: Optional[str]
    priority: int
    created_by: Optional[str]
    created_at: datetime

    class Config:
        from_attributes = True
