import uuid from datetime import datetime from decimal import Decimal from typing import Literal from pydantic import BaseModel, Field AccountType = Literal[ "checking", "savings", "cash_isa", "stocks_shares_isa", "credit_card", "investment", "cash", "crypto_wallet", "loan", "mortgage", "pension", "other" ] class AccountCreate(BaseModel): name: str = Field(..., min_length=1, max_length=100) institution: str | None = None type: AccountType currency: str = Field(default="GBP", min_length=3, max_length=10) credit_limit: Decimal | None = None interest_rate: Decimal | None = None include_in_net_worth: bool = True color: str = Field(default="#6366f1", pattern=r"^#[0-9a-fA-F]{6}$") icon: str | None = None notes: str | None = None opening_balance: Decimal = Field(default=Decimal("0")) class AccountUpdate(BaseModel): name: str | None = Field(default=None, min_length=1, max_length=100) institution: str | None = None opening_balance: Decimal | None = None credit_limit: Decimal | None = None interest_rate: Decimal | None = None include_in_net_worth: bool | None = None is_active: bool | None = None color: str | None = Field(default=None, pattern=r"^#[0-9a-fA-F]{6}$") icon: str | None = None notes: str | None = None class AccountResponse(BaseModel): id: uuid.UUID name: str institution: str | None type: str currency: str current_balance: Decimal credit_limit: Decimal | None interest_rate: Decimal | None is_active: bool include_in_net_worth: bool color: str icon: str | None notes: str | None created_at: datetime updated_at: datetime model_config = {"from_attributes": True}