from datetime import datetime
from typing import Optional

from pydantic import BaseModel, Field


class ExchangeRateBaseDTO(BaseModel):
    date: datetime = Field(..., description="Exchange rate date")
    value: Optional[float] = Field(None, description="Exchange rate value")
    local_currency: Optional[str] = Field(None, max_length=7, description="Local currency code")
    foreign_currency: Optional[str] = Field(None, max_length=7, description="Foreign currency code")


class ExchangeRateCreateDTO(ExchangeRateBaseDTO):
    """Schema for creating an exchange rate"""
    pass


class ExchangeRateUpdateDTO(ExchangeRateBaseDTO):
    """Schema for updating an exchange rate"""
    date: Optional[datetime] = Field(None, description="Exchange rate date")


class ExchangeRateResponseDTO(ExchangeRateBaseDTO):
    """Schema for exchange rate response"""
    id: int
    company_id: int
    tenant_id: int

    class Config:
        from_attributes = True
