from typing import Optional, List
from pydantic import BaseModel, Field, ConfigDict

# Equivalency Item DTOs


class EquivalencyItemBase(BaseModel):
    original_field: str = Field(..., max_length=100,
                                description="Original Field (Unit of Measure)")
    external_field: str = Field(..., max_length=100,
                                description="External Field")


class EquivalencyItemCreate(EquivalencyItemBase):
    pass


class EquivalencyItemUpdate(BaseModel):
    original_field: Optional[str] = Field(None, max_length=100)
    external_field: Optional[str] = Field(None, max_length=100)


class EquivalencyItemResponse(EquivalencyItemBase):
    id: int
    equivalency_id: int

    model_config = ConfigDict(from_attributes=True)

# Equivalency DTOs


class EquivalencyBase(BaseModel):
    fraccion_mex: str = Field(..., max_length=10, description="Fraccion MX (Identifier)")
    fraccion_us: str = Field(..., max_length=100, description="Fraccion US (External Field)")
    description: Optional[str] = Field(
        None, max_length=200, description="Description")


class EquivalencyCreate(EquivalencyBase):
    pass


class EquivalencyUpdate(BaseModel):
    fraccion_mex: Optional[str] = Field(None, max_length=10)
    fraccion_us: Optional[str] = Field(None, max_length=100)
    description: Optional[str] = Field(None, max_length=200)


class EquivalencyResponse(EquivalencyBase):
    id: int
    tenant_id: int
    company_id: int

    model_config = ConfigDict(from_attributes=True)

    model_config = ConfigDict(from_attributes=True)
