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

class HistoricalTariffFractionBase(BaseModel):
    """Base schema for Historical Tariff Fraction"""
    historical_fraction: Optional[str] = Field(None, max_length=8)
    unit_of_measure_code: Optional[str] = None
    country: Optional[str] = None
    fraction_type: Optional[str] = Field(None, max_length=7)
    sector: Optional[str] = Field(None, max_length=5)
    import_tax_rate: Optional[Decimal] = None
    export_tax_rate: Optional[Decimal] = None
    publication_date: Optional[datetime] = None
    is_immex: Optional[bool] = None
    normal_temporality: Optional[bool] = None
    services_temporality: Optional[bool] = None
    certified_temporality: Optional[bool] = None
    by_log: Optional[bool] = None
    end_date: Optional[datetime] = None

class HistoricalTariffFractionCreate(HistoricalTariffFractionBase):
    """Schema for creating a Historical Tariff Fraction"""
    pass

class HistoricalTariffFractionUpdate(HistoricalTariffFractionBase):
    """Schema for updating a Historical Tariff Fraction"""
    pass

class HistoricalTariffFractionResponse(HistoricalTariffFractionBase):
    """Schema for reading a Historical Tariff Fraction"""
    id: int

    class Config:
        from_attributes = True

class HistoricalTariffFractionListResponse(BaseModel):
    """Schema for paginated list of Historical Tariff Fractions"""
    items: List[HistoricalTariffFractionResponse]
    total: int
    page: int
    page_size: int
    pages: int
