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


class MultiCurrencyTypeBase(BaseModel):
    currency_type_code: str = Field(..., max_length=3,
                                    description="Currency Type Code")
    country_key: Optional[str] = Field(
        None, max_length=3, description="Country Key")
    conversion_factor: Optional[Decimal] = Field(
        None, description="Conversion Factor")
    publication_date: int = Field(...,
                                  description="Publication Date (YYYYMMDD)")


class MultiCurrencyTypeCreate(MultiCurrencyTypeBase):
    pass


class MultiCurrencyTypeUpdate(BaseModel):
    currency_type_code: Optional[str] = Field(None, max_length=3)
    country_key: Optional[str] = Field(None, max_length=3)
    conversion_factor: Optional[Decimal] = None
    publication_date: Optional[int] = None


class MultiCurrencyTypeResponse(MultiCurrencyTypeBase):
    id: int
    company_id: int
    tenant_id: int
    
    model_config = ConfigDict(from_attributes=True)
