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


class ConceptBase(BaseModel):
    code: str = Field(..., max_length=15, description="Concept Code (CLAVE)")
    company_id: int = Field(..., description="Company ID")
    description: Optional[str] = Field(
        None, max_length=120, description="Description")
    description_en: Optional[str] = Field(
        None, max_length=120, description="English Description")
    detailed_description: Optional[str] = Field(
        None, max_length=1000, description="Detailed Description")
    priority: Optional[int] = Field(None, description="Priority")
    priority_ame: Optional[int] = Field(None, description="American Priority")
    first_total: Optional[bool] = Field(None, description="First Total")
    type: Optional[str] = Field(None, max_length=9, description="Type")
    is_printed: Optional[bool] = Field(None, description="Is Printed")
    section: Optional[int] = Field(None, description="Section")
    classification: Optional[str] = Field(
        None, max_length=30, description="Classification")


class ConceptCreate(ConceptBase):
    pass


class ConceptUpdate(BaseModel):
    code: Optional[str] = Field(None, max_length=15)
    description: Optional[str] = Field(None, max_length=120)
    description_en: Optional[str] = Field(None, max_length=120)
    detailed_description: Optional[str] = Field(None, max_length=1000)
    priority: Optional[int] = None
    priority_ame: Optional[int] = None
    first_total: Optional[bool] = None  
    type: Optional[str] = Field(None, max_length=9)
    is_printed: Optional[bool] = None
    section: Optional[int] = None
    classification: Optional[str] = Field(None, max_length=30)


class ConceptResponse(ConceptBase):
    id: int
    tenant_id: int

    model_config = ConfigDict(from_attributes=True)
