Skip to main content

Finance

Accounts, transactions in cents, profile tags, budgets, debts, savings, and daily summaries.
5 min read

Sources: 000007_finance.up.sql, 000010_finance_debt_groups.up.sql, 000017_finance_categories_to_workspace_tags.up.sql, 000023_normalize_shared_links.up.sql, 000030_finance_recurring_transfers.up.sql, 000035_finance_debt_savings_account.up.sql, 000036_finance_debt_account_detail.up.sql, 000037_finance_transaction_debt_payments.up.sql, 000064_finance_coherence.up.sql.

Model (simplified)#

Finance-specific categories (finance_categories) were removed. Classification = profile tags with domain_scope = 'finance' (finance pickers also include general tags).

Catalog#

Finance tags#

Uses profile_tags (domain_scope = 'finance') and, for recurring rules, profile_tag_links (entity_type = finance_recurring_rule). CRUD via the tags API, not finance. Legacy entity types (transaction, recurring_rule) are normalized to finance_transaction / finance_recurring_rule.

finance_accounts#

ColumnNotes
name / kind / currency
opening_balance_centsBIGINT default 0
balance_centsCurrent balance
credit_limit_centsNullable
statement_dayINT 1–31 (000036); statement closing day, especially cards
is_primaryBOOLEAN default false (000036); partial unique per profile among non-deleted accounts
mask_last4TEXT (000036); CHECK exactly 4 digits
is_archivedHides the account from the active list/pickers. Transaction history for that account still appears in reports. “Current” net worth excludes archived accounts (active wealth).
soft delete

Movements#

finance_transactions#

ColumnTypeNotes
profile_idUUID
typeTEXTCHECK expense | income | transfer
amount_centsBIGINT NOT NULLAlways cents
occurred_atTIMESTAMPTZ
from_account_id / to_account_idUUID → accountsTransfer uses both
name / noteTEXT
search_blobTEXTFull-text
tag_idUUID → profile_tagsNull on transfers
debt_idUUID → debtsExpense-only
savings_goal_idUUID → savings goals (000064)Income-only
recurring_rule_idUUID
recurring_period_keyTEXTUnique with rule
recurring_manual_overrideBOOLEAN
is_paidBOOLEAN
created_byUUID
soft delete

Indexes: occurred, deleted+occurred, recurring period, GIN search. Unique: one generated tx per rule+period (if not deleted).

Ledger by tag: GET /finance/profiles/:profileId/tags/:tagId/ledger (filters transactions by tag_id).

Recurring#

finance_recurring_rules#

ColumnNotes
typeexpense | income | transfer
amount_cents / day_of_month
from_account_id / to_account_id / debt_id / savings_goal_idTransfer requires distinct origin and destination; does not allow debt or savings. Income may link a savings goal (000064).
agenda/email remindersseveral *_reminder_* fields
max_occurrences / generated_occurrence_count
effective_start_year / month
is_active / soft delete

Rule tag: profile_tag_links (no column on the rule). Recurring transfers do not allow a tag and, when materialized, generate a pending transfer transaction. The user marks it paid when appropriate; only then do they move balance between accounts. They do not alter the profile's projected income, expense, or net.

finance_recurring_ensure_cooldown#

Control of “ensure month” per profile+year+month. EnsureRecurringForMonth reads last_run_at (TTL ~10 min) before materializing; responds { skipped } if it does not run.

Debts and savings#

finance_debt_groups#

ColumnNotes
profile_id / name / created_bysoft delete

finance_debts#

ColumnNotes
name / kind / lender / currency
starting_balance_cents / current_balance_cents
annual_interest_rate_bpsBasis points
minimum_payment_cents / due_day_of_month
target_payoff_date
group_id→ debt_groups (000010)
account_id→ accounts (000035); default payment account
settled_atTIMESTAMPTZ nullable (000036); marks the debt as settled. Index (profile_id, settled_at)
soft delete

finance_debt_payments#

Payment linked to debt_id. Registering a payment creates a paid expense and stores its transaction_id. Creating or marking as paid any expense with a debt syncs this row and the debt balance in the same transaction; reverting to pending or deleting it reverses the effect. Migration 000037 repairs current recurring occurrences that did not inherit the debt and recovers paid movements that had no payment row.

Indexes: (debt_id, occurred_at DESC) (000036) for history and partial unique (profile_id, transaction_id) (000037) so each movement originates at most one payment.

finance_savings_goals#

target_amount_cents, current_amount_cents, target_date, account_id → accounts (000035; default destination for contributions), currency (000064; backfilled from the linked or primary account).

finance_savings_contributions#

Contributions with amount_cents. Creating or marking paid an income with savings_goal_id syncs this row and the goal balance in the same transaction. Partial unique (profile_id, transaction_id) (000064) so each movement originates at most one contribution. Direct contribution create still writes a paid income when transaction_id is omitted.

Planner (000024)#

finance_planner_scenarios#

Planner «what-if» scenarios (/finance/planner).

ColumnNotes
name / descriptionOptional description
currencyScenario currency (000064). Projection stays inside this scope.
starting_balance_modeaccounts (sum of active non-archived same-currency accounts) | custom | zero
custom_starting_balance_centsRequired if mode is custom; cleared when switching to another mode
soft delete

finance_planner_scenario_items#

Hypothetical line items of a scenario. The projection combines them with real recurring rules; they do not generate transactions.

ColumnNotes
scenario_id→ finance_planner_scenarios
typeexpense | income
amount_cents
recurrenceone_off | monthly
start_year / start_monthApplication month (monthly granularity)
end_year / end_monthOptional; only for monthly
is_active«what-if» toggle without deleting
soft delete

Budgets and materialized analytics#

finance_budgets#

ColumnNotes
nameBudget's own name (required on upsert)
currencyBudget currency (000064). Progress only counts same-currency expenses.
tag_idNullable = global budget (total spend for the month)
periodDefault monthly
amount_cents
alert_threshold_pctAlert threshold (default 80)
alert_email_enabledIf true, an email is sent when crossing the threshold or the cap
alert_email_last_sent_period_keyLast send: YYYY-MM:warning or YYYY-MM:exceeded (one email per band per month). A legacy YYYY-MM value counts as warning already sent
is_active / soft delete

finance_daily_profile_summaries#

ColumnNotes
day_keyYYYY-MM-DD
income_cents / expense_cents
expense_paid_cents / expense_pending_cents
transfer_count
currencyAccount currency of the movement; blank = unknown (000064)
UNIQUE (profile_id, day_key, currency)

Written on every transaction mutation. Read: period summary and monthly trend (GetPeriodSummary / GetMonthlyTrend) aggregate by day_key range.

finance_daily_tag_summaries#

Aggregated by day + tag_key + optional tag_id + currency (000064). Read: period expense breakdown.

Plan limits#

Finance accounts and transactions are unlimited for customers. Private abuse safeguards may return CAPACITY_GUARD_REACHED. Tags share the general profile_tags safeguard (not a separate category quota).

Who writes#

  • Go: internal/finance
  • Front: features/finance
  • OpenAPI: tag Finance