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>
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
import uuid
|
|
from datetime import date as DateType, datetime
|
|
from decimal import Decimal
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
BudgetPeriod = Literal["weekly", "monthly", "quarterly", "yearly"]
|
|
|
|
|
|
class BudgetCreate(BaseModel):
|
|
category_id: uuid.UUID
|
|
name: str = Field(..., min_length=1, max_length=200)
|
|
amount: Decimal = Field(..., gt=0)
|
|
currency: str = Field(default="GBP", min_length=3, max_length=10)
|
|
period: BudgetPeriod = "monthly"
|
|
start_date: DateType
|
|
end_date: DateType | None = None
|
|
rollover: bool = False
|
|
alert_threshold: Decimal = Field(default=Decimal("80"), ge=0, le=100)
|
|
|
|
|
|
class BudgetUpdate(BaseModel):
|
|
name: str | None = Field(default=None, min_length=1, max_length=200)
|
|
amount: Decimal | None = Field(default=None, gt=0)
|
|
period: BudgetPeriod | None = None
|
|
end_date: DateType | None = None
|
|
rollover: bool | None = None
|
|
alert_threshold: Decimal | None = Field(default=None, ge=0, le=100)
|
|
is_active: bool | None = None
|
|
|
|
|
|
class BudgetResponse(BaseModel):
|
|
id: uuid.UUID
|
|
category_id: uuid.UUID
|
|
name: str
|
|
amount: Decimal
|
|
currency: str
|
|
period: str
|
|
start_date: DateType
|
|
end_date: DateType | None
|
|
rollover: bool
|
|
alert_threshold: Decimal
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class BudgetSummaryItem(BaseModel):
|
|
budget_id: uuid.UUID
|
|
budget_name: str
|
|
category_id: uuid.UUID
|
|
category_name: str
|
|
period: str
|
|
budget_amount: Decimal
|
|
spent_amount: Decimal
|
|
remaining_amount: Decimal
|
|
percent_used: Decimal
|
|
is_over_budget: bool
|
|
alert_triggered: bool
|
|
currency: str
|
|
period_start: DateType
|
|
period_end: DateType
|