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>
23 lines
835 B
Python
23 lines
835 B
Python
import structlog
|
|
from sqlalchemy import select
|
|
|
|
logger = structlog.get_logger()
|
|
|
|
|
|
async def snapshot_job() -> None:
|
|
from app.dependencies import get_session_factory
|
|
from app.db.models.user import User
|
|
from app.services.report_service import take_net_worth_snapshot
|
|
|
|
session_factory = get_session_factory()
|
|
async with session_factory() as db:
|
|
try:
|
|
result = await db.execute(select(User).where(User.deleted_at.is_(None)))
|
|
users = result.scalars().all()
|
|
for user in users:
|
|
await take_net_worth_snapshot(db, user.id, user.base_currency)
|
|
await db.commit()
|
|
logger.info("snapshot_job_done", users=len(users))
|
|
except Exception as exc:
|
|
await db.rollback()
|
|
logger.error("snapshot_job_failed", error=str(exc))
|