Full-stack self-hosted finance app with FastAPI backend and React frontend. Features: - Accounts, transactions, budgets, investments with GBP base currency - CSV import with auto-detection for 10 UK bank formats - ML predictions: spending forecast, net worth projection, Monte Carlo - 7 selectable themes (Obsidian, Arctic, Midnight, Vault, Terminal, Synthwave, Ledger) - Receipt/document attachments on transactions (JPEG, PNG, WebP, PDF) - AES-256-GCM field encryption, RS256 JWT, TOTP 2FA, RLS, audit log - Encrypted nightly backups + key rotation script - Mobile-responsive layout with bottom nav Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
|
|
from sqlalchemy import Boolean, DateTime, Integer, Numeric, String, Text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class Currency(Base):
|
|
__tablename__ = "currencies"
|
|
|
|
code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
name: Mapped[str] = mapped_column(Text, nullable=False)
|
|
symbol: Mapped[str] = mapped_column(String(5), nullable=False)
|
|
is_crypto: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
|
decimal_places: Mapped[int] = mapped_column(Integer, default=2, nullable=False)
|
|
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
|
|
|
|
|
class ExchangeRate(Base):
|
|
__tablename__ = "exchange_rates"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
base_currency: Mapped[str] = mapped_column(String(10), nullable=False, index=True)
|
|
quote_currency: Mapped[str] = mapped_column(String(10), nullable=False, index=True)
|
|
rate: Mapped[Decimal] = mapped_column(Numeric(20, 10), nullable=False)
|
|
source: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
fetched_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, index=True)
|