Commit Graph
47 Commits
Author SHA1 Message Date
Herculino Trotta 3716b9b0e3 feat(transactions): link transfer sides and show them as a single item
Transfers are still two transactions, now linked to each other:
- shown as one item in lists, with each side's amount, account,
  category and tags ("Combine transfers" user setting, on by default)
- date, reference date, paid and mute stay in sync between sides
- edit opens the transfer form; delete, restore, duplicate and bulk
  actions act on both sides
- transfers made by the transfer form now trigger rules for each side

Recurring and quick transactions gain a Transfer type, with a "To
account" and optional "To amount", generating linked transfers. A
transfer can be converted into either.

Existing transfers are left as they are, since there is no reliable
way to pair them.
2026-11-02 01:14:46 -03:00
Herculino Trotta 1e486a608e fix(import): enforce object-level authorization on import profiles and runs
ImportProfile and ImportRun had no owner, and neither the web views nor the
REST viewsets filtered by the requesting user, so any authenticated user could
read, edit and delete every other user's import profiles and runs
(GHSA-q668-h56g-mfp4).

- ImportProfile is now a SharedObject, with share and take-ownership views
  like transaction rules; the global unique constraint on name is dropped.
- ImportRun is now an OwnedObject owned by the uploader, so runs made with a
  shared profile stay private to whoever ran them.
- Existing runs are backfilled with the owner of their imported
  transactions; existing profiles stay unowned and usable by everyone.
2026-10-24 13:26:37 -03:00
Herculino Trotta e2f26b3629 fix(sharing): enforce object-level authorization outside the rules app
The rules endpoints were one instance of a pattern repeated across every
SharedObject-backed app. Route the rest through the same helper.

DCA entries were the worst case and are strictly wider than the reported
rules bug: DCAEntry has an unscoped default manager, so filtering by
strategy__id alone reached entries on strategies the caller could not see
at all. No public or shared strategy was needed -- only a guessable
integer. strategy_entry_add/edit/delete now resolve through the parent
strategy with via="strategy".

Every SharedObject delete view carried an inverted condition:

    if obj.owner != request.user and request.user in obj.shared_with.all():
        obj.shared_with.remove(request.user)
    else:
        obj.delete()

An object its owner had made public matched neither branch's intent and
fell through to delete(), so any authenticated user could destroy it.
Confirmed reachable for accounts, account groups, categories, tags,
entities and DCA strategies. The owner now deletes, a shared user revokes
only their own access, and anyone else gets a 403.

The API viewsets had no object-level check at all. DjangoModelPermissions
gated them shut for ordinary users, who hold no model permissions, so this
was not reachable in a default install -- but the check belongs there
regardless, and a user granted change_account in the admin could write any
visible account. SharedObjectPermission adds it for the SharedObject
viewsets, leaving reads to SharedObjectManager.

account_toggle_untracked only flips the calling user's own row in the
untracked_by m2m, so it takes READ rather than EDIT.

Refs GHSA-83g9-vjqf-2j5q
2026-09-01 23:15:41 -03:00
obervinovandClaude Opus 4.8 ca14f77f41 test: cover demo-mode block on revoked-token delete
Parity with the existing demo-mode tests for token create/revoke.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 00:00:10 +04:00
Herculino Trotta 106d721279 feat: add demo mode tests to ensure API is disabled on it 2026-06-27 18:02:31 -03:00
4273c541c5 Add API tokens and OAuth2 client support for external integrations
- Personal API tokens (model, user-settings UI, admin, management command,
  DRF auth class) for non-interactive API access from automations like n8n.
  Raw token shown once; only a SHA-256 hash is stored; last_used_at writes
  are throttled.
- OAuth2 authorization server via django-oauth-toolkit with authorization
  server metadata and optional, off-by-default Dynamic Client Registration
  (RFC 7591), so remote OAuth/MCP clients can authenticate and self-register.
- Tests for token auth, DCR gating and the management commands, plus
  .env.example and README documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 19:15:31 +04:00
Herculino Trotta 63c69e5c6a test(api): expect unauthorized for anonymous requests 2026-05-02 16:16:08 -03:00
Herculino Trotta 49cac0588e add tests and fix missing get_queryset 2026-01-11 12:20:27 +01:00
icovada 3b2b6d6473 Query all DCA Strategies 2026-01-11 12:19:57 +01:00
icovada db30bcbeb7 Remove filtering function superseesed by search_fields 2026-01-11 12:19:57 +01:00
icovada a122733a47 Enable filtering and sorting on all API views 2026-01-11 12:19:30 +01:00
Herculino Trotta 96318f003d Merge branch 'main' into rest_filtering 2026-01-10 17:43:45 -03:00
Herculino Trotta 1a0412264a add tests and fix missing get_queryset 2026-01-10 17:42:37 -03:00
icovada c015b78cd6 Apply CustomNumberPagination to all API views 2026-01-10 17:14:53 +00:00
Herculino Trotta 0a03745ce6 Merge pull request #493 from eitchtee/dev
fix(dca): strategy api endpoint returns nothing
2026-01-09 23:53:04 -03:00
Herculino Trotta ff4bd79634 fix(dca): strategy api endpoint returns nothing 2026-01-09 23:51:31 -03:00
icovada 0c961a8250 Query all DCA Strategies 2026-01-08 22:51:50 +01:00
icovada e28c651973 Remove filtering function superseesed by search_fields 2026-01-08 22:51:50 +01:00
icovada 7687ff81c3 Enable filtering and sorting on all API views 2026-01-08 22:51:49 +01:00
Herculino Trotta 16de87376a Merge pull request #429
fix(api): inefficient transaction update operation
2025-12-07 13:55:29 -03:00
Herculino Trotta e8e1144fdd fix(api): inefficient transaction update operation 2025-12-07 13:53:30 -03:00
Herculino Trotta d77eddbd26 Merge pull request #428 from SerafimPikalov/fix/null-category-serialization
fix: handle null category in TransactionCategoryField serialization
2025-12-07 13:44:25 -03:00
Sera Pikalov fb1b383962 fix: handle null category in TransactionCategoryField serialization
Fix AttributeError when serializing transactions with null categories.
The to_representation method now checks for None before accessing
category properties, returning None instead of crashing.

Fixes issue where API returns 500 error when retrieving transactions
without assigned categories.
2025-12-07 12:37:05 +02:00
Herculino Trotta d3a816d91b feat(api): add endpoints for importing files and getting account balance 2025-12-07 00:32:18 -03:00
Herculino Trotta c738f5ee29 changes 2025-09-02 09:47:27 -03:00
Herculino Trotta d2e5c1d6b3 feat(transactions:recurring): try to create transactions on update 2025-08-07 23:35:57 -03:00
Herculino Trotta 46eb471a34 fix(api:transactions): wrong schema definition for TransactionCategory 2025-05-11 12:46:30 -03:00
Herculino Trotta 6dc14c73d6 fix(api:accounts): unable to create an account with an account group
Fixes #253
2025-05-11 12:41:26 -03:00
Herculino Trotta 26b218ae51 feat(app): disable API when demo mode is enabled 2025-03-31 02:28:48 -03:00
Herculino Trotta d6fbb71f41 fix(api): re-order transactions from newest to oldest 2025-03-08 23:23:07 -03:00
Herculino Trotta 211963ea7d fix(api): unable to create transaction 2025-03-08 22:09:24 -03:00
Herculino Trotta 020dd74f80 feat: multi tenancy support 2025-03-08 12:03:17 -03:00
Herculino Trotta b951e5f069 feat(recurring-transaction): update unpaid transactions info when recurring transaction is updated 2025-01-11 13:34:49 -03:00
Herculino Trotta 1b47c12a22 feat(api): add RecurringTransaction and InstallmentPlan endpoints 2025-01-05 11:13:23 -03:00
Herculino Trotta 091f73bf8d feat(api): support string name and ids for installmentplan endpoint 2025-01-05 11:07:38 -03:00
Herculino Trotta 73fe17de64 feat(api): add auth permission to all api endpoint 2025-01-05 11:04:50 -03:00
Herculino Trotta 8efa087aee feat(api): add API endpoints to add DCA entries and strategies 2025-01-05 10:54:31 -03:00
Herculino Trotta 5ccb9ff152 locale: add lazy translations to missing ValidationErrors 2025-01-04 18:17:06 -03:00
Herculino Trotta 2382abf3c0 feat: add Transaction Entity 2024-11-30 17:12:35 -03:00
Herculino Trotta dfb57ec4cc fix: partial updates broken due to validation 2024-10-26 02:52:01 -03:00
Herculino Trotta 287a649bf2 fix: partial updates broken due to validation 2024-10-26 02:51:52 -03:00
Herculino Trotta b9a9e279dc feat: add rules for transactions 2024-10-23 00:39:14 -03:00
Herculino Trotta 0c8ba28142 feat(api): accept %Y-%m as reference_date input on for adding transaction 2024-10-21 15:58:34 -03:00
Herculino Trotta 2b5011071f fix: not-null constraint violation when creating ExchangeRate 2024-10-21 00:02:34 -03:00
Herculino Trotta 1909184d55 feat(api): make category and tags create or get 2024-10-19 20:43:05 -03:00
Herculino Trotta 07cbfefb95 changes, fixes and improvements 2024-10-16 00:16:48 -03:00
Herculino Trotta d66ca1e8af feat: add api 2024-10-09 22:25:22 -03:00