# app/schemas/item.py
from pydantic import BaseModel, ConfigDict
from datetime import datetime
from typing import Optional
from decimal import Decimal

# Properties to return to client
class ItemPublic(BaseModel):
    id: int
    list_id: int
    name: str
    quantity: Optional[str] = None
    is_complete: bool
    price: Optional[Decimal] = None
    added_by_id: int
    completed_by_id: Optional[int] = None
    created_at: datetime
    updated_at: datetime
    version: int
    model_config = ConfigDict(from_attributes=True)

# Properties to receive via API on creation
class ItemCreate(BaseModel):
    name: str
    quantity: Optional[str] = None
    # list_id will be from path param
    # added_by_id will be from current_user

# Properties to receive via API on update
class ItemUpdate(BaseModel):
    name: Optional[str] = None
    quantity: Optional[str] = None
    is_complete: Optional[bool] = None
    price: Optional[Decimal] = None # Price added here for update
    position: Optional[int] = None # For reordering
    version: int
    # completed_by_id will be set internally if is_complete is true