Phase 3 — Investments: - Multi-currency support: holdings track purchase currency, FX rates convert to base for totals - Capital gains report using UK Section 104 pool method, grouped by tax year - Capital Gains tab added to Reports page Phase 5 — Polish & Hardening: - Mobile-responsive layout: bottom nav, sidebar hidden on mobile, logo in TopBar, compact header buttons, hover-only actions now always visible on touch - Backup system: encrypted GPG backups via backup.sh, nightly scheduler job, admin API (list/trigger/download/restore), Settings UI with drag-to-restore confirmation - Docker entrypoint with gosu privilege drop to fix bind-mount ownership on fresh deployments - OWASP fixes: refresh token now bound to its session (new refresh_token_hash column + migration), CSRF secure flag tied to environment, IP-level rate limiting on login, TOTPEnableRequest Pydantic schema replaces raw dict - AES-256-GCM key rotation script (rotate_keys.py) with dry-run mode and atomic DB transaction - CLAUDE.md added for AI-assisted development context - README updated: correct reverse proxy port, accurate backup/restore commands, key rotation instructions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
78 lines
2.3 KiB
Python
78 lines
2.3 KiB
Python
import uuid
|
|
from datetime import date as DateType, datetime
|
|
from decimal import Decimal
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
TransactionType = Literal["income", "expense", "transfer", "investment"]
|
|
TransactionStatus = Literal["pending", "cleared", "reconciled", "void"]
|
|
|
|
|
|
class TransactionCreate(BaseModel):
|
|
account_id: uuid.UUID
|
|
transfer_account_id: uuid.UUID | None = None
|
|
category_id: uuid.UUID | None = None
|
|
type: TransactionType
|
|
status: TransactionStatus = "cleared"
|
|
amount: Decimal
|
|
currency: str = Field(default="GBP", min_length=3, max_length=10)
|
|
date: DateType
|
|
description: str = Field(..., min_length=1, max_length=500)
|
|
merchant: str | None = None
|
|
notes: str | None = None
|
|
tags: list[str] = []
|
|
is_recurring: bool = False
|
|
recurring_rule: dict | None = None
|
|
|
|
|
|
class TransactionUpdate(BaseModel):
|
|
category_id: uuid.UUID | None = None
|
|
status: TransactionStatus | None = None
|
|
amount: Decimal | None = None
|
|
date: DateType | None = None
|
|
description: str | None = Field(default=None, min_length=1, max_length=500)
|
|
merchant: str | None = None
|
|
notes: str | None = None
|
|
tags: list[str] | None = None
|
|
|
|
|
|
class TransactionFilter(BaseModel):
|
|
account_id: uuid.UUID | None = None
|
|
category_id: uuid.UUID | None = None
|
|
type: TransactionType | None = None
|
|
status: TransactionStatus | None = None
|
|
date_from: DateType | None = None
|
|
date_to: DateType | None = None
|
|
min_amount: Decimal | None = None
|
|
max_amount: Decimal | None = None
|
|
search: str | None = None
|
|
tags: list[str] = []
|
|
is_recurring: bool | None = None
|
|
page: int = Field(default=1, ge=1)
|
|
page_size: int = Field(default=50, ge=1, le=200)
|
|
|
|
|
|
class TransactionResponse(BaseModel):
|
|
id: uuid.UUID
|
|
account_id: uuid.UUID
|
|
transfer_account_id: uuid.UUID | None
|
|
category_id: uuid.UUID | None
|
|
type: str
|
|
status: str
|
|
amount: Decimal
|
|
amount_base: Decimal | None
|
|
currency: str
|
|
base_currency: str
|
|
exchange_rate: Decimal | None
|
|
date: DateType
|
|
description: str
|
|
merchant: str | None
|
|
notes: str | None
|
|
tags: list[str]
|
|
is_recurring: bool
|
|
attachment_refs: list[dict] = []
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|