- Recurring service: auto-detects direct debits/subscriptions from CSV imports using frequency analysis; manual toggle in transaction detail drawer - Subscriptions page (/subscriptions): groups recurring payments with monthly cost equivalents, next-payment badges, and re-scan trigger - UK Tax page (/tax): payslips/P60 entry, income tax + NI + CGT + dividend tax calculations, configurable rate tables per tax year (pre-seeded 2024/25 and 2025/26), editable in-app so Budget changes need no rebuild - Migration 0006: tax_rate_configs, tax_profiles, payslips, manual_cgt_disposals with RLS; seeds 2025/2026 rate configs for existing users - Chart tooltip fix: all Recharts tooltips now use TOOLTIP_STYLE constant so they render correctly across all dark/light themes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
81 lines
2.4 KiB
Python
81 lines
2.4 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
|
|
is_recurring: bool | None = None
|
|
recurring_rule: dict | 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
|
|
recurring_rule: dict | None = None
|
|
attachment_refs: list[dict] = []
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|