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

# ============================================================================
# LINE REFERENCE SCHEMAS
# ============================================================================

class LineReferenceBase(BaseModel):
    """Base schema for line references"""
    serie_id: Optional[int] = Field(None, description="Serie ID (SERIEPARTIDA)")
    
    # Customer/Vendor
    customer_invoice: Optional[str] = Field(None, description="Customer invoice (CLIENTEFACTURAR)")
    assigned_client: Optional[str] = Field(None, description="Assigned client (CLIENTEASIGNADO)")
    supplier: Optional[str] = Field(None, description="Supplier (PROVEEDOR)")
    requisitioner: Optional[str] = Field(None, description="Requisitioner (REQUISITOR)")
    sent_to: Optional[str] = Field(None, description="Sent to (ENVIADOA)")
    
    # PED line reference
    ped_line: Optional[int] = Field(None, description="PED line (LINEAPED)")
    ro_line: Optional[int] = Field(None, description="RO line (LINEARO)")


class LineReferenceCreate(LineReferenceBase):
    """Schema for creating line reference"""
    pass


class LineReferenceUpdate(LineReferenceBase):
    """Schema for updating line reference"""
    pass


class LineReferenceResponse(LineReferenceBase):
    """Schema for line reference response"""
    id: int
    item_line_id: int

    model_config = ConfigDict(from_attributes=True)
