mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-13 02:56:39 +07:00
Aurum — a self-hosted personal finance operating system: cash flow, net worth tracking, budgets, goals, recurring payments, reports, proactive alerts, and a compound-interest returns calculator, all bilingual (RU/EN) and mobile-first. Ships as a three-container Docker Compose stack (Postgres + FastAPI + nginx-served React frontend). See README.md for setup and CONTRIBUTING.md for development.
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
from decimal import Decimal
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
from app.models.enums import AccountType
|
|
|
|
|
|
class AccountBase(BaseModel):
|
|
name: str = Field(min_length=1, max_length=100)
|
|
type: AccountType = AccountType.CHECKING
|
|
currency: str = Field(default="USD", min_length=3, max_length=3)
|
|
color: str | None = Field(default=None, pattern=r"^#[0-9a-fA-F]{6}$")
|
|
|
|
|
|
class AccountCreate(AccountBase):
|
|
pass
|
|
|
|
|
|
class AccountUpdate(BaseModel):
|
|
name: str | None = Field(default=None, min_length=1, max_length=100)
|
|
type: AccountType | None = None
|
|
currency: str | None = Field(default=None, min_length=3, max_length=3)
|
|
color: str | None = Field(default=None, pattern=r"^#[0-9a-fA-F]{6}$")
|
|
is_archived: bool | None = None
|
|
|
|
|
|
class AccountRead(AccountBase):
|
|
"""Used wherever an account is embedded in another response (e.g.
|
|
TransactionRead.account) — deliberately balance-less so adding a field
|
|
here can never break an unrelated endpoint's serialization."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
is_archived: bool
|
|
|
|
|
|
class AccountWithBalance(AccountRead):
|
|
"""The Accounts page's shape — adds the live balance (see
|
|
services/account_service.py), summed from Transaction rows rather than
|
|
stored, the same "derive it" approach net_worth_service.py uses for
|
|
Cash. Used only by /api/accounts' own endpoints, never nested."""
|
|
|
|
balance: Decimal
|