mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-16 12:36:40 +07:00
Initial public release
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.
This commit is contained in:
44
backend/app/schemas/account.py
Normal file
44
backend/app/schemas/account.py
Normal file
@@ -0,0 +1,44 @@
|
||||
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
|
||||
Reference in New Issue
Block a user