mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-12 18:46:40 +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.
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
"""An account is any place money lives: bank account, card, cash, wallet."""
|
|
from sqlalchemy import Boolean, Enum, String
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.db.base import Base
|
|
from app.models.enums import AccountType
|
|
from app.models.mixins import TimestampMixin
|
|
|
|
|
|
class Account(Base, TimestampMixin):
|
|
__tablename__ = "accounts"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
type: Mapped[AccountType] = mapped_column(
|
|
Enum(AccountType, name="account_type", native_enum=False, length=20),
|
|
nullable=False,
|
|
default=AccountType.CHECKING,
|
|
)
|
|
currency: Mapped[str] = mapped_column(String(3), nullable=False, default="USD")
|
|
# Hex color used for account-scoped UI accents (e.g. transaction list avatars).
|
|
color: Mapped[str | None] = mapped_column(String(7), nullable=True)
|
|
is_archived: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
|
|
transactions: Mapped[list["Transaction"]] = relationship(
|
|
back_populates="account",
|
|
foreign_keys="Transaction.account_id",
|
|
cascade="all, delete-orphan",
|
|
)
|