640 Commits
Author SHA1 Message Date
Herculino Trotta 8d6b86b7ca feat(export): export and restore on the page, with progress and messages
The export and restore forms now sit on the Export and Restore page
instead of an offcanvas. Exporting shows a progress line and a toast
when the download starts; restoring splits ZIP and CSV uploads into
tabs and shows errors in the form.

- An empty export warns instead of downloading the message as a file
- Export errors show a message instead of a stuck spinner
- The download link is kept long enough for Safari to save the file
- Non-superusers get a 403 instead of a redirect loop with the login
- The asset classes CSV can be uploaded on its own
- Drop the export form's unknown investment_classes layout field
2026-11-17 13:01:25 -03:00
Herculino Trotta 5ea7f79f56 fix(export): keep each user's names on restore and speed up big exports
Restore looked categories, tags and entities up through the admin's
filtered manager, so other users' transactions moved to the admin's
categories and lost their tags. They are now matched to the row's
owner (then to ones that owner can see) and created for that owner.
Export also read tags and entities through that manager and left other
users' private ones out.

Recurring transactions and installment plans now export account_owner,
which restore already read but never received.

Transaction exports ran a few queries per row and paged prefetched rows
with OFFSET, so large histories timed out. They now load relations up
front and read in cursor chunks: 200k transactions export in ~43s with
~200 queries (10k took 34s and ~21k queries before).

Fixes #691
Fixes #692
2026-11-17 13:01:25 -03:00
Herculino Trotta faa47d2d7c Merge pull request #688 from eitchtee/feat/native-mcp
feat(api): native MCP server at /mcp
2026-11-15 16:44:18 -03:00
Herculino Trotta f5414223ab fix(transactions): drop unpaid recurring occurrences past a shorter end date
Editing a recurring transaction to end earlier kept its unpaid occurrences
after the new end date, counting them in projected balances, and left
last_generated_date past it. Remove them (both sides of a generated transfer;
a partner linked from elsewhere is unlinked and kept) and move the bookmark
back to the last remaining occurrence. Paid occurrences stay.

Also pin ENABLE_SOFT_DELETE=False on the test that asserts hard deletes, so a
.env that turns soft delete on no longer fails it.
2026-11-15 16:36:29 -03:00
Herculino Trotta 4754f7e022 feat(api): serve a native MCP server at /mcp
Off unless MCP_ENABLED=true. Runs inside the web app (stateless Streamable
HTTP, JSON responses), so no extra container or supervisord program.

- Tools run the REST views in-process as the caller, so permissions,
  sharing, validation and transaction rules stay the API's.
- 11 curated tools with compact output, plus search_api/call_api to reach
  every other API endpoint from the OpenAPI schema.
- OAuth protected-resource metadata (RFC 9728) and a WWW-Authenticate hint
  on 401s, so MCP clients find the existing OAuth server and DCR.
- GET /api/transactions/summary/: totals per currency and type, optionally
  grouped by category, tag, entity, account or month.

API changes found while testing it:

- Writes no longer need Django model permissions, which nothing granted;
  access now matches the web UI (signed-in user, scoped querysets, owner-only
  edits of shared objects). API tokens and OAuth apps can now write for
  regular users.
- Account group owner is read-only; it could be set to another user.
- Reject negative installment, recurring, DCA and exchange-rate amounts, a
  zero recurrence interval, and performance on non-investment accounts.
- Accounts can be archived; group_id/exchange_currency_id are optional;
  category accepts null; currency prefix/suffix keep their spaces.
- Transactions filter by tags and entities.
- OpenAPI: separate request schemas (COMPONENT_SPLIT_REQUEST) and real
  descriptions for the viewsets and DCA chart actions.
2026-11-15 16:29:06 -03:00
Herculino Trotta eb51e240ac Merge pull request #672 from officialasishkumar/fix/qif-dedup-account
fix(import): make QIF deduplication account-aware and keep identical transactions
2026-11-14 12:20:49 -03:00
Herculino Trotta d763d0ffb8 fix(import): leave QIF headers out of the hash and skip non-transaction sections
The !Type header line was buffered into the first transaction's raw
lines, so a transaction hashed differently depending on whether it
opened the export. An overlapping export with a different first
transaction imported it twice. Header lines are now left out of the
internal ID. The previous-hash check still hashes the full lines,
headers included, and runs on the first appearance of each of those,
so a first transaction and an identical later one imported before
this change are both still recognized.

Account blocks (!Account and !Option:AutoSwitch account lists) and
non-transaction sections (!Type:Cat, !Type:Class, !Type:Memorized and
any type not in QIF_TRANSACTION_SECTIONS) were read with the
transaction codes, where T is an account's type and D a description,
so files containing them failed to import. They are now skipped, and
each skipped section is logged.
2026-11-14 12:16:15 -03:00
Herculino Trotta 72502c8873 fix(transactions): renumber filter preset migration after sub-transactions
main added 0053_sub_transaction, which also depends on 0052, so the
filter preset migration becomes 0054 to keep a single leaf.
2026-11-14 11:36:30 -03:00
Herculino Trotta 262ac3fbb6 Merge remote-tracking branch 'origin/main' into feat/filter-preset-relative-dates
# Conflicts:
#	app/apps/transactions/filters.py
2026-11-14 11:29:15 -03:00
Herculino Trotta 35c288582b fix(transactions): store filter preset dates as ISO
Presets kept dates as typed, such as "Novembro 2026" or "14/11/2026",
so changing the language or date format made them unreadable and they
were silently dropped. Dates are now stored as ISO and shown in the
user's current format when the preset is applied. Presets saved before
this keep working while the language and format stay the same.
2026-11-14 11:28:36 -03:00
Herculino Trotta c5717d41c2 feat(transactions): keep whole-month preset ranges on whole months
A preset whose dates run from the 1st to the last day of a month moved
by days, so a "this month" range drifted into the next month. Such a
range now moves by months, ending on the last day of its new month.
2026-11-14 11:27:38 -03:00
Herculino Trotta ed513a2171 fix(transactions): unlink outside transfers broken by a recurrence edit
An unpaid occurrence linked to a transaction outside its recurrence (e.g. through a DCA entry) could end up as two expenses, or both sides in one account, after the recurrence's type or account changed. The link is now dropped in that case; the partner is left untouched.
2026-11-14 11:02:38 -03:00
Asish Kumar 4532677e49 fix(transactions): move unpaid recurring transactions when the account or type changes
Editing a recurring transaction only refreshed the amount, description,
category, notes, tags and entities of its unpaid transactions. Changing its
account or type left the already generated transactions behind: a monthly
expense moved to another account kept its upcoming months in the old one,
and an expense turned into an income kept pulling projected balances down.
New occurrences followed the new settings, so the recurrence ended up split
across two accounts.

Unpaid transactions now take the recurrence's account and type as well,
keeping their dates, the same way installment plans already update theirs.
For recurring transfers:

- the "to" sides follow the "to" account and amount;
- turning a recurrence into a transfer adds the missing "to" sides;
- turning a transfer into an income or expense removes the unpaid "to"
  sides and leaves the paid transfers linked.

A "to" side is now recognised by its partner belonging to the same
recurrence, so an occurrence the user linked by hand to another
transaction is updated like any other occurrence instead of being treated
as a generated "to" side.
2026-11-14 17:00:17 +05:30
Herculino Trotta 709a8a89f0 Merge pull request #684 from eitchtee/fix/sharing-help-text
fix(sharing): clarify what shared and public visibility allow
2026-11-14 03:23:07 -03:00
Herculino Trotta 66351aee49 fix(sharing): clarify what shared and public visibility allow
"Only editable by the owner" read as covering an account's transactions
too, which led to GHSA-36w2-769w-h62g being reported. Sharing an account
or making it public deliberately opens its ledger to everyone who can
see it; only the object itself stays owner-only.

State that in the generic visibility help text, and spell out the
account case on the account share panel.
2026-11-14 03:18:37 -03:00
Herculino Trotta 348bc6e519 fix(transactions): scope installment plan and recurring transaction lookups
InstallmentPlan and RecurringTransaction declare the unfiltered
all_objects manager first and set no default_manager_name, so
get_object_or_404(Model, id=...) bypassed account visibility. Any
logged-in user could read, refresh, pause, finish or delete another
user's plans (and their transactions) by id.

Resolve the nine per-object views through the filtered objects manager,
as the list views, the API and the transaction views already do.

Refs GHSA-vcr4-g82g-wcq8
2026-11-14 03:01:49 -03:00
Herculino Trotta 3b47562cfb Merge pull request #681 from eitchtee/fix/api-docs-warnings
fix(api): clear the API docs schema warnings
2026-11-14 02:37:25 -03:00
Herculino Trotta 59dccd72d8 Merge pull request #680 from eitchtee/fix/rule-dry-run-connection
fix(rules): rule dry runs fail with a 500
2026-11-14 02:37:12 -03:00
Herculino Trotta a970c99e12 chore(demo): add sub-transaction examples to the demo data 2026-11-14 02:13:22 -03:00
Herculino Trotta 3dcc2316fb feat(export): back up sub-transactions and quick transactions 2026-11-14 02:13:21 -03:00
Herculino Trotta 188876fdf0 feat(rules): add, change and remove sub-transactions in rules
Adds a Sub-transactions field to edit actions and update-or-create
actions. Expressions get a sub_transactions variable and return a list of
{name, amount}; an empty list removes the parts. Rules skip transfers, and
setting the amount of a split transaction is skipped.
2026-11-14 02:13:21 -03:00
Herculino Trotta 5459865366 feat(api): read and write sub-transactions
Transactions, installment plans and recurring transactions take a nested
sub_transactions list; their amount becomes the parts' sum. Changing only
the amount of a split transaction, or adding parts to a transfer, is a
validation error.
2026-11-14 02:13:21 -03:00
Herculino Trotta ae245fb1d1 feat(transactions): add sub-transactions
Splits a transaction into named parts whose amounts add up to its amount,
e.g. the items of a big purchase or the fees inside an investment
contribution. Parts can be set on transactions, installment plans,
recurring and quick transactions, and are copied to the transactions they
generate. Transfers can't have parts.

Transactions show their parts under a tab on the card and in the
investment detail. The content filter matches part names, and bulk edits
leave the amount of split transactions alone.
2026-11-14 02:13:21 -03:00
Herculino Trotta a432fae632 fix(api): clear the API docs schema warnings
Describe the API token authentication, name the colliding transaction
type enums, and use nullable instead of an OpenAPI 3.1 null type. A test
keeps the schema free of warnings.
2026-11-14 02:12:16 -03:00
Herculino Trotta 00f014ccae fix(rules): keep the connection when tasks run inside a transaction
Rule dry runs call tasks directly inside an atomic block they roll back.
The connection cleanup wrapper closed that connection, so every dry run
failed with a 500.
2026-11-14 02:11:15 -03:00
Herculino Trotta a0588e33d6 Merge pull request #678 from eitchtee/feat/convert-to-transfer
feat(transactions): convert a transaction into a transfer
2026-11-13 18:56:18 -03:00
Herculino Trotta 2a06bd4a06 feat(transactions): convert a transaction into a transfer
Adds Convert > Transfer to the transaction menu. The transfer form opens
prefilled on the side matching the transaction type (expense = from,
income = to); saving creates the transfer and deletes the original.
Not available for transfers or plan/recurrence transactions.
2026-11-13 18:50:46 -03:00
Herculino Trotta 9d6379c324 Merge pull request #676 from eitchtee/feat/negative-filters-2
feat(transactions): add exclude tab to transaction filter
2026-11-13 18:49:28 -03:00
Herculino Trotta 623131eb2f feat(transactions): add bulk move to today, change month and hide from summaries
Hiding skips transactions whose visibility is controlled by their account or category.
2026-11-13 18:44:12 -03:00
Herculino Trotta 0d8de481d6 feat(transactions): add exclude tab to transaction filter
Split the filter into Include and Exclude tabs. Exclusions for content, accounts, currencies, categories, tags and entities are applied together with the existing filters, and are kept by presets, Clear and the active-filter indicator.
2026-11-13 18:43:29 -03:00
Asish Kumar ced7f3826e feat(transactions): keep filter preset dates relative to today
Filter presets save the exact dates they were created with, so a preset
for "from today" or "this month" goes stale the next day or month.

The save dialog now offers "Keep dates relative to today". When ticked,
the preset remembers the day it was saved (`FilterPreset.relative_to`)
and, when applied, moves its dates forward by the time elapsed since:
"Date from"/"Until" by days and the reference months by months. A preset
saved with today as the start date always starts today, and one saved
for the current reference month always shows the current month.

- The option is only stored when the preset has a date filter.
- Presets with relative dates show a clock icon in the presets menu.
- Presets saved before this change, or without the option, keep their
  fixed dates.
2026-11-12 22:59:59 +05:30
Asish Kumar 70be7b3161 fix(import): make QIF deduplication account-aware and keep identical transactions
QIF imports deduplicate each transaction by storing a SHA-256 of its raw
lines as the transaction's internal_id and skipping rows whose hash is
already taken. The hash didn't include the account, which broke two
cases:

- Importing the same file into two accounts (possible since the account
  can be picked per run) skipped every row of the second import.
- Two real transactions with the same date, amount and payee in one file
  hashed to the same ID, so the second one was always dropped.

The internal ID now hashes the account's ID and the transaction's
occurrence (how many identical transactions came before it in the file)
together with the raw lines. Using the occurrence instead of the
position in the file keeps the IDs stable when a later export of the
same statement has more transactions before or between the repeated
ones.

Transactions imported before this change keep their old IDs. So that
re-importing an old file doesn't duplicate them, the first occurrence
of a transaction is also matched against the previous hash, limited to
the account being imported into. Repeats of identical transactions,
which the old hash always skipped, are imported now.

The duplicate check also looks at soft-deleted transactions, like the
CSV/Excel deduplication does. internal_id is unique, so a soft-deleted
transaction with the same ID used to fail the import with an integrity
error instead of being skipped.

Fixes #671
2026-11-12 15:44:27 +05:30
Herculino Trotta 03c22b8fc2 Merge pull request #670 from officialasishkumar/feat/import-run-account
feat(import): pick the account when running an import
2026-11-12 00:24:10 -03:00
Herculino Trotta df6ccda7b3 feat(import): read any line of the file with a line transformation
Some banks name the account once in a header cell above the table, which
skip_lines and start_row throw away. A `line` transformation returns a line
of the file (or one of its columns) as text, so a mapping can read it and
clean it up with regex or replace.

CSV keeps only the requested lines during the existing counting pass; Excel
reads them straight from each sheet. An account picked on the run still
overrides the mapped one.
2026-11-12 00:17:14 -03:00
Herculino Trotta e617e809c0 fix(import): reject archived accounts when importing through the API
The upload form only lists active accounts, but the API accepted any account
the user can access, archived ones included.
2026-11-12 00:14:06 -03:00
Asish Kumar 1ed5dc5d31 feat(import): pick the account when running an import
An import run can now be given an account, and every transaction it
creates goes into that account instead of the one the profile maps. This
lets a single profile serve several accounts at the same bank, for
statements that only name the account in a header cell or not at all,
instead of keeping one copy of the profile per account.

- ImportRun gets an optional `account` (SET_NULL), shown on the run card.
- The upload form offers the user's active accounts when the profile
  imports transactions, and leaves the field out for profiles that import
  accounts, currencies, categories, tags or entities.
- CSV and Excel rows take the run's account before deduplication, so
  rules comparing `account` check against the picked account. The
  profile's account mapping is skipped for these rows.
- QIF files use the run's account instead of the account named after the
  file.
- The import API accepts an optional `account_id`, limited to accounts
  the user can access, rejected for profiles that don't import
  transactions, and returns `account` on import runs.

Leaving the account empty keeps the current behaviour.

Closes #538
2026-11-11 22:41:37 +05:30
Herculino Trotta dea8cfee4e test(net-worth): assert share text instead of badge markup 2026-11-11 14:02:56 -03:00
Asish Kumar d590dc39ab feat(net-worth): break consolidated totals down by currency share
A consolidated total on the Net Worth page was a single number: it said
what everything is worth in one currency, but not how much of it each
currency makes up, which is what you want to know when you hold the same
money in several currencies (or in currencies standing for gold, stocks
or crypto).

calculate_currency_totals now keeps, next to each consolidated total, the
components it was built from: the currency's own total and the exchanged
total of every currency that exchanges into it, all in the consolidated
currency. calculate_consolidated_shares gives each of them its share of
the total as a percentage, drops the ones that add nothing and sorts the
rest from largest to smallest. Shares are taken over the absolute total,
so a currency that adds to it always has a positive share and one that
takes from it (debt) a negative one; with a zero total there's no share.

Currencies that hide their exchanged amounts still show up, since they
still count towards the consolidated total, and so do exchange targets
that only exist through the deep search.

On the Net Worth page, each Consolidated row now lists its components
with their share and amount in the consolidated currency. Clicking one
shows that currency's line on the charts, like the currency rows above.
2026-11-11 21:27:17 +05:30
Herculino Trotta 220ccee140 fix(insights): show exchanged amounts in the overview 2026-11-11 10:53:15 -03:00
Herculino Trotta cd33b82b4e feat(investments): show exchanged amounts in movements and honor the display switch
Movements without an other-currency transfer side now show the exchanged
amount, and the converted value card follows show_exchanged_amounts.
2026-11-11 10:39:06 -03:00
Herculino Trotta 00d37d8c81 refactor(currencies): keep the exchanged amounts display rule in one place
Account.displayed_exchange_currency holds the account/currency precedence for transactions, and shown_exchange_currency() expresses the same rule as a query expression for the insights and account totals, replacing the per-module checks.
2026-11-11 10:22:50 -03:00
Asish Kumar d3f29f5ad1 feat(currencies): make displaying exchanged amounts optional
Currencies and accounts get a "Show exchanged amounts" switch, on by
default. Turning it off hides the amounts converted to the exchange
currency without removing the exchange currency, so consolidated totals
on the Net Worth page keep working.

The switch belongs to whichever one provides the exchange currency:

- Transactions (including both legs of combined transfers) use the
  account's switch when the account has its own exchange currency, and
  the currency's switch otherwise, matching how the exchanged amount is
  picked.
- Account cards and Net Worth account rows follow the account.
- Currency cards, the monthly summary and daily allowance, Net Worth
  currency rows and the month-by-month and year-by-year insights follow
  the currency.

Currency totals still convert hidden currencies, because the
consolidated totals are built from those values; the setting only
leaves them out of the displayed data. The API keeps returning
exchanged_amount for transactions, and the account serializer exposes
the new field (currencies already serialize all fields).

Closes #486
2026-11-11 15:26:04 +05:30
Herculino Trotta 3468b10e94 feat(dca): limit create-transaction accounts to the strategy currencies 2026-11-10 21:57:39 -03:00
Herculino Trotta 750b86394e feat(dca): optional amounts, currency-checked links and entities on entries
- Amounts default to the linked transaction's amount when left empty
- Linked transactions must be in the strategy's payment/target currency; pickers only search those
- Allow setting entities on transactions created from an entry
- Fix crash when only the expense transaction was linked
2026-11-10 21:55:29 -03:00
Herculino Trotta 706f8fea2b feat(transactions): allow filtering the transaction picker search
TransactionSelect takes a filters dict sent as query params; the search endpoint applies allowlisted ones (currency, account).
2026-11-10 21:55:29 -03:00
Herculino Trotta 0093cabfc9 fix(investments): solve short-period return over the holding period
Holdings under a year annualized their rate before turning it back into
the period return, so a few days with a modest gain (+1.3% in one day is
~10,600% a year) fell outside xirr's search range and showed no percentage.
Solve the rate over the period held instead.
2026-11-10 20:35:03 -03:00
Jay Hemnani 6a289327b6 fix(transactions): keep a recurrence on its day after a short month
A monthly recurrence on the 31st clamped to Feb 28 and stayed on the
28th for every later month.
2026-11-10 03:51:15 +05:30
Herculino Trotta a7ae1c7ec4 Merge pull request #657 from eitchtee/feat/distribution-totals-bracket
feat(distribution): show combined projected + current percentage
2026-11-08 23:34:56 -03:00
Herculino Trotta d0b6be14e7 feat(investments): calmer list and detail pages, group holdings by asset class
- One hero number with a single return line; secondary totals behind a Details toggle
- Holdings in one list card with quiet group subheaders, value and %/yr per row
- Group holdings by account group or asset class, remembered in the session
- Detail page: value and chart up top, Your position and home-currency sidebar
- Replace tooltips with visible text; keep amounts from wrapping on phones
2026-11-08 21:48:40 -03:00
Herculino Trotta 55f064ee7c feat(distribution): bracket projected + current segments with their sum
Remove the unused exchanged branch from calculate_percentage_distribution; nothing read it and it mixed up income_current with expense_projected.
2026-11-08 20:16:13 -03:00