"""POS Pro DTOs — Phase 12.5."""
from __future__ import annotations

from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, Field

from app.models.types import LifecycleStatus, PosDiscountKind, PosPaymentMethod
from app.schemas.common import ORMBase


class PosPaymentCreate(BaseModel):
    venue_id: UUID
    ticket_id: UUID
    method: PosPaymentMethod = PosPaymentMethod.CASH
    amount: int
    currency_code: str = Field(default="IRR", max_length=3)
    external_payment_ref: str | None = Field(default=None, max_length=255)


class PosPaymentRead(ORMBase):
    id: UUID
    tenant_id: UUID
    venue_id: UUID
    ticket_id: UUID
    method: PosPaymentMethod
    amount: int
    currency_code: str
    external_payment_ref: str | None
    status: LifecycleStatus
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


class PosDiscountCreate(BaseModel):
    venue_id: UUID
    ticket_id: UUID
    code: str = Field(max_length=50)
    kind: PosDiscountKind = PosDiscountKind.PERCENT
    value: int
    name: str | None = Field(default=None, max_length=255)


class PosDiscountRead(ORMBase):
    id: UUID
    tenant_id: UUID
    venue_id: UUID
    ticket_id: UUID
    code: str
    kind: PosDiscountKind
    value: int
    name: str | None
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


class PosTaxLineCreate(BaseModel):
    venue_id: UUID
    ticket_id: UUID
    code: str = Field(max_length=50)
    name: str = Field(max_length=255)
    rate_bps: int
    amount: int


class PosTaxLineRead(ORMBase):
    id: UUID
    tenant_id: UUID
    venue_id: UUID
    ticket_id: UUID
    code: str
    name: str
    rate_bps: int
    amount: int
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


class PosFloorPlanCreate(BaseModel):
    venue_id: UUID
    code: str = Field(max_length=50)
    name: str = Field(max_length=255)
    dining_area_id: UUID | None = None
    status: LifecycleStatus = LifecycleStatus.ACTIVE


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


class PosStationCreate(BaseModel):
    venue_id: UUID
    floor_plan_id: UUID | None = None
    code: str = Field(max_length=50)
    name: str = Field(max_length=255)
    status: LifecycleStatus = LifecycleStatus.ACTIVE


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