"""Kitchen DTOs — Phase 12.6."""
from __future__ import annotations

from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, Field

from app.models.types import (
    KitchenItemStatus,
    KitchenTicketSource,
    KitchenTicketStatus,
    LifecycleStatus,
)
from app.schemas.common import ORMBase


class KitchenStationCreate(BaseModel):
    venue_id: UUID
    code: str = Field(max_length=50)
    name: str = Field(max_length=255)
    status: LifecycleStatus = LifecycleStatus.ACTIVE


class KitchenStationRead(ORMBase):
    id: UUID
    tenant_id: UUID
    venue_id: UUID
    code: str
    name: str
    status: LifecycleStatus
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


class KitchenTicketCreate(BaseModel):
    venue_id: UUID
    station_id: UUID | None = None
    source_type: KitchenTicketSource = KitchenTicketSource.POS_TICKET
    source_id: UUID
    code: str = Field(max_length=50)
    notes: str | None = None


class KitchenTicketStatusUpdate(BaseModel):
    status: KitchenTicketStatus


class KitchenTicketRead(ORMBase):
    id: UUID
    tenant_id: UUID
    venue_id: UUID
    station_id: UUID | None
    source_type: KitchenTicketSource
    source_id: UUID
    code: str
    status: KitchenTicketStatus
    notes: str | None
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


class KitchenTicketItemCreate(BaseModel):
    venue_id: UUID
    kitchen_ticket_id: UUID
    menu_item_id: UUID
    quantity: int = 1
    sort_order: int | None = None


class KitchenTicketItemStatusUpdate(BaseModel):
    status: KitchenItemStatus


class KitchenTicketItemRead(ORMBase):
    id: UUID
    tenant_id: UUID
    venue_id: UUID
    kitchen_ticket_id: UUID
    menu_item_id: UUID
    quantity: int
    status: KitchenItemStatus
    sort_order: int
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime
