54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
from datetime import datetime
|
|
from decimal import Decimal
|
|
from pydantic import BaseModel, Field
|
|
from app.schemas.currency import CurrencyOut
|
|
|
|
|
|
class AccountTypeOut(BaseModel):
|
|
id: int
|
|
name: str
|
|
icon: str | None = None
|
|
description: str | None = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class AccountCreate(BaseModel):
|
|
name: str = Field(..., max_length=200)
|
|
account_type_id: int
|
|
currency_id: int
|
|
initial_balance: Decimal = Decimal("0.00")
|
|
credit_limit: Decimal | None = None
|
|
description: str | None = None
|
|
icon: str | None = None
|
|
color: str | None = Field(None, pattern=r"^#[0-9A-Fa-f]{6}$")
|
|
|
|
|
|
class AccountUpdate(BaseModel):
|
|
name: str | None = Field(None, max_length=200)
|
|
is_active: bool | None = None
|
|
credit_limit: Decimal | None = None
|
|
description: str | None = None
|
|
icon: str | None = None
|
|
color: str | None = Field(None, pattern=r"^#[0-9A-Fa-f]{6}$")
|
|
|
|
|
|
class AccountOut(BaseModel):
|
|
id: int
|
|
user_id: int
|
|
name: str
|
|
account_type_id: int
|
|
account_type: AccountTypeOut
|
|
currency_id: int
|
|
currency: CurrencyOut
|
|
balance: Decimal
|
|
initial_balance: Decimal
|
|
is_active: bool
|
|
credit_limit: Decimal | None = None
|
|
description: str | None = None
|
|
icon: str | None = None
|
|
color: str | None = None
|
|
created_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|