from datetime import datetime
from typing import Optional

from pydantic import BaseModel, ConfigDict, Field


class PedimentoConfigCalculationsBase(BaseModel):
    """Base schema for Pedimento Config Calculations"""

    pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
    tenant_id: Optional[int] = Field(None, description="Tenant ID")
    dta_type: Optional[str] = Field(None, max_length=1, description="DTA type")
    dta_operation: Optional[bool] = Field(False, description="DTA operation")
    dta_vehicle_count: Optional[int] = Field(0, description="DTA vehicle count")
    dta_mixed_rate_8permil: Optional[bool] = Field(
        False, description="DTA mixed rate 8 per mil"
    )
    pays_vat: Optional[bool] = Field(False, description="Pays VAT")
    pays_prevalidation: Optional[bool] = Field(False, description="Pays prevalidation")
    include_sagar_certificate_fee: Optional[bool] = Field(
        False, description="Include SAGAR certificate fee"
    )
    fixed_vehicle_dta_fee: Optional[bool] = Field(
        False, description="Fixed vehicle DTA fee"
    )
    additional_fixed_fee: Optional[int] = Field(
        0, description="Additional fixed fee"
    )
    additional_fixed_fee_payment_method: Optional[int] = Field(
        None, description="Additional fixed fee payment method"
    )


class PedimentoConfigCalculationsCreate(PedimentoConfigCalculationsBase):
    """Schema for creating a new Pedimento Config Calculations"""

    pass


class PedimentoConfigCalculationsUpdate(BaseModel):
    """Schema for updating a Pedimento Config Calculations"""

    dta_type: Optional[str] = Field(None, max_length=1)
    dta_operation: Optional[bool] = None
    dta_vehicle_count: Optional[int] = None
    dta_mixed_rate_8permil: Optional[bool] = None
    pays_vat: Optional[bool] = None
    pays_prevalidation: Optional[bool] = None
    include_sagar_certificate_fee: Optional[bool] = None
    fixed_vehicle_dta_fee: Optional[bool] = None
    additional_fixed_fee: Optional[int] = None
    additional_fixed_fee_payment_method: Optional[int] = None


class PedimentoConfigCalculationsResponse(PedimentoConfigCalculationsBase):
    """Schema for Pedimento Config Calculations response"""

    id: int
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)
