from datetime import datetime
from typing import Optional

from pydantic import BaseModel, ConfigDict, Field


class PedimentoConfigAdditionalBase(BaseModel):
    """Base schema for Pedimento Config Additional"""

    pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
    tenant_id: Optional[int] = Field(None, description="Tenant ID")
    add_po_identifier: Optional[bool] = Field(None, description="Add PO identifier")
    do_not_exempt_norms_complement_x: Optional[bool] = Field(
        None, description="Do not exempt norms complement X"
    )
    manual_pedimento_year: Optional[str] = Field(
        None, max_length=2, description="Manual pedimento year"
    )
    enable_import_invoice_recipient: Optional[bool] = Field(
        None, description="Enable import invoice recipient"
    )
    send_502_validation_file_for_consolidated: Optional[bool] = Field(
        None, description="Send 502 validation file for consolidated"
    )
    add_remove_norms: Optional[bool] = Field(None, description="Add/remove norms")
    choose_invoice_cove: Optional[bool] = Field(None, description="Choose invoice COVE in items")


class PedimentoConfigAdditionalCreate(PedimentoConfigAdditionalBase):
    """Schema for creating a new Pedimento Config Additional"""

    pass


class PedimentoConfigAdditionalUpdate(BaseModel):
    """Schema for updating a Pedimento Config Additional"""

    add_po_identifier: Optional[bool] = None
    do_not_exempt_norms_complement_x: Optional[bool] = None
    manual_pedimento_year: Optional[str] = Field(None, max_length=2)
    enable_import_invoice_recipient: Optional[bool] = None
    send_502_validation_file_for_consolidated: Optional[bool] = None
    add_remove_norms: Optional[bool] = None
    choose_invoice_cove: Optional[bool] = None


class PedimentoConfigAdditionalResponse(PedimentoConfigAdditionalBase):
    """Schema for Pedimento Config Additional response"""

    id: int
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)
