from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel

from models.items import Product


class Promotion(BaseModel):
    id: Optional[int] = None
    price: Optional[float] = None

class ItemWeb(BaseModel):
    id: int
    price: int
    quantity: int
    comment: str
    promotion: Optional[Promotion] = None


class OrderWeb(BaseModel):
    customerId: int
    items: List[ItemWeb]
    totalAmount: float
    orderDate: str
    table: int

class Sale(BaseModel):
    """Sale model matching the database schema"""
    id: int
    user_id: int
    total: float
    fudo_id: str
    date: datetime
    table: int
    username: Optional[str] = None
    user_email: Optional[str] = None
    products: List[Product] = []
