From 1ec0cfc02f68988d92a60f176d4b70b3dbc04116 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 14:09:59 +0000 Subject: [PATCH 01/24] chore(deps): bump soupsieve from 2.9 to 4.0 Bumps [soupsieve](https://github.com/facelessuser/soupsieve) from 2.9 to 4.0. - [Release notes](https://github.com/facelessuser/soupsieve/releases) - [Commits](https://github.com/facelessuser/soupsieve/compare/2.9...4.0) --- updated-dependencies: - dependency-name: soupsieve dependency-version: '4.0' dependency-type: indirect ... Signed-off-by: dependabot[bot] --- uv.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uv.lock b/uv.lock index 872ac4e0..acc87821 100644 --- a/uv.lock +++ b/uv.lock @@ -1069,11 +1069,11 @@ wheels = [ [[package]] name = "soupsieve" -version = "2.9" +version = "4.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/80/f1/93422647dd7e461f23d254e6b2bfa687a85b53aeb4903fcdbb74474d4584/soupsieve-2.9.tar.gz", hash = "sha256:acee8417325c5653e1377dc31eccad59eb82cbc65942afe6174c53b3aaad63fc", size = 122122, upload-time = "2026-07-19T01:35:18.425Z" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/5e/19b7c5d20bc2f226c44f33a9d9aab9740efed7555b96e656231fd564e514/soupsieve-4.0.tar.gz", hash = "sha256:ccd6470b256394ac44b08b86fd94b30a17d335a5335c8a3d15565f7b03d3c8cf", size = 151929, upload-time = "2026-11-03T14:28:55.388Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/7b/d6/3185ab5ad1280319b31986898f3206dd7227cd75e293d4dba2a5e6bf27a0/soupsieve-2.9-py3-none-any.whl", hash = "sha256:a2b2c76d67df2382d245409fd71e321a571717e58463efa32ace87dcadac2c12", size = 37387, upload-time = "2026-07-19T01:35:17.106Z" }, + { url = "https://files.pythonhosted.org/packages/4f/18/d24df2f733ee0655c58717d51add4118a70e64692d0e47d403b9aac4cf98/soupsieve-4.0-py3-none-any.whl", hash = "sha256:5e7494bfce90e06676cfb4c5c2cf22243e98e5cf24646bb1ecdda46d318550a0", size = 50158, upload-time = "2026-11-03T14:28:53.988Z" }, ] [[package]] From 9cf8cca1cbcb9522b229732c5540a3cc9bdb5aff Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Fri, 13 Nov 2026 15:04:41 -0300 Subject: [PATCH 02/24] fix(datepicker): keep preserved pickers working after boosted navigation The filter on the Monthly and All pages is wrapped in hx-preserve, so a boosted navigation keeps its pickers instead of recreating them. The AirDatepicker global container they render into lives on the body and is swapped out with it, leaving those pickers drawing into a detached node. After each swap, move the detached container's pickers into the new container, or reattach it when no new picker created one. --- frontend/src/js/datepicker.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/src/js/datepicker.js b/frontend/src/js/datepicker.js index 6f5f4fbc..0da3ad6b 100644 --- a/frontend/src/js/datepicker.js +++ b/frontend/src/js/datepicker.js @@ -113,6 +113,7 @@ function isMobile() { // swaps the body: AirDatepicker then rebuilds the container, but keeps the old // overlay, which is left detached and can't receive the clicks that close a picker. let mobileOverlay = null; +let globalContainer = null; function createAirDatepicker(element, opts) { const datepicker = new AirDatepicker(element, opts); @@ -122,9 +123,24 @@ function createAirDatepicker(element, opts) { mobileOverlay.classList.remove('-active-'); // its picker was swapped out while open container.appendChild(mobileOverlay); } + globalContainer = document.getElementById(AirDatepicker.defaultGlobalContainerId) ?? globalContainer; return datepicker; } +// Pickers kept across a boosted navigation by hx-preserve aren't recreated, but the +// global container they render into was swapped out with the body. htmx:load (which +// creates the new pickers) runs before htmx:afterSwap, so by now any new container exists. +document.addEventListener('htmx:afterSwap', () => { + if (!globalContainer || globalContainer.isConnected) return; + const current = document.getElementById(AirDatepicker.defaultGlobalContainerId); + if (current) { + current.append(...globalContainer.children); + globalContainer = current; + } else { + document.body.appendChild(globalContainer); + } +}); + window.DatePicker = async function createDynamicDatePicker(element) { let todayButton = { content: element.dataset.nowButtonTxt, From e2981bf1f6276692ba3c2d52006797e6989efbcd Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Fri, 13 Nov 2026 15:18:06 -0300 Subject: [PATCH 03/24] fix(datepicker): keep pickers working after history back and forward A history restore swaps in htmx's snapshot of the body, which carries a lifeless copy of AirDatepicker's global container. The previous fix looked the container up by id, found that copy, and left the library's real container detached, so pickers opened into nothing. Track the container through datepicker.$container instead, remove any snapshot copies after a swap, and reattach the real one when detached. --- frontend/src/js/datepicker.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/frontend/src/js/datepicker.js b/frontend/src/js/datepicker.js index 0da3ad6b..ff530a06 100644 --- a/frontend/src/js/datepicker.js +++ b/frontend/src/js/datepicker.js @@ -113,32 +113,30 @@ function isMobile() { // swaps the body: AirDatepicker then rebuilds the container, but keeps the old // overlay, which is left detached and can't receive the clicks that close a picker. let mobileOverlay = null; +// The container AirDatepicker opens every picker into (its own reference, not a lookup by +// id: a history restore brings back lifeless copies of it from htmx's snapshot). let globalContainer = null; function createAirDatepicker(element, opts) { const datepicker = new AirDatepicker(element, opts); - mobileOverlay ??= document.querySelector('.air-datepicker-overlay'); - const container = document.getElementById(AirDatepicker.defaultGlobalContainerId); - if (mobileOverlay && !mobileOverlay.isConnected && container) { + globalContainer = datepicker.$container; + mobileOverlay ??= globalContainer.querySelector('.air-datepicker-overlay'); + if (mobileOverlay && !mobileOverlay.isConnected) { mobileOverlay.classList.remove('-active-'); // its picker was swapped out while open - container.appendChild(mobileOverlay); + globalContainer.appendChild(mobileOverlay); } - globalContainer = document.getElementById(AirDatepicker.defaultGlobalContainerId) ?? globalContainer; return datepicker; } -// Pickers kept across a boosted navigation by hx-preserve aren't recreated, but the -// global container they render into was swapped out with the body. htmx:load (which -// creates the new pickers) runs before htmx:afterSwap, so by now any new container exists. +// Pickers kept by hx-preserve aren't recreated, so nothing makes AirDatepicker rebuild +// the container the swap removed: put it back, and drop any snapshot copies of it. +// Runs after htmx:load, so pickers created by this swap have already set globalContainer. document.addEventListener('htmx:afterSwap', () => { - if (!globalContainer || globalContainer.isConnected) return; - const current = document.getElementById(AirDatepicker.defaultGlobalContainerId); - if (current) { - current.append(...globalContainer.children); - globalContainer = current; - } else { - document.body.appendChild(globalContainer); - } + if (!globalContainer) return; + document.querySelectorAll(`#${AirDatepicker.defaultGlobalContainerId}`).forEach(c => { + if (c !== globalContainer) c.remove(); + }); + if (!globalContainer.isConnected) document.body.appendChild(globalContainer); }); window.DatePicker = async function createDynamicDatePicker(element) { From 0d8de481d693f7d430a2f672db7caa9ce51c99fc Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Fri, 13 Nov 2026 18:43:29 -0300 Subject: [PATCH 04/24] 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. --- app/apps/transactions/filters.py | 127 +++++++++++++++--- .../tests/test_exclude_filters.py | 71 ++++++++++ 2 files changed, 183 insertions(+), 15 deletions(-) create mode 100644 app/apps/transactions/tests/test_exclude_filters.py diff --git a/app/apps/transactions/filters.py b/app/apps/transactions/filters.py index f25a5dd0..2a940a48 100644 --- a/app/apps/transactions/filters.py +++ b/app/apps/transactions/filters.py @@ -12,7 +12,7 @@ from apps.transactions.models import ( TransactionTag, ) from crispy_forms.helper import FormHelper -from crispy_forms.layout import Column, Field, Layout, Row +from crispy_forms.layout import HTML, Column, Div, Field, Layout, Row from django import forms from django.db.models import Q from django.utils.translation import gettext_lazy as _ @@ -36,6 +36,18 @@ def content_filter(queryset, name, value): return queryset +def exclude_matching(positive_filter): + """Turn a positive filter method into one that drops the rows it would keep.""" + + def method(queryset, name, value): + if not value: + return queryset + matching = positive_filter(queryset, name, value) + return queryset.exclude(pk__in=matching.values("pk")) + + return method + + class MonthYearFilter(Filter): field_class = MonthYearFormField @@ -124,6 +136,42 @@ class TransactionsFilter(django_filters.FilterSet): lookup_expr="lte", label=_("Amount max"), ) + exclude_description = django_filters.CharFilter( + label=_("Content"), + method=exclude_matching(content_filter), + widget=forms.TextInput(attrs={"type": "search"}), + ) + exclude_account = django_filters.ModelMultipleChoiceFilter( + field_name="account__name", + queryset=Account.objects.all(), + to_field_name="name", + exclude=True, + label=_("Accounts"), + widget=TomSelectMultiple(checkboxes=True, remove_button=True, group_by="group"), + ) + exclude_currency = django_filters.ModelMultipleChoiceFilter( + field_name="account__currency", + queryset=Currency.objects.all(), + to_field_name="id", + exclude=True, + label=_("Currencies"), + widget=TomSelectMultiple(checkboxes=True, remove_button=True), + ) + exclude_category = django_filters.MultipleChoiceFilter( + label=_("Categories"), + widget=TomSelectMultiple(checkboxes=True, remove_button=True), + method="filter_exclude_category", + ) + exclude_tags = django_filters.MultipleChoiceFilter( + label=_("Tags"), + widget=TomSelectMultiple(checkboxes=True, remove_button=True), + method="filter_exclude_tags", + ) + exclude_entities = django_filters.MultipleChoiceFilter( + label=_("Entities"), + widget=TomSelectMultiple(checkboxes=True, remove_button=True), + method="filter_exclude_entities", + ) class Meta: model = Transaction @@ -178,21 +226,53 @@ class TransactionsFilter(django_filters.FilterSet): "mute_status", template="transactions/widgets/transaction_type_filter_buttons.html", ), - Field("description"), - Row(Column("date_start"), Column("date_end")), - Row( - Column("reference_date_start"), - Column("reference_date_end"), + Div( + HTML( + '
' + '" + '" + "
" + ), + Div( + Field("description"), + Row(Column("date_start"), Column("date_end")), + Row( + Column("reference_date_start"), + Column("reference_date_end"), + ), + Row( + Column("from_amount"), + Column("to_amount"), + ), + Field("account", size=1), + Field("currency", size=1), + Field("category", size=1), + Field("tags", size=1), + Field("entities", size=1), + role="tabpanel", + x_show="tab === 'include'", + ), + Div( + Field("exclude_description"), + Field("exclude_account", size=1), + Field("exclude_currency", size=1), + Field("exclude_category", size=1), + Field("exclude_tags", size=1), + Field("exclude_entities", size=1), + role="tabpanel", + x_show="tab === 'exclude'", + x_cloak="", + ), + x_data="{ tab: 'include' }", ), - Row( - Column("from_amount"), - Column("to_amount"), - ), - Field("account", size=1), - Field("currency", size=1), - Field("category", size=1), - Field("tags", size=1), - Field("entities", size=1), ) self.form.fields["to_amount"].widget = ArbitraryDecimalDisplayNumberInput() @@ -201,6 +281,7 @@ class TransactionsFilter(django_filters.FilterSet): self.form.fields["date_end"].widget = AirDatePickerInput() self.form.fields["account"].queryset = Account.objects.all() + self.form.fields["exclude_account"].queryset = Account.objects.all() category_choices = list( TransactionCategory.objects.values_list("name", "name").order_by("name") ) @@ -209,11 +290,15 @@ class TransactionsFilter(django_filters.FilterSet): ("uncategorized", _("Uncategorized")), ] self.form.fields["category"].choices = custom_choices + category_choices + self.form.fields["exclude_category"].choices = ( + custom_choices + category_choices + ) tag_choices = list( TransactionTag.objects.values_list("name", "name").order_by("name") ) custom_tag_choices = [("any", _("Tagged")), ("untagged", _("Untagged"))] self.form.fields["tags"].choices = custom_tag_choices + tag_choices + self.form.fields["exclude_tags"].choices = custom_tag_choices + tag_choices entity_choices = list( TransactionEntity.objects.values_list("name", "name").order_by("name") ) @@ -222,6 +307,9 @@ class TransactionsFilter(django_filters.FilterSet): ("no_entity", _("No entity")), ] self.form.fields["entities"].choices = custom_entity_choices + entity_choices + self.form.fields["exclude_entities"].choices = ( + custom_entity_choices + entity_choices + ) @property def has_active_filters(self): @@ -309,6 +397,15 @@ class TransactionsFilter(django_filters.FilterSet): return queryset + def filter_exclude_category(self, queryset, name, value): + return exclude_matching(self.filter_category)(queryset, name, value) + + def filter_exclude_tags(self, queryset, name, value): + return exclude_matching(self.filter_tags)(queryset, name, value) + + def filter_exclude_entities(self, queryset, name, value): + return exclude_matching(self.filter_entities)(queryset, name, value) + @staticmethod def filter_mute_status(queryset, name, value): from apps.common.middleware.thread_local import get_current_user diff --git a/app/apps/transactions/tests/test_exclude_filters.py b/app/apps/transactions/tests/test_exclude_filters.py new file mode 100644 index 00000000..b1b5f326 --- /dev/null +++ b/app/apps/transactions/tests/test_exclude_filters.py @@ -0,0 +1,71 @@ +from decimal import Decimal + +from django.contrib.auth import get_user_model +from django.test import TestCase, override_settings +from django.urls import reverse +from django.utils import timezone + +from apps.accounts.models import Account +from apps.currencies.models import Currency +from apps.transactions.models import Transaction, TransactionCategory, TransactionTag + + +@override_settings( + STORAGES={ + "default": {"BACKEND": "django.core.files.storage.FileSystemStorage"}, + "staticfiles": { + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage" + }, + }, + WHITENOISE_AUTOREFRESH=True, +) +class ExcludeFilterTests(TestCase): + def setUp(self): + self.user = get_user_model().objects.create_user( + email="exclude@test.com", password="pass" + ) + self.client.force_login(self.user) + currency = Currency.objects.create(code="BRL", name="Real", decimal_places=2) + self.account = Account.objects.create(name="Wallet", currency=currency) + food = TransactionCategory.objects.create(name="Food") + home = TransactionTag.objects.create(name="home") + + self.make("Groceries", category=food).tags.add(home) + self.make("Restaurant", category=food, notes="with friends") + self.make("Rent").tags.add(home) + self.make("Gift") + + def make(self, description, **kwargs): + today = timezone.localdate(timezone.now()) + return Transaction.objects.create( + account=self.account, + type=Transaction.Type.EXPENSE, + date=today, + reference_date=today.replace(day=1), + amount=Decimal("10"), + description=description, + **kwargs, + ) + + def listed(self, params): + response = self.client.get( + reverse("transactions_all_list"), params, HTTP_HX_REQUEST="true" + ) + self.assertEqual(response.status_code, 200) + page = response.context["page_obj"] + late = response.context["late_transactions"] or [] + return sorted(t.description for t in [*page, *late]) + + def test_exclusions_join_with_inclusions(self): + cases = [ + ({"exclude_category": ["Food"]}, ["Gift", "Rent"]), + ({"exclude_category": ["uncategorized"]}, ["Groceries", "Restaurant"]), + ({"exclude_tags": ["home"]}, ["Gift", "Restaurant"]), + ({"exclude_tags": ["untagged"]}, ["Groceries", "Rent"]), + ({"exclude_description": "friends"}, ["Gift", "Groceries", "Rent"]), + ({"exclude_account": ["Wallet"]}, []), + # positive and negative filters are applied together + ({"category": ["Food"], "exclude_tags": ["home"]}, ["Restaurant"]), + ] + for params, expected in cases: + self.assertEqual(self.listed(params), expected, params) From 6bf0dafaee96282deda638b19d2d65c4275f5582 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Fri, 13 Nov 2026 18:44:11 -0300 Subject: [PATCH 05/24] fix(transactions): keep transaction rows from overflowing on small screens --- app/templates/cotton/transaction/item.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/cotton/transaction/item.html b/app/templates/cotton/transaction/item.html index 9da2e221..9751fc63 100644 --- a/app/templates/cotton/transaction/item.html +++ b/app/templates/cotton/transaction/item.html @@ -15,7 +15,7 @@
+ w-full min-w-0 transaction-item bg-base-100 rounded">
{% if not transaction.deleted %} From 623131eb2ffea99fe7ee723838340f25092c1028 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Fri, 13 Nov 2026 18:44:12 -0300 Subject: [PATCH 06/24] 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. --- app/apps/transactions/tests/test_transfers.py | 59 ++++++++++++++ app/apps/transactions/urls.py | 15 ++++ app/apps/transactions/views/actions.py | 76 +++++++++++++++++++ 3 files changed, 150 insertions(+) diff --git a/app/apps/transactions/tests/test_transfers.py b/app/apps/transactions/tests/test_transfers.py index cdaf7a16..adf31b52 100644 --- a/app/apps/transactions/tests/test_transfers.py +++ b/app/apps/transactions/tests/test_transfers.py @@ -439,3 +439,62 @@ class TransferReviewFixTests(TransferTestBase): partner.refresh_from_db() self.assertIsNone(partner.linked_transaction) + + +class BulkActionTests(TransferTestBase): + def _get(self, name, *ids, **kwargs): + query = "&".join(f"transactions={pk}" for pk in ids) + return self.client.get( + reverse(name, kwargs=kwargs) + f"?{query}", HTTP_HX_REQUEST="true" + ) + + def _expense(self, **fields): + return Transaction.objects.create( + account=self.checking, + type=Transaction.Type.EXPENSE, + amount=Decimal("10"), + date=date(2026, 3, 10), + description="Coffee", + **fields, + ) + + def test_change_month_updates_a_fully_selected_transfer_once_per_side(self): + from_t, to_t = self._transfer() + updated = [] + receiver = lambda sender, **kwargs: updated.append(sender.pk) # noqa: E731 + transaction_updated.connect(receiver, weak=False) + self.addCleanup(transaction_updated.disconnect, receiver) + + response = self._get( + "transactions_bulk_change_month", from_t.id, to_t.id, change_type="next" + ) + + self.assertEqual(response.status_code, 204) + from_t.refresh_from_db() + to_t.refresh_from_db() + self.assertEqual(from_t.reference_date, date(2026, 4, 1)) + self.assertEqual(to_t.reference_date, date(2026, 4, 1)) + self.assertEqual(sorted(updated), sorted([from_t.pk, to_t.pk])) # once per side + + def test_change_month_rejects_unknown_direction(self): + t = self._expense() + response = self._get("transactions_bulk_change_month", t.id, change_type="sideways") + self.assertEqual(response.status_code, 400) + + def test_move_to_today(self): + t = self._expense() + self._get("transactions_bulk_move_to_today", t.id) + t.refresh_from_db() + self.assertEqual(t.date, timezone.localdate(timezone.now())) + + def test_mute_skips_transactions_controlled_elsewhere(self): + muted_category = TransactionCategory.objects.create(name="Hidden", mute=True) + plain = self._expense() + by_category = self._expense(category=muted_category) + + self._get("transactions_bulk_mute", plain.id, by_category.id) + + plain.refresh_from_db() + by_category.refresh_from_db() + self.assertTrue(plain.mute) + self.assertFalse(by_category.mute) diff --git a/app/apps/transactions/urls.py b/app/apps/transactions/urls.py index fa54b3a6..8c430ba2 100644 --- a/app/apps/transactions/urls.py +++ b/app/apps/transactions/urls.py @@ -81,6 +81,21 @@ urlpatterns = [ views.bulk_clone_transactions, name="transactions_bulk_clone", ), + path( + "transactions/actions/change-month//", + views.bulk_change_month, + name="transactions_bulk_change_month", + ), + path( + "transactions/actions/move-to-today/", + views.bulk_move_to_today, + name="transactions_bulk_move_to_today", + ), + path( + "transactions/actions/mute/", + views.bulk_mute, + name="transactions_bulk_mute", + ), path( "transaction//pay/", views.transaction_pay, diff --git a/app/apps/transactions/views/actions.py b/app/apps/transactions/views/actions.py index eec3af02..fdaf3a0f 100644 --- a/app/apps/transactions/views/actions.py +++ b/app/apps/transactions/views/actions.py @@ -1,10 +1,12 @@ import json from copy import deepcopy +from dateutil.relativedelta import relativedelta from django.contrib import messages from django.contrib.auth.decorators import login_required from django.db.models import Q from django.http import HttpResponse +from django.utils import timezone from django.utils.translation import gettext_lazy as _, ngettext_lazy from apps.common.decorators.htmx import only_htmx @@ -149,6 +151,80 @@ def bulk_undelete_transactions(request): ) +def _bulk_update(request, transactions, change): + """Applies change to each selected transaction like its single action does. + + A transfer moves as a pair through save(), so a selected partner is skipped. + """ + done = set() + for transaction in transactions: + if transaction.linked_transaction_id in done: + continue + old_data = deepcopy(transaction) + change(transaction) + transaction.save() + transaction_updated.send(sender=transaction, old_data=old_data) + done.add(transaction.id) + + count = len(done) + messages.success( + request, + ngettext_lazy( + "%(count)s transaction updated successfully", + "%(count)s transactions updated successfully", + count, + ) + % {"count": count}, + ) + return HttpResponse(status=204, headers={"HX-Trigger": "updated"}) + + +@only_htmx +@login_required +def bulk_change_month(request, change_type): + months = {"previous": -1, "next": 1}.get(change_type) + if months is None: + return HttpResponse(status=400) + + def change(transaction): + transaction.reference_date += relativedelta(months=months) + + return _bulk_update( + request, + Transaction.objects.filter(id__in=request.GET.getlist("transactions")), + change, + ) + + +@only_htmx +@login_required +def bulk_move_to_today(request): + today = timezone.localdate(timezone.now()) + + def change(transaction): + transaction.date = today + + return _bulk_update( + request, + Transaction.objects.filter(id__in=request.GET.getlist("transactions")), + change, + ) + + +@only_htmx +@login_required +def bulk_mute(request): + # Visibility controlled by the account or category can't be changed here. + transactions = Transaction.objects.filter( + id__in=request.GET.getlist("transactions"), mute=False + ).exclude(Q(account__untracked_by=request.user) | Q(category__mute=True)) + + def change(transaction): + transaction.mute = True + + return _bulk_update(request, transactions, change) + + @only_htmx @login_required def bulk_clone_transactions(request): From 15c29ecfb0c70dc90f3ae3f177d0fee160910a42 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Fri, 13 Nov 2026 18:44:12 -0300 Subject: [PATCH 07/24] feat(transactions): rework the selection action bar - Split the selection control into an unselect button and a dropdown - Expose the new bulk actions in the edit dropdown - Fold the actions into a single menu and hide the sum on small screens --- .../ui/deleted_transactions_action_bar.html | 62 ++++----- .../cotton/ui/transactions_action_bar.html | 129 +++++++++++------- .../includes/transactions_bulk_actions.html | 35 +++++ 3 files changed, 143 insertions(+), 83 deletions(-) create mode 100644 app/templates/includes/transactions_bulk_actions.html diff --git a/app/templates/cotton/ui/deleted_transactions_action_bar.html b/app/templates/cotton/ui/deleted_transactions_action_bar.html index 6b6d5864..918ab801 100644 --- a/app/templates/cotton/ui/deleted_transactions_action_bar.html +++ b/app/templates/cotton/ui/deleted_transactions_action_bar.html @@ -17,38 +17,38 @@ end end">
-
+
{% spaceless %}
0
-
- -
+
-
+
- - + + -
+
- - -
+
+ {# Below md every action folds into a single menu so the bar doesn't overflow #} + +
+ + +
+
- - + +
+ {% else %}
  • {% translate 'Installment Plan' %}
  • +
  • {% translate 'Transfer' %} +
  • {% endif %} {% endif %} From 9714df882078dea06b90b62c251af23b98c988fb Mon Sep 17 00:00:00 2001 From: eitchtee <10510126+eitchtee@users.noreply.github.com> Date: Fri, 13 Nov 2026 21:56:52 +0000 Subject: [PATCH 10/24] chore(locale): update translation files [skip ci] Automatically generated by Django makemessages workflow --- app/locale/de/LC_MESSAGES/django.po | 51 ++++++++++++++--------- app/locale/en/LC_MESSAGES/django.po | 49 +++++++++++++--------- app/locale/es/LC_MESSAGES/django.po | 51 ++++++++++++++--------- app/locale/fr/LC_MESSAGES/django.po | 51 ++++++++++++++--------- app/locale/hu/LC_MESSAGES/django.po | 51 ++++++++++++++--------- app/locale/id/LC_MESSAGES/django.po | 49 +++++++++++++--------- app/locale/it/LC_MESSAGES/django.po | 51 ++++++++++++++--------- app/locale/nl/LC_MESSAGES/django.po | 51 ++++++++++++++--------- app/locale/pl/LC_MESSAGES/django.po | 51 ++++++++++++++--------- app/locale/pt_BR/LC_MESSAGES/django.po | 53 +++++++++++++++--------- app/locale/ru/LC_MESSAGES/django.po | 50 +++++++++++++--------- app/locale/sv/LC_MESSAGES/django.po | 49 +++++++++++++--------- app/locale/sw/LC_MESSAGES/django.po | 49 +++++++++++++--------- app/locale/uk/LC_MESSAGES/django.po | 51 ++++++++++++++--------- app/locale/zh_Hant/LC_MESSAGES/django.po | 51 ++++++++++++++--------- 15 files changed, 473 insertions(+), 285 deletions(-) diff --git a/app/locale/de/LC_MESSAGES/django.po b/app/locale/de/LC_MESSAGES/django.po index bf295fd7..094d9c8e 100644 --- a/app/locale/de/LC_MESSAGES/django.po +++ b/app/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-13 21:50+0000\n" +"POT-Creation-Date: 2026-11-13 21:56+0000\n" "PO-Revision-Date: 2026-08-10 12:57+0000\n" "Last-Translator: GitEbu \n" "Language-Team: German \n" "Language-Team: LANGUAGE \n" @@ -1246,7 +1246,7 @@ msgstr "" msgid "Update or create transaction actions" msgstr "" -#: apps/export_app/forms.py:199 templates/cotton/transaction/item.html:310 +#: apps/export_app/forms.py:199 templates/cotton/transaction/item.html:325 #: templates/cotton/ui/deleted_transactions_action_bar.html:53 #: templates/export_app/fragments/restore.html:5 #: templates/export_app/pages/index.html:19 @@ -1832,6 +1832,8 @@ msgstr "" #: apps/transactions/forms.py:741 apps/transactions/models.py:992 #: apps/transactions/models.py:1303 templates/cotton/transaction/item.html:52 #: templates/cotton/transaction/item.html:60 +#: templates/cotton/transaction/item.html:270 +#: templates/cotton/transaction/item.html:302 #: templates/cotton/ui/quick_transactions_buttons.html:40 #: templates/cotton/ui/transactions_fab.html:44 msgid "Transfer" @@ -1924,14 +1926,14 @@ msgstr "" #: apps/transactions/models.py:380 apps/transactions/models.py:787 #: templates/cotton/transaction/item.html:260 -#: templates/cotton/transaction/item.html:277 #: templates/cotton/transaction/item.html:287 +#: templates/cotton/transaction/item.html:297 msgid "Installment Plan" msgstr "" #: apps/transactions/models.py:389 apps/transactions/models.py:1067 #: templates/cotton/transaction/item.html:250 -#: templates/cotton/transaction/item.html:270 +#: templates/cotton/transaction/item.html:280 msgid "Recurring Transaction" msgstr "" @@ -2173,33 +2175,41 @@ msgstr "" msgid "Category deleted successfully" msgstr "" -#: apps/transactions/views/conversions.py:72 +#: apps/transactions/views/conversions.py:73 #: apps/transactions/views/quick_transactions.py:46 apps/users/views.py:252 msgid "Item added successfully" msgstr "" -#: apps/transactions/views/conversions.py:91 +#: apps/transactions/views/conversions.py:92 msgid "Convert into quick transaction" msgstr "" -#: apps/transactions/views/conversions.py:108 +#: apps/transactions/views/conversions.py:109 #: apps/transactions/views/recurring_transactions.py:112 msgid "Recurring Transaction added successfully" msgstr "" -#: apps/transactions/views/conversions.py:129 +#: apps/transactions/views/conversions.py:130 msgid "Convert into recurring transaction" msgstr "" -#: apps/transactions/views/conversions.py:148 +#: apps/transactions/views/conversions.py:149 #: apps/transactions/views/installment_plans.py:87 msgid "Installment Plan added successfully" msgstr "" -#: apps/transactions/views/conversions.py:167 +#: apps/transactions/views/conversions.py:168 msgid "Convert into installment plan" msgstr "" +#: apps/transactions/views/conversions.py:188 +msgid "Transaction converted into a transfer" +msgstr "" + +#: apps/transactions/views/conversions.py:219 +msgid "Convert into transfer" +msgstr "" + #: apps/transactions/views/entities.py:72 msgid "Entity added successfully" msgstr "" @@ -2668,7 +2678,7 @@ msgstr "" #: templates/bank_sync/fragments/list.html:50 #: templates/categories/fragments/table.html:51 #: templates/cotton/transaction/item.html:190 -#: templates/cotton/transaction/item.html:316 +#: templates/cotton/transaction/item.html:331 #: templates/cotton/ui/deleted_transactions_action_bar.html:57 #: templates/cotton/ui/transactions_action_bar.html:75 #: templates/cotton/ui/transactions_action_bar.html:107 @@ -2703,7 +2713,7 @@ msgstr "" #: templates/bank_sync/fragments/list.html:54 #: templates/categories/fragments/table.html:56 #: templates/cotton/transaction/item.html:192 -#: templates/cotton/transaction/item.html:322 +#: templates/cotton/transaction/item.html:337 #: templates/cotton/ui/deleted_transactions_action_bar.html:58 #: templates/cotton/ui/transactions_action_bar.html:76 #: templates/cotton/ui/transactions_action_bar.html:105 @@ -2735,7 +2745,7 @@ msgstr "" #: templates/accounts/fragments/list.html:76 #: templates/categories/fragments/table.html:57 #: templates/cotton/transaction/item.html:193 -#: templates/cotton/transaction/item.html:323 +#: templates/cotton/transaction/item.html:338 #: templates/cotton/ui/deleted_transactions_action_bar.html:58 #: templates/cotton/ui/transactions_action_bar.html:76 #: templates/cotton/ui/transactions_action_bar.html:105 @@ -2759,7 +2769,7 @@ msgstr "" #: templates/bank_sync/fragments/list.html:56 #: templates/categories/fragments/table.html:58 #: templates/cotton/transaction/item.html:194 -#: templates/cotton/transaction/item.html:324 +#: templates/cotton/transaction/item.html:339 #: templates/currencies/fragments/list.html:46 #: templates/dca/fragments/strategy/details.html:77 #: templates/dca/fragments/strategy/list.html:44 @@ -2967,29 +2977,30 @@ msgstr "" #: templates/cotton/transaction/item.html:252 #: templates/cotton/transaction/item.html:262 +#: templates/cotton/transaction/item.html:272 msgid "Already part of a plan or recurrence" msgstr "" -#: templates/cotton/transaction/item.html:279 +#: templates/cotton/transaction/item.html:289 msgid "Not available for transfers" msgstr "" -#: templates/cotton/transaction/item.html:296 +#: templates/cotton/transaction/item.html:311 #: templates/includes/transactions_bulk_actions.html:22 msgid "Move to previous month" msgstr "" -#: templates/cotton/transaction/item.html:300 +#: templates/cotton/transaction/item.html:315 #: templates/includes/transactions_bulk_actions.html:28 msgid "Move to next month" msgstr "" -#: templates/cotton/transaction/item.html:303 +#: templates/cotton/transaction/item.html:318 #: templates/includes/transactions_bulk_actions.html:33 msgid "Move to today" msgstr "" -#: templates/cotton/transaction/item.html:307 +#: templates/cotton/transaction/item.html:322 #: templates/cotton/ui/transactions_action_bar.html:71 #: templates/cotton/ui/transactions_action_bar.html:98 msgid "Duplicate" diff --git a/app/locale/es/LC_MESSAGES/django.po b/app/locale/es/LC_MESSAGES/django.po index 1fa1a71b..9a6ecaf2 100644 --- a/app/locale/es/LC_MESSAGES/django.po +++ b/app/locale/es/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-13 21:50+0000\n" +"POT-Creation-Date: 2026-11-13 21:56+0000\n" "PO-Revision-Date: 2026-07-10 04:57+0000\n" "Last-Translator: Juan David Afanador \n" "Language-Team: Spanish \n" "Language-Team: French \n" "Language-Team: Hungarian \n" "Language-Team: Italian \n" "Language-Team: Dutch \n" "Language-Team: Polish \n" "Language-Team: Portuguese (Brazil) \n" "Language-Team: Russian \n" "Language-Team: Swedish \n" "Language-Team: Swahili \n" "Language-Team: Ukrainian \n" "Language-Team: Chinese (Traditional Han script) Date: Sat, 14 Nov 2026 02:11:15 -0300 Subject: [PATCH 11/24] 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. --- app/apps/common/procrastinate.py | 10 +++++++++- app/apps/common/tests/test_procrastinate.py | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/apps/common/procrastinate.py b/app/apps/common/procrastinate.py index 8e27e289..a6e2eebc 100644 --- a/app/apps/common/procrastinate.py +++ b/app/apps/common/procrastinate.py @@ -2,12 +2,20 @@ import functools import inspect import procrastinate -from django.db import close_old_connections +from django.db import close_old_connections as _close_old_connections +from django.db import connection _CONNECTION_CLEANUP_WRAPPED = "_wygiwyh_connection_cleanup_wrapped" +def close_old_connections(): + # Rule dry runs call tasks directly inside a transaction they roll back; + # closing its connection there would break it. Worker jobs never run in one. + if not connection.in_atomic_block: + _close_old_connections() + + def _wrap_task_with_django_connection_cleanup(task): if getattr(task.func, _CONNECTION_CLEANUP_WRAPPED, False): return diff --git a/app/apps/common/tests/test_procrastinate.py b/app/apps/common/tests/test_procrastinate.py index be175bf3..97a396ab 100644 --- a/app/apps/common/tests/test_procrastinate.py +++ b/app/apps/common/tests/test_procrastinate.py @@ -1,7 +1,7 @@ from unittest.mock import patch import procrastinate -from django.db import connection +from django.db import connection, transaction from django.test import SimpleTestCase, TransactionTestCase from procrastinate.testing import InMemoryConnector @@ -87,3 +87,18 @@ class ProcrastinateConnectionRecoveryTests(TransactionTestCase): connection.connection.close() self.assertEqual(task.func(), 1) + + def test_task_called_inside_a_transaction_keeps_its_connection(self): + """Rule dry runs call tasks directly inside a transaction they roll back.""" + + def sample_task(): + with connection.cursor() as cursor: + cursor.execute("SELECT 1") + return cursor.fetchone()[0] + + app, task = make_app_with_task(sample_task) + on_app_ready(app) + + with transaction.atomic(): + connection.close_at = 0 # obsolete, as with CONN_MAX_AGE=0 + self.assertEqual(task.func(), 1) From a432fae632eb8d04182f55ab953882ef2101f624 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 14 Nov 2026 02:12:16 -0300 Subject: [PATCH 12/24] 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. --- app/WYGIWYH/settings.py | 5 +++++ app/apps/api/apps.py | 3 +++ app/apps/api/fields/transactions.py | 3 ++- app/apps/api/schema.py | 20 ++++++++++++++++++++ app/apps/api/tests/test_schema.py | 11 +++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 app/apps/api/schema.py create mode 100644 app/apps/api/tests/test_schema.py diff --git a/app/WYGIWYH/settings.py b/app/WYGIWYH/settings.py index 9adb0d72..ff20f06a 100644 --- a/app/WYGIWYH/settings.py +++ b/app/WYGIWYH/settings.py @@ -517,6 +517,11 @@ SPECTACULAR_SETTINGS = { "DESCRIPTION": "A no-frills expense tracker", "VERSION": "1.0.0", "SERVE_INCLUDE_SCHEMA": False, + # Several models have a "type" field with different choices + "ENUM_NAME_OVERRIDES": { + "TransactionTypeEnum": "apps.transactions.models.Transaction.Type", + "TemplateTypeEnum": "apps.transactions.models.QuickTransaction.Type", + }, # OTHER SETTINGS } diff --git a/app/apps/api/apps.py b/app/apps/api/apps.py index a79077ab..05889f2a 100644 --- a/app/apps/api/apps.py +++ b/app/apps/api/apps.py @@ -4,3 +4,6 @@ from django.apps import AppConfig class ApiConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" name = "apps.api" + + def ready(self): + import apps.api.schema # noqa: F401 registers the API token scheme for the docs diff --git a/app/apps/api/fields/transactions.py b/app/apps/api/fields/transactions.py index b64ac83c..c0185f6f 100644 --- a/app/apps/api/fields/transactions.py +++ b/app/apps/api/fields/transactions.py @@ -10,7 +10,8 @@ from apps.transactions.models import ( @extend_schema_field( { - "oneOf": [{"type": "string"}, {"type": "integer"}, {"type": "null"}], + "oneOf": [{"type": "string"}, {"type": "integer"}], + "nullable": True, "description": "TransactionCategory ID or name. If the name doesn't exist, a new one will be created. Can be null if no category is assigned.", } ) diff --git a/app/apps/api/schema.py b/app/apps/api/schema.py new file mode 100644 index 00000000..499c2542 --- /dev/null +++ b/app/apps/api/schema.py @@ -0,0 +1,20 @@ +from drf_spectacular.extensions import OpenApiAuthenticationExtension + +from apps.users.models import APIToken + + +class APITokenAuthenticationScheme(OpenApiAuthenticationExtension): + """Describes APITokenAuthentication in the API docs.""" + + target_class = "apps.api.authentication.APITokenAuthentication" + name = "apiToken" + + def get_security_definition(self, auto_schema): + return { + "type": "apiKey", + "in": "header", + "name": "Authorization", + "description": ( + f"A personal API token, sent as `Token {APIToken.TOKEN_PREFIX}…`." + ), + } diff --git a/app/apps/api/tests/test_schema.py b/app/apps/api/tests/test_schema.py new file mode 100644 index 00000000..9032ff3b --- /dev/null +++ b/app/apps/api/tests/test_schema.py @@ -0,0 +1,11 @@ +import tempfile + +from django.core.management import call_command +from django.test import SimpleTestCase + + +class SchemaTests(SimpleTestCase): + def test_schema_is_valid_without_warnings(self): + """Keeps /api/docs/ complete: drf-spectacular warns when it can't describe something.""" + with tempfile.NamedTemporaryFile(suffix=".yml") as schema: + call_command("spectacular", "--validate", "--fail-on-warn", "--file", schema.name) From ae245fb1d1d8101b9e1553f732db2b8c2742ee83 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 14 Nov 2026 02:13:21 -0300 Subject: [PATCH 13/24] 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. --- app/apps/calendar_view/views.py | 2 +- app/apps/insights/views.py | 3 +- app/apps/investments/views.py | 1 + app/apps/monthly_overview/views.py | 1 + app/apps/transactions/filters.py | 6 +- app/apps/transactions/forms.py | 99 +++++++- .../migrations/0053_sub_transaction.py | 34 +++ app/apps/transactions/models.py | 109 ++++++++- .../tests/test_sub_transactions.py | 223 ++++++++++++++++++ app/apps/transactions/views/actions.py | 1 + app/apps/transactions/views/conversions.py | 7 + .../transactions/views/installment_plans.py | 2 +- .../transactions/views/quick_transactions.py | 1 + .../views/recurring_transactions.py | 2 +- app/apps/transactions/views/transactions.py | 4 + app/templates/cotton/transaction/item.html | 33 ++- .../investments/fragments/detail.html | 10 +- .../widgets/sub_transaction_row.html | 14 ++ .../widgets/sub_transactions.html | 58 +++++ 19 files changed, 595 insertions(+), 15 deletions(-) create mode 100644 app/apps/transactions/migrations/0053_sub_transaction.py create mode 100644 app/apps/transactions/tests/test_sub_transactions.py create mode 100644 app/templates/transactions/widgets/sub_transaction_row.html create mode 100644 app/templates/transactions/widgets/sub_transactions.html diff --git a/app/apps/calendar_view/views.py b/app/apps/calendar_view/views.py index bf03bb44..852e06a2 100644 --- a/app/apps/calendar_view/views.py +++ b/app/apps/calendar_view/views.py @@ -66,7 +66,7 @@ def calendar_list(request, month: int, year: int): @require_http_methods(["GET"]) def calendar_transactions_list(request, day: int, month: int, year: int): date = datetime.date(year=year, month=month, day=day) - transactions = Transaction.objects.filter(date=date).collapse_transfers().order_by( + transactions = Transaction.objects.filter(date=date).collapse_transfers().prefetch_related("sub_transactions").order_by( "date", "-type", "-is_paid", diff --git a/app/apps/insights/views.py b/app/apps/insights/views.py index f0a806e5..ff4e2857 100644 --- a/app/apps/insights/views.py +++ b/app/apps/insights/views.py @@ -308,6 +308,7 @@ def latest_transactions(request): transactions = ( Transaction.objects.filter(created_at__gte=limit) .collapse_transfers() + .prefetch_related("sub_transactions") .order_by("-id")[:30] ) @@ -325,7 +326,7 @@ def late_transactions(request): now = timezone.localdate(timezone.now()) transactions = Transaction.objects.filter( is_paid=False, date__lt=now - ).collapse_transfers() + ).collapse_transfers().prefetch_related("sub_transactions") return render( request, diff --git a/app/apps/investments/views.py b/app/apps/investments/views.py index ddc18c45..417f0658 100644 --- a/app/apps/investments/views.py +++ b/app/apps/investments/views.py @@ -215,6 +215,7 @@ def investment_detail(request, account_id): "account__currency__exchange_currency", "account__exchange_currency", ) + .prefetch_related("sub_transactions") .order_by("-date", "-id")[:50] ) income = [] diff --git a/app/apps/monthly_overview/views.py b/app/apps/monthly_overview/views.py index f0f85a20..01876021 100644 --- a/app/apps/monthly_overview/views.py +++ b/app/apps/monthly_overview/views.py @@ -93,6 +93,7 @@ def transactions_list(request, month: int, year: int): "installment_plan", "entities", "dca_expense_entries", + "sub_transactions", "dca_income_entries", "linked_transaction__account__currency", "linked_transaction__account__group", diff --git a/app/apps/transactions/filters.py b/app/apps/transactions/filters.py index 2a940a48..784598ca 100644 --- a/app/apps/transactions/filters.py +++ b/app/apps/transactions/filters.py @@ -6,6 +6,7 @@ from apps.common.widgets.decimal import ArbitraryDecimalDisplayNumberInput from apps.common.widgets.tom_select import TomSelectMultiple from apps.currencies.models import Currency from apps.transactions.models import ( + SubTransaction, Transaction, TransactionCategory, TransactionEntity, @@ -31,7 +32,10 @@ MUTE_STATUS_CHOICES = ( def content_filter(queryset, name, value): queryset = queryset.filter( - Q(description__icontains=value) | Q(notes__icontains=value) + Q(description__icontains=value) + | Q(notes__icontains=value) + # a subquery, so a transaction with several matching parts isn't listed twice + | Q(pk__in=SubTransaction.objects.filter(name__icontains=value).values("transaction")) ) return queryset diff --git a/app/apps/transactions/forms.py b/app/apps/transactions/forms.py index 743dea1c..24ebe568 100644 --- a/app/apps/transactions/forms.py +++ b/app/apps/transactions/forms.py @@ -17,6 +17,7 @@ from apps.transactions.models import ( TransactionAttachment, QuickTransaction, RecurringTransaction, + SubTransaction, Transaction, TransactionCategory, TransactionEntity, @@ -54,7 +55,89 @@ class MultipleFileField(forms.FileField): return [] -class TransactionForm(forms.ModelForm): +class SubTransactionForm(forms.ModelForm): + class Meta: + model = SubTransaction + fields = ["name", "amount"] + widgets = { + "name": forms.TextInput( + attrs={"class": "input join-item flex-1", "placeholder": _("Name")} + ), + } + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Built per request so the mask uses the user's number format + self.fields["amount"].widget = ArbitraryDecimalDisplayNumberInput( + attrs={ + "class": "input join-item w-2/5", + "inputmode": "decimal", + "placeholder": _("Amount"), + } + ) + + +class SubTransactionsFormMixin: + """Adds sub-transactions to a transaction or template form; while there are any, + the amount field is their sum. Transfers don't take them. + + Rendered by transactions/widgets/sub_transactions.html, placed after the amount. + """ + + sub_amount_field = "amount" + + def __init__(self, *args, sub_transactions_initial=None, **kwargs): + super().__init__(*args, **kwargs) + data = self.data if self.is_bound else None + if data is not None and "sub-TOTAL_FORMS" not in data: + # Posts without the formset (e.g. shortcuts to /add/) leave sub-transactions alone + data = {"sub-TOTAL_FORMS": "0", "sub-INITIAL_FORMS": "0"} + initial = sub_transactions_initial or [] + self.sub_transactions = forms.inlineformset_factory( + type(self.instance), + SubTransaction, + form=SubTransactionForm, + extra=len(initial), + can_delete=True, + )(data, instance=self.instance, prefix="sub", initial=initial) + # With sub-transactions the amount is their sum, see clean() + self.fields[self.sub_amount_field].required = False + + def _takes_sub_transactions(self): + return self.cleaned_data.get("type") != "TR" + + def clean(self): + cleaned_data = super().clean() + field = self.sub_amount_field + if self._takes_sub_transactions() and self.sub_transactions.is_valid(): + amounts = [ + f.cleaned_data["amount"] + for f in self.sub_transactions.forms + if f.cleaned_data and not f.cleaned_data.get("DELETE") + ] + if amounts: + cleaned_data[field] = sum(amounts) + if cleaned_data.get(field) is None and field not in self.errors: + self.add_error(field, self.fields[field].error_messages["required"]) + return cleaned_data + + def is_valid(self): + return super().is_valid() and ( + not self._takes_sub_transactions() or self.sub_transactions.is_valid() + ) + + def save(self, *args, **kwargs): + with db_transaction.atomic(): + instance = super().save(*args, **kwargs) + if self._takes_sub_transactions(): + self.sub_transactions.instance = instance + self.sub_transactions.save() + else: + instance.sub_transactions.all().delete() + return instance + + +class TransactionForm(SubTransactionsFormMixin, forms.ModelForm): category = DynamicModelChoiceField( create_field="name", model=TransactionCategory, @@ -164,6 +247,7 @@ class TransactionForm(forms.ModelForm): ), "description", Field("amount", inputmode="decimal"), + HTML('{% include "transactions/widgets/sub_transactions.html" %}'), Row( Column("category"), Column("tags"), @@ -187,6 +271,7 @@ class TransactionForm(forms.ModelForm): ), "description", Field("amount", inputmode="decimal"), + HTML('{% include "transactions/widgets/sub_transactions.html" %}'), Accordion( AccordionGroup( _("More"), @@ -322,7 +407,7 @@ def _type_aware(form, *layout): ) -class QuickTransactionForm(forms.ModelForm): +class QuickTransactionForm(SubTransactionsFormMixin, forms.ModelForm): category = DynamicModelChoiceField( create_field="name", model=TransactionCategory, @@ -432,6 +517,7 @@ class QuickTransactionForm(forms.ModelForm): ), "description", Field("amount", inputmode="decimal"), + HTML('{% include "transactions/widgets/sub_transactions.html" %}'), _transfer_fields(self), Row( Column("category"), @@ -833,7 +919,9 @@ class TransferForm(forms.Form): return from_transaction, to_transaction -class InstallmentPlanForm(forms.ModelForm): +class InstallmentPlanForm(SubTransactionsFormMixin, forms.ModelForm): + sub_amount_field = "installment_amount" + account = forms.ModelChoiceField( queryset=Account.objects.filter(is_archived=False), label=_("Account"), @@ -956,6 +1044,7 @@ class InstallmentPlanForm(forms.ModelForm): Column("recurrence", css_class="col-span-12 md:col-span-4"), ), "installment_amount", + HTML('{% include "transactions/widgets/sub_transactions.html" %}'), Row( Column("category"), Column("tags"), @@ -989,6 +1078,7 @@ class InstallmentPlanForm(forms.ModelForm): # Take the amount set on the form, even if already paid source_transaction.amount = instance.installment_amount source_transaction.save() + source_transaction.copy_sub_transactions_from(instance) instance.update_transactions() elif is_new: instance.create_transactions() @@ -1085,7 +1175,7 @@ class TransactionCategoryForm(forms.ModelForm): ) -class RecurringTransactionForm(forms.ModelForm): +class RecurringTransactionForm(SubTransactionsFormMixin, forms.ModelForm): account = forms.ModelChoiceField( queryset=Account.objects.filter(is_archived=False), label=_("Account"), @@ -1209,6 +1299,7 @@ class RecurringTransactionForm(forms.ModelForm): "description", Switch("add_description_to_transaction"), "amount", + HTML('{% include "transactions/widgets/sub_transactions.html" %}'), _transfer_fields(self), Row( Column("category"), diff --git a/app/apps/transactions/migrations/0053_sub_transaction.py b/app/apps/transactions/migrations/0053_sub_transaction.py new file mode 100644 index 00000000..85f003fa --- /dev/null +++ b/app/apps/transactions/migrations/0053_sub_transaction.py @@ -0,0 +1,34 @@ +# Generated by Django 5.2.17 on 2026-11-13 22:22 + +import apps.transactions.validators +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('transactions', '0052_transfer_templates'), + ] + + operations = [ + migrations.CreateModel( + name='SubTransaction', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255, verbose_name='Name')), + ('amount', models.DecimalField(decimal_places=30, max_digits=42, validators=[apps.transactions.validators.validate_non_negative, apps.transactions.validators.validate_decimal_places], verbose_name='Amount')), + ('installment_plan', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sub_transactions', to='transactions.installmentplan')), + ('quick_transaction', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sub_transactions', to='transactions.quicktransaction')), + ('recurring_transaction', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sub_transactions', to='transactions.recurringtransaction')), + ('transaction', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sub_transactions', to='transactions.transaction', verbose_name='Transaction')), + ], + options={ + 'verbose_name': 'Sub-transaction', + 'verbose_name_plural': 'Sub-transactions', + 'db_table': 'sub_transactions', + 'ordering': ['id'], + 'constraints': [models.CheckConstraint(condition=models.Q(models.Q(('installment_plan__isnull', True), ('quick_transaction__isnull', True), ('recurring_transaction__isnull', True), ('transaction__isnull', False)), models.Q(('installment_plan__isnull', True), ('quick_transaction__isnull', True), ('recurring_transaction__isnull', False), ('transaction__isnull', True)), models.Q(('installment_plan__isnull', False), ('quick_transaction__isnull', True), ('recurring_transaction__isnull', True), ('transaction__isnull', True)), models.Q(('installment_plan__isnull', True), ('quick_transaction__isnull', False), ('recurring_transaction__isnull', True), ('transaction__isnull', True)), _connector='OR'), name='sub_transaction_has_one_parent')], + }, + ), + ] diff --git a/app/apps/transactions/models.py b/app/apps/transactions/models.py index e928b062..da76eaf9 100644 --- a/app/apps/transactions/models.py +++ b/app/apps/transactions/models.py @@ -1,6 +1,8 @@ import calendar import decimal +import functools import logging +import operator import uuid from copy import deepcopy from pathlib import Path @@ -444,9 +446,10 @@ class Transaction(OwnedObject): if isinstance(self.amount, (str, int, float)): self.amount = decimal.Decimal(str(self.amount)) - self.amount = truncate_decimal( - value=self.amount, decimal_places=account.currency.decimal_places - ) + if self.amount is not None: # missing amount is reported by field validation + self.amount = truncate_decimal( + value=self.amount, decimal_places=account.currency.decimal_places + ) # Normalize reference_date if self.reference_date: @@ -572,6 +575,24 @@ class Transaction(OwnedObject): def hard_delete(self, *args, **kwargs): super().delete(*args, **kwargs) + @property + def has_sub_transactions(self): + return bool(self.pk) and self.sub_transactions.exists() + + @property + def saved_sub_transactions(self): + """Sub-transactions, or none for an unsaved preview (which can't query them).""" + return self.sub_transactions.all() if self.pk else [] + + def copy_sub_transactions_from(self, source): + """Makes this transaction's sub-transactions copies of ``source``'s (a + transaction or a template that generates them).""" + self.sub_transactions.all().delete() + SubTransaction.objects.bulk_create( + SubTransaction(transaction=self, name=sub.name, amount=sub.amount) + for sub in source.sub_transactions.all() + ) + def exchanged_amount(self): return self._exchanged_to( self.account.exchange_currency or self.account.currency.exchange_currency @@ -658,6 +679,81 @@ class Transaction(OwnedObject): return new_obj +SUB_TRANSACTION_PARENTS = ( + "transaction", + "recurring_transaction", + "installment_plan", + "quick_transaction", +) + + +class SubTransaction(models.Model): + """A named part of a transaction, or of a template that generates them; when + present, the parts add up to its amount. Exactly one parent is set. + + Soft deletion follows the parent: sub-transactions are only reached through it. + """ + + transaction = models.ForeignKey( + Transaction, + on_delete=models.CASCADE, + null=True, + blank=True, + related_name="sub_transactions", + verbose_name=_("Transaction"), + ) + recurring_transaction = models.ForeignKey( + "RecurringTransaction", + on_delete=models.CASCADE, + null=True, + blank=True, + related_name="sub_transactions", + ) + installment_plan = models.ForeignKey( + "InstallmentPlan", + on_delete=models.CASCADE, + null=True, + blank=True, + related_name="sub_transactions", + ) + quick_transaction = models.ForeignKey( + "QuickTransaction", + on_delete=models.CASCADE, + null=True, + blank=True, + related_name="sub_transactions", + ) + name = models.CharField(max_length=255, verbose_name=_("Name")) + amount = models.DecimalField( + max_digits=42, + decimal_places=30, + verbose_name=_("Amount"), + validators=[validate_non_negative, validate_decimal_places], + ) + + class Meta: + verbose_name = _("Sub-transaction") + verbose_name_plural = _("Sub-transactions") + db_table = "sub_transactions" + ordering = ["id"] + constraints = [ + models.CheckConstraint( + # One of: only "transaction" set, only "recurring_transaction" set, ... + condition=functools.reduce( + operator.or_, + ( + Q(**{f"{p}__isnull": p != parent for p in SUB_TRANSACTION_PARENTS}) + for parent in SUB_TRANSACTION_PARENTS + ), + ), + name="sub_transaction_has_one_parent", + ) + ] + + def __str__(self): + return self.name + + class TransactionAttachment(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) transaction = models.ForeignKey( @@ -855,6 +951,7 @@ class InstallmentPlan(models.Model): ) new_transaction.tags.set(self.tags.all()) new_transaction.entities.set(self.entities.all()) + new_transaction.copy_sub_transactions_from(self) @transaction.atomic def update_transactions(self): @@ -896,6 +993,7 @@ class InstallmentPlan(models.Model): not existing_transaction.is_paid ): # Don't update value for paid transactions existing_transaction.amount = self.installment_amount + existing_transaction.copy_sub_transactions_from(self) existing_transaction.save() @@ -922,6 +1020,7 @@ class InstallmentPlan(models.Model): ) new_transaction.tags.set(self.tags.all()) new_transaction.entities.set(self.entities.all()) + new_transaction.copy_sub_transactions_from(self) # Remove any extra transactions that are no longer part of the plan self.transactions.filter( @@ -1127,6 +1226,7 @@ class RecurringTransaction(TransferTemplate): # different one, and the scoped default manager would hide private rows. created_transaction.tags.set(self.tags(manager="all_objects").all()) created_transaction.entities.set(self.entities(manager="all_objects").all()) + created_transaction.copy_sub_transactions_from(self) self.complete_transfer(created_transaction) def adopt_transaction(self, existing_transaction, date, reference_date): @@ -1169,6 +1269,7 @@ class RecurringTransaction(TransferTemplate): existing_transaction.save() existing_transaction.tags.set(self.tags(manager="all_objects").all()) existing_transaction.entities.set(self.entities(manager="all_objects").all()) + existing_transaction.copy_sub_transactions_from(self) def get_recurrence_delta(self): if self.recurrence_type == self.RecurrenceType.DAY: @@ -1286,6 +1387,8 @@ class RecurringTransaction(TransferTemplate): self.entities(manager="all_objects").all() ) + existing_transaction.copy_sub_transactions_from(self) + # Save updated transaction existing_transaction.save() diff --git a/app/apps/transactions/tests/test_sub_transactions.py b/app/apps/transactions/tests/test_sub_transactions.py new file mode 100644 index 00000000..12eda71c --- /dev/null +++ b/app/apps/transactions/tests/test_sub_transactions.py @@ -0,0 +1,223 @@ +from decimal import Decimal + +from django.contrib.auth import get_user_model +from django.test import TestCase, override_settings +from django.urls import reverse +from django.utils import timezone +from rest_framework.test import APIClient + +from apps.accounts.models import Account, AccountGroup +from apps.currencies.models import Currency +from apps.transactions.models import ( + InstallmentPlan, + QuickTransaction, + RecurringTransaction, + SubTransaction, + Transaction, +) +from apps.transactions.filters import content_filter, exclude_matching +from apps.transactions.views.actions import clone_transaction + + +def _subs(*rows, initial=0): + data = {"sub-TOTAL_FORMS": str(len(rows)), "sub-INITIAL_FORMS": str(initial)} + for i, row in enumerate(rows): + data.update({f"sub-{i}-{k}": v for k, v in row.items()}) + return data + + +@override_settings( + STORAGES={ + "default": {"BACKEND": "django.core.files.storage.FileSystemStorage"}, + "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}, + }, + WHITENOISE_AUTOREFRESH=True, +) +class SubTransactionTests(TestCase): + def setUp(self): + user = get_user_model().objects.create_user(email="u@test.com", password="pw") + self.client.login(username="u@test.com", password="pw") + currency = Currency.objects.create(code="USD", name="USD", decimal_places=2) + self.account = Account.objects.create( + name="A", group=AccountGroup.objects.create(name="G"), currency=currency + ) + self.base = { + "account": self.account.id, + "type": "EX", + "is_paid": True, + "date": timezone.localdate().isoformat(), + "description": "Groceries", + } + + def _add(self, data): + return self.client.post( + reverse("transaction_add"), {**data, "submit": ""}, headers={"HX-Request": "true"} + ) + + def test_amount_is_sum_of_sub_transactions(self): + response = self._add( + {**self.base, "amount": "999", **_subs( + {"name": "Milk", "amount": "2.50"}, {"name": "Bread", "amount": "4"} + )} + ) + self.assertEqual(response.status_code, 204) + transaction = Transaction.objects.get() + self.assertEqual(transaction.amount, Decimal("6.50")) + self.assertEqual( + list(transaction.sub_transactions.values_list("name", flat=True)), + ["Milk", "Bread"], + ) + + def test_amount_required_without_sub_transactions(self): + response = self._add({**self.base, **_subs()}) + self.assertEqual(response.status_code, 200) + self.assertIn("amount", response.context["form"].errors) + self.assertFalse(Transaction.objects.exists()) + + def test_sub_transaction_needs_name(self): + response = self._add({**self.base, **_subs({"name": "", "amount": "3"})}) + self.assertEqual(response.status_code, 200) + self.assertFalse(Transaction.objects.exists()) + + def test_edit_removing_sub_transactions_restores_typed_amount(self): + transaction = Transaction.objects.create( + account=self.account, type="EX", date=timezone.localdate(), amount=5 + ) + sub = SubTransaction.objects.create(transaction=transaction, name="Fee", amount=5) + response = self.client.post( + reverse("transaction_edit", kwargs={"transaction_id": transaction.id}), + {**self.base, "amount": "12", **_subs( + {"id": sub.id, "name": "Fee", "amount": "5", "DELETE": "on"}, initial=1 + )}, + headers={"HX-Request": "true"}, + ) + self.assertEqual(response.status_code, 204) + transaction.refresh_from_db() + self.assertEqual(transaction.amount, Decimal("12")) + self.assertFalse(transaction.sub_transactions.exists()) + + @override_settings(ENABLE_SOFT_DELETE=True) + def test_soft_delete_hides_and_hard_delete_removes_sub_transactions(self): + transaction = Transaction.objects.create( + account=self.account, type="EX", date=timezone.localdate(), amount=5 + ) + SubTransaction.objects.create(transaction=transaction, name="Fee", amount=5) + url = reverse("transaction_delete", kwargs={"transaction_id": transaction.id}) + self.client.delete(url, headers={"HX-Request": "true"}) + # soft: sub-transactions stay with (and are hidden by) the deleted parent + self.assertTrue(Transaction.deleted_objects.filter(pk=transaction.pk).exists()) + self.assertEqual(SubTransaction.objects.count(), 1) + self.client.delete(url, headers={"HX-Request": "true"}) + self.assertFalse(SubTransaction.objects.exists()) + + def test_clone_copies_sub_transactions(self): + transaction = Transaction.objects.create( + account=self.account, type="EX", date=timezone.localdate(), amount=5 + ) + SubTransaction.objects.create(transaction=transaction, name="Fee", amount=5) + clone = clone_transaction(transaction) + self.assertEqual(list(clone.sub_transactions.values_list("name", "amount")), [("Fee", Decimal("5"))]) + + def test_content_filter_matches_sub_transaction_names(self): + shop = Transaction.objects.create( + account=self.account, type="EX", date=timezone.localdate(), amount=5, description="Shop" + ) + SubTransaction.objects.create(transaction=shop, name="Milk", amount=2) + SubTransaction.objects.create(transaction=shop, name="Oat milk", amount=3) + other = Transaction.objects.create( + account=self.account, type="EX", date=timezone.localdate(), amount=1, description="Bus" + ) + everything = Transaction.all_objects.all() + self.assertEqual(list(content_filter(everything, "description", "milk")), [shop]) + self.assertEqual(list(exclude_matching(content_filter)(everything, "x", "milk")), [other]) + + def test_bulk_edit_leaves_amount_of_split_transactions(self): + split = Transaction.objects.create( + account=self.account, type="EX", date=timezone.localdate(), amount=5 + ) + SubTransaction.objects.create(transaction=split, name="Fee", amount=5) + plain = Transaction.objects.create( + account=self.account, type="EX", date=timezone.localdate(), amount=1 + ) + response = self.client.post( + reverse("transactions_bulk_edit"), + {"transactions": [split.id, plain.id], "amount": "50", "description": "Edited"}, + headers={"HX-Request": "true"}, + ) + self.assertEqual(response.status_code, 204) + split.refresh_from_db() + plain.refresh_from_db() + self.assertEqual((split.amount, split.description), (Decimal("5"), "Edited")) + self.assertEqual(plain.amount, Decimal("50")) + + def _post(self, url_name, data): + return self.client.post(reverse(url_name), data, headers={"HX-Request": "true"}) + + def _parts(self, transaction): + return list(transaction.sub_transactions.values_list("name", "amount")) + + def test_quick_transaction_parts_are_copied_to_created_transaction(self): + self._post( + "quick_transaction_add", + {**self.base, "name": "Lunch", **_subs({"name": "Meal", "amount": "20"}, {"name": "Tip", "amount": "2"})}, + ) + quick = QuickTransaction.objects.get() + self.assertEqual(quick.amount, Decimal("22")) + self.client.get( + reverse("quick_transaction_add_as_transaction", kwargs={"quick_transaction_id": quick.id}), + headers={"HX-Request": "true"}, + ) + transaction = Transaction.objects.get() + self.assertEqual(transaction.amount, Decimal("22")) + self.assertEqual(self._parts(transaction), [("Meal", Decimal("20")), ("Tip", Decimal("2"))]) + + def test_quick_transfer_drops_parts(self): + other = Account.objects.create(name="B", group=self.account.group, currency=self.account.currency) + response = self._post( + "quick_transaction_add", + {**self.base, "type": "TR", "to_account": other.id, "amount": "5", "name": "Move", + **_subs({"name": "Hidden", "amount": "9"})}, + ) + self.assertEqual(response.status_code, 204) + quick = QuickTransaction.objects.get() + self.assertEqual(quick.amount, Decimal("5")) + self.assertFalse(quick.sub_transactions.exists()) + + def test_recurring_parts_follow_generated_and_unpaid_transactions(self): + self._post( + "recurring_transaction_add", + {**self.base, "start_date": timezone.localdate().isoformat(), "recurrence_type": "month", + "recurrence_interval": 1, "keep_at_most": 2, **_subs({"name": "Plan", "amount": "10"})}, + ) + recurring = RecurringTransaction.all_objects.get() + self.assertEqual(recurring.amount, Decimal("10")) + generated = recurring.transactions.all() + self.assertTrue(generated) + for transaction in generated: + self.assertEqual(self._parts(transaction), [("Plan", Decimal("10"))]) + + sub = recurring.sub_transactions.get() + self.client.post( + reverse("recurring_transaction_edit", kwargs={"recurring_transaction_id": recurring.id}), + {**self.base, "start_date": timezone.localdate().isoformat(), "recurrence_type": "month", + "recurrence_interval": 1, "keep_at_most": 2, + **_subs({"id": sub.id, "name": "Plan", "amount": "10"}, {"name": "Tax", "amount": "1"}, initial=1)}, + headers={"HX-Request": "true"}, + ) + for transaction in recurring.transactions.all(): + self.assertEqual(transaction.amount, Decimal("11")) + self.assertEqual(len(self._parts(transaction)), 2) + + def test_installment_parts_are_copied_to_each_installment(self): + self._post( + "installment_plan_add", + {**self.base, "number_of_installments": 2, "installment_start": 1, + "start_date": timezone.localdate().isoformat(), "recurrence": "monthly", + **_subs({"name": "Principal", "amount": "90"}, {"name": "Interest", "amount": "10"})}, + ) + plan = InstallmentPlan.all_objects.get() + self.assertEqual(plan.installment_amount, Decimal("100")) + self.assertEqual(plan.transactions.count(), 2) + for transaction in plan.transactions.all(): + self.assertEqual(transaction.amount, Decimal("100")) + self.assertEqual(len(self._parts(transaction)), 2) diff --git a/app/apps/transactions/views/actions.py b/app/apps/transactions/views/actions.py index fdaf3a0f..287e9ca8 100644 --- a/app/apps/transactions/views/actions.py +++ b/app/apps/transactions/views/actions.py @@ -32,6 +32,7 @@ def _copy(transaction): new_transaction.tags.add(*transaction.tags.all()) new_transaction.entities.add(*transaction.entities.all()) + new_transaction.copy_sub_transactions_from(transaction) return new_transaction diff --git a/app/apps/transactions/views/conversions.py b/app/apps/transactions/views/conversions.py index 8d57d5f4..6a6b5911 100644 --- a/app/apps/transactions/views/conversions.py +++ b/app/apps/transactions/views/conversions.py @@ -37,6 +37,10 @@ def _initial_from_transaction(transaction: Transaction): return initial +def _sub_transactions_initial(transaction: Transaction): + return list(transaction.sub_transactions.values("name", "amount")) + + def _get_unlinked_transaction(transaction_id): # Transactions already generated by a plan or recurrence can't be converted again return get_object_or_404( @@ -78,6 +82,7 @@ def transaction_convert_to_quick_transaction(request, transaction_id): ) else: form = QuickTransactionForm( + sub_transactions_initial=_sub_transactions_initial(transaction), initial={ **_initial_from_transaction(transaction), "is_paid": transaction.is_paid, @@ -114,6 +119,7 @@ def transaction_convert_to_recurring_transaction(request, transaction_id): ) else: form = RecurringTransactionForm( + sub_transactions_initial=_sub_transactions_initial(transaction), initial={ **_initial_from_transaction(transaction), "amount": transaction.amount, @@ -154,6 +160,7 @@ def transaction_convert_to_installment_plan(request, transaction_id): ) else: form = InstallmentPlanForm( + sub_transactions_initial=_sub_transactions_initial(transaction), initial={ **_initial_from_transaction(transaction), "installment_amount": transaction.amount, diff --git a/app/apps/transactions/views/installment_plans.py b/app/apps/transactions/views/installment_plans.py index f2927591..5f1fd192 100644 --- a/app/apps/transactions/views/installment_plans.py +++ b/app/apps/transactions/views/installment_plans.py @@ -67,7 +67,7 @@ def finished_installment_plans_list(request): @require_http_methods(["GET"]) def installment_plan_transactions(request, installment_plan_id): installment_plan = get_object_or_404(InstallmentPlan, id=installment_plan_id) - transactions = installment_plan.transactions.all().order_by("reference_date", "id") + transactions = installment_plan.transactions.prefetch_related("sub_transactions").order_by("reference_date", "id") return render( request, diff --git a/app/apps/transactions/views/quick_transactions.py b/app/apps/transactions/views/quick_transactions.py index 0c60e438..59af0192 100644 --- a/app/apps/transactions/views/quick_transactions.py +++ b/app/apps/transactions/views/quick_transactions.py @@ -155,6 +155,7 @@ def quick_transaction_add_as_transaction(request, quick_transaction_id): new_transaction.save() new_transaction.tags.set(quick_transaction.tags.all()) new_transaction.entities.set(quick_transaction.entities.all()) + new_transaction.copy_sub_transactions_from(quick_transaction) to_transaction = quick_transaction.complete_transfer(new_transaction) transaction_created.send(sender=new_transaction) diff --git a/app/apps/transactions/views/recurring_transactions.py b/app/apps/transactions/views/recurring_transactions.py index d12cfd9a..bca4fb18 100644 --- a/app/apps/transactions/views/recurring_transactions.py +++ b/app/apps/transactions/views/recurring_transactions.py @@ -90,7 +90,7 @@ def recurring_transaction_transactions(request, recurring_transaction_id): recurring_transaction = get_object_or_404( RecurringTransaction, id=recurring_transaction_id ) - transactions = recurring_transaction.transactions.collapse_transfers().order_by( + transactions = recurring_transaction.transactions.collapse_transfers().prefetch_related("sub_transactions").order_by( "reference_date", "id" ) diff --git a/app/apps/transactions/views/transactions.py b/app/apps/transactions/views/transactions.py index 9ca4e68d..29040c27 100644 --- a/app/apps/transactions/views/transactions.py +++ b/app/apps/transactions/views/transactions.py @@ -409,6 +409,8 @@ def transactions_bulk_edit(request): transaction.tags.set(value) elif field_name == "entities": transaction.entities.set(value) + elif field_name == "amount" and transaction.has_sub_transactions: + continue # its amount is the sum of its parts else: setattr(transaction, field_name, value) @@ -802,6 +804,7 @@ def transaction_all_list(request): "installment_plan", "entities", "dca_expense_entries", + "sub_transactions", "dca_income_entries", "linked_transaction__account__currency", "linked_transaction__account__group", @@ -971,6 +974,7 @@ def transactions_trash_can_list(request): "installment_plan", "entities", "dca_expense_entries", + "sub_transactions", "dca_income_entries", "linked_transaction__account__currency", "linked_transaction__account__group", diff --git a/app/templates/cotton/transaction/item.html b/app/templates/cotton/transaction/item.html index 5275b51d..8c5d6490 100644 --- a/app/templates/cotton/transaction/item.html +++ b/app/templates/cotton/transaction/item.html @@ -2,10 +2,12 @@ {% load i18n %} {# With "Combine transfers" on, a transfer is shown once: its "from" side with the "to" side alongside #} {% with transaction=transaction.display_transaction transfer_to=transaction.transfer_to is_transfer=transaction.shown_as_transfer %} +{% with subs=transaction.saved_sub_transactions %}
    -
    + class="transaction {% if is_transfer %}transfer{% elif transaction.type == "EX" %}expense{% else %}income{% endif %} group/transaction" + {% if subs %}x-data="{ subsOpen: false }"{% endif %}> +
    {% if not disable_selection or not dummy %}
    + {% if subs %} + {# Breakdown, opened from the tab hanging under the card; amounts line up with the total #} +
    +
      + {% for sub in subs %} +
    • + {{ sub.name }} + +
    • + {% endfor %} +
    +
    + + {% endif %}
    {% endwith %} +{% endwith %} diff --git a/app/templates/investments/fragments/detail.html b/app/templates/investments/fragments/detail.html index 2f31ad2d..e5342855 100644 --- a/app/templates/investments/fragments/detail.html +++ b/app/templates/investments/fragments/detail.html @@ -283,8 +283,16 @@ {% endif %} {% endif %}
    + {# Breakdown, e.g. fees and taxes inside a contribution #} + {% with subs=tx.sub_transactions.all %}{% if subs %} +
      + {% for sub in subs %} +
    • {{ sub.name }}
    • + {% endfor %} +
    + {% endif %}{% endwith %} - + {# What the other side paid beats a rate conversion, so it's shown first #} {% if p and p.account.currency != a %} diff --git a/app/templates/transactions/widgets/sub_transaction_row.html b/app/templates/transactions/widgets/sub_transaction_row.html new file mode 100644 index 00000000..014fc4ba --- /dev/null +++ b/app/templates/transactions/widgets/sub_transaction_row.html @@ -0,0 +1,14 @@ +{% load i18n %} +
    + {{ sub.id }} + +
    + {{ sub.name }} + {{ sub.amount }} + +
    + {% for error in sub.non_field_errors %}
    {{ error }}
    {% endfor %} + {% for error in sub.name.errors %}
    {{ error }}
    {% endfor %} + {% for error in sub.amount.errors %}
    {{ error }}
    {% endfor %} +
    diff --git a/app/templates/transactions/widgets/sub_transactions.html b/app/templates/transactions/widgets/sub_transactions.html new file mode 100644 index 00000000..92f22928 --- /dev/null +++ b/app/templates/transactions/widgets/sub_transactions.html @@ -0,0 +1,58 @@ +{% load i18n formats %} +{% with formset=form.sub_transactions %} +{# The amount is the sum of these rows, so it's hidden while there are any. #} +{# Transfers don't take them; `type` comes from the form's _type_aware scope when it has one. #} +
    + {{ formset.management_form }} + {% for error in formset.non_form_errors %}
    {{ error }}
    {% endfor %} + + {% translate 'Sub-transactions' %} + +
    + {% for sub in formset %} + {% include "transactions/widgets/sub_transaction_row.html" with sub=sub %} + {% endfor %} +
    + + + +
    + + {% translate 'Total' %}: +
    +
    +{% endwith %} From 5459865366cbdc2b0d42bd4d7ff7c21edddb31ef Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 14 Nov 2026 02:13:21 -0300 Subject: [PATCH 14/24] 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. --- app/apps/api/serializers/transactions.py | 131 ++++++++++++++---- app/apps/api/views/transactions.py | 6 +- .../tests/test_sub_transactions.py | 98 +++++++++++++ 3 files changed, 206 insertions(+), 29 deletions(-) diff --git a/app/apps/api/serializers/transactions.py b/app/apps/api/serializers/transactions.py index 05d51c08..8628ffde 100644 --- a/app/apps/api/serializers/transactions.py +++ b/app/apps/api/serializers/transactions.py @@ -1,5 +1,6 @@ from decimal import Decimal +from django.db import transaction as db_transaction from django.utils.translation import gettext_lazy as _ from drf_spectacular import openapi from drf_spectacular.types import OpenApiTypes @@ -22,10 +23,85 @@ from apps.transactions.models import ( InstallmentPlan, TransactionEntity, RecurringTransaction, + SubTransaction, ) from apps.common.middleware.thread_local import get_current_user +class SubTransactionSerializer(serializers.ModelSerializer): + class Meta: + model = SubTransaction + fields = ["id", "name", "amount"] + read_only_fields = ["id"] + + +class SubTransactionsMixin: + """`sub_transactions`, when sent, replaces the parts; a non-empty list sets + the amount to their sum. Declare the field on the serializer itself.""" + + sub_amount_field = "amount" + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields[self.sub_amount_field].required = False + + def is_transfer(self, data): + return False + + def validate(self, data): + field = self.sub_amount_field + subs = data.get("sub_transactions") + has_parts = self.instance is not None and self.instance.sub_transactions.exists() + if self.is_transfer(data): + if subs: + raise serializers.ValidationError( + {"sub_transactions": _("Transfers can't have sub-transactions.")} + ) + if has_parts: + data["sub_transactions"] = [] + elif subs: + data[field] = sum(sub["amount"] for sub in subs) + elif subs is None and field in data and has_parts: + raise serializers.ValidationError( + { + field: _( + "The amount is the sum of the sub-transactions; " + "send sub_transactions instead." + ) + } + ) + if not self.partial and data.get(field) is None: + raise serializers.ValidationError({field: _("This field is required.")}) + return super().validate(data) + + @staticmethod + def set_sub_transactions(instance, subs): + if subs is None: + return + instance.sub_transactions.all().delete() + for sub in subs: + instance.sub_transactions.create(**sub) + + def create(self, validated_data): + subs = validated_data.pop("sub_transactions", None) + with db_transaction.atomic(): + instance = super().create(validated_data) + self.set_sub_transactions(instance, subs) + self.after_save(instance, created=True) + return instance + + def update(self, instance, validated_data): + subs = validated_data.pop("sub_transactions", None) + with db_transaction.atomic(): + instance = super().update(instance, validated_data) + self.set_sub_transactions(instance, subs) + self.after_save(instance, created=False) + return instance + + def after_save(self, instance, created): + """Runs once the parts are saved, e.g. to generate transactions from them.""" + + class TransactionCategorySerializer(serializers.ModelSerializer): permission_classes = [IsAuthenticated] @@ -62,7 +138,9 @@ class TransactionEntitySerializer(serializers.ModelSerializer): ] -class InstallmentPlanSerializer(serializers.ModelSerializer): +class InstallmentPlanSerializer(SubTransactionsMixin, serializers.ModelSerializer): + sub_amount_field = "installment_amount" + sub_transactions = SubTransactionSerializer(many=True, required=False) category: str | int = TransactionCategoryField(required=False) tags: str | int = TransactionTagField(required=False) entities: str | int = TransactionEntityField(required=False) @@ -84,6 +162,7 @@ class InstallmentPlanSerializer(serializers.ModelSerializer): "end_date", "recurrence", "installment_amount", + "sub_transactions", "category", "tags", "entities", @@ -91,18 +170,15 @@ class InstallmentPlanSerializer(serializers.ModelSerializer): ] read_only_fields = ["installment_total_number", "end_date"] - def create(self, validated_data): - instance = super().create(validated_data) - instance.create_transactions() - return instance - - def update(self, instance, validated_data): - instance = super().update(instance, validated_data) - instance.update_transactions() - return instance + def after_save(self, instance, created): + if created: + instance.create_transactions() + else: + instance.update_transactions() -class RecurringTransactionSerializer(serializers.ModelSerializer): +class RecurringTransactionSerializer(SubTransactionsMixin, serializers.ModelSerializer): + sub_transactions = SubTransactionSerializer(many=True, required=False) category: str | int = TransactionCategoryField(required=False) tags: str | int = TransactionTagField(required=False) entities: str | int = TransactionEntityField(required=False) @@ -115,6 +191,7 @@ class RecurringTransactionSerializer(serializers.ModelSerializer): "account", "type", "amount", + "sub_transactions", "to_account", "to_amount", "description", @@ -142,19 +219,20 @@ class RecurringTransactionSerializer(serializers.ModelSerializer): ) return super().validate(attrs) - def create(self, validated_data): - instance = super().create(validated_data) - instance.create_upcoming_transactions() - return instance + def is_transfer(self, data): + type_ = data.get("type", getattr(self.instance, "type", None)) + return type_ == RecurringTransaction.Type.TRANSFER - def update(self, instance, validated_data): - instance = super().update(instance, validated_data) - instance.update_unpaid_transactions() - instance.generate_upcoming_transactions() - return instance + def after_save(self, instance, created): + if created: + instance.create_upcoming_transactions() + else: + instance.update_unpaid_transactions() + instance.generate_upcoming_transactions() -class TransactionSerializer(serializers.ModelSerializer): +class TransactionSerializer(SubTransactionsMixin, serializers.ModelSerializer): + sub_transactions = SubTransactionSerializer(many=True, required=False) category: str | int = TransactionCategoryField(required=False) tags: str | int = TransactionTagField(required=False) entities: str | int = TransactionEntityField(required=False) @@ -194,6 +272,9 @@ class TransactionSerializer(serializers.ModelSerializer): self.fields["account_id"].queryset = Account.objects.all() + def is_transfer(self, data): + return bool(self.instance and self.instance.linked_transaction_id) + def validate(self, data): if not self.partial: if "date" in data and "reference_date" not in data: @@ -204,12 +285,12 @@ class TransactionSerializer(serializers.ModelSerializer): raise serializers.ValidationError( _("Either 'date' or 'reference_date' must be provided.") ) - return data + return super().validate(data) def create(self, validated_data): tags = validated_data.pop("tags", []) entities = validated_data.pop("entities", []) - transaction = Transaction.objects.create(**validated_data) + transaction = super().create(validated_data) transaction.tags.set(tags) transaction.entities.set(entities) return transaction @@ -217,9 +298,7 @@ class TransactionSerializer(serializers.ModelSerializer): def update(self, instance, validated_data): tags = validated_data.pop("tags", None) entities = validated_data.pop("entities", None) - for attr, value in validated_data.items(): - setattr(instance, attr, value) - instance.save() + instance = super().update(instance, validated_data) if tags is not None: instance.tags.set(tags) diff --git a/app/apps/api/views/transactions.py b/app/apps/api/views/transactions.py index fdc00030..50e11517 100644 --- a/app/apps/api/views/transactions.py +++ b/app/apps/api/views/transactions.py @@ -52,7 +52,7 @@ class TransactionViewSet(viewsets.ModelViewSet): ordering = ["-id"] def get_queryset(self): - return Transaction.objects.all() + return Transaction.objects.prefetch_related("sub_transactions") def perform_create(self, serializer): instance = serializer.save() @@ -145,7 +145,7 @@ class InstallmentPlanViewSet(viewsets.ModelViewSet): ordering = ["-id"] def get_queryset(self): - return InstallmentPlan.objects.all() + return InstallmentPlan.objects.prefetch_related("sub_transactions") class RecurringTransactionViewSet(viewsets.ModelViewSet): @@ -175,4 +175,4 @@ class RecurringTransactionViewSet(viewsets.ModelViewSet): ordering = ["-id"] def get_queryset(self): - return RecurringTransaction.objects.all() + return RecurringTransaction.objects.prefetch_related("sub_transactions") diff --git a/app/apps/transactions/tests/test_sub_transactions.py b/app/apps/transactions/tests/test_sub_transactions.py index 12eda71c..7d2104b7 100644 --- a/app/apps/transactions/tests/test_sub_transactions.py +++ b/app/apps/transactions/tests/test_sub_transactions.py @@ -221,3 +221,101 @@ class SubTransactionTests(TestCase): for transaction in plan.transactions.all(): self.assertEqual(transaction.amount, Decimal("100")) self.assertEqual(len(self._parts(transaction)), 2) + + +class SubTransactionApiTests(TestCase): + def setUp(self): + user = get_user_model().objects.create_user( + email="api@test.com", password="pw", is_superuser=True + ) + self.api = APIClient() + self.api.force_authenticate(user=user) + currency = Currency.objects.create(code="EUR", name="EUR", decimal_places=2) + self.account = Account.objects.create(name="A", currency=currency, owner=user) + + def test_create_read_and_update_sub_transactions(self): + response = self.api.post( + "/api/transactions/", + {"account_id": self.account.id, "type": "EX", "date": "2030-01-10", "description": "Shop", + "sub_transactions": [{"name": "A", "amount": "1.50"}, {"name": "B", "amount": "2"}]}, + format="json", + ) + self.assertEqual(response.status_code, 201, response.data) + self.assertEqual(Decimal(response.data["amount"]), Decimal("3.50")) + self.assertEqual([s["name"] for s in response.data["sub_transactions"]], ["A", "B"]) + url = f"/api/transactions/{response.data['id']}/" + + # The amount can't drift from the parts + response = self.api.patch(url, {"amount": "9"}, format="json") + self.assertEqual(response.status_code, 400) + + response = self.api.patch(url, {"sub_transactions": [{"name": "C", "amount": "4"}]}, format="json") + self.assertEqual(response.status_code, 200, response.data) + self.assertEqual(Decimal(response.data["amount"]), Decimal("4")) + self.assertEqual(self.api.get(url).data["sub_transactions"][0]["name"], "C") + + def test_amount_required_without_sub_transactions(self): + response = self.api.post( + "/api/transactions/", + {"account_id": self.account.id, "type": "EX", "date": "2030-01-10"}, + format="json", + ) + self.assertEqual(response.status_code, 400) + self.assertIn("amount", response.data) + + def _parts(self, owner): + return [(s.name, s.amount) for s in owner.sub_transactions.all()] + + def test_installment_plan_parts_reach_every_installment(self): + response = self.api.post( + "/api/installment-plans/", + {"account": self.account.id, "type": "EX", "description": "Laptop", + "number_of_installments": 3, "start_date": "2030-01-10", "recurrence": "monthly", + "sub_transactions": [{"name": "Principal", "amount": "90"}, {"name": "Interest", "amount": "10"}]}, + format="json", + ) + self.assertEqual(response.status_code, 201, response.data) + self.assertEqual(Decimal(response.data["installment_amount"]), Decimal("100")) + plan = InstallmentPlan.all_objects.get() + installments = plan.transactions.all() + self.assertEqual(len(installments), 3) + for transaction in installments: + self.assertEqual(transaction.amount, Decimal("100")) + self.assertEqual(len(self._parts(transaction)), 2) + + url = f"/api/installment-plans/{plan.id}/" + self.assertEqual(self.api.patch(url, {"installment_amount": "5"}, format="json").status_code, 400) + response = self.api.patch(url, {"sub_transactions": [{"name": "Principal", "amount": "80"}]}, format="json") + self.assertEqual(response.status_code, 200, response.data) + for transaction in plan.transactions.all(): + self.assertEqual(self._parts(transaction), [("Principal", Decimal("80"))]) + self.assertEqual(transaction.amount, Decimal("80")) + + def test_recurring_parts_follow_its_transactions_and_transfers_drop_them(self): + response = self.api.post( + "/api/recurring-transactions/", + {"account": self.account.id, "type": "EX", "description": "Internet", + "start_date": timezone.localdate().isoformat(), "recurrence_type": "month", "recurrence_interval": 1, + "sub_transactions": [{"name": "Plan", "amount": "50"}, {"name": "Router", "amount": "10"}]}, + format="json", + ) + self.assertEqual(response.status_code, 201, response.data) + self.assertEqual(Decimal(response.data["amount"]), Decimal("60")) + self.assertEqual([s["name"] for s in response.data["sub_transactions"]], ["Plan", "Router"]) + recurring = RecurringTransaction.all_objects.get() + generated = Transaction.all_objects.filter(recurring_transaction=recurring) + self.assertTrue(generated) + for transaction in generated: + self.assertEqual(transaction.amount, Decimal("60")) + self.assertEqual(len(self._parts(transaction)), 2) + + other = Account.objects.create(name="B", currency=self.account.currency, owner=self.account.owner) + url = f"/api/recurring-transactions/{recurring.id}/" + self.assertEqual( + self.api.patch(url, {"type": "TR", "to_account": other.id, + "sub_transactions": [{"name": "X", "amount": "1"}]}, format="json").status_code, + 400, + ) + response = self.api.patch(url, {"type": "TR", "to_account": other.id}, format="json") + self.assertEqual(response.status_code, 200, response.data) + self.assertEqual(response.data["sub_transactions"], []) From 188876fdf00a2bc2d1dad1e6dcb835e6f8c9fec9 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 14 Nov 2026 02:13:21 -0300 Subject: [PATCH 15/24] 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. --- app/apps/rules/forms.py | 2 + .../rules/migrations/0019_sub_transactions.py | 23 ++++ app/apps/rules/models.py | 5 + app/apps/rules/tasks.py | 100 +++++++++++++++- app/apps/rules/tests/test_tasks.py | 110 +++++++++++++++++- app/apps/rules/utils/transactions.py | 4 + 6 files changed, 236 insertions(+), 8 deletions(-) create mode 100644 app/apps/rules/migrations/0019_sub_transactions.py diff --git a/app/apps/rules/forms.py b/app/apps/rules/forms.py index b5b39357..d001efbf 100644 --- a/app/apps/rules/forms.py +++ b/app/apps/rules/forms.py @@ -190,6 +190,7 @@ class UpdateOrCreateTransactionRuleActionForm(forms.ModelForm): "set_date": _("Date"), "set_reference_date": _("Reference Date"), "set_amount": _("Amount"), + "set_sub_transactions": _("Sub-transactions"), "set_description": _("Description"), "set_tags": _("Tags"), "set_entities": _("Entities"), @@ -367,6 +368,7 @@ class UpdateOrCreateTransactionRuleActionForm(forms.ModelForm): Field("set_reference_date", rows=1), Field("set_description", rows=1), Field("set_amount", rows=1), + Field("set_sub_transactions", rows=1), Field("set_category", rows=1), Field("set_tags", rows=1), Field("set_notes", rows=1), diff --git a/app/apps/rules/migrations/0019_sub_transactions.py b/app/apps/rules/migrations/0019_sub_transactions.py new file mode 100644 index 00000000..4106d3f7 --- /dev/null +++ b/app/apps/rules/migrations/0019_sub_transactions.py @@ -0,0 +1,23 @@ +# Generated by Django 5.2.17 on 2026-11-14 03:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('rules', '0018_transactionrule_order'), + ] + + operations = [ + migrations.AddField( + model_name='updateorcreatetransactionruleaction', + name='set_sub_transactions', + field=models.TextField(blank=True, verbose_name='Sub-transactions'), + ), + migrations.AlterField( + model_name='transactionruleaction', + name='field', + field=models.CharField(choices=[('account', 'Account'), ('type', 'Type'), ('is_paid', 'Paid'), ('date', 'Date'), ('reference_date', 'Reference Date'), ('mute', 'Mute'), ('amount', 'Amount'), ('sub_transactions', 'Sub-transactions'), ('description', 'Description'), ('notes', 'Notes'), ('category', 'Category'), ('tags', 'Tags'), ('entities', 'Entities'), ('internal_nome', 'Internal Note'), ('internal_id', 'Internal ID')], max_length=50, verbose_name='Field'), + ), + ] diff --git a/app/apps/rules/models.py b/app/apps/rules/models.py index 653c87c7..85259278 100644 --- a/app/apps/rules/models.py +++ b/app/apps/rules/models.py @@ -39,6 +39,7 @@ class TransactionRuleAction(models.Model): reference_date = "reference_date", _("Reference Date") mute = "mute", _("Mute") amount = "amount", _("Amount") + sub_transactions = "sub_transactions", _("Sub-transactions") description = "description", _("Description") notes = "notes", _("Notes") category = "category", _("Category") @@ -315,6 +316,10 @@ class UpdateOrCreateTransactionRuleAction(models.Model): verbose_name=_("Tags"), blank=True, ) + set_sub_transactions = models.TextField( + verbose_name=_("Sub-transactions"), + blank=True, + ) set_mute = models.TextField( verbose_name=_("Mute"), blank=True, diff --git a/app/apps/rules/tasks.py b/app/apps/rules/tasks.py index 427be97d..ba4573c1 100644 --- a/app/apps/rules/tasks.py +++ b/app/apps/rules/tasks.py @@ -17,12 +17,14 @@ from procrastinate.contrib.django import app from simpleeval import EvalWithCompoundTypes from apps.accounts.models import Account +from apps.common.functions.decimals import truncate_decimal from apps.common.middleware.thread_local import write_current_user, delete_current_user from apps.rules.models import ( TransactionRule, TransactionRuleAction, ) from apps.transactions.models import ( + SubTransaction, Transaction, TransactionCategory, TransactionTag, @@ -32,6 +34,39 @@ from apps.rules.utils import transactions logger = logging.getLogger(__name__) +SUB_TRANSACTIONS_SHAPE = ( + "Sub-transactions must be a list like [{'name': 'Fee', 'amount': 1.5}, ...]" +) + + +def build_sub_transactions(transaction: Transaction, value) -> list[SubTransaction]: + """Validated sub-transactions for `transaction` from a rule expression's result.""" + if not isinstance(value, (list, tuple)): + raise ValueError(SUB_TRANSACTIONS_SHAPE) + places = transaction.account.currency.decimal_places + subs = [] + for item in value: + if not isinstance(item, dict) or item.get("amount") is None: + raise ValueError(SUB_TRANSACTIONS_SHAPE) + sub = SubTransaction( + transaction=transaction, + name=str(item.get("name") or "").strip(), + amount=truncate_decimal( + value=Decimal(str(item["amount"])), decimal_places=places + ), + ) + # the transaction may not be saved yet, so its link isn't checked here + sub.full_clean(exclude=["transaction"], validate_constraints=False) + subs.append(sub) + return subs + + +def _snapshot(transaction: Transaction) -> Transaction: + """A copy to show in dry-run results, as the transaction is right now.""" + copy = transaction.deepcopy() + copy.copy_sub_transactions_from(transaction) + return copy + class DryRunResults: def __init__(self, dry_run: bool): @@ -49,7 +84,7 @@ class DryRunResults: if not self.dry_run: return if isinstance(instance, Transaction): - instance = instance.deepcopy() + instance = _snapshot(instance) elif isinstance(instance, dict): instance = deepcopy(instance) @@ -65,7 +100,7 @@ class DryRunResults: if not self.dry_run: return if isinstance(instance, Transaction): - instance = instance.deepcopy() + instance = _snapshot(instance) elif isinstance(instance, dict): instance = deepcopy(instance) @@ -95,7 +130,7 @@ class DryRunResults: return if isinstance(end_instance, Transaction): - end_instance = end_instance.deepcopy() + end_instance = _snapshot(end_instance) elif isinstance(end_instance, dict): end_instance = deepcopy(end_instance) @@ -201,6 +236,14 @@ def check_for_transaction_rules( f"{prefix}entities_ids": ( [x.id for x in transaction.entities.all()] if transaction.id else [] ), + f"{prefix}sub_transactions": ( + [ + {"name": s.name, "amount": s.amount} + for s in transaction.sub_transactions.all() + ] + if transaction.id + else [] + ), f"{prefix}is_expense": transaction.type == Transaction.Type.EXPENSE, f"{prefix}is_income": transaction.type == Transaction.Type.INCOME, f"{prefix}is_paid": transaction.is_paid, @@ -250,6 +293,10 @@ def check_for_transaction_rules( f"{prefix}entities_ids": [ x[0] for x in transaction.get("entities", []) ], + f"{prefix}sub_transactions": [ + {"name": s["name"], "amount": Decimal(s["amount"])} + for s in transaction.get("sub_transactions", []) + ], f"{prefix}is_expense": transaction.get("type") == Transaction.Type.EXPENSE, f"{prefix}is_income": transaction.get("type") @@ -274,6 +321,22 @@ def check_for_transaction_rules( f"{prefix}installment_total": transaction.get("installment_total"), } + def _evaluate_sub_transactions(transaction, value): + """The parts an expression's `value` gives `transaction`, with its amount set + to their sum, or None for a transfer, which can't have any.""" + if transaction.linked_transaction_id: + _log("Skipped: transfers can't have sub-transactions") + return None + subs = build_sub_transactions(transaction, value) + if subs: + transaction.amount = sum(s.amount for s in subs) + _log(f"Sub-transactions will be set as: {[(s.name, s.amount) for s in subs]}") + return subs + + def _save_sub_transactions(transaction, subs): + transaction.sub_transactions.all().delete() + SubTransaction.objects.bulk_create(subs) + def _process_update_or_create_transaction_action(processed_action): """Helper to process a single linked transaction action""" @@ -295,7 +358,7 @@ def check_for_transaction_rules( existing = True if dry_run: - starting_instance = transaction.deepcopy() + starting_instance = _snapshot(transaction) _log("Found at least one matching transaction, using latest:") _log("{}".format(pformat(model_to_dict(transaction)))) @@ -348,7 +411,15 @@ def check_for_transaction_rules( processed_action.set_reference_date ) - if processed_action.set_amount: + subs = None + if processed_action.set_sub_transactions: + subs = _evaluate_sub_transactions( + transaction, simple.eval(processed_action.set_sub_transactions) + ) + + # A transaction with parts gets its amount from them + has_parts = bool(subs) if subs is not None else transaction.has_sub_transactions + if processed_action.set_amount and not has_parts: transaction.amount = simple.eval(processed_action.set_amount) if processed_action.set_description: @@ -383,6 +454,8 @@ def check_for_transaction_rules( ) ) transaction.save() + if subs is not None: + _save_sub_transactions(transaction, subs) # Handle M2M fields after save tags = [] @@ -441,7 +514,10 @@ def check_for_transaction_rules( dry_run_results.header("edit_transaction", action=processed_action) field = processed_action.field - original_value = getattr(transaction, field) + if field == TransactionRuleAction.Field.sub_transactions: + original_value = list(transaction.sub_transactions.values("name", "amount")) + else: + original_value = getattr(transaction, field) new_value = simple.eval(processed_action.value) tags = [] @@ -518,6 +594,18 @@ def check_for_transaction_rules( transaction.entities.add(entity) entities.append(entity) + elif field == TransactionRuleAction.Field.sub_transactions: + subs = _evaluate_sub_transactions(transaction, new_value) + if subs is not None: + _save_sub_transactions(transaction, subs) + new_value = ", ".join(f"{s.name}: {s.amount}" for s in subs) or "[]" + + elif ( + field == TransactionRuleAction.Field.amount + and transaction.has_sub_transactions + ): + _log("Skipped: the amount is the sum of the transaction's sub-transactions") + else: setattr( transaction, diff --git a/app/apps/rules/tests/test_tasks.py b/app/apps/rules/tests/test_tasks.py index 9520318a..b03f26cc 100644 --- a/app/apps/rules/tests/test_tasks.py +++ b/app/apps/rules/tests/test_tasks.py @@ -6,10 +6,15 @@ from django.contrib.auth import get_user_model from django.test import TransactionTestCase from apps.accounts.models import Account +from apps.common.middleware.thread_local import write_current_user from apps.currencies.models import Currency -from apps.rules.models import TransactionRule, UpdateOrCreateTransactionRuleAction +from apps.rules.models import ( + TransactionRule, + TransactionRuleAction, + UpdateOrCreateTransactionRuleAction, +) from apps.rules.tasks import check_for_transaction_rules -from apps.transactions.models import Transaction +from apps.transactions.models import SubTransaction, Transaction def run_check_for_transaction_rules_without_worker_wrapper(**kwargs): @@ -122,3 +127,104 @@ class CheckForTransactionRulesTests(TransactionTestCase): generated_transaction = Transaction.objects.get(description="Muted copy") self.assertTrue(generated_transaction.mute) self.assertFalse(generated_transaction.is_paid) + + @patch("apps.rules.signals.check_for_transaction_rules.defer") + def test_edit_amount_skips_transactions_with_sub_transactions(self, mock_defer): + rule = TransactionRule.objects.create( + active=True, on_update=True, name="Set amount", trigger="True", owner=self.user + ) + TransactionRuleAction.objects.create(rule=rule, field="amount", value="99") + TransactionRuleAction.objects.create(rule=rule, field="description", value="'Ruled'") + amounts = {} + for parts in ([], [Decimal("4"), Decimal("6")]): + transaction = Transaction.objects.create( + account=self.account, type=Transaction.Type.EXPENSE, amount=sum(parts) or 1, + date=date(2026, 5, 4), owner=self.user, + ) + for amount in parts: + SubTransaction.objects.create(transaction=transaction, name="Part", amount=amount) + run_check_for_transaction_rules_without_worker_wrapper( + instance_id=transaction.id, user_id=self.user.id, signal="transaction_updated" + ) + transaction.refresh_from_db() + self.assertEqual(transaction.description, "Ruled") + amounts[len(parts)] = transaction.amount + self.assertEqual(amounts, {0: Decimal("99"), 2: Decimal("10")}) + + +class SubTransactionRuleTests(TransactionTestCase): + def setUp(self): + self.user = get_user_model().objects.create_user(email="subs@example.com", password="x") + currency = Currency.objects.create(code="USD", name="US Dollar", decimal_places=2) + self.account = Account.objects.create(name="Main", currency=currency, owner=self.user) + self.rule = TransactionRule.objects.create( + active=True, on_update=True, name="Parts", trigger="True", owner=self.user + ) + + def _transaction(self, *parts, amount=None): + transaction = Transaction.objects.create( + account=self.account, type=Transaction.Type.EXPENSE, date=date(2026, 5, 4), + amount=amount if amount is not None else sum(a for _, a in parts), owner=self.user, + ) + for name, part in parts: + SubTransaction.objects.create(transaction=transaction, name=name, amount=part) + return transaction + + def _run(self, transaction): + with patch("apps.rules.signals.check_for_transaction_rules.defer"): + run_check_for_transaction_rules_without_worker_wrapper( + instance_id=transaction.id, user_id=self.user.id, signal="transaction_updated" + ) + transaction.refresh_from_db() + return transaction.amount, list(transaction.sub_transactions.values_list("name", "amount")) + + def _edit(self, expression): + TransactionRuleAction.objects.create(rule=self.rule, field="sub_transactions", value=expression) + + def test_edit_action_adds_changes_and_deletes_parts(self): + self._edit( + '[{"name": s["name"], "amount": s["amount"] * 2} for s in sub_transactions' + ' if s["name"] != "Tip"] + [{"name": "Fee", "amount": decimal("0.50")}]' + ) + result = self._run(self._transaction(("Meal", Decimal("10")), ("Tip", Decimal("2")))) + self.assertEqual(result, (Decimal("20.50"), [("Meal", Decimal("20")), ("Fee", Decimal("0.5"))])) + + def test_edit_action_splits_a_plain_transaction_and_clearing_keeps_amount(self): + self._edit('[{"name": "Principal", "amount": amount - 5}, {"name": "Fee", "amount": 5}]') + self.assertEqual( + self._run(self._transaction(amount=Decimal("100"))), + (Decimal("100"), [("Principal", Decimal("95")), ("Fee", Decimal("5"))]), + ) + self.rule.transaction_actions.update(value="[]") + self.assertEqual(self._run(self._transaction(("A", Decimal("3")))), (Decimal("3"), [])) + + def test_invalid_parts_leave_the_transaction_alone(self): + transaction = self._transaction(("A", Decimal("3"))) + for expression in ('"Fee"', '[{"name": "Fee"}]', '[{"name": "", "amount": 1}]', + '[{"name": "Refund", "amount": -1}]'): + with self.subTest(expression=expression): + self.rule.transaction_actions.all().delete() + self._edit(expression) + self.assertEqual(self._run(transaction), (Decimal("3"), [("A", Decimal("3"))])) + + def test_transfers_are_skipped(self): + out, inc = self._transaction(amount=Decimal("5")), self._transaction(amount=Decimal("5")) + write_current_user(self.user) + with patch("apps.rules.signals.check_for_transaction_rules.defer"): + Transaction.objects.filter(pk=out.pk).update(linked_transaction=inc) + self._edit('[{"name": "Fee", "amount": 1}]') + self.assertEqual(self._run(out), (Decimal("5"), [])) + + def test_update_or_create_creates_a_transaction_from_its_parts(self): + UpdateOrCreateTransactionRuleAction.objects.create( + rule=self.rule, set_account="account_id", set_type="'EX'", set_date="date", + set_description="'Copy'", set_amount="999", + set_sub_transactions="sub_transactions + [{'name': 'Fee', 'amount': 1}]", + ) + self._run(self._transaction(("A", Decimal("3")))) + copy = Transaction.objects.get(description="Copy") + self.assertEqual(copy.amount, Decimal("4")) + self.assertEqual( + list(copy.sub_transactions.values_list("name", "amount")), + [("A", Decimal("3")), ("Fee", Decimal("1"))], + ) diff --git a/app/apps/rules/utils/transactions.py b/app/apps/rules/utils/transactions.py index 9dd7cba2..85361ebe 100644 --- a/app/apps/rules/utils/transactions.py +++ b/app/apps/rules/utils/transactions.py @@ -86,6 +86,10 @@ def serialize_transaction(sender: Transaction, deleted: bool): "notes": sender.notes, "tags": list(sender.tags.values_list("id", "name")), "entities": list(sender.entities.values_list("id", "name")), + "sub_transactions": [ + {"name": name, "amount": str(amount)} + for name, amount in sender.sub_transactions.values_list("name", "amount") + ], "deleted": deleted, "internal_note": sender.internal_note, "internal_id": sender.internal_id, From 3dcc2316fbc6d0c41d0c80985ff560919e65719f Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 14 Nov 2026 02:13:21 -0300 Subject: [PATCH 16/24] feat(export): back up sub-transactions and quick transactions --- app/apps/export_app/forms.py | 11 ++ app/apps/export_app/resources/transactions.py | 110 ++++++++++++++++++ app/apps/export_app/tests.py | 72 +++++++++++- app/apps/export_app/views.py | 28 +++++ 4 files changed, 219 insertions(+), 2 deletions(-) diff --git a/app/apps/export_app/forms.py b/app/apps/export_app/forms.py index caa436c8..7d50ffb1 100644 --- a/app/apps/export_app/forms.py +++ b/app/apps/export_app/forms.py @@ -61,6 +61,12 @@ class ExportForm(forms.Form): label=_("Installment Plans"), initial=True, ) + quick_transactions = forms.BooleanField( + required=False, + widget=forms.CheckboxInput(), + label=_("Quick Transactions"), + initial=True, + ) exchange_rates = forms.BooleanField( required=False, widget=forms.CheckboxInput(), @@ -116,6 +122,7 @@ class ExportForm(forms.Form): "tags", "installment_plans", "recurring_transactions", + "quick_transactions", "exchange_rates_services", "exchange_rates", "bank_sync", @@ -142,10 +149,12 @@ class RestoreForm(forms.Form): transactions_tags = forms.FileField(required=False, label=_("Tags")) transactions_entities = forms.FileField(required=False, label=_("Entities")) transactions = forms.FileField(required=False, label=_("Transactions")) + sub_transactions = forms.FileField(required=False, label=_("Sub-transactions")) installment_plans = forms.FileField(required=False, label=_("Installment Plans")) recurring_transactions = forms.FileField( required=False, label=_("Recurring Transactions") ) + quick_transactions = forms.FileField(required=False, label=_("Quick Transactions")) automatic_exchange_rates = forms.FileField( required=False, label=_("Automatic Exchange Rates") ) @@ -180,11 +189,13 @@ class RestoreForm(forms.Form): "accounts", "currencies", "transactions", + "sub_transactions", "transactions_categories", "transactions_entities", "transactions_tags", "installment_plans", "recurring_transactions", + "quick_transactions", "automatic_exchange_rates", "exchange_rates", "bank_sync_services", diff --git a/app/apps/export_app/resources/transactions.py b/app/apps/export_app/resources/transactions.py index dbcb0f14..1abde7ca 100644 --- a/app/apps/export_app/resources/transactions.py +++ b/app/apps/export_app/resources/transactions.py @@ -1,4 +1,9 @@ +from functools import reduce +from operator import or_ + +from django.db.models import Q from import_export import fields, resources +from import_export.widgets import ForeignKeyWidget from apps.accounts.models import Account from apps.export_app.widgets.foreign_key import ( @@ -14,6 +19,8 @@ from apps.transactions.models import ( TransactionEntity, RecurringTransaction, InstallmentPlan, + QuickTransaction, + SubTransaction, ) from apps.export_app.widgets.numbers import UniversalDecimalWidget @@ -166,3 +173,106 @@ class InstallmentPlanResource(resources.ModelResource): def dehydrate_account_owner(self, obj): """Export the account's owner ID for proper import matching.""" return obj.account.owner_id if obj.account else None + + +class AnyOwnerForeignKeyWidget(ForeignKeyWidget): + """Finds the parent among every user's rows, soft-deleted ones included.""" + + def get_queryset(self, value, row, *args, **kwargs): + return self.model._base_manager.all() + + +class QuickTransactionResource(resources.ModelResource): + account = fields.Field( + attribute="account", + column_name="account", + widget=AllObjectsForeignKeyWidget(Account, "name"), + ) + to_account = fields.Field( + attribute="to_account", + column_name="to_account", + widget=AllObjectsForeignKeyWidget(Account, "name"), + ) + category = fields.Field( + attribute="category", + column_name="category", + widget=AutoCreateForeignKeyWidget(TransactionCategory, "name"), + ) + tags = fields.Field( + attribute="tags", + column_name="tags", + widget=AutoCreateManyToManyWidget(TransactionTag, field="name"), + ) + entities = fields.Field( + attribute="entities", + column_name="entities", + widget=AutoCreateManyToManyWidget(TransactionEntity, field="name"), + ) + internal_id = EmptyStringToNoneField( + column_name="internal_id", attribute="internal_id" + ) + amount = fields.Field( + attribute="amount", + column_name="amount", + widget=UniversalDecimalWidget(), + ) + to_amount = fields.Field( + attribute="to_amount", + column_name="to_amount", + widget=UniversalDecimalWidget(), + ) + + class Meta: + model = QuickTransaction + + def get_queryset(self): + return QuickTransaction.all_objects.all() + + +SUB_TRANSACTION_BACKUP_PARENTS = ( + "transaction", + "installment_plan", + "recurring_transaction", + "quick_transaction", +) + + +class SubTransactionResource(resources.ModelResource): + transaction = fields.Field( + attribute="transaction", + column_name="transaction", + widget=AnyOwnerForeignKeyWidget(Transaction), + ) + installment_plan = fields.Field( + attribute="installment_plan", + column_name="installment_plan", + widget=AnyOwnerForeignKeyWidget(InstallmentPlan), + ) + recurring_transaction = fields.Field( + attribute="recurring_transaction", + column_name="recurring_transaction", + widget=AnyOwnerForeignKeyWidget(RecurringTransaction), + ) + quick_transaction = fields.Field( + attribute="quick_transaction", + column_name="quick_transaction", + widget=AnyOwnerForeignKeyWidget(QuickTransaction), + ) + amount = fields.Field( + attribute="amount", + column_name="amount", + widget=UniversalDecimalWidget(), + ) + + def __init__(self, parents=SUB_TRANSACTION_BACKUP_PARENTS, **kwargs): + """`parents`: the kinds of parent being exported, whose parts go along.""" + super().__init__(**kwargs) + self.parents = parents + + class Meta: + model = SubTransaction + + def get_queryset(self): + return SubTransaction.objects.filter( + reduce(or_, (Q(**{f"{p}__isnull": False}) for p in self.parents), Q(pk__in=[])) + ) diff --git a/app/apps/export_app/tests.py b/app/apps/export_app/tests.py index e70c0357..e929864c 100644 --- a/app/apps/export_app/tests.py +++ b/app/apps/export_app/tests.py @@ -1,4 +1,5 @@ import io +from datetime import date import zipfile from decimal import Decimal @@ -9,9 +10,21 @@ from apps.accounts.models import Account, InvestmentClass from apps.common.middleware.thread_local import delete_current_user, write_current_user from apps.currencies.models import Currency from apps.export_app.resources.accounts import AccountResource, InvestmentClassResource -from apps.export_app.resources.transactions import TransactionEntityResource +from apps.export_app.resources.transactions import ( + InstallmentPlanResource, + QuickTransactionResource, + SubTransactionResource, + TransactionEntityResource, + TransactionResource, +) from apps.export_app.views import process_imports -from apps.transactions.models import TransactionEntity +from apps.transactions.models import ( + InstallmentPlan, + QuickTransaction, + SubTransaction, + Transaction, + TransactionEntity, +) class InvestmentRestoreTests(TestCase): @@ -51,3 +64,58 @@ class InvestmentRestoreTests(TestCase): self.assertEqual(account.investment_class.name, "Stocks") self.assertEqual(account.investment_class.target, Decimal("60")) self.assertEqual([e.name for e in account.income_entities.all()], ["Broker"]) + + +class SubTransactionBackupTests(TestCase): + def setUp(self): + self.user = get_user_model().objects.create_user(email="s@test.com", password="pw") + write_current_user(self.user) + self.addCleanup(delete_current_user) + account = Account.objects.create( + name="A", currency=Currency.objects.create(code="USD", name="USD", decimal_places=2) + ) + self.transaction = Transaction.objects.create( + account=account, type="EX", date=date(2030, 1, 10), amount=5 + ) + self.plan = InstallmentPlan.objects.create( + account=account, type="EX", description="Laptop", number_of_installments=2, + start_date=date(2030, 1, 10), installment_amount=100, + ) + SubTransaction.objects.create(transaction=self.transaction, name="Fee", amount="1.25") + SubTransaction.objects.create(transaction=self.transaction, name="Item", amount="3.75") + SubTransaction.objects.create(installment_plan=self.plan, name="Principal", amount=100) + lunch = QuickTransaction.objects.create( + name="Lunch", account=account, type="EX", amount=Decimal("13.90") + ) + SubTransaction.objects.create(quick_transaction=lunch, name="Meal", amount="11.90") + SubTransaction.objects.create(quick_transaction=lunch, name="Tip", amount=2) + + def _parts(self): + return sorted( + SubTransaction.objects.values_list( + "name", "transaction", "installment_plan", "quick_transaction__name", "amount" + ) + ) + + def test_round_trip_puts_parts_back_on_their_parents(self): + before = self._parts() + backup = io.BytesIO() + with zipfile.ZipFile(backup, "w") as z: + for resource, name in ( + (TransactionResource(), "transactions"), + (InstallmentPlanResource(), "installment_plans"), + (QuickTransactionResource(), "quick_transactions"), + (SubTransactionResource(), "sub_transactions"), + ): + z.writestr(f"{name}.csv", resource.export().csv) + + SubTransaction.objects.all().delete() + QuickTransaction.all_objects.all().delete() + backup.seek(0) + process_imports(None, {"zip_file": backup}) + + self.assertEqual(self._parts(), before) + + def test_exports_only_the_parts_of_exported_parents(self): + dataset = SubTransactionResource(parents=["installment_plan"]).export() + self.assertEqual([row["name"] for row in dataset.dict], ["Principal"]) diff --git a/app/apps/export_app/views.py b/app/apps/export_app/views.py index c413d3e4..3a521ddc 100644 --- a/app/apps/export_app/views.py +++ b/app/apps/export_app/views.py @@ -46,6 +46,8 @@ from apps.export_app.resources.transactions import ( TransactionCategoyResource, InstallmentPlanResource, RecurringTransactionResource, + QuickTransactionResource, + SubTransactionResource, ) from apps.export_app.resources.users import UserResource from apps.common.decorators.demo import disabled_on_demo @@ -84,6 +86,9 @@ def export_form(request): export_recurring_transactions = form.cleaned_data.get( "recurring_transactions", False ) + export_quick_transactions = form.cleaned_data.get( + "quick_transactions", False + ) export_exchange_rates_services = form.cleaned_data.get( "exchange_rates_services", False @@ -123,6 +128,27 @@ def export_form(request): exports.append( (RecurringTransactionResource().export(), "recurring_transactions") ) + if export_quick_transactions: + exports.append( + (QuickTransactionResource().export(), "quick_transactions") + ) + sub_transaction_parents = [ + parent + for parent, exported in ( + ("transaction", export_transactions), + ("installment_plan", export_installment_plans), + ("recurring_transaction", export_recurring_transactions), + ("quick_transaction", export_quick_transactions), + ) + if exported + ] + if sub_transaction_parents: + exports.append( + ( + SubTransactionResource(parents=sub_transaction_parents).export(), + "sub_transactions", + ) + ) if export_exchange_rates_services: exports.append( (ExchangeRateServiceResource().export(), "automatic_exchange_rates") @@ -250,7 +276,9 @@ def process_imports(request, cleaned_data): ("exchange_rates", ExchangeRateResource), ("installment_plans", InstallmentPlanResource), ("recurring_transactions", RecurringTransactionResource), + ("quick_transactions", QuickTransactionResource), ("transactions", TransactionResource), + ("sub_transactions", SubTransactionResource), ("bank_sync_services", BankSyncServiceResource), ("bank_sync_accounts", BankSyncAccountResource), ("dca_strategies", DCAStrategyResource), From a970c99e1274ba74e9ce54b5596db56e481f8a21 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 14 Nov 2026 02:13:22 -0300 Subject: [PATCH 17/24] chore(demo): add sub-transaction examples to the demo data --- .../management/commands/load_demo_data.py | 25 ++++++++++++++++--- app/apps/common/tests/test_demo_data.py | 22 +++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/app/apps/common/management/commands/load_demo_data.py b/app/apps/common/management/commands/load_demo_data.py index 8455e0c1..b17b86c1 100644 --- a/app/apps/common/management/commands/load_demo_data.py +++ b/app/apps/common/management/commands/load_demo_data.py @@ -118,6 +118,12 @@ class Command(BaseCommand): out.save() return out, inc + def split(self, owner, *parts): + """Breaks `owner` into named parts; call before it generates transactions.""" + for name, amount in parts: + owner.sub_transactions.create(name=name, amount=Decimal(amount)) + return owner + def rate(self, series, months): return series[months + HISTORY_MONTHS] @@ -278,6 +284,7 @@ class Command(BaseCommand): notes="12 interest-free installments on the credit card.", ) laptop.entities.set([self.ents["BuyMore"]]) + self.split(laptop, ("Laptop", "99.90"), ("Extended warranty", "8.35")) laptop.create_transactions() dental = InstallmentPlan.objects.create( account=checking, type=EX, description="Dental treatment", @@ -289,7 +296,8 @@ class Command(BaseCommand): # Recurring transactions def recurring(account, amount, description, category, start, entity=None, - recurrence=RecurringTransaction.RecurrenceType.MONTH, paused=False): + recurrence=RecurringTransaction.RecurrenceType.MONTH, paused=False, + parts=()): r = RecurringTransaction.objects.create( account=account, type=EX, amount=amount, description=description, category=self.cats[category], start_date=start, recurrence_type=recurrence, @@ -297,6 +305,7 @@ class Command(BaseCommand): ) if entity: r.entities.set([self.ents[entity]]) + self.split(r, *parts) if not paused: r.create_upcoming_transactions() return r @@ -304,7 +313,8 @@ class Command(BaseCommand): recurring(card, Decimal("15.99"), "StreamFlix", "Subscriptions", self.day(-HISTORY_MONTHS, 3), "StreamFlix") recurring(checking, Decimal("59.99"), "Internet", "Utilities", - self.day(-HISTORY_MONTHS, 15), "FiberNet") + self.day(-HISTORY_MONTHS, 15), "FiberNet", + parts=[("Internet plan", "49.99"), ("Router rental", "10.00")]) recurring(checking, Decimal("39.90"), "Gym membership", "Health", self.day(-HISTORY_MONTHS, 2), "Iron Gym") recurring(card, Decimal("14.99"), "Domain renewal", "Subscriptions", @@ -458,8 +468,9 @@ class Command(BaseCommand): self.transfer(stock_acc, checking, Decimal("3"), self.day(-2, 21), "Sell AAPL", to_amount=q(3 * self.rate(aapl_usd, -2)), mute=False, category="Investments") - self.tx(retirement, EX, Decimal("45.00"), self.day(-6, 30), "Annual management fee", - "Fees") + fee = self.tx(retirement, EX, Decimal("45.00"), self.day(-6, 30), + "Annual management fee", "Fees") + self.split(fee, ("Management fee", "40.00"), ("Custody fee", "5.00")) for m, spent in ((-9, 1500), (-3, 800)): self.transfer(checking, gold_acc, Decimal(spent), self.day(m, 12), "Buy gold", to_amount=q(Decimal(spent) / self.rate(gold_usd, m)), mute=False, @@ -489,6 +500,11 @@ class Command(BaseCommand): notes="Very old transactions are no problem.") self.transfer(old_bank, checking, Decimal("1200.00"), self.day(-HISTORY_MONTHS, 3), "Closing old bank account", category="Transfers") + # One receipt, split into what was bought + shop = self.tx(card, EX, Decimal("87.35"), self.day(-1, 24), "Big grocery shop", + "Groceries", ["essentials", "home"], ["Fresh Market"]) + self.split(shop, ("Produce", "24.80"), ("Meat & fish", "38.15"), + ("Household supplies", "16.40"), ("Snacks", "8.00")) # Balance reconciliation: the wallet had less cash than recorded self.tx(cash, EX, Decimal("12.40"), self.day(-2, 28), "Balance reconciliation") @@ -511,6 +527,7 @@ class Command(BaseCommand): description="Lunch", category=self.cats["Dining"], ) lunch.tags.set([self.tags["work"]]) + self.split(lunch, ("Meal", "11.90"), ("Tip", "2.00")) # Rules run on transactions you create or edit ride = TransactionRule.objects.create( diff --git a/app/apps/common/tests/test_demo_data.py b/app/apps/common/tests/test_demo_data.py index 54eeb246..7a54625e 100644 --- a/app/apps/common/tests/test_demo_data.py +++ b/app/apps/common/tests/test_demo_data.py @@ -10,7 +10,12 @@ from apps.accounts.models import Account from apps.common.middleware.thread_local import delete_current_user, write_current_user from apps.dca.models import DCAStrategy from apps.investments.services import get_holding_performance -from apps.transactions.models import Transaction +from apps.transactions.models import ( + InstallmentPlan, + QuickTransaction, + RecurringTransaction, + Transaction, +) @override_settings( @@ -73,6 +78,21 @@ class LoadDemoDataTests(TestCase): self.assertNotEqual(apple.realized, 0) # partial sale self.assertTrue(perfs["Retirement Fund"].results) # gains and losses + def test_sub_transactions_add_up(self): + self.load(date(2031, 7, 14)) + owners = [ + *Transaction.all_objects.filter(sub_transactions__isnull=False).distinct(), + *RecurringTransaction.all_objects.filter(sub_transactions__isnull=False).distinct(), + *QuickTransaction.objects.filter(sub_transactions__isnull=False).distinct(), + ] + plans = InstallmentPlan.all_objects.filter(sub_transactions__isnull=False).distinct() + self.assertTrue(plans) + self.assertGreater(len(owners), len(plans)) + for owner in [*owners, *plans]: + with self.subTest(owner=str(owner)): + amount = getattr(owner, "installment_amount", None) or owner.amount + self.assertEqual(sum(s.amount for s in owner.sub_transactions.all()), amount) + def test_running_twice_is_a_no_op(self): self.load(date(2031, 7, 14)) count = Transaction.all_objects.count() From 11c9d60954648fce749de725e36130e1e841825c Mon Sep 17 00:00:00 2001 From: eitchtee <10510126+eitchtee@users.noreply.github.com> Date: Sat, 14 Nov 2026 05:38:09 +0000 Subject: [PATCH 18/24] chore(locale): update translation files [skip ci] Automatically generated by Django makemessages workflow --- app/locale/de/LC_MESSAGES/django.po | 687 +++++++++++----------- app/locale/en/LC_MESSAGES/django.po | 679 +++++++++++----------- app/locale/es/LC_MESSAGES/django.po | 687 +++++++++++----------- app/locale/fr/LC_MESSAGES/django.po | 687 +++++++++++----------- app/locale/hu/LC_MESSAGES/django.po | 685 +++++++++++----------- app/locale/id/LC_MESSAGES/django.po | 678 +++++++++++----------- app/locale/it/LC_MESSAGES/django.po | 687 +++++++++++----------- app/locale/nl/LC_MESSAGES/django.po | 687 +++++++++++----------- app/locale/pl/LC_MESSAGES/django.po | 688 ++++++++++++----------- app/locale/pt_BR/LC_MESSAGES/django.po | 687 +++++++++++----------- app/locale/ru/LC_MESSAGES/django.po | 688 ++++++++++++----------- app/locale/sv/LC_MESSAGES/django.po | 679 +++++++++++----------- app/locale/sw/LC_MESSAGES/django.po | 679 +++++++++++----------- app/locale/uk/LC_MESSAGES/django.po | 688 ++++++++++++----------- app/locale/zh_Hant/LC_MESSAGES/django.po | 686 +++++++++++----------- 15 files changed, 5457 insertions(+), 4815 deletions(-) diff --git a/app/locale/de/LC_MESSAGES/django.po b/app/locale/de/LC_MESSAGES/django.po index 094d9c8e..44536b1d 100644 --- a/app/locale/de/LC_MESSAGES/django.po +++ b/app/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-13 21:56+0000\n" +"POT-Creation-Date: 2026-11-14 05:38+0000\n" "PO-Revision-Date: 2026-08-10 12:57+0000\n" "Last-Translator: GitEbu \n" "Language-Team: German \n" "Language-Team: LANGUAGE \n" @@ -27,11 +27,11 @@ msgstr "" #: apps/currencies/forms.py:59 apps/currencies/forms.py:93 #: apps/currencies/forms.py:170 apps/dca/forms.py:51 apps/dca/forms.py:216 #: apps/import_app/forms.py:34 apps/rules/forms.py:60 apps/rules/forms.py:100 -#: apps/rules/forms.py:385 apps/transactions/forms.py:219 -#: apps/transactions/forms.py:452 apps/transactions/forms.py:571 -#: apps/transactions/forms.py:741 apps/transactions/forms.py:971 -#: apps/transactions/forms.py:1018 apps/transactions/forms.py:1046 -#: apps/transactions/forms.py:1077 apps/transactions/forms.py:1239 +#: apps/rules/forms.py:387 apps/transactions/forms.py:304 +#: apps/transactions/forms.py:538 apps/transactions/forms.py:657 +#: apps/transactions/forms.py:827 apps/transactions/forms.py:1060 +#: apps/transactions/forms.py:1108 apps/transactions/forms.py:1136 +#: apps/transactions/forms.py:1167 apps/transactions/forms.py:1330 #: apps/users/forms.py:264 apps/users/forms.py:422 #: templates/rules/fragments/transaction_rule/dry_run/updated.html:5 #: templates/rules/fragments/transaction_rule/view.html:128 @@ -43,11 +43,11 @@ msgstr "" #: apps/common/widgets/tom_select.py:16 apps/currencies/forms.py:65 #: apps/currencies/forms.py:99 apps/currencies/forms.py:176 #: apps/dca/forms.py:57 apps/dca/forms.py:222 apps/import_app/forms.py:40 -#: apps/rules/forms.py:66 apps/rules/forms.py:106 apps/rules/forms.py:391 -#: apps/transactions/forms.py:206 apps/transactions/forms.py:226 -#: apps/transactions/forms.py:459 apps/transactions/forms.py:977 -#: apps/transactions/forms.py:1024 apps/transactions/forms.py:1052 -#: apps/transactions/forms.py:1083 apps/transactions/forms.py:1245 +#: apps/rules/forms.py:66 apps/rules/forms.py:106 apps/rules/forms.py:393 +#: apps/transactions/forms.py:291 apps/transactions/forms.py:311 +#: apps/transactions/forms.py:545 apps/transactions/forms.py:1066 +#: apps/transactions/forms.py:1114 apps/transactions/forms.py:1142 +#: apps/transactions/forms.py:1173 apps/transactions/forms.py:1336 #: apps/users/forms.py:270 apps/users/forms.py:428 #: templates/mini_tools/simulator.html:177 #: templates/mini_tools/unit_price_calculator.html:168 @@ -70,29 +70,29 @@ msgstr "" #: apps/accounts/forms.py:206 apps/dca/forms.py:84 apps/dca/forms.py:91 #: apps/insights/forms.py:117 apps/insights/views.py:44 apps/rules/forms.py:181 -#: apps/rules/forms.py:197 apps/rules/models.py:44 apps/rules/models.py:311 -#: apps/transactions/forms.py:62 apps/transactions/forms.py:330 -#: apps/transactions/forms.py:510 apps/transactions/forms.py:607 -#: apps/transactions/forms.py:614 apps/transactions/forms.py:854 -#: apps/transactions/forms.py:1106 apps/transactions/models.py:358 -#: apps/transactions/models.py:765 apps/transactions/models.py:1021 -#: apps/transactions/models.py:1342 +#: apps/rules/forms.py:198 apps/rules/models.py:45 apps/rules/models.py:312 +#: apps/transactions/forms.py:145 apps/transactions/forms.py:415 +#: apps/transactions/forms.py:596 apps/transactions/forms.py:693 +#: apps/transactions/forms.py:700 apps/transactions/forms.py:942 +#: apps/transactions/forms.py:1196 apps/transactions/models.py:360 +#: apps/transactions/models.py:861 apps/transactions/models.py:1120 +#: apps/transactions/models.py:1445 #: templates/insights/fragments/month_by_month.html:84 #: templates/insights/fragments/year_by_year.html:52 msgid "Category" msgstr "" #: apps/accounts/forms.py:213 apps/dca/forms.py:100 apps/dca/forms.py:108 -#: apps/export_app/forms.py:43 apps/export_app/forms.py:142 -#: apps/insights/views.py:50 apps/rules/forms.py:184 apps/rules/forms.py:194 -#: apps/rules/models.py:45 apps/rules/models.py:315 -#: apps/transactions/filters.py:91 apps/transactions/filters.py:166 -#: apps/transactions/forms.py:70 apps/transactions/forms.py:338 -#: apps/transactions/forms.py:518 apps/transactions/forms.py:623 -#: apps/transactions/forms.py:631 apps/transactions/forms.py:847 -#: apps/transactions/forms.py:1099 apps/transactions/models.py:364 -#: apps/transactions/models.py:767 apps/transactions/models.py:1025 -#: apps/transactions/models.py:1348 templates/includes/sidebar.html:162 +#: apps/export_app/forms.py:43 apps/export_app/forms.py:149 +#: apps/insights/views.py:50 apps/rules/forms.py:184 apps/rules/forms.py:195 +#: apps/rules/models.py:46 apps/rules/models.py:316 +#: apps/transactions/filters.py:95 apps/transactions/filters.py:170 +#: apps/transactions/forms.py:153 apps/transactions/forms.py:423 +#: apps/transactions/forms.py:604 apps/transactions/forms.py:709 +#: apps/transactions/forms.py:717 apps/transactions/forms.py:935 +#: apps/transactions/forms.py:1189 apps/transactions/models.py:366 +#: apps/transactions/models.py:863 apps/transactions/models.py:1124 +#: apps/transactions/models.py:1451 templates/includes/sidebar.html:162 #: templates/insights/fragments/month_by_month.html:29 #: templates/insights/fragments/month_by_month.html:32 #: templates/insights/fragments/year_by_year.html:24 @@ -119,9 +119,9 @@ msgstr "" #: apps/accounts/forms.py:266 apps/currencies/forms.py:72 #: apps/dca/models.py:158 apps/rules/forms.py:176 apps/rules/forms.py:190 -#: apps/rules/models.py:38 apps/rules/models.py:279 -#: apps/transactions/forms.py:86 apps/transactions/forms.py:482 -#: apps/transactions/forms.py:652 apps/transactions/models.py:340 +#: apps/rules/models.py:38 apps/rules/models.py:280 +#: apps/transactions/forms.py:169 apps/transactions/forms.py:568 +#: apps/transactions/forms.py:738 apps/transactions/models.py:342 #: templates/dca/fragments/strategy/details.html:49 #: templates/exchange_rates/fragments/table.html:10 #: templates/exchange_rates_services/fragments/table.html:11 @@ -135,8 +135,9 @@ msgstr "" #: apps/accounts/models.py:19 apps/accounts/models.py:36 #: apps/accounts/models.py:84 apps/bank_sync/models.py:14 apps/dca/models.py:13 #: apps/import_app/models.py:20 apps/rules/models.py:13 -#: apps/transactions/models.py:250 apps/transactions/models.py:275 -#: apps/transactions/models.py:299 apps/transactions/models.py:1310 +#: apps/transactions/forms.py:64 apps/transactions/models.py:252 +#: apps/transactions/models.py:277 apps/transactions/models.py:301 +#: apps/transactions/models.py:726 apps/transactions/models.py:1413 #: apps/users/models.py:577 templates/account_groups/fragments/list.html:22 #: templates/accounts/fragments/list.html:22 #: templates/bank_sync/fragments/list.html:20 @@ -186,7 +187,7 @@ msgid "" "%(taken)s%%." msgstr "" -#: apps/accounts/models.py:74 apps/export_app/forms.py:139 +#: apps/accounts/models.py:74 apps/export_app/forms.py:146 #: templates/includes/sidebar.html:190 #: templates/investment_classes/fragments/list.html:9 #: templates/investment_classes/pages/index.html:4 @@ -293,11 +294,11 @@ msgstr "" #: apps/accounts/models.py:190 apps/bank_sync/models.py:89 #: apps/import_app/forms.py:50 apps/import_app/models.py:88 #: apps/rules/forms.py:173 apps/rules/forms.py:187 apps/rules/models.py:35 -#: apps/rules/models.py:267 apps/transactions/forms.py:82 -#: apps/transactions/forms.py:350 apps/transactions/forms.py:477 -#: apps/transactions/forms.py:839 apps/transactions/forms.py:1091 -#: apps/transactions/models.py:330 apps/transactions/models.py:725 -#: apps/transactions/models.py:1003 apps/transactions/models.py:1316 +#: apps/rules/models.py:268 apps/transactions/forms.py:165 +#: apps/transactions/forms.py:435 apps/transactions/forms.py:563 +#: apps/transactions/forms.py:927 apps/transactions/forms.py:1181 +#: apps/transactions/models.py:332 apps/transactions/models.py:821 +#: apps/transactions/models.py:1102 apps/transactions/models.py:1419 #: templates/import_app/fragments/runs/list.html:95 #: templates/installment_plans/fragments/table.html:17 #: templates/quick_transactions/fragments/list.html:14 @@ -307,8 +308,8 @@ msgid "Account" msgstr "" #: apps/accounts/models.py:191 apps/export_app/forms.py:19 -#: apps/export_app/forms.py:138 apps/transactions/filters.py:75 -#: apps/transactions/filters.py:149 templates/accounts/fragments/list.html:9 +#: apps/export_app/forms.py:145 apps/transactions/filters.py:79 +#: apps/transactions/filters.py:153 templates/accounts/fragments/list.html:9 #: templates/accounts/pages/index.html:4 #: templates/bank_sync/fragments/accounts.html:5 #: templates/bank_sync/fragments/list.html:22 @@ -387,27 +388,27 @@ msgstr "" msgid "Account balances have been reconciled successfully" msgstr "" -#: apps/api/fields/transactions.py:31 +#: apps/api/fields/transactions.py:32 msgid "Category with this ID does not exist." msgstr "" -#: apps/api/fields/transactions.py:41 +#: apps/api/fields/transactions.py:42 msgid "Invalid category data. Provide an ID or name." msgstr "" -#: apps/api/fields/transactions.py:74 +#: apps/api/fields/transactions.py:75 msgid "Tag with this ID does not exist." msgstr "" -#: apps/api/fields/transactions.py:84 +#: apps/api/fields/transactions.py:85 msgid "Invalid tag data. Provide an ID or name." msgstr "" -#: apps/api/fields/transactions.py:109 +#: apps/api/fields/transactions.py:110 msgid "Entity with this ID does not exist." msgstr "" -#: apps/api/fields/transactions.py:119 +#: apps/api/fields/transactions.py:120 msgid "Invalid entity data. Provide an ID or name." msgstr "" @@ -415,12 +416,22 @@ msgstr "" msgid "Only transaction imports can use an account." msgstr "" -#: apps/api/serializers/transactions.py:141 apps/dca/forms.py:298 -#: apps/transactions/models.py:975 +#: apps/api/serializers/transactions.py:58 +msgid "Transfers can't have sub-transactions." +msgstr "" + +#: apps/api/serializers/transactions.py:68 +msgid "" +"The amount is the sum of the sub-transactions; send sub_transactions instead." +msgstr "" + +#: apps/api/serializers/transactions.py:74 +#: apps/api/serializers/transactions.py:218 apps/dca/forms.py:298 +#: apps/transactions/models.py:1074 msgid "This field is required." msgstr "" -#: apps/api/serializers/transactions.py:205 +#: apps/api/serializers/transactions.py:286 msgid "Either 'date' or 'reference_date' must be provided." msgstr "" @@ -431,8 +442,8 @@ msgstr "" #: apps/bank_sync/forms.py:113 apps/bank_sync/models.py:76 #: apps/currencies/models.py:54 apps/export_app/forms.py:25 -#: apps/export_app/forms.py:140 apps/transactions/filters.py:82 -#: apps/transactions/filters.py:157 templates/currencies/fragments/list.html:9 +#: apps/export_app/forms.py:147 apps/transactions/filters.py:86 +#: apps/transactions/filters.py:161 templates/currencies/fragments/list.html:9 #: templates/currencies/pages/index.html:4 templates/includes/sidebar.html:196 #: templates/includes/sidebar.html:198 #: templates/monthly_overview/pages/overview.html:63 @@ -457,8 +468,8 @@ msgid "Service Type" msgstr "" #: apps/bank_sync/models.py:18 apps/currencies/models.py:130 -#: apps/transactions/filters.py:27 apps/transactions/models.py:254 -#: apps/transactions/models.py:278 apps/transactions/models.py:302 +#: apps/transactions/filters.py:28 apps/transactions/models.py:256 +#: apps/transactions/models.py:280 apps/transactions/models.py:304 #: templates/categories/fragments/list.html:16 #: templates/entities/fragments/list.html:16 #: templates/installment_plans/fragments/list.html:16 @@ -507,7 +518,7 @@ msgstr "" msgid "Bank Sync Service" msgstr "" -#: apps/bank_sync/models.py:51 apps/export_app/forms.py:154 +#: apps/bank_sync/models.py:51 apps/export_app/forms.py:163 msgid "Bank Sync Services" msgstr "" @@ -789,6 +800,7 @@ msgid "Now" msgstr "" #: apps/common/widgets/tom_select.py:14 +#: templates/transactions/widgets/sub_transaction_row.html:9 msgid "Remove" msgstr "" @@ -865,8 +877,8 @@ msgstr "" msgid "Auto" msgstr "" -#: apps/currencies/models.py:91 apps/export_app/forms.py:67 -#: apps/export_app/forms.py:152 templates/exchange_rates/fragments/list.html:10 +#: apps/currencies/models.py:91 apps/export_app/forms.py:73 +#: apps/export_app/forms.py:161 templates/exchange_rates/fragments/list.html:10 #: templates/exchange_rates/pages/index.html:4 #: templates/includes/sidebar.html:204 msgid "Exchange Rates" @@ -1015,25 +1027,25 @@ msgstr "" msgid "Create transaction" msgstr "" -#: apps/dca/forms.py:69 apps/transactions/forms.py:582 +#: apps/dca/forms.py:69 apps/transactions/forms.py:668 msgid "From Account" msgstr "" -#: apps/dca/forms.py:75 apps/transactions/forms.py:587 +#: apps/dca/forms.py:75 apps/transactions/forms.py:673 msgid "To Account" msgstr "" #: apps/dca/forms.py:117 apps/dca/forms.py:125 apps/export_app/forms.py:49 -#: apps/export_app/forms.py:143 apps/insights/views.py:57 -#: apps/rules/forms.py:185 apps/rules/forms.py:195 apps/rules/models.py:46 -#: apps/rules/models.py:307 apps/transactions/filters.py:96 -#: apps/transactions/filters.py:171 apps/transactions/forms.py:78 -#: apps/transactions/forms.py:346 apps/transactions/forms.py:526 -#: apps/transactions/forms.py:640 apps/transactions/forms.py:647 -#: apps/transactions/forms.py:862 apps/transactions/forms.py:1114 -#: apps/transactions/models.py:313 apps/transactions/models.py:369 -#: apps/transactions/models.py:770 apps/transactions/models.py:1028 -#: apps/transactions/models.py:1353 templates/entities/fragments/list.html:9 +#: apps/export_app/forms.py:150 apps/insights/views.py:57 +#: apps/rules/forms.py:185 apps/rules/forms.py:196 apps/rules/models.py:47 +#: apps/rules/models.py:308 apps/transactions/filters.py:100 +#: apps/transactions/filters.py:175 apps/transactions/forms.py:161 +#: apps/transactions/forms.py:431 apps/transactions/forms.py:612 +#: apps/transactions/forms.py:726 apps/transactions/forms.py:733 +#: apps/transactions/forms.py:950 apps/transactions/forms.py:1204 +#: apps/transactions/models.py:315 apps/transactions/models.py:371 +#: apps/transactions/models.py:866 apps/transactions/models.py:1127 +#: apps/transactions/models.py:1456 templates/entities/fragments/list.html:9 #: templates/entities/pages/index.html:4 templates/includes/sidebar.html:168 #: templates/insights/fragments/month_by_month.html:40 #: templates/insights/fragments/month_by_month.html:43 @@ -1068,8 +1080,8 @@ msgstr "" msgid "You must provide an account." msgstr "" -#: apps/dca/forms.py:322 apps/transactions/forms.py:780 -#: apps/transactions/models.py:978 +#: apps/dca/forms.py:322 apps/transactions/forms.py:866 +#: apps/transactions/models.py:1077 msgid "From and To accounts must be different." msgstr "" @@ -1087,10 +1099,10 @@ msgid "Payment Currency" msgstr "" #: apps/dca/models.py:26 apps/dca/models.py:181 apps/rules/forms.py:180 -#: apps/rules/forms.py:196 apps/rules/models.py:43 apps/rules/models.py:295 -#: apps/transactions/forms.py:504 apps/transactions/forms.py:668 -#: apps/transactions/models.py:354 apps/transactions/models.py:774 -#: apps/transactions/models.py:1031 apps/transactions/models.py:1338 +#: apps/rules/forms.py:197 apps/rules/models.py:44 apps/rules/models.py:296 +#: apps/transactions/forms.py:590 apps/transactions/forms.py:754 +#: apps/transactions/models.py:356 apps/transactions/models.py:870 +#: apps/transactions/models.py:1130 apps/transactions/models.py:1441 msgid "Notes" msgstr "" @@ -1098,7 +1110,7 @@ msgstr "" msgid "DCA Strategy" msgstr "" -#: apps/dca/models.py:35 apps/export_app/forms.py:166 +#: apps/dca/models.py:35 apps/export_app/forms.py:175 msgid "DCA Strategies" msgstr "" @@ -1118,7 +1130,7 @@ msgstr "" msgid "DCA Entry" msgstr "" -#: apps/dca/models.py:187 apps/export_app/forms.py:167 +#: apps/dca/models.py:187 apps/export_app/forms.py:176 msgid "DCA Entries" msgstr "" @@ -1146,14 +1158,14 @@ msgstr "" msgid "Entry deleted successfully" msgstr "" -#: apps/export_app/forms.py:13 apps/export_app/forms.py:137 +#: apps/export_app/forms.py:13 apps/export_app/forms.py:144 #: templates/includes/sidebar.html:247 templates/users/fragments/list.html:10 #: templates/users/pages/index.html:4 msgid "Users" msgstr "" -#: apps/export_app/forms.py:31 apps/export_app/forms.py:144 -#: apps/transactions/models.py:423 templates/includes/sidebar.html:81 +#: apps/export_app/forms.py:31 apps/export_app/forms.py:151 +#: apps/transactions/models.py:425 templates/includes/sidebar.html:81 #: templates/includes/sidebar.html:154 #: templates/recurring_transactions/fragments/list_transactions.html:5 #: templates/recurring_transactions/fragments/table.html:37 @@ -1161,9 +1173,9 @@ msgstr "" msgid "Transactions" msgstr "" -#: apps/export_app/forms.py:37 apps/export_app/forms.py:141 -#: apps/insights/views.py:43 apps/transactions/filters.py:86 -#: apps/transactions/filters.py:161 templates/categories/fragments/list.html:9 +#: apps/export_app/forms.py:37 apps/export_app/forms.py:148 +#: apps/insights/views.py:43 apps/transactions/filters.py:90 +#: apps/transactions/filters.py:165 templates/categories/fragments/list.html:9 #: templates/categories/pages/index.html:4 templates/includes/sidebar.html:156 #: templates/insights/fragments/month_by_month.html:18 #: templates/insights/fragments/month_by_month.html:21 @@ -1172,100 +1184,113 @@ msgstr "" msgid "Categories" msgstr "" -#: apps/export_app/forms.py:55 apps/export_app/forms.py:147 -#: apps/transactions/models.py:1068 templates/includes/sidebar.html:110 +#: apps/export_app/forms.py:55 apps/export_app/forms.py:155 +#: apps/transactions/models.py:1167 templates/includes/sidebar.html:110 #: templates/recurring_transactions/fragments/list.html:9 #: templates/recurring_transactions/pages/index.html:4 msgid "Recurring Transactions" msgstr "" -#: apps/export_app/forms.py:61 apps/export_app/forms.py:145 -#: apps/transactions/models.py:788 templates/includes/sidebar.html:104 +#: apps/export_app/forms.py:61 apps/export_app/forms.py:153 +#: apps/transactions/models.py:884 templates/includes/sidebar.html:104 #: templates/installment_plans/fragments/list.html:9 #: templates/installment_plans/pages/index.html:4 msgid "Installment Plans" msgstr "" -#: apps/export_app/forms.py:73 apps/export_app/forms.py:150 +#: apps/export_app/forms.py:67 apps/export_app/forms.py:157 +#: apps/transactions/models.py:1474 templates/includes/sidebar.html:98 +#: templates/quick_transactions/pages/index.html:5 +#: templates/quick_transactions/pages/index.html:15 +msgid "Quick Transactions" +msgstr "" + +#: apps/export_app/forms.py:79 apps/export_app/forms.py:159 #: templates/exchange_rates_services/fragments/list.html:10 #: templates/exchange_rates_services/pages/index.html:4 #: templates/includes/sidebar.html:232 msgid "Automatic Exchange Rates" msgstr "" -#: apps/export_app/forms.py:79 templates/bank_sync/fragments/list.html:8 +#: apps/export_app/forms.py:85 templates/bank_sync/fragments/list.html:8 #: templates/bank_sync/pages/index.html:4 templates/includes/sidebar.html:238 msgid "Bank Sync" msgstr "" -#: apps/export_app/forms.py:80 +#: apps/export_app/forms.py:86 msgid "Includes the providers' API keys" msgstr "" -#: apps/export_app/forms.py:86 templates/includes/sidebar.html:212 +#: apps/export_app/forms.py:92 templates/includes/sidebar.html:212 #: templates/rules/fragments/list.html:9 templates/rules/pages/index.html:4 msgid "Rules" msgstr "" -#: apps/export_app/forms.py:92 templates/cotton/transaction/item.html:66 +#: apps/export_app/forms.py:98 templates/cotton/transaction/item.html:68 msgid "DCA" msgstr "" -#: apps/export_app/forms.py:98 apps/export_app/forms.py:168 +#: apps/export_app/forms.py:104 apps/export_app/forms.py:177 #: templates/import_app/fragments/profiles/list.html:21 #: templates/import_app/pages/profiles_index.html:4 msgid "Import Profiles" msgstr "" -#: apps/export_app/forms.py:126 templates/export_app/fragments/export.html:5 +#: apps/export_app/forms.py:133 templates/export_app/fragments/export.html:5 #: templates/export_app/pages/index.html:13 msgid "Export" msgstr "" -#: apps/export_app/forms.py:134 +#: apps/export_app/forms.py:141 msgid "Import a ZIP file exported from WYGIWYH" msgstr "" -#: apps/export_app/forms.py:135 +#: apps/export_app/forms.py:142 msgid "ZIP File" msgstr "" -#: apps/export_app/forms.py:157 +#: apps/export_app/forms.py:152 apps/rules/forms.py:193 apps/rules/models.py:42 +#: apps/rules/models.py:320 apps/transactions/models.py:736 +#: templates/transactions/widgets/sub_transactions.html:39 +msgid "Sub-transactions" +msgstr "" + +#: apps/export_app/forms.py:166 msgid "Bank Sync Accounts" msgstr "" -#: apps/export_app/forms.py:159 apps/rules/models.py:27 +#: apps/export_app/forms.py:168 apps/rules/models.py:27 msgid "Transaction rules" msgstr "" -#: apps/export_app/forms.py:161 apps/rules/models.py:68 +#: apps/export_app/forms.py:170 apps/rules/models.py:69 msgid "Edit transaction action" msgstr "" -#: apps/export_app/forms.py:164 apps/rules/models.py:327 +#: apps/export_app/forms.py:173 apps/rules/models.py:332 msgid "Update or create transaction actions" msgstr "" -#: apps/export_app/forms.py:199 templates/cotton/transaction/item.html:325 +#: apps/export_app/forms.py:210 templates/cotton/transaction/item.html:327 #: templates/cotton/ui/deleted_transactions_action_bar.html:53 #: templates/export_app/fragments/restore.html:5 #: templates/export_app/pages/index.html:19 msgid "Restore" msgstr "" -#: apps/export_app/forms.py:209 +#: apps/export_app/forms.py:220 msgid "Please upload either a ZIP file or at least one CSV file" msgstr "" -#: apps/export_app/views.py:190 +#: apps/export_app/views.py:216 msgid "You have to select at least one export" msgstr "" -#: apps/export_app/views.py:210 +#: apps/export_app/views.py:236 msgid "Data restored successfully" msgstr "" -#: apps/export_app/views.py:222 +#: apps/export_app/views.py:248 msgid "" "There was an error restoring your data. Check the logs for more details." msgstr "" @@ -1352,7 +1377,7 @@ msgstr "" #: apps/insights/forms.py:118 apps/insights/utils/sankey.py:36 #: apps/insights/utils/sankey.py:167 apps/insights/views.py:45 -#: apps/transactions/filters.py:290 +#: apps/transactions/filters.py:294 #: templates/insights/fragments/month_by_month.html:119 #: templates/insights/fragments/year_by_year.html:73 msgid "Uncategorized" @@ -1409,24 +1434,24 @@ msgstr "" msgid "Tag" msgstr "" -#: apps/insights/views.py:52 apps/transactions/filters.py:299 +#: apps/insights/views.py:52 apps/transactions/filters.py:303 #: templates/insights/fragments/month_by_month.html:121 #: templates/insights/fragments/year_by_year.html:75 msgid "Untagged" msgstr "" -#: apps/insights/views.py:53 apps/transactions/models.py:611 +#: apps/insights/views.py:53 apps/transactions/models.py:632 #: templates/tags/fragments/table.html:69 msgid "No tags" msgstr "" -#: apps/insights/views.py:58 apps/transactions/models.py:312 +#: apps/insights/views.py:58 apps/transactions/models.py:314 #: templates/insights/fragments/month_by_month.html:88 #: templates/insights/fragments/year_by_year.html:56 msgid "Entity" msgstr "" -#: apps/insights/views.py:59 apps/transactions/filters.py:307 +#: apps/insights/views.py:59 apps/transactions/filters.py:311 #: templates/insights/fragments/month_by_month.html:123 #: templates/insights/fragments/year_by_year.html:77 msgid "No entity" @@ -1444,15 +1469,15 @@ msgstr "" msgid "Unclassified" msgstr "" -#: apps/investments/views.py:289 +#: apps/investments/views.py:290 msgid "Asset class added successfully" msgstr "" -#: apps/investments/views.py:297 +#: apps/investments/views.py:298 msgid "Asset class updated successfully" msgstr "" -#: apps/investments/views.py:318 +#: apps/investments/views.py:319 msgid "Asset class deleted successfully" msgstr "" @@ -1485,13 +1510,13 @@ msgstr "" msgid "Set field" msgstr "" -#: apps/rules/forms.py:77 templates/cotton/transaction/item.html:123 +#: apps/rules/forms.py:77 templates/cotton/transaction/item.html:125 #: templates/insights/fragments/sankey.html:101 msgid "To" msgstr "" #: apps/rules/forms.py:78 apps/rules/forms.py:158 apps/rules/models.py:20 -#: apps/rules/models.py:62 apps/rules/models.py:323 +#: apps/rules/models.py:63 apps/rules/models.py:328 #: templates/rules/fragments/list.html:23 msgid "Order" msgstr "" @@ -1509,36 +1534,37 @@ msgid "Operator" msgstr "" #: apps/rules/forms.py:174 apps/rules/forms.py:188 apps/rules/models.py:36 -#: apps/rules/models.py:271 apps/transactions/forms.py:468 -#: apps/transactions/models.py:337 apps/transactions/models.py:730 -#: apps/transactions/models.py:1009 apps/transactions/models.py:1323 +#: apps/rules/models.py:272 apps/transactions/forms.py:554 +#: apps/transactions/models.py:339 apps/transactions/models.py:826 +#: apps/transactions/models.py:1108 apps/transactions/models.py:1426 #: templates/mini_tools/simulator.html:63 msgid "Type" msgstr "" #: apps/rules/forms.py:175 apps/rules/forms.py:189 apps/rules/models.py:37 -#: apps/rules/models.py:275 apps/transactions/filters.py:22 -#: apps/transactions/forms.py:472 apps/transactions/forms.py:650 -#: apps/transactions/models.py:339 apps/transactions/models.py:1325 -#: templates/cotton/transaction/item.html:23 -#: templates/cotton/transaction/item.html:34 +#: apps/rules/models.py:276 apps/transactions/filters.py:23 +#: apps/transactions/forms.py:558 apps/transactions/forms.py:736 +#: apps/transactions/models.py:341 apps/transactions/models.py:1428 +#: templates/cotton/transaction/item.html:25 +#: templates/cotton/transaction/item.html:36 #: templates/transactions/widgets/paid_toggle_button.html:10 #: templates/transactions/widgets/unselectable_paid_toggle_button.html:13 msgid "Paid" msgstr "" #: apps/rules/forms.py:177 apps/rules/forms.py:191 apps/rules/models.py:39 -#: apps/rules/models.py:283 apps/transactions/forms.py:90 -#: apps/transactions/forms.py:488 apps/transactions/forms.py:655 -#: apps/transactions/forms.py:868 apps/transactions/models.py:341 -#: apps/transactions/models.py:748 apps/transactions/models.py:1033 +#: apps/rules/models.py:284 apps/transactions/forms.py:173 +#: apps/transactions/forms.py:574 apps/transactions/forms.py:741 +#: apps/transactions/forms.py:956 apps/transactions/models.py:343 +#: apps/transactions/models.py:844 apps/transactions/models.py:1132 msgid "Reference Date" msgstr "" #: apps/rules/forms.py:178 apps/rules/forms.py:192 apps/rules/models.py:41 -#: apps/rules/models.py:287 apps/transactions/forms.py:495 -#: apps/transactions/models.py:347 apps/transactions/models.py:1014 -#: apps/transactions/models.py:1331 +#: apps/rules/models.py:288 apps/transactions/forms.py:75 +#: apps/transactions/forms.py:581 apps/transactions/models.py:349 +#: apps/transactions/models.py:730 apps/transactions/models.py:1113 +#: apps/transactions/models.py:1434 #: templates/insights/fragments/sankey.html:102 #: templates/installment_plans/fragments/table.html:18 #: templates/mini_tools/simulator.html:70 @@ -1547,51 +1573,52 @@ msgstr "" msgid "Amount" msgstr "" -#: apps/rules/forms.py:179 apps/rules/forms.py:193 apps/rules/models.py:14 -#: apps/rules/models.py:42 apps/rules/models.py:291 -#: apps/transactions/forms.py:499 apps/transactions/forms.py:659 -#: apps/transactions/models.py:352 apps/transactions/models.py:732 -#: apps/transactions/models.py:1017 apps/transactions/models.py:1336 +#: apps/rules/forms.py:179 apps/rules/forms.py:194 apps/rules/models.py:14 +#: apps/rules/models.py:43 apps/rules/models.py:292 +#: apps/transactions/forms.py:585 apps/transactions/forms.py:745 +#: apps/transactions/models.py:354 apps/transactions/models.py:828 +#: apps/transactions/models.py:1116 apps/transactions/models.py:1439 msgid "Description" msgstr "" -#: apps/rules/forms.py:182 apps/rules/forms.py:198 apps/rules/models.py:47 -#: apps/rules/models.py:299 apps/transactions/models.py:399 -#: apps/transactions/models.py:1358 +#: apps/rules/forms.py:182 apps/rules/forms.py:199 apps/rules/models.py:48 +#: apps/rules/models.py:300 apps/transactions/models.py:401 +#: apps/transactions/models.py:1461 msgid "Internal Note" msgstr "" -#: apps/rules/forms.py:183 apps/rules/forms.py:199 apps/rules/models.py:48 -#: apps/rules/models.py:303 apps/transactions/models.py:401 -#: apps/transactions/models.py:1360 +#: apps/rules/forms.py:183 apps/rules/forms.py:200 apps/rules/models.py:49 +#: apps/rules/models.py:304 apps/transactions/models.py:403 +#: apps/transactions/models.py:1463 msgid "Internal ID" msgstr "" -#: apps/rules/forms.py:186 apps/rules/forms.py:200 apps/rules/models.py:40 -#: apps/rules/models.py:319 apps/transactions/forms.py:672 -#: apps/transactions/models.py:251 apps/transactions/models.py:342 -#: apps/transactions/models.py:1326 +#: apps/rules/forms.py:186 apps/rules/forms.py:201 apps/rules/models.py:40 +#: apps/rules/models.py:324 apps/transactions/forms.py:758 +#: apps/transactions/models.py:253 apps/transactions/models.py:344 +#: apps/transactions/models.py:1429 msgid "Mute" msgstr "" -#: apps/rules/forms.py:215 +#: apps/rules/forms.py:216 msgid "Search Criteria" msgstr "" -#: apps/rules/forms.py:360 +#: apps/rules/forms.py:361 msgid "Set Values" msgstr "" -#: apps/rules/forms.py:407 apps/rules/forms.py:442 apps/rules/forms.py:477 -#: apps/transactions/models.py:422 apps/transactions/models.py:667 +#: apps/rules/forms.py:409 apps/rules/forms.py:444 apps/rules/forms.py:479 +#: apps/transactions/models.py:424 apps/transactions/models.py:703 +#: apps/transactions/models.py:763 msgid "Transaction" msgstr "" -#: apps/rules/forms.py:411 apps/rules/forms.py:446 apps/rules/forms.py:481 +#: apps/rules/forms.py:413 apps/rules/forms.py:448 apps/rules/forms.py:483 msgid "Type to search for a transaction" msgstr "" -#: apps/rules/forms.py:422 apps/rules/forms.py:457 apps/rules/forms.py:491 +#: apps/rules/forms.py:424 apps/rules/forms.py:459 apps/rules/forms.py:493 #: templates/rules/fragments/transaction_rule/dry_run/created.html:5 #: templates/rules/fragments/transaction_rule/dry_run/deleted.html:5 #: templates/rules/fragments/transaction_rule/dry_run/updated.html:5 @@ -1611,15 +1638,15 @@ msgstr "" msgid "Transaction rule" msgstr "" -#: apps/rules/models.py:54 apps/rules/models.py:98 +#: apps/rules/models.py:55 apps/rules/models.py:99 msgid "Rule" msgstr "" -#: apps/rules/models.py:59 +#: apps/rules/models.py:60 msgid "Field" msgstr "" -#: apps/rules/models.py:61 templates/investments/fragments/charts.html:86 +#: apps/rules/models.py:62 templates/investments/fragments/charts.html:86 #: templates/investments/fragments/detail.html:68 #: templates/investments/fragments/detail.html:127 #: templates/investments/fragments/detail.html:245 @@ -1627,57 +1654,57 @@ msgstr "" msgid "Value" msgstr "" -#: apps/rules/models.py:69 +#: apps/rules/models.py:70 msgid "Edit transaction actions" msgstr "" -#: apps/rules/models.py:84 +#: apps/rules/models.py:85 msgid "is exactly" msgstr "" -#: apps/rules/models.py:85 +#: apps/rules/models.py:86 msgid "contains" msgstr "" -#: apps/rules/models.py:86 +#: apps/rules/models.py:87 msgid "starts with" msgstr "" -#: apps/rules/models.py:87 +#: apps/rules/models.py:88 msgid "ends with" msgstr "" -#: apps/rules/models.py:88 +#: apps/rules/models.py:89 msgid "equals" msgstr "" -#: apps/rules/models.py:89 +#: apps/rules/models.py:90 msgid "greater than" msgstr "" -#: apps/rules/models.py:90 +#: apps/rules/models.py:91 msgid "less than" msgstr "" -#: apps/rules/models.py:91 +#: apps/rules/models.py:92 msgid "greater than or equal" msgstr "" -#: apps/rules/models.py:92 +#: apps/rules/models.py:93 msgid "less than or equal" msgstr "" -#: apps/rules/models.py:102 +#: apps/rules/models.py:103 msgid "Filter" msgstr "" -#: apps/rules/models.py:105 +#: apps/rules/models.py:106 msgid "" "Generic expression to enable or disable execution. Should evaluate to True " "or False" msgstr "" -#: apps/rules/models.py:326 +#: apps/rules/models.py:331 msgid "Update or create transaction action" msgstr "" @@ -1721,8 +1748,8 @@ msgstr "" msgid "Update or Create Transaction action deleted successfully" msgstr "" -#: apps/transactions/filters.py:23 templates/cotton/transaction/item.html:23 -#: templates/cotton/transaction/item.html:34 +#: apps/transactions/filters.py:24 templates/cotton/transaction/item.html:25 +#: templates/cotton/transaction/item.html:36 #: templates/insights/fragments/overview/index.html:68 #: templates/net_worth/net_worth.html:39 templates/net_worth/net_worth.html:43 #: templates/transactions/widgets/paid_toggle_button.html:7 @@ -1730,170 +1757,170 @@ msgstr "" msgid "Projected" msgstr "" -#: apps/transactions/filters.py:28 templates/categories/fragments/table.html:18 +#: apps/transactions/filters.py:29 templates/categories/fragments/table.html:18 msgid "Muted" msgstr "" -#: apps/transactions/filters.py:63 apps/transactions/filters.py:140 +#: apps/transactions/filters.py:67 apps/transactions/filters.py:144 msgid "Content" msgstr "" -#: apps/transactions/filters.py:69 +#: apps/transactions/filters.py:73 msgid "Transaction Type" msgstr "" -#: apps/transactions/filters.py:107 +#: apps/transactions/filters.py:111 msgid "Mute Status" msgstr "" -#: apps/transactions/filters.py:112 +#: apps/transactions/filters.py:116 msgid "Date from" msgstr "" -#: apps/transactions/filters.py:117 apps/transactions/filters.py:127 +#: apps/transactions/filters.py:121 apps/transactions/filters.py:131 msgid "Until" msgstr "" -#: apps/transactions/filters.py:122 +#: apps/transactions/filters.py:126 msgid "Reference date from" msgstr "" -#: apps/transactions/filters.py:132 +#: apps/transactions/filters.py:136 msgid "Amount min" msgstr "" -#: apps/transactions/filters.py:137 +#: apps/transactions/filters.py:141 msgid "Amount max" msgstr "" -#: apps/transactions/filters.py:236 +#: apps/transactions/filters.py:240 msgid "Include" msgstr "" -#: apps/transactions/filters.py:241 +#: apps/transactions/filters.py:245 msgid "Exclude" msgstr "" -#: apps/transactions/filters.py:289 +#: apps/transactions/filters.py:293 msgid "Categorized" msgstr "" -#: apps/transactions/filters.py:299 +#: apps/transactions/filters.py:303 msgid "Tagged" msgstr "" -#: apps/transactions/filters.py:306 +#: apps/transactions/filters.py:310 msgid "Any entity" msgstr "" -#: apps/transactions/forms.py:192 +#: apps/transactions/forms.py:277 msgid "More" msgstr "" -#: apps/transactions/forms.py:229 +#: apps/transactions/forms.py:314 msgid "Save and add similar" msgstr "" -#: apps/transactions/forms.py:234 +#: apps/transactions/forms.py:319 msgid "Save and add another" msgstr "" -#: apps/transactions/forms.py:271 templates/cotton/transaction/item.html:184 +#: apps/transactions/forms.py:356 templates/cotton/transaction/item.html:186 #: templates/transactions/fragments/attachments.html:4 msgid "Attachments" msgstr "" -#: apps/transactions/forms.py:272 +#: apps/transactions/forms.py:357 msgid "" "Files are private and only visible to users with access to this transaction." msgstr "" -#: apps/transactions/forms.py:283 +#: apps/transactions/forms.py:368 msgid "Upload" msgstr "" -#: apps/transactions/forms.py:355 apps/transactions/forms.py:1120 -#: apps/transactions/models.py:947 +#: apps/transactions/forms.py:440 apps/transactions/forms.py:1210 +#: apps/transactions/models.py:1046 msgid "To account" msgstr "" -#: apps/transactions/forms.py:382 apps/transactions/forms.py:675 +#: apps/transactions/forms.py:467 apps/transactions/forms.py:761 msgid "Muted transactions won't be displayed on monthly summaries" msgstr "" -#: apps/transactions/forms.py:594 +#: apps/transactions/forms.py:680 msgid "From Amount" msgstr "" -#: apps/transactions/forms.py:599 +#: apps/transactions/forms.py:685 msgid "To Amount" msgstr "" -#: apps/transactions/forms.py:741 apps/transactions/models.py:992 -#: apps/transactions/models.py:1303 templates/cotton/transaction/item.html:52 -#: templates/cotton/transaction/item.html:60 -#: templates/cotton/transaction/item.html:270 -#: templates/cotton/transaction/item.html:302 +#: apps/transactions/forms.py:827 apps/transactions/models.py:1091 +#: apps/transactions/models.py:1406 templates/cotton/transaction/item.html:54 +#: templates/cotton/transaction/item.html:62 +#: templates/cotton/transaction/item.html:272 +#: templates/cotton/transaction/item.html:304 #: templates/cotton/ui/quick_transactions_buttons.html:40 #: templates/cotton/ui/transactions_fab.html:44 msgid "Transfer" msgstr "" -#: apps/transactions/forms.py:1005 +#: apps/transactions/forms.py:1095 msgid "Tag name" msgstr "" -#: apps/transactions/forms.py:1033 +#: apps/transactions/forms.py:1123 msgid "Entity name" msgstr "" -#: apps/transactions/forms.py:1061 +#: apps/transactions/forms.py:1151 msgid "Category name" msgstr "" -#: apps/transactions/forms.py:1063 +#: apps/transactions/forms.py:1153 msgid "Muted categories won't be displayed on monthly summaries" msgstr "" -#: apps/transactions/forms.py:1228 +#: apps/transactions/forms.py:1319 msgid "future transactions" msgstr "" -#: apps/transactions/forms.py:1255 +#: apps/transactions/forms.py:1346 msgid "End date should be after the start date" msgstr "" -#: apps/transactions/models.py:256 +#: apps/transactions/models.py:258 msgid "" "Deactivated categories won't be able to be selected when creating new " "transactions" msgstr "" -#: apps/transactions/models.py:264 +#: apps/transactions/models.py:266 msgid "Transaction Category" msgstr "" -#: apps/transactions/models.py:265 +#: apps/transactions/models.py:267 msgid "Transaction Categories" msgstr "" -#: apps/transactions/models.py:280 +#: apps/transactions/models.py:282 msgid "" "Deactivated tags won't be able to be selected when creating new transactions" msgstr "" -#: apps/transactions/models.py:288 apps/transactions/models.py:289 +#: apps/transactions/models.py:290 apps/transactions/models.py:291 msgid "Transaction Tags" msgstr "" -#: apps/transactions/models.py:304 +#: apps/transactions/models.py:306 msgid "" "Deactivated entities won't be able to be selected when creating new " "transactions" msgstr "" -#: apps/transactions/models.py:324 apps/transactions/models.py:991 -#: apps/transactions/models.py:1302 +#: apps/transactions/models.py:326 apps/transactions/models.py:1090 +#: apps/transactions/models.py:1405 #: templates/calendar_view/fragments/list.html:42 #: templates/calendar_view/fragments/list.html:44 #: templates/calendar_view/fragments/list.html:52 @@ -1905,14 +1932,14 @@ msgstr "" #: templates/investments/fragments/detail.html:71 #: templates/investments/fragments/detail.html:175 #: templates/investments/fragments/detail.html:227 -#: templates/investments/fragments/detail.html:318 +#: templates/investments/fragments/detail.html:326 #: templates/mini_tools/simulator.html:66 #: templates/monthly_overview/fragments/monthly_summary.html:42 msgid "Income" msgstr "" -#: apps/transactions/models.py:325 apps/transactions/models.py:993 -#: apps/transactions/models.py:1304 +#: apps/transactions/models.py:327 apps/transactions/models.py:1092 +#: apps/transactions/models.py:1407 #: templates/calendar_view/fragments/list.html:46 #: templates/calendar_view/fragments/list.html:48 #: templates/calendar_view/fragments/list.html:56 @@ -1924,192 +1951,190 @@ msgstr "" msgid "Expense" msgstr "" -#: apps/transactions/models.py:380 apps/transactions/models.py:787 -#: templates/cotton/transaction/item.html:260 -#: templates/cotton/transaction/item.html:287 -#: templates/cotton/transaction/item.html:297 +#: apps/transactions/models.py:382 apps/transactions/models.py:883 +#: templates/cotton/transaction/item.html:262 +#: templates/cotton/transaction/item.html:289 +#: templates/cotton/transaction/item.html:299 msgid "Installment Plan" msgstr "" -#: apps/transactions/models.py:389 apps/transactions/models.py:1067 -#: templates/cotton/transaction/item.html:250 -#: templates/cotton/transaction/item.html:280 +#: apps/transactions/models.py:391 apps/transactions/models.py:1166 +#: templates/cotton/transaction/item.html:252 +#: templates/cotton/transaction/item.html:282 msgid "Recurring Transaction" msgstr "" -#: apps/transactions/models.py:397 +#: apps/transactions/models.py:399 msgid "Linked Transaction" msgstr "" -#: apps/transactions/models.py:405 +#: apps/transactions/models.py:407 msgid "Deleted" msgstr "" -#: apps/transactions/models.py:410 +#: apps/transactions/models.py:412 msgid "Deleted At" msgstr "" -#: apps/transactions/models.py:518 +#: apps/transactions/models.py:521 msgid "A transfer needs one expense and one income." msgstr "" -#: apps/transactions/models.py:520 +#: apps/transactions/models.py:523 msgid "A transfer needs two different accounts." msgstr "" -#: apps/transactions/models.py:524 +#: apps/transactions/models.py:527 msgid "This transaction is already part of another transfer." msgstr "" -#: apps/transactions/models.py:613 +#: apps/transactions/models.py:634 msgid "No category" msgstr "" -#: apps/transactions/models.py:615 +#: apps/transactions/models.py:636 msgid "No description" msgstr "" -#: apps/transactions/models.py:672 +#: apps/transactions/models.py:735 +msgid "Sub-transaction" +msgstr "" + +#: apps/transactions/models.py:768 msgid "File" msgstr "" -#: apps/transactions/models.py:674 +#: apps/transactions/models.py:770 msgid "Original Name" msgstr "" -#: apps/transactions/models.py:676 +#: apps/transactions/models.py:772 msgid "Content Type" msgstr "" -#: apps/transactions/models.py:678 +#: apps/transactions/models.py:774 msgid "Size" msgstr "" -#: apps/transactions/models.py:683 +#: apps/transactions/models.py:779 msgid "Uploaded By" msgstr "" -#: apps/transactions/models.py:688 +#: apps/transactions/models.py:784 msgid "Transaction Attachment" msgstr "" -#: apps/transactions/models.py:689 +#: apps/transactions/models.py:785 msgid "Transaction Attachments" msgstr "" -#: apps/transactions/models.py:719 templates/includes/sidebar.html:57 +#: apps/transactions/models.py:815 templates/includes/sidebar.html:57 msgid "Yearly" msgstr "" -#: apps/transactions/models.py:720 apps/users/models.py:469 +#: apps/transactions/models.py:816 apps/users/models.py:469 #: templates/includes/sidebar.html:51 msgid "Monthly" msgstr "" -#: apps/transactions/models.py:721 +#: apps/transactions/models.py:817 msgid "Weekly" msgstr "" -#: apps/transactions/models.py:722 +#: apps/transactions/models.py:818 msgid "Daily" msgstr "" -#: apps/transactions/models.py:735 +#: apps/transactions/models.py:831 msgid "Number of Installments" msgstr "" -#: apps/transactions/models.py:740 +#: apps/transactions/models.py:836 msgid "Installment Start" msgstr "" -#: apps/transactions/models.py:741 +#: apps/transactions/models.py:837 msgid "The installment number to start counting from" msgstr "" -#: apps/transactions/models.py:746 apps/transactions/models.py:1037 +#: apps/transactions/models.py:842 apps/transactions/models.py:1136 msgid "Start Date" msgstr "" -#: apps/transactions/models.py:750 apps/transactions/models.py:1038 +#: apps/transactions/models.py:846 apps/transactions/models.py:1137 msgid "End Date" msgstr "" -#: apps/transactions/models.py:755 +#: apps/transactions/models.py:851 msgid "Recurrence" msgstr "" -#: apps/transactions/models.py:758 +#: apps/transactions/models.py:854 msgid "Installment Amount" msgstr "" -#: apps/transactions/models.py:777 apps/transactions/models.py:1057 +#: apps/transactions/models.py:873 apps/transactions/models.py:1156 msgid "Add description to transactions" msgstr "" -#: apps/transactions/models.py:780 apps/transactions/models.py:1060 +#: apps/transactions/models.py:876 apps/transactions/models.py:1159 msgid "Add notes to transactions" msgstr "" -#: apps/transactions/models.py:954 +#: apps/transactions/models.py:1053 msgid "To amount" msgstr "" -#: apps/transactions/models.py:955 +#: apps/transactions/models.py:1054 msgid "Leave empty to use the same amount" msgstr "" -#: apps/transactions/models.py:996 templates/mini_tools/simulator.html:129 +#: apps/transactions/models.py:1095 templates/mini_tools/simulator.html:129 msgid "day(s)" msgstr "" -#: apps/transactions/models.py:997 templates/mini_tools/simulator.html:130 +#: apps/transactions/models.py:1096 templates/mini_tools/simulator.html:130 msgid "week(s)" msgstr "" -#: apps/transactions/models.py:998 templates/mini_tools/simulator.html:131 +#: apps/transactions/models.py:1097 templates/mini_tools/simulator.html:131 msgid "month(s)" msgstr "" -#: apps/transactions/models.py:999 templates/mini_tools/simulator.html:132 +#: apps/transactions/models.py:1098 templates/mini_tools/simulator.html:132 msgid "year(s)" msgstr "" -#: apps/transactions/models.py:1001 +#: apps/transactions/models.py:1100 #: templates/recurring_transactions/fragments/list.html:18 msgid "Paused" msgstr "" -#: apps/transactions/models.py:1040 +#: apps/transactions/models.py:1139 msgid "Recurrence Type" msgstr "" -#: apps/transactions/models.py:1043 +#: apps/transactions/models.py:1142 msgid "Recurrence Interval" msgstr "" -#: apps/transactions/models.py:1046 +#: apps/transactions/models.py:1145 msgid "Keep at most" msgstr "" -#: apps/transactions/models.py:1050 +#: apps/transactions/models.py:1149 msgid "Last Generated Date" msgstr "" -#: apps/transactions/models.py:1053 +#: apps/transactions/models.py:1152 msgid "Last Generated Reference Date" msgstr "" -#: apps/transactions/models.py:1370 templates/cotton/transaction/item.html:243 +#: apps/transactions/models.py:1473 templates/cotton/transaction/item.html:245 #: templates/cotton/ui/transactions_fab.html:59 msgid "Quick Transaction" msgstr "" -#: apps/transactions/models.py:1371 templates/includes/sidebar.html:98 -#: templates/quick_transactions/pages/index.html:5 -#: templates/quick_transactions/pages/index.html:15 -msgid "Quick Transactions" -msgstr "" - #: apps/transactions/validators.py:8 #, python-format msgid "%(value)s has too many decimal places. Maximum is 30." @@ -2120,43 +2145,43 @@ msgstr "" msgid "%(value)s is not a non-negative number" msgstr "" -#: apps/transactions/views/actions.py:60 +#: apps/transactions/views/actions.py:61 #, python-format msgid "%(count)s transaction marked as paid" msgid_plural "%(count)s transactions marked as paid" msgstr[0] "" msgstr[1] "" -#: apps/transactions/views/actions.py:83 +#: apps/transactions/views/actions.py:84 #, python-format msgid "%(count)s transaction marked as not paid" msgid_plural "%(count)s transactions marked as not paid" msgstr[0] "" msgstr[1] "" -#: apps/transactions/views/actions.py:107 +#: apps/transactions/views/actions.py:108 #, python-format msgid "%(count)s transaction deleted successfully" msgid_plural "%(count)s transactions deleted successfully" msgstr[0] "" msgstr[1] "" -#: apps/transactions/views/actions.py:141 +#: apps/transactions/views/actions.py:142 #, python-format msgid "%(count)s transaction restored successfully" msgid_plural "%(count)s transactions restored successfully" msgstr[0] "" msgstr[1] "" -#: apps/transactions/views/actions.py:173 -#: apps/transactions/views/transactions.py:421 +#: apps/transactions/views/actions.py:174 +#: apps/transactions/views/transactions.py:423 #, python-format msgid "%(count)s transaction updated successfully" msgid_plural "%(count)s transactions updated successfully" msgstr[0] "" msgstr[1] "" -#: apps/transactions/views/actions.py:246 +#: apps/transactions/views/actions.py:247 #, python-format msgid "%(count)s transaction duplicated successfully" msgid_plural "%(count)s transactions duplicated successfully" @@ -2175,38 +2200,38 @@ msgstr "" msgid "Category deleted successfully" msgstr "" -#: apps/transactions/views/conversions.py:73 +#: apps/transactions/views/conversions.py:77 #: apps/transactions/views/quick_transactions.py:46 apps/users/views.py:252 msgid "Item added successfully" msgstr "" -#: apps/transactions/views/conversions.py:92 +#: apps/transactions/views/conversions.py:97 msgid "Convert into quick transaction" msgstr "" -#: apps/transactions/views/conversions.py:109 +#: apps/transactions/views/conversions.py:114 #: apps/transactions/views/recurring_transactions.py:112 msgid "Recurring Transaction added successfully" msgstr "" -#: apps/transactions/views/conversions.py:130 +#: apps/transactions/views/conversions.py:136 msgid "Convert into recurring transaction" msgstr "" -#: apps/transactions/views/conversions.py:149 +#: apps/transactions/views/conversions.py:155 #: apps/transactions/views/installment_plans.py:87 msgid "Installment Plan added successfully" msgstr "" -#: apps/transactions/views/conversions.py:168 +#: apps/transactions/views/conversions.py:175 msgid "Convert into installment plan" msgstr "" -#: apps/transactions/views/conversions.py:188 +#: apps/transactions/views/conversions.py:195 msgid "Transaction converted into a transfer" msgstr "" -#: apps/transactions/views/conversions.py:219 +#: apps/transactions/views/conversions.py:226 msgid "Convert into transfer" msgstr "" @@ -2242,7 +2267,7 @@ msgstr "" msgid "Item deleted successfully" msgstr "" -#: apps/transactions/views/quick_transactions.py:164 +#: apps/transactions/views/quick_transactions.py:165 #: apps/transactions/views/transactions.py:156 #: apps/transactions/views/transactions.py:343 msgid "Transaction added successfully" @@ -2292,23 +2317,23 @@ msgstr "" msgid "Transaction updated successfully" msgstr "" -#: apps/transactions/views/transactions.py:448 +#: apps/transactions/views/transactions.py:450 msgid "Transaction duplicated successfully" msgstr "" -#: apps/transactions/views/transactions.py:493 +#: apps/transactions/views/transactions.py:495 msgid "Transaction deleted successfully" msgstr "" -#: apps/transactions/views/transactions.py:523 +#: apps/transactions/views/transactions.py:525 msgid "Transaction restored successfully" msgstr "" -#: apps/transactions/views/transactions.py:549 +#: apps/transactions/views/transactions.py:551 msgid "Transfer added successfully" msgstr "" -#: apps/transactions/views/transactions.py:579 +#: apps/transactions/views/transactions.py:581 msgid "Transfer updated successfully" msgstr "" @@ -2626,7 +2651,7 @@ msgstr "" #: templates/accounts/fragments/list.html:37 #: templates/bank_sync/fragments/list.html:33 #: templates/categories/fragments/table.html:29 -#: templates/cotton/transaction/item.html:178 +#: templates/cotton/transaction/item.html:180 #: templates/cotton/ui/transactions_action_bar.html:56 #: templates/cotton/ui/transactions_action_bar.html:90 #: templates/currencies/fragments/list.html:34 @@ -2639,8 +2664,8 @@ msgstr "" #: templates/import_app/fragments/profiles/list.html:46 #: templates/installment_plans/fragments/table.html:28 #: templates/investment_classes/fragments/list.html:39 -#: templates/investments/fragments/detail.html:302 -#: templates/investments/fragments/detail.html:330 +#: templates/investments/fragments/detail.html:310 +#: templates/investments/fragments/detail.html:338 #: templates/quick_transactions/fragments/list.html:25 #: templates/recurring_transactions/fragments/table.html:30 #: templates/rules/fragments/transaction_rule/view.html:22 @@ -2677,8 +2702,8 @@ msgstr "" #: templates/accounts/fragments/list.html:71 #: templates/bank_sync/fragments/list.html:50 #: templates/categories/fragments/table.html:51 -#: templates/cotton/transaction/item.html:190 -#: templates/cotton/transaction/item.html:331 +#: templates/cotton/transaction/item.html:192 +#: templates/cotton/transaction/item.html:333 #: templates/cotton/ui/deleted_transactions_action_bar.html:57 #: templates/cotton/ui/transactions_action_bar.html:75 #: templates/cotton/ui/transactions_action_bar.html:107 @@ -2712,8 +2737,8 @@ msgstr "" #: templates/accounts/fragments/list.html:75 #: templates/bank_sync/fragments/list.html:54 #: templates/categories/fragments/table.html:56 -#: templates/cotton/transaction/item.html:192 -#: templates/cotton/transaction/item.html:337 +#: templates/cotton/transaction/item.html:194 +#: templates/cotton/transaction/item.html:339 #: templates/cotton/ui/deleted_transactions_action_bar.html:58 #: templates/cotton/ui/transactions_action_bar.html:76 #: templates/cotton/ui/transactions_action_bar.html:105 @@ -2744,8 +2769,8 @@ msgstr "" #: templates/account_groups/fragments/list.html:59 #: templates/accounts/fragments/list.html:76 #: templates/categories/fragments/table.html:57 -#: templates/cotton/transaction/item.html:193 -#: templates/cotton/transaction/item.html:338 +#: templates/cotton/transaction/item.html:195 +#: templates/cotton/transaction/item.html:340 #: templates/cotton/ui/deleted_transactions_action_bar.html:58 #: templates/cotton/ui/transactions_action_bar.html:76 #: templates/cotton/ui/transactions_action_bar.html:105 @@ -2768,8 +2793,8 @@ msgstr "" #: templates/accounts/fragments/list.html:77 #: templates/bank_sync/fragments/list.html:56 #: templates/categories/fragments/table.html:58 -#: templates/cotton/transaction/item.html:194 -#: templates/cotton/transaction/item.html:339 +#: templates/cotton/transaction/item.html:196 +#: templates/cotton/transaction/item.html:341 #: templates/currencies/fragments/list.html:46 #: templates/dca/fragments/strategy/details.html:77 #: templates/dca/fragments/strategy/list.html:44 @@ -2943,69 +2968,76 @@ msgstr "" msgid "Search" msgstr "" -#: templates/cotton/transaction/item.html:12 +#: templates/cotton/transaction/item.html:14 msgid "Select" msgstr "" -#: templates/cotton/transaction/item.html:123 +#: templates/cotton/transaction/item.html:125 #: templates/insights/fragments/sankey.html:100 msgid "From" msgstr "" -#: templates/cotton/transaction/item.html:207 -#: templates/cotton/transaction/item.html:218 -#: templates/cotton/transaction/item.html:228 +#: templates/cotton/transaction/item.html:209 +#: templates/cotton/transaction/item.html:220 +#: templates/cotton/transaction/item.html:230 msgid "Show on summaries" msgstr "" -#: templates/cotton/transaction/item.html:209 +#: templates/cotton/transaction/item.html:211 msgid "Controlled by account" msgstr "" -#: templates/cotton/transaction/item.html:220 +#: templates/cotton/transaction/item.html:222 msgid "Controlled by category" msgstr "" -#: templates/cotton/transaction/item.html:233 +#: templates/cotton/transaction/item.html:235 #: templates/includes/transactions_bulk_actions.html:15 msgid "Hide from summaries" msgstr "" -#: templates/cotton/transaction/item.html:237 +#: templates/cotton/transaction/item.html:239 msgid "Convert" msgstr "" -#: templates/cotton/transaction/item.html:252 -#: templates/cotton/transaction/item.html:262 -#: templates/cotton/transaction/item.html:272 +#: templates/cotton/transaction/item.html:254 +#: templates/cotton/transaction/item.html:264 +#: templates/cotton/transaction/item.html:274 msgid "Already part of a plan or recurrence" msgstr "" -#: templates/cotton/transaction/item.html:289 +#: templates/cotton/transaction/item.html:291 msgid "Not available for transfers" msgstr "" -#: templates/cotton/transaction/item.html:311 +#: templates/cotton/transaction/item.html:313 #: templates/includes/transactions_bulk_actions.html:22 msgid "Move to previous month" msgstr "" -#: templates/cotton/transaction/item.html:315 +#: templates/cotton/transaction/item.html:317 #: templates/includes/transactions_bulk_actions.html:28 msgid "Move to next month" msgstr "" -#: templates/cotton/transaction/item.html:318 +#: templates/cotton/transaction/item.html:320 #: templates/includes/transactions_bulk_actions.html:33 msgid "Move to today" msgstr "" -#: templates/cotton/transaction/item.html:322 +#: templates/cotton/transaction/item.html:324 #: templates/cotton/ui/transactions_action_bar.html:71 #: templates/cotton/ui/transactions_action_bar.html:98 msgid "Duplicate" msgstr "" +#: templates/cotton/transaction/item.html:373 +#, python-format +msgid "%(counter)s item" +msgid_plural "%(counter)s items" +msgstr[0] "" +msgstr[1] "" + #: templates/cotton/ui/account_card.html:10 #: templates/cotton/ui/currency_card.html:10 msgid "projected income" @@ -3637,6 +3669,7 @@ msgstr "" #: templates/insights/fragments/year_by_year.html:140 #: templates/investment_classes/fragments/list.html:65 #: templates/monthly_overview/fragments/monthly_summary.html:168 +#: templates/transactions/widgets/sub_transactions.html:55 msgid "Total" msgstr "" @@ -4039,11 +4072,11 @@ msgstr "" msgid "Loss, tax or fee" msgstr "" -#: templates/investments/fragments/detail.html:312 +#: templates/investments/fragments/detail.html:320 msgid "No movements yet" msgstr "" -#: templates/investments/fragments/detail.html:312 +#: templates/investments/fragments/detail.html:320 msgid "Use the + button to buy or contribute" msgstr "" @@ -4598,6 +4631,10 @@ msgstr "" msgid "Deleted transactions" msgstr "" +#: templates/transactions/widgets/sub_transactions.html:53 +msgid "Add sub-transaction" +msgstr "" + #: templates/transactions/widgets/unselectable_income_expense_toggle_buttons.html:11 #: templates/transactions/widgets/unselectable_paid_toggle_button.html:7 msgid "Unchanged" diff --git a/app/locale/es/LC_MESSAGES/django.po b/app/locale/es/LC_MESSAGES/django.po index 9a6ecaf2..79a982ee 100644 --- a/app/locale/es/LC_MESSAGES/django.po +++ b/app/locale/es/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-13 21:56+0000\n" +"POT-Creation-Date: 2026-11-14 05:38+0000\n" "PO-Revision-Date: 2026-07-10 04:57+0000\n" "Last-Translator: Juan David Afanador \n" "Language-Team: Spanish \n" "Language-Team: French \n" "Language-Team: Hungarian \n" "Language-Team: Italian \n" "Language-Team: Dutch \n" "Language-Team: Polish \n" "Language-Team: Portuguese (Brazil) \n" "Language-Team: Russian \n" "Language-Team: Swedish \n" "Language-Team: Swahili \n" "Language-Team: Ukrainian \n" "Language-Team: Chinese (Traditional Han script) Date: Sat, 14 Nov 2026 03:01:49 -0300 Subject: [PATCH 19/24] 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 --- app/apps/transactions/tests/test_views.py | 60 +++++++++++++++++++ .../transactions/views/installment_plans.py | 8 +-- .../views/recurring_transactions.py | 10 ++-- 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/app/apps/transactions/tests/test_views.py b/app/apps/transactions/tests/test_views.py index 8a9f00db..660111b5 100644 --- a/app/apps/transactions/tests/test_views.py +++ b/app/apps/transactions/tests/test_views.py @@ -380,3 +380,63 @@ class TransactionConvertViewTests(TestCase): self.assertEqual( self._get("transaction_convert_to_installment_plan").status_code, 404 ) + + +@override_settings( + STORAGES={ + "default": {"BACKEND": "django.core.files.storage.FileSystemStorage"}, + "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}, + }, + WHITENOISE_AUTOREFRESH=True, +) +class InstallmentRecurringIsolationTests(TestCase): + """Per-object plan views must 404 for objects on another user's private account.""" + + def setUp(self): + User = get_user_model() + owner = User.objects.create_user(email="owner@test.com", password="pw") + User.objects.create_user(email="other@test.com", password="pw") + self.client.login(username="other@test.com", password="pw") + + currency = Currency.objects.create(code="USD", name="US Dollar", decimal_places=2) + account = Account.all_objects.create(name="Private", currency=currency, owner=owner) + self.plan = InstallmentPlan.all_objects.create( + account=account, + type=Transaction.Type.EXPENSE, + description="Owner plan", + number_of_installments=3, + start_date=date(2025, 1, 1), + installment_amount=100, + ) + self.recurring = RecurringTransaction.all_objects.create( + account=account, + type=Transaction.Type.EXPENSE, + amount=50, + description="Owner recurring", + start_date=date(2025, 1, 1), + recurrence_type=RecurringTransaction.RecurrenceType.MONTH, + recurrence_interval=1, + ) + + def test_other_user_gets_404(self): + cases = [ + ("get", "installment_plan_transactions", "installment_plan_id", self.plan), + ("get", "installment_plan_edit", "installment_plan_id", self.plan), + ("get", "installment_plan_refresh", "installment_plan_id", self.plan), + ("delete", "installment_plan_delete", "installment_plan_id", self.plan), + ("get", "recurring_transaction_transactions", "recurring_transaction_id", self.recurring), + ("get", "recurring_transaction_edit", "recurring_transaction_id", self.recurring), + ("get", "recurring_transaction_toggle_pause", "recurring_transaction_id", self.recurring), + ("get", "recurring_transaction_finish", "recurring_transaction_id", self.recurring), + ("delete", "recurring_transaction_delete", "recurring_transaction_id", self.recurring), + ] + for method, name, kwarg, obj in cases: + with self.subTest(name=name): + url = reverse(name, kwargs={kwarg: obj.id}) + response = getattr(self.client, method)(url, HTTP_HX_REQUEST="true") + self.assertEqual(response.status_code, 404) + + self.assertTrue(InstallmentPlan.all_objects.filter(id=self.plan.id).exists()) + self.recurring.refresh_from_db() + self.assertFalse(self.recurring.is_paused) + self.assertIsNone(self.recurring.end_date) diff --git a/app/apps/transactions/views/installment_plans.py b/app/apps/transactions/views/installment_plans.py index 5f1fd192..c89b9cd5 100644 --- a/app/apps/transactions/views/installment_plans.py +++ b/app/apps/transactions/views/installment_plans.py @@ -66,7 +66,7 @@ def finished_installment_plans_list(request): @login_required @require_http_methods(["GET"]) def installment_plan_transactions(request, installment_plan_id): - installment_plan = get_object_or_404(InstallmentPlan, id=installment_plan_id) + installment_plan = get_object_or_404(InstallmentPlan.objects, id=installment_plan_id) transactions = installment_plan.transactions.prefetch_related("sub_transactions").order_by("reference_date", "id") return render( @@ -106,7 +106,7 @@ def installment_plan_add(request): @login_required @require_http_methods(["GET", "POST"]) def installment_plan_edit(request, installment_plan_id): - installment_plan = get_object_or_404(InstallmentPlan, id=installment_plan_id) + installment_plan = get_object_or_404(InstallmentPlan.objects, id=installment_plan_id) if request.method == "POST": form = InstallmentPlanForm(request.POST, instance=installment_plan) @@ -134,7 +134,7 @@ def installment_plan_edit(request, installment_plan_id): @login_required @require_http_methods(["GET"]) def installment_plan_refresh(request, installment_plan_id): - installment_plan = get_object_or_404(InstallmentPlan, id=installment_plan_id) + installment_plan = get_object_or_404(InstallmentPlan.objects, id=installment_plan_id) installment_plan.update_transactions() messages.success(request, _("Installment Plan refreshed successfully")) @@ -151,7 +151,7 @@ def installment_plan_refresh(request, installment_plan_id): @login_required @require_http_methods(["DELETE"]) def installment_plan_delete(request, installment_plan_id): - installment_plan = get_object_or_404(InstallmentPlan, id=installment_plan_id) + installment_plan = get_object_or_404(InstallmentPlan.objects, id=installment_plan_id) installment_plan.delete() diff --git a/app/apps/transactions/views/recurring_transactions.py b/app/apps/transactions/views/recurring_transactions.py index bca4fb18..e41386e7 100644 --- a/app/apps/transactions/views/recurring_transactions.py +++ b/app/apps/transactions/views/recurring_transactions.py @@ -88,7 +88,7 @@ def finished_recurring_transactions_list(request): @require_http_methods(["GET"]) def recurring_transaction_transactions(request, recurring_transaction_id): recurring_transaction = get_object_or_404( - RecurringTransaction, id=recurring_transaction_id + RecurringTransaction.objects, id=recurring_transaction_id ) transactions = recurring_transaction.transactions.collapse_transfers().prefetch_related("sub_transactions").order_by( "reference_date", "id" @@ -132,7 +132,7 @@ def recurring_transaction_add(request): @require_http_methods(["GET", "POST"]) def recurring_transaction_edit(request, recurring_transaction_id): recurring_transaction = get_object_or_404( - RecurringTransaction, id=recurring_transaction_id + RecurringTransaction.objects, id=recurring_transaction_id ) if request.method == "POST": @@ -162,7 +162,7 @@ def recurring_transaction_edit(request, recurring_transaction_id): @require_http_methods(["GET"]) def recurring_transaction_toggle_pause(request, recurring_transaction_id): recurring_transaction = get_object_or_404( - RecurringTransaction, id=recurring_transaction_id + RecurringTransaction.objects, id=recurring_transaction_id ) current_paused = recurring_transaction.is_paused recurring_transaction.is_paused = not current_paused @@ -201,7 +201,7 @@ def recurring_transaction_toggle_pause(request, recurring_transaction_id): @require_http_methods(["GET"]) def recurring_transaction_finish(request, recurring_transaction_id): recurring_transaction: RecurringTransaction = get_object_or_404( - RecurringTransaction, id=recurring_transaction_id + RecurringTransaction.objects, id=recurring_transaction_id ) today = timezone.localdate(timezone.now()) - relativedelta(days=1) @@ -227,7 +227,7 @@ def recurring_transaction_finish(request, recurring_transaction_id): @require_http_methods(["DELETE"]) def recurring_transaction_delete(request, recurring_transaction_id): recurring_transaction = get_object_or_404( - RecurringTransaction, id=recurring_transaction_id + RecurringTransaction.objects, id=recurring_transaction_id ) recurring_transaction.delete() From 66351aee495965d7f5ced8b8b275aebbf265c8d7 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 14 Nov 2026 03:18:37 -0300 Subject: [PATCH 20/24] 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. --- app/apps/common/forms.py | 6 ++++-- app/templates/accounts/fragments/share.html | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/apps/common/forms.py b/app/apps/common/forms.py index 9f6ca959..560af509 100644 --- a/app/apps/common/forms.py +++ b/app/apps/common/forms.py @@ -40,9 +40,11 @@ class SharedObjectForm(forms.Form): label=_("Visibility"), widget=TomSelect(clear_button=False), help_text=_( - "Private: Only shown for the owner and shared users. Only editable by the owner." + "Private: Only shown for the owner and shared users." "
    " - "Public: Shown for all users. Only editable by the owner." + "Public: Shown for all users." + "
    " + "Only the owner can edit, share or delete it." ), ) diff --git a/app/templates/accounts/fragments/share.html b/app/templates/accounts/fragments/share.html index 6e18189b..bdfb5bfe 100644 --- a/app/templates/accounts/fragments/share.html +++ b/app/templates/accounts/fragments/share.html @@ -5,6 +5,7 @@ {% block title %}{% translate 'Share settings' %}{% endblock %} {% block body %} +

    {% translate "Everyone who can see this account can add, edit and delete its transactions, installment plans and recurring transactions." %}

    {% crispy form %}
    From 93fa7b272ee870b445ba0bec0f6e31c13af302f9 Mon Sep 17 00:00:00 2001 From: eitchtee <10510126+eitchtee@users.noreply.github.com> Date: Sat, 14 Nov 2026 06:23:31 +0000 Subject: [PATCH 21/24] chore(locale): update translation files [skip ci] Automatically generated by Django makemessages workflow --- app/locale/de/LC_MESSAGES/django.po | 20 +++++++++++++++----- app/locale/en/LC_MESSAGES/django.po | 16 +++++++++++----- app/locale/es/LC_MESSAGES/django.po | 20 +++++++++++++++----- app/locale/fr/LC_MESSAGES/django.po | 20 +++++++++++++++----- app/locale/hu/LC_MESSAGES/django.po | 16 +++++++++++----- app/locale/id/LC_MESSAGES/django.po | 16 +++++++++++----- app/locale/it/LC_MESSAGES/django.po | 20 +++++++++++++++----- app/locale/nl/LC_MESSAGES/django.po | 20 +++++++++++++++----- app/locale/pl/LC_MESSAGES/django.po | 20 +++++++++++++++----- app/locale/pt_BR/LC_MESSAGES/django.po | 20 +++++++++++++++----- app/locale/ru/LC_MESSAGES/django.po | 20 +++++++++++++++----- app/locale/sv/LC_MESSAGES/django.po | 16 +++++++++++----- app/locale/sw/LC_MESSAGES/django.po | 16 +++++++++++----- app/locale/uk/LC_MESSAGES/django.po | 20 +++++++++++++++----- app/locale/zh_Hant/LC_MESSAGES/django.po | 20 +++++++++++++++----- 15 files changed, 205 insertions(+), 75 deletions(-) diff --git a/app/locale/de/LC_MESSAGES/django.po b/app/locale/de/LC_MESSAGES/django.po index 44536b1d..cbb426c5 100644 --- a/app/locale/de/LC_MESSAGES/django.po +++ b/app/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2026-08-10 12:57+0000\n" "Last-Translator: GitEbu \n" "Language-Team: German Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "Privat: Nur für den Besitzer und geteilte Nutzer sichtbar.
    Öffentlich: " "Sichtbar für alle Nutzer. Nur bearbeitbar durch Besitzer." -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Speichern" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "Sie können dieses Objekt nicht mit seinem Besitzer teilen." @@ -3047,6 +3051,12 @@ msgstr "Entfolgen" msgid "No accounts" msgstr "Keine Konten" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 #, fuzzy #| msgid "No transactions on this date" diff --git a/app/locale/en/LC_MESSAGES/django.po b/app/locale/en/LC_MESSAGES/django.po index 92141207..bed85050 100644 --- a/app/locale/en/LC_MESSAGES/django.po +++ b/app/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -683,17 +683,17 @@ msgstr "" #: apps/common/forms.py:43 msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "" @@ -2874,6 +2874,12 @@ msgstr "" msgid "No accounts" msgstr "" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 msgid "No accounts found on this service" msgstr "" diff --git a/app/locale/es/LC_MESSAGES/django.po b/app/locale/es/LC_MESSAGES/django.po index 79a982ee..78815db9 100644 --- a/app/locale/es/LC_MESSAGES/django.po +++ b/app/locale/es/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2026-07-10 04:57+0000\n" "Last-Translator: Juan David Afanador \n" "Language-Team: Spanish Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "Privado: Solo visible para el propietario y los usuarios con los que se haya " "compartido. Solo el propietario puede editarlo.
    Público: Visible para " "todos los usuarios. Solo el propietario puede editarlo." -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Guardar" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "No puede compartir este item con su propietario." @@ -3017,6 +3021,12 @@ msgstr "Dejar de seguir" msgid "No accounts" msgstr "Sin cuentas" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 #, fuzzy #| msgid "No transactions for this year" diff --git a/app/locale/fr/LC_MESSAGES/django.po b/app/locale/fr/LC_MESSAGES/django.po index cfb08552..97a0a8d1 100644 --- a/app/locale/fr/LC_MESSAGES/django.po +++ b/app/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2026-11-02 18:46+0000\n" "Last-Translator: sorcierwax \n" "Language-Team: French Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "Privé : Visible uniquement pour le propriétaire et les utilisateurs " "partagés. Seulement modifiable par le propriétaire.
    Publique : Visible " "par tous. Seulement modifiable par le propriétaire." -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Sauvegarder" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "Vous ne pouvez pas partager cet item avec son propriétaire." @@ -2988,6 +2992,12 @@ msgstr "Ne plus suivre" msgid "No accounts" msgstr "Pas de comptes" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 #, fuzzy #| msgid "No transactions for this year" diff --git a/app/locale/hu/LC_MESSAGES/django.po b/app/locale/hu/LC_MESSAGES/django.po index 91577cae..86cce85e 100644 --- a/app/locale/hu/LC_MESSAGES/django.po +++ b/app/locale/hu/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2026-01-10 03:09+0000\n" "Last-Translator: Herculino Trotta \n" "Language-Team: Hungarian Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Mentés" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "Nem tudod megosztani ezt az elemet a tulajdonosával." @@ -2964,6 +2964,12 @@ msgstr "" msgid "No accounts" msgstr "" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 msgid "No accounts found on this service" msgstr "" diff --git a/app/locale/id/LC_MESSAGES/django.po b/app/locale/id/LC_MESSAGES/django.po index 5dbae955..baba1997 100644 --- a/app/locale/id/LC_MESSAGES/django.po +++ b/app/locale/id/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -682,17 +682,17 @@ msgstr "" #: apps/common/forms.py:43 msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "" @@ -2873,6 +2873,12 @@ msgstr "" msgid "No accounts" msgstr "" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 msgid "No accounts found on this service" msgstr "" diff --git a/app/locale/it/LC_MESSAGES/django.po b/app/locale/it/LC_MESSAGES/django.po index 2c4765d4..a95629b3 100644 --- a/app/locale/it/LC_MESSAGES/django.po +++ b/app/locale/it/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2025-12-28 22:24+0000\n" "Last-Translator: icovada \n" "Language-Team: Italian Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "Privato: visibile solo al proprietario e agli utenti con cui è condiviso. " "Modificabile solo dal proprietario.
    Pubblico: visibile da tutti gli " "utenti. Modificabile solo dal proprietario." -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Salva" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "Non puoi condividere questo elemento con il suo proprietario." @@ -3048,6 +3052,12 @@ msgstr "Smetti di tracciare" msgid "No accounts" msgstr "Nessun conto" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 #, fuzzy #| msgid "No transactions on this date" diff --git a/app/locale/nl/LC_MESSAGES/django.po b/app/locale/nl/LC_MESSAGES/django.po index 5e179f04..d1530952 100644 --- a/app/locale/nl/LC_MESSAGES/django.po +++ b/app/locale/nl/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2026-11-02 17:58+0000\n" "Last-Translator: Dimitri Decrock \n" "Language-Team: Dutch Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "Privé: Alleen weergegeven voor de eigenaar en gedeelde gebruikers. Alleen " "bewerkbaar door de eigenaar.
    Publiek: Weergegeven voor alle gebruikers. " "Alleen bewerkbaar door de eigenaar." -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Opslaan" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "Je kunt dit item niet delen met zijn eigenaar." @@ -2973,6 +2977,12 @@ msgstr "Niet gevolgd" msgid "No accounts" msgstr "Geen rekeningen" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 #, fuzzy #| msgid "No transactions for this year" diff --git a/app/locale/pl/LC_MESSAGES/django.po b/app/locale/pl/LC_MESSAGES/django.po index 62fc1789..82865bac 100644 --- a/app/locale/pl/LC_MESSAGES/django.po +++ b/app/locale/pl/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2026-06-08 07:57+0000\n" "Last-Translator: Pawel Augustyn \n" "Language-Team: Polish Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "Prywatny: Widoczne tylko dla właściciela oraz osób, którym wpis został " "udostępnione. Tylko właściciel może dokonywać zmian.
    Publiczny: " "Widoczne dla wszystkich. Tylko właściciel może dokonywać zmian." -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Zapisz" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "Nie możesz udostępniać tego wpisu obecnemu właścicielowi." @@ -3020,6 +3024,12 @@ msgstr "Przestań śledzić" msgid "No accounts" msgstr "Brak kont" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 #, fuzzy #| msgid "No transactions for this year" diff --git a/app/locale/pt_BR/LC_MESSAGES/django.po b/app/locale/pt_BR/LC_MESSAGES/django.po index 1e927d0a..4dd3d7da 100644 --- a/app/locale/pt_BR/LC_MESSAGES/django.po +++ b/app/locale/pt_BR/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2026-11-08 19:40+0000\n" "Last-Translator: Herculino Trotta \n" "Language-Team: Portuguese (Brazil) Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "Privado: Exibido somente para o proprietário e usuários compartilhados. " "Somente editável pelo proprietário.
    Público: Exibido para todos os " "usuários. Somente editável pelo proprietário." -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Salvar" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "Você não pode compartilhar este item com o seu proprietário." @@ -2970,6 +2974,12 @@ msgstr "Parar de acompanhar" msgid "No accounts" msgstr "Nenhuma conta" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 msgid "No accounts found on this service" msgstr "Nenhuma conta encontrada neste serviço" diff --git a/app/locale/ru/LC_MESSAGES/django.po b/app/locale/ru/LC_MESSAGES/django.po index d0e78944..40b7a7b5 100644 --- a/app/locale/ru/LC_MESSAGES/django.po +++ b/app/locale/ru/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2026-11-10 07:58+0000\n" "Last-Translator: masttera \n" "Language-Team: Russian Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "Приватный: Отображается только для владельца и общих пользователей. Может " "быть изменено только владельцем
    Публичный: Отображается для всех " "пользователей. Может быть изменено только владельцем." -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Сохранить" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "Вы не можете поделиться этим элементом с его владельцем." @@ -2974,6 +2978,12 @@ msgstr "Скрыть" msgid "No accounts" msgstr "Нет счетов" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 msgid "No accounts found on this service" msgstr "" diff --git a/app/locale/sv/LC_MESSAGES/django.po b/app/locale/sv/LC_MESSAGES/django.po index e8cf5126..66da704a 100644 --- a/app/locale/sv/LC_MESSAGES/django.po +++ b/app/locale/sv/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2025-04-14 06:16+0000\n" "Last-Translator: Emil \n" "Language-Team: Swedish Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "" @@ -2879,6 +2879,12 @@ msgstr "" msgid "No accounts" msgstr "" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 msgid "No accounts found on this service" msgstr "" diff --git a/app/locale/sw/LC_MESSAGES/django.po b/app/locale/sw/LC_MESSAGES/django.po index 942e25ef..ce5015bb 100644 --- a/app/locale/sw/LC_MESSAGES/django.po +++ b/app/locale/sw/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2026-01-18 19:24+0000\n" "Last-Translator: Ebrahim Tayabali \n" "Language-Team: Swahili Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "" @@ -2887,6 +2887,12 @@ msgstr "" msgid "No accounts" msgstr "" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 msgid "No accounts found on this service" msgstr "" diff --git a/app/locale/uk/LC_MESSAGES/django.po b/app/locale/uk/LC_MESSAGES/django.po index 2575a836..5c40f43c 100644 --- a/app/locale/uk/LC_MESSAGES/django.po +++ b/app/locale/uk/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2025-11-01 01:17+0000\n" "Last-Translator: mlystopad \n" "Language-Team: Ukrainian Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "Private: Відображається лише для власника та користувачів із загальним " "доступом. Редагувати може лише власник.
    Public: Відображається для всіх " "користувачів. Редагувати може лише власник." -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "Зберегти" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "Ви не можете поділитися цією річчю з її власником." @@ -3006,6 +3010,12 @@ msgstr "" msgid "No accounts" msgstr "" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 #, fuzzy #| msgid "Transactions" diff --git a/app/locale/zh_Hant/LC_MESSAGES/django.po b/app/locale/zh_Hant/LC_MESSAGES/django.po index fa126667..bd3743ce 100644 --- a/app/locale/zh_Hant/LC_MESSAGES/django.po +++ b/app/locale/zh_Hant/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 05:38+0000\n" +"POT-Creation-Date: 2026-11-14 06:23+0000\n" "PO-Revision-Date: 2025-10-08 16:17+0000\n" "Last-Translator: doody \n" "Language-Team: Chinese (Traditional Han script) Public: Shown for all users. Only editable by the owner." msgid "" -"Private: Only shown for the owner and shared users. Only editable by the " -"owner.
    Public: Shown for all users. Only editable by the owner." +"Private: Only shown for the owner and shared users.
    Public: Shown for " +"all users.
    Only the owner can edit, share or delete it." msgstr "" "私人:只會顯示給擁有者或著已分享的使用者。只有擁有者可以編輯這個選項。
    公" "開:所有使用者都可以看到。只有擁有者可以編輯這個選項。" -#: apps/common/forms.py:76 apps/users/forms.py:191 +#: apps/common/forms.py:78 apps/users/forms.py:191 #: templates/bank_sync/fragments/accounts.html:34 #: templates/transactions/fragments/filter_actions.html:5 msgid "Save" msgstr "儲存" -#: apps/common/forms.py:90 +#: apps/common/forms.py:92 msgid "You cannot share this item with its owner." msgstr "你不能將這個項目分享給他的擁有者。" @@ -3000,6 +3004,12 @@ msgstr "不追蹤" msgid "No accounts" msgstr "沒有帳戶" +#: templates/accounts/fragments/share.html:8 +msgid "" +"Everyone who can see this account can add, edit and delete its transactions, " +"installment plans and recurring transactions." +msgstr "" + #: templates/bank_sync/fragments/accounts.html:31 #, fuzzy #| msgid "No transactions on this date" From 4532677e4941dd4ad6f5e49bb600041f42384e8a Mon Sep 17 00:00:00 2001 From: Asish Kumar Date: Fri, 13 Nov 2026 18:50:17 +0000 Subject: [PATCH 22/24] 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. --- app/apps/transactions/models.py | 79 +++++--- app/apps/transactions/tests/test_transfers.py | 176 ++++++++++++++++-- 2 files changed, 217 insertions(+), 38 deletions(-) diff --git a/app/apps/transactions/models.py b/app/apps/transactions/models.py index da76eaf9..bc99a82c 100644 --- a/app/apps/transactions/models.py +++ b/app/apps/transactions/models.py @@ -1359,38 +1359,65 @@ class RecurringTransaction(TransferTemplate): """ Updates all unpaid transactions associated with this RecurringTransaction. - Only unpaid transactions (`is_paid=False`) are modified. Updates fields like - amount, description, category, notes, and many-to-many relationships (tags, entities). + Only unpaid transactions (`is_paid=False`) are modified. They keep their dates + and take the account, type, amount, description, category, notes, tags and + entities of the recurrence; a transfer's "to" side takes the "to" account and + amount. Turning the recurrence into a transfer adds the missing "to" sides, + and turning it into an income or expense removes them. """ - unpaid_transactions = self.transactions.filter(is_paid=False) + unpaid_transactions = list( + self.transactions.filter(is_paid=False).select_related( + "linked_transaction" + ) + ) + to_side_ids = { + existing_transaction.pk + for existing_transaction in unpaid_transactions + if self._is_to_side(existing_transaction) + } for existing_transaction in unpaid_transactions: - # Update fields based on RecurringTransaction - is_to_side = ( - existing_transaction.linked_transaction_id - and existing_transaction.type == Transaction.Type.INCOME - ) - existing_transaction.amount = ( - self.to_amount or self.amount if is_to_side else self.amount - ) - existing_transaction.description = ( - self.description if self.add_description_to_transaction else "" - ) - existing_transaction.category = self.category - existing_transaction.notes = ( - self.notes if self.add_notes_to_transaction else "" - ) + if existing_transaction.pk in to_side_ids: + if self.is_transfer: + self._apply_to( + existing_transaction, + self.to_account, + Transaction.Type.INCOME, + self.to_amount or self.amount, + existing_transaction.date, + existing_transaction.reference_date, + ) + # Otherwise its unpaid "from" side removes it below + continue - # Update many-to-many relationships (see create_transaction) - existing_transaction.tags.set(self.tags(manager="all_objects").all()) - existing_transaction.entities.set( - self.entities(manager="all_objects").all() + if ( + not self.is_transfer + and existing_transaction.linked_transaction_id in to_side_ids + ): + to_side = existing_transaction.linked_transaction + existing_transaction.linked_transaction = None + to_side.linked_transaction = None + to_side.delete(_with_partner=False) + + self._apply_to( + existing_transaction, + self.account, + self.transaction_type, + self.amount, + existing_transaction.date, + existing_transaction.reference_date, ) + if not existing_transaction.linked_transaction_id: + self.complete_transfer(existing_transaction) - existing_transaction.copy_sub_transactions_from(self) - - # Save updated transaction - existing_transaction.save() + def _is_to_side(self, existing_transaction): + """Whether a transaction is the "to" side of a transfer this generated.""" + return bool( + existing_transaction.linked_transaction_id + and existing_transaction.type == Transaction.Type.INCOME + and existing_transaction.linked_transaction.recurring_transaction_id + == self.pk + ) def delete_unpaid_transactions(self): """ diff --git a/app/apps/transactions/tests/test_transfers.py b/app/apps/transactions/tests/test_transfers.py index adf31b52..9f400967 100644 --- a/app/apps/transactions/tests/test_transfers.py +++ b/app/apps/transactions/tests/test_transfers.py @@ -251,19 +251,20 @@ class TransferTemplateTests(TransferTestBase): """Recurring and quick transactions of type Transfer.""" def _recurring(self, **overrides): - return RecurringTransaction.objects.create( - account=self.checking, - type=RecurringTransaction.Type.TRANSFER, - to_account=self.savings, - amount=Decimal("100"), - to_amount=Decimal("95"), - description="Savings", - start_date=timezone.localdate(), - recurrence_type=RecurringTransaction.RecurrenceType.MONTH, - recurrence_interval=1, - keep_at_most=2, + data = { + "account": self.checking, + "type": RecurringTransaction.Type.TRANSFER, + "to_account": self.savings, + "amount": Decimal("100"), + "to_amount": Decimal("95"), + "description": "Savings", + "start_date": timezone.localdate(), + "recurrence_type": RecurringTransaction.RecurrenceType.MONTH, + "recurrence_interval": 1, + "keep_at_most": 2, **overrides, - ) + } + return RecurringTransaction.objects.create(**data) def test_recurring_transfer_generates_linked_pairs(self): recurring = self._recurring() @@ -294,6 +295,157 @@ class TransferTemplateTests(TransferTestBase): {(Transaction.Type.EXPENSE, Decimal("10")), (Transaction.Type.INCOME, Decimal("9"))}, ) + def test_recurring_update_moves_unpaid_to_new_account_and_type(self): + recurring = self._recurring(type=RecurringTransaction.Type.EXPENSE) + recurring.create_upcoming_transactions() + paid = recurring.transactions.earliest("date") + paid.is_paid = True + paid.save() + + recurring.account = self.savings + recurring.type = RecurringTransaction.Type.INCOME + recurring.save() + recurring.update_unpaid_transactions() + + paid.refresh_from_db() + self.assertEqual( + (paid.account, paid.type), (self.checking, Transaction.Type.EXPENSE) + ) + unpaid = recurring.transactions.filter(is_paid=False) + self.assertTrue(unpaid.exists()) + self.assertEqual( + set(unpaid.values_list("account", "type")), + {(self.savings.id, Transaction.Type.INCOME)}, + ) + + def test_recurring_transfer_update_moves_to_sides_to_new_account(self): + recurring = self._recurring() + recurring.create_upcoming_transactions() + brokerage = Account.objects.create( + name="Brokerage", group=self.checking.group, currency=self.checking.currency + ) + + recurring.to_account = brokerage + recurring.save() + recurring.update_unpaid_transactions() + + self.assertEqual( + set(recurring.transactions.values_list("type", "account")), + { + (Transaction.Type.EXPENSE, self.checking.id), + (Transaction.Type.INCOME, brokerage.id), + }, + ) + + def test_recurring_update_into_transfer_adds_to_sides(self): + recurring = self._recurring(type=RecurringTransaction.Type.INCOME) + recurring.create_upcoming_transactions() + occurrences = recurring.transactions.count() + + recurring.type = RecurringTransaction.Type.TRANSFER + recurring.save() + recurring.update_unpaid_transactions() + + expenses = recurring.transactions.filter(type=Transaction.Type.EXPENSE) + self.assertEqual(expenses.count(), occurrences) + self.assertEqual(recurring.transactions.count(), occurrences * 2) + for from_t in expenses: + to_t = from_t.linked_transaction + self.assertEqual(from_t.account, self.checking) + self.assertEqual(to_t.linked_transaction, from_t) + self.assertEqual(to_t.account, self.savings) + self.assertEqual(to_t.amount, Decimal("95")) + self.assertEqual(to_t.recurring_transaction, recurring) + + def _assert_update_out_of_transfer_removes_to_sides(self): + recurring = self._recurring() + recurring.create_upcoming_transactions() + paid_from = recurring.transactions.filter( + type=Transaction.Type.EXPENSE + ).earliest("date") + paid_from.is_paid = True + paid_from.save() + paid_to = paid_from.linked_transaction + occurrences = recurring.transactions.filter( + type=Transaction.Type.EXPENSE + ).count() + + recurring.type = RecurringTransaction.Type.EXPENSE + recurring.save() + recurring.update_unpaid_transactions() + + unpaid = recurring.transactions.filter(is_paid=False) + self.assertEqual(unpaid.count(), occurrences - 1) + self.assertEqual( + set(unpaid.values_list("account", "type", "linked_transaction")), + {(self.checking.id, Transaction.Type.EXPENSE, None)}, + ) + paid_from.refresh_from_db() + self.assertEqual(paid_from.linked_transaction, paid_to) + + def test_recurring_update_out_of_transfer_removes_to_sides(self): + self._assert_update_out_of_transfer_removes_to_sides() + self.assertFalse(Transaction.deleted_objects.exists()) + + @override_settings(ENABLE_SOFT_DELETE=True) + def test_recurring_update_out_of_transfer_soft_deletes_to_sides(self): + self._assert_update_out_of_transfer_removes_to_sides() + self.assertTrue(Transaction.deleted_objects.exists()) + self.assertFalse( + Transaction.deleted_objects.exclude(linked_transaction=None).exists() + ) + + def test_recurring_update_keeps_transfer_linked_by_hand(self): + recurring = self._recurring(type=RecurringTransaction.Type.INCOME) + recurring.create_upcoming_transactions() + income = recurring.transactions.earliest("date") + expense = Transaction.objects.create( + account=self.savings, + type=Transaction.Type.EXPENSE, + amount=Decimal("100"), + date=income.date, + description="Outside", + is_paid=False, + ) + expense.link_transfer(income) + + recurring.amount = Decimal("120") + recurring.save() + recurring.update_unpaid_transactions() + + income.refresh_from_db() + self.assertEqual(income.linked_transaction, expense) + self.assertEqual(income.amount, Decimal("120")) + self.assertTrue(Transaction.objects.filter(pk=expense.pk).exists()) + + def test_edit_view_moves_unpaid_transactions(self): + recurring = self._recurring(type=RecurringTransaction.Type.EXPENSE) + recurring.create_upcoming_transactions() + + response = self.client.post( + reverse( + "recurring_transaction_edit", + kwargs={"recurring_transaction_id": recurring.id}, + ), + { + "type": "EX", + "account": self.savings.id, + "amount": "100", + "description": "Savings", + "start_date": recurring.start_date.isoformat(), + "recurrence_type": "month", + "recurrence_interval": "1", + "keep_at_most": "2", + }, + HTTP_HX_REQUEST="true", + ) + + self.assertEqual(response.status_code, 204) + self.assertEqual( + set(recurring.transactions.values_list("account", flat=True)), + {self.savings.id}, + ) + def test_transfer_type_requires_other_account(self): form = RecurringTransactionForm( { From ed513a21716819c03f67756119a9f2275370588d Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 14 Nov 2026 11:02:38 -0300 Subject: [PATCH 23/24] 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. --- app/apps/transactions/models.py | 17 +++++++++++ app/apps/transactions/tests/test_transfers.py | 30 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/app/apps/transactions/models.py b/app/apps/transactions/models.py index bc99a82c..d5eac13a 100644 --- a/app/apps/transactions/models.py +++ b/app/apps/transactions/models.py @@ -1399,6 +1399,23 @@ class RecurringTransaction(TransferTemplate): to_side.linked_transaction = None to_side.delete(_with_partner=False) + partner = existing_transaction.linked_transaction + if ( + partner + and partner.recurring_transaction_id != self.pk + and ( + {self.transaction_type, partner.type} + != {Transaction.Type.INCOME, Transaction.Type.EXPENSE} + or self.account_id == partner.account_id + ) + ): + # A link made elsewhere (e.g. a DCA entry) that the new type or account + # would break: unlink it and keep the partner + Transaction.all_objects.filter(pk=partner.pk).update( + linked_transaction=None + ) + existing_transaction.linked_transaction = None + self._apply_to( existing_transaction, self.account, diff --git a/app/apps/transactions/tests/test_transfers.py b/app/apps/transactions/tests/test_transfers.py index 9f400967..3cd72112 100644 --- a/app/apps/transactions/tests/test_transfers.py +++ b/app/apps/transactions/tests/test_transfers.py @@ -418,6 +418,36 @@ class TransferTemplateTests(TransferTestBase): self.assertEqual(income.amount, Decimal("120")) self.assertTrue(Transaction.objects.filter(pk=expense.pk).exists()) + def test_recurring_update_unlinks_transfer_linked_by_hand_when_broken(self): + for change in ({"type": RecurringTransaction.Type.EXPENSE}, {"account": self.savings}): + with self.subTest(change=change): + recurring = self._recurring(type=RecurringTransaction.Type.INCOME) + recurring.create_upcoming_transactions() + income = recurring.transactions.earliest("date") + outside = Transaction.objects.create( + account=self.savings, + type=Transaction.Type.EXPENSE, + amount=Decimal("100"), + date=income.date, + description="Outside", + is_paid=False, + ) + outside.link_transfer(income) + + for field, value in change.items(): + setattr(recurring, field, value) + recurring.save() + recurring.update_unpaid_transactions() + + income.refresh_from_db() + outside.refresh_from_db() + self.assertIsNone(income.linked_transaction) + self.assertIsNone(outside.linked_transaction) + self.assertEqual( + (outside.account, outside.type, outside.amount), + (self.savings, Transaction.Type.EXPENSE, Decimal("100")), + ) + def test_edit_view_moves_unpaid_transactions(self): recurring = self._recurring(type=RecurringTransaction.Type.EXPENSE) recurring.create_upcoming_transactions() From 6c4b117d117fc031fbfdc59734b818e16492cb7f Mon Sep 17 00:00:00 2001 From: eitchtee <10510126+eitchtee@users.noreply.github.com> Date: Sat, 14 Nov 2026 14:06:20 +0000 Subject: [PATCH 24/24] chore(locale): update translation files [skip ci] Automatically generated by Django makemessages workflow --- app/locale/de/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/en/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/es/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/fr/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/hu/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/id/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/it/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/nl/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/pl/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/pt_BR/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/ru/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/sv/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/sw/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/uk/LC_MESSAGES/django.po | 38 ++++++++++++------------ app/locale/zh_Hant/LC_MESSAGES/django.po | 38 ++++++++++++------------ 15 files changed, 285 insertions(+), 285 deletions(-) diff --git a/app/locale/de/LC_MESSAGES/django.po b/app/locale/de/LC_MESSAGES/django.po index cbb426c5..86cac455 100644 --- a/app/locale/de/LC_MESSAGES/django.po +++ b/app/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 06:23+0000\n" +"POT-Creation-Date: 2026-11-14 14:06+0000\n" "PO-Revision-Date: 2026-08-10 12:57+0000\n" "Last-Translator: GitEbu \n" "Language-Team: German \n" "Language-Team: LANGUAGE \n" @@ -76,7 +76,7 @@ msgstr "" #: apps/transactions/forms.py:700 apps/transactions/forms.py:942 #: apps/transactions/forms.py:1196 apps/transactions/models.py:360 #: apps/transactions/models.py:861 apps/transactions/models.py:1120 -#: apps/transactions/models.py:1445 +#: apps/transactions/models.py:1489 #: templates/insights/fragments/month_by_month.html:84 #: templates/insights/fragments/year_by_year.html:52 msgid "Category" @@ -92,7 +92,7 @@ msgstr "" #: apps/transactions/forms.py:717 apps/transactions/forms.py:935 #: apps/transactions/forms.py:1189 apps/transactions/models.py:366 #: apps/transactions/models.py:863 apps/transactions/models.py:1124 -#: apps/transactions/models.py:1451 templates/includes/sidebar.html:162 +#: apps/transactions/models.py:1495 templates/includes/sidebar.html:162 #: templates/insights/fragments/month_by_month.html:29 #: templates/insights/fragments/month_by_month.html:32 #: templates/insights/fragments/year_by_year.html:24 @@ -137,7 +137,7 @@ msgstr "" #: apps/import_app/models.py:20 apps/rules/models.py:13 #: apps/transactions/forms.py:64 apps/transactions/models.py:252 #: apps/transactions/models.py:277 apps/transactions/models.py:301 -#: apps/transactions/models.py:726 apps/transactions/models.py:1413 +#: apps/transactions/models.py:726 apps/transactions/models.py:1457 #: apps/users/models.py:577 templates/account_groups/fragments/list.html:22 #: templates/accounts/fragments/list.html:22 #: templates/bank_sync/fragments/list.html:20 @@ -298,7 +298,7 @@ msgstr "" #: apps/transactions/forms.py:435 apps/transactions/forms.py:563 #: apps/transactions/forms.py:927 apps/transactions/forms.py:1181 #: apps/transactions/models.py:332 apps/transactions/models.py:821 -#: apps/transactions/models.py:1102 apps/transactions/models.py:1419 +#: apps/transactions/models.py:1102 apps/transactions/models.py:1463 #: templates/import_app/fragments/runs/list.html:95 #: templates/installment_plans/fragments/table.html:17 #: templates/quick_transactions/fragments/list.html:14 @@ -1045,7 +1045,7 @@ msgstr "" #: apps/transactions/forms.py:950 apps/transactions/forms.py:1204 #: apps/transactions/models.py:315 apps/transactions/models.py:371 #: apps/transactions/models.py:866 apps/transactions/models.py:1127 -#: apps/transactions/models.py:1456 templates/entities/fragments/list.html:9 +#: apps/transactions/models.py:1500 templates/entities/fragments/list.html:9 #: templates/entities/pages/index.html:4 templates/includes/sidebar.html:168 #: templates/insights/fragments/month_by_month.html:40 #: templates/insights/fragments/month_by_month.html:43 @@ -1102,7 +1102,7 @@ msgstr "" #: apps/rules/forms.py:197 apps/rules/models.py:44 apps/rules/models.py:296 #: apps/transactions/forms.py:590 apps/transactions/forms.py:754 #: apps/transactions/models.py:356 apps/transactions/models.py:870 -#: apps/transactions/models.py:1130 apps/transactions/models.py:1441 +#: apps/transactions/models.py:1130 apps/transactions/models.py:1485 msgid "Notes" msgstr "" @@ -1199,7 +1199,7 @@ msgid "Installment Plans" msgstr "" #: apps/export_app/forms.py:67 apps/export_app/forms.py:157 -#: apps/transactions/models.py:1474 templates/includes/sidebar.html:98 +#: apps/transactions/models.py:1518 templates/includes/sidebar.html:98 #: templates/quick_transactions/pages/index.html:5 #: templates/quick_transactions/pages/index.html:15 msgid "Quick Transactions" @@ -1536,7 +1536,7 @@ msgstr "" #: apps/rules/forms.py:174 apps/rules/forms.py:188 apps/rules/models.py:36 #: apps/rules/models.py:272 apps/transactions/forms.py:554 #: apps/transactions/models.py:339 apps/transactions/models.py:826 -#: apps/transactions/models.py:1108 apps/transactions/models.py:1426 +#: apps/transactions/models.py:1108 apps/transactions/models.py:1470 #: templates/mini_tools/simulator.html:63 msgid "Type" msgstr "" @@ -1544,7 +1544,7 @@ msgstr "" #: apps/rules/forms.py:175 apps/rules/forms.py:189 apps/rules/models.py:37 #: apps/rules/models.py:276 apps/transactions/filters.py:23 #: apps/transactions/forms.py:558 apps/transactions/forms.py:736 -#: apps/transactions/models.py:341 apps/transactions/models.py:1428 +#: apps/transactions/models.py:341 apps/transactions/models.py:1472 #: templates/cotton/transaction/item.html:25 #: templates/cotton/transaction/item.html:36 #: templates/transactions/widgets/paid_toggle_button.html:10 @@ -1564,7 +1564,7 @@ msgstr "" #: apps/rules/models.py:288 apps/transactions/forms.py:75 #: apps/transactions/forms.py:581 apps/transactions/models.py:349 #: apps/transactions/models.py:730 apps/transactions/models.py:1113 -#: apps/transactions/models.py:1434 +#: apps/transactions/models.py:1478 #: templates/insights/fragments/sankey.html:102 #: templates/installment_plans/fragments/table.html:18 #: templates/mini_tools/simulator.html:70 @@ -1577,26 +1577,26 @@ msgstr "" #: apps/rules/models.py:43 apps/rules/models.py:292 #: apps/transactions/forms.py:585 apps/transactions/forms.py:745 #: apps/transactions/models.py:354 apps/transactions/models.py:828 -#: apps/transactions/models.py:1116 apps/transactions/models.py:1439 +#: apps/transactions/models.py:1116 apps/transactions/models.py:1483 msgid "Description" msgstr "" #: apps/rules/forms.py:182 apps/rules/forms.py:199 apps/rules/models.py:48 #: apps/rules/models.py:300 apps/transactions/models.py:401 -#: apps/transactions/models.py:1461 +#: apps/transactions/models.py:1505 msgid "Internal Note" msgstr "" #: apps/rules/forms.py:183 apps/rules/forms.py:200 apps/rules/models.py:49 #: apps/rules/models.py:304 apps/transactions/models.py:403 -#: apps/transactions/models.py:1463 +#: apps/transactions/models.py:1507 msgid "Internal ID" msgstr "" #: apps/rules/forms.py:186 apps/rules/forms.py:201 apps/rules/models.py:40 #: apps/rules/models.py:324 apps/transactions/forms.py:758 #: apps/transactions/models.py:253 apps/transactions/models.py:344 -#: apps/transactions/models.py:1429 +#: apps/transactions/models.py:1473 msgid "Mute" msgstr "" @@ -1857,7 +1857,7 @@ msgid "To Amount" msgstr "" #: apps/transactions/forms.py:827 apps/transactions/models.py:1091 -#: apps/transactions/models.py:1406 templates/cotton/transaction/item.html:54 +#: apps/transactions/models.py:1450 templates/cotton/transaction/item.html:54 #: templates/cotton/transaction/item.html:62 #: templates/cotton/transaction/item.html:272 #: templates/cotton/transaction/item.html:304 @@ -1920,7 +1920,7 @@ msgid "" msgstr "" #: apps/transactions/models.py:326 apps/transactions/models.py:1090 -#: apps/transactions/models.py:1405 +#: apps/transactions/models.py:1449 #: templates/calendar_view/fragments/list.html:42 #: templates/calendar_view/fragments/list.html:44 #: templates/calendar_view/fragments/list.html:52 @@ -1939,7 +1939,7 @@ msgid "Income" msgstr "" #: apps/transactions/models.py:327 apps/transactions/models.py:1092 -#: apps/transactions/models.py:1407 +#: apps/transactions/models.py:1451 #: templates/calendar_view/fragments/list.html:46 #: templates/calendar_view/fragments/list.html:48 #: templates/calendar_view/fragments/list.html:56 @@ -2130,7 +2130,7 @@ msgstr "" msgid "Last Generated Reference Date" msgstr "" -#: apps/transactions/models.py:1473 templates/cotton/transaction/item.html:245 +#: apps/transactions/models.py:1517 templates/cotton/transaction/item.html:245 #: templates/cotton/ui/transactions_fab.html:59 msgid "Quick Transaction" msgstr "" diff --git a/app/locale/es/LC_MESSAGES/django.po b/app/locale/es/LC_MESSAGES/django.po index 78815db9..dead14b0 100644 --- a/app/locale/es/LC_MESSAGES/django.po +++ b/app/locale/es/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-14 06:23+0000\n" +"POT-Creation-Date: 2026-11-14 14:06+0000\n" "PO-Revision-Date: 2026-07-10 04:57+0000\n" "Last-Translator: Juan David Afanador \n" "Language-Team: Spanish \n" "Language-Team: French \n" "Language-Team: Hungarian \n" "Language-Team: Italian \n" "Language-Team: Dutch \n" "Language-Team: Polish \n" "Language-Team: Portuguese (Brazil) \n" "Language-Team: Russian \n" "Language-Team: Swedish \n" "Language-Team: Swahili \n" "Language-Team: Ukrainian \n" "Language-Team: Chinese (Traditional Han script)