from datetime import datetime, date from decimal import Decimal from pydantic import BaseModel, Field class CurrencyCreate(BaseModel): code: str = Field(..., min_length=3, max_length=3) name: str = Field(..., max_length=100) symbol: str | None = Field(None, max_length=10) is_active: bool = True class CurrencyUpdate(BaseModel): name: str | None = Field(None, max_length=100) symbol: str | None = Field(None, max_length=10) is_active: bool | None = None class CurrencyOut(BaseModel): id: int code: str name: str symbol: str | None = None is_active: bool model_config = {"from_attributes": True} class ExchangeRateCreate(BaseModel): currency_from_id: int currency_to_id: int rate: Decimal = Field(..., gt=0) rate_date: date source: str | None = None class ExchangeRateOut(BaseModel): id: int currency_from_id: int currency_to_id: int rate: Decimal rate_date: date source: str | None = None created_at: datetime currency_from: CurrencyOut currency_to: CurrencyOut model_config = {"from_attributes": True}