Commit Graph
663 Commits
Author SHA1 Message Date
Herculino Trotta e7b8e488e3 Merge pull request #710 from eitchtee/feat/investments-asset-rebalance
feat(investments): show a per-asset breakdown in the rebalance
2026-12-05 02:40:26 -03:00
Herculino Trotta 43014b0113 Merge pull request #711 from officialasishkumar/feat/export-split-expenses
feat(export): back up split expenses
2026-12-05 02:39:20 -03:00
Herculino Trotta 3a5b4cb608 Merge pull request #707 from officialasishkumar/fix/split-sync-run-rules
fix(splits): run rules on transactions created from split events
2026-12-05 02:39:15 -03:00
Herculino Trotta 3b70746a3c Merge pull request #713 from officialasishkumar/fix/duplicate-transaction-rules
fix(transactions): run creation rules on duplicates, not on the originals
2026-12-05 02:39:11 -03:00
Asish Kumar aaa6e3be70 fix(transactions): run creation rules on duplicates, not on the originals
Duplicating a transaction sent transaction_created for the transaction
being duplicated instead of the new copy. Rules that run on creation,
and auto-tagging, were applied to the original a second time: an edit
action rewrote the original's fields while the copy kept them unchanged.
Duplicating a transfer ran nothing on its new "to" side, and bulk
duplicate never ran rules at all.

Both views now send transaction_created for each copy once it's saved,
and for both new sides of a duplicated transfer, the way the transfer
form and quick transactions already do. clone_transaction keeps
returning the copy without side effects, so it can still be used where
no user is signed in.
2026-12-05 05:58:00 +05:30
Asish Kumar a41b32420a feat(export): back up split expenses
Export and restore left split events out, so moving to a new instance or
restoring a backup lost every event, its people, expenses, payments and
the links to the members' own transactions.

- Export has a "Split Expenses" option, on by default. It writes
  split_events, split_participants, split_expenses, split_expense_shares
  and split_payments. Like the bank sync option, it warns that the file
  carries something sensitive: the events' share links, kept so the links
  people already have keep working after a restore.
- split_transaction_links goes along only when transactions are exported
  too, the same way sub-transactions follow their parents, so a restore
  never points at transactions missing from the backup.
- Restore reads the new files after users, currencies and transactions,
  in dependency order. Everything is matched by id, except the event's
  currency (by name, like DCA strategies) and the linked transaction,
  which is looked up across every user: restore runs as the admin, who
  can't see the other members' transactions.
- Guests' usernames and password hashes are restored, so they can still
  sign in through the share link.
- Attachments stay out, as transaction attachments do: they're files,
  not rows.
2026-12-05 05:46:57 +05:30
Herculino Trotta 2d816f6c57 feat(investments): show a per-asset breakdown in the rebalance
Each asset class now lists its holdings with a suggestion: the class buy
goes to the holdings below an equal share of the class target, lowest first,
and a class sell comes from the ones above it, highest first. A class on
target shows no suggestion, since the spread among its assets doesn't matter.

Also drops the "Left out" line from the rebalance.
2026-12-03 22:30:41 -03:00
Asish Kumar e51a688b23 fix(splits): run rules on transactions created from split events
Adding a split expense, payment or planned settlement to "my transactions"
with "Create new WYGIWYH transaction" saved the transaction without sending
transaction_created. Rules and auto-tagging never ran on it, unlike
transactions created from the form, the API, imports, quick transactions
and bank sync.

create_and_link_transaction now sends transaction_created once the
transaction, its tags and entities, and the split link are committed, the
same way quick transactions do. Linking an existing transaction still
doesn't trigger rules, as with bank sync matching.
2026-11-28 11:00:28 +05:30
Jay Hemnani e8f1478c6d fix(import): read comma-decimal amounts in QIF files 2026-11-24 06:48:56 +05:30
Herculino Trotta 70a2255e0c Merge pull request #702 from eitchtee/docs/sharing-edit-wording
docs(sharing): owner-only edits cover the shared object, not its contents
2026-11-20 20:32:59 -03:00
Herculino Trotta 6de57d0511 Merge pull request #701 from eitchtee/GHSA-hjfv-p3g6-mwch
fix(rules): only run rules owned by or shared with the acting user
2026-11-20 20:32:54 -03:00
Herculino Trotta 9989cec8b6 Merge pull request #700 from eitchtee/GHSA-fh52-f8r4-hv6g
fix(charts): embed chart data with json_script instead of |safe
2026-11-20 20:32:49 -03:00
Herculino Trotta c8f972d01a fix(templates): pass names to hyperscript through data attributes
Django's ' escaping is decoded by the browser before hyperscript parses
a _="..." attribute, so a quote in a currency or account name closed the
string and the rest ran as hyperscript. Names now live in plain data-*
attributes and are read with @data-*. Spaces in currency prefixes and
suffixes are kept.

Refs GHSA-fh52-f8r4-hv6g
2026-11-20 20:26:30 -03:00
Herculino Trotta c5662708e4 docs(sharing): say that owner-only edits cover the shared object, not its contents
The old wording ("sharing grants read access only") read as if a shared
account's transactions were read-only, which keeps producing BOLA reports
against intended behaviour.
2026-11-20 20:17:04 -03:00
Herculino Trotta c0eca55489 fix(rules): only run rules owned by or shared with the acting user
Rule selection went through SharedObjectManager, which includes every
user's public rules, so a public rule ran against other users'
transactions. Public rules stay readable by everyone; shared rules keep
running for the users they are shared with.

Fixes GHSA-hjfv-p3g6-mwch
2026-11-20 20:16:38 -03:00
Herculino Trotta 2997cf72f0 fix(charts): embed chart data with json_script instead of |safe
Currency, account and category names were rendered into inline <script>
blocks with |safe, so a name containing </script> or a quote ran as script
for every user whose net worth or insights page included it.

Fixes GHSA-fh52-f8r4-hv6g
2026-11-20 20:13:58 -03:00
Herculino Trotta fe2e366a74 feat(api): expose split expenses in the REST API and MCP
Add /api/splits/ endpoints for events, participants, expenses and payments,
plus an event summary (balances and settle-up) and leave action. They share
the web UI's access rules and share calculation. MCP reaches them through
search_api/call_api, and its instructions now point to them.
2026-11-20 19:43:23 -03:00
Herculino Trotta 77bf2d7bdb feat(splits): add split expenses for shared group costs
Track expenses shared with other people (trips, flats, dinners) and settle
up with the fewest payments.

- Events with WYGIWYH users and people without an account, who join through
  a share link and pick a password on first sign-in
- Equal, exact, percentage and share-weight splits that always add up
- Balances, a minimal settle-up plan and an activity feed showing what each
  item means for you
- Link items to your own transactions; recording a payment marks planned
  ones as paid
- Share menu: printable PDF report and PNG images of the summary, settle-up
  and balances (adds modern-screenshot)
- Only the two people involved or the organizer can record a payment;
  members can leave events they don't organize
2026-11-20 19:43:23 -03:00
Herculino Trotta f9a630d618 fix(migrations): make filterpreset is_default migration depend on 0055 2026-11-20 16:46:59 -03:00
Herculino Trotta 25c9018aab fix(migrations): renumber filterpreset is_default migration after main's 0055 2026-11-20 16:45:15 -03:00
Herculino Trotta 1114a5a1c4 Merge remote-tracking branch 'origin/main' into feat/default-filter-preset 2026-11-20 16:42:50 -03:00
Herculino Trotta c29a6bea8f feat(transactions): add lightweight auto-tagging for unclassified transactions 2026-11-19 20:00:51 -03:00
Asish Kumar b10323b6f5 feat(transactions): open the transaction pages with a default filter preset
Saved filter presets have to be picked from the menu every time a page
opens, so a view someone always wants, like hiding projected
transactions (#521), takes a few clicks on every visit or a bookmarked
URL.

A preset can now be set as the default from the presets menu, with the
star next to its name. All transactions and the Monthly overview then
open with it applied, relative dates moved to today, whenever their
URL has no filters of its own:

- `FilterPreset.is_default`, with a constraint allowing one default per
  user. Starring another preset moves the default to it, and starring
  the default again turns it off.
- Filters in the URL, like `/transactions/?is_paid=1`, take precedence
  over the default, and Clear still empties the filter for the visit.
- The star stays visible on the default preset and shows on hover for
  the others, like the delete button.
- Building a filter from a preset moves into
  `TransactionsFilter.from_preset`, shared by applying a preset and
  opening a page with the default one.
2026-11-20 02:28:10 +05:30
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