from pydantic import BaseModel, Field from typing import Optional from datetime import datetime from uuid import UUID class SaleBase(BaseModel): customer_id: UUID = Field(..., description="The ID of the customer") product_id: UUID = Field(..., description="The ID of the product") quantity: int = Field(..., gt=0, description="The quantity of the product sold") price: float = Field(..., gt=0, description="The price of the product") total_amount: float = Field(..., gt=0, description="The total amount of the sale") class SaleCreate(SaleBase): pass class SaleUpdate(SaleBase): quantity: Optional[int] = Field(None, gt=0, description="The quantity of the product sold") price: Optional[float] = Field(None, gt=0, description="The price of the product") total_amount: Optional[float] = Field(None, gt=0, description="The total amount of the sale") class SaleSchema(SaleBase): id: UUID created_at: datetime updated_at: datetime class Config: orm_mode = True