
from typing import Optional, List
from pydantic import BaseModel, Field, ConfigDict
from datetime import datetime
from decimal import Decimal

class CanadianTariffFractionBase(BaseModel):
    fraction: str = Field(..., max_length=13)
    ad_valorem: Optional[Decimal] = Field(None, max_digits=5, decimal_places=2)
    unit_of_measure: Optional[str] = Field(None, max_length=5)
    country_code: str = Field(..., max_length=3)
    description: Optional[str] = Field(None, max_length=1000)

class CanadianTariffFractionCreate(CanadianTariffFractionBase):
    pass

class CanadianTariffFractionUpdate(CanadianTariffFractionBase):
    pass

class CanadianTariffFractionResponse(CanadianTariffFractionBase):
    id: int
    created_at: datetime
    updated_at: datetime

    model_config = ConfigDict(from_attributes=True)

class CanadianTariffFractionListResponse(BaseModel):
    items: List[CanadianTariffFractionResponse]
    total: int
    page: int
    page_size: int
    pages: int
