From 35ef1dd716632cb9ef9e5144316082abb30a84e8 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Mon, 12 Oct 2026 02:41:14 -0300 Subject: [PATCH 1/2] fix(transactions): apply the form amount to a paid transaction converted into a recurring transaction --- app/apps/transactions/models.py | 4 +--- app/apps/transactions/tests/test_views.py | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/apps/transactions/models.py b/app/apps/transactions/models.py index 8fd0285b..be54a1f7 100644 --- a/app/apps/transactions/models.py +++ b/app/apps/transactions/models.py @@ -976,9 +976,7 @@ class RecurringTransaction(models.Model): existing_transaction.category = self.category existing_transaction.notes = self.notes if self.add_notes_to_transaction else "" existing_transaction.recurring_transaction = self - - if not existing_transaction.is_paid: # Don't update value for paid transactions - existing_transaction.amount = self.amount + existing_transaction.amount = self.amount existing_transaction.save() existing_transaction.tags.set(self.tags(manager="all_objects").all()) diff --git a/app/apps/transactions/tests/test_views.py b/app/apps/transactions/tests/test_views.py index 88a51694..4fd7bc8d 100644 --- a/app/apps/transactions/tests/test_views.py +++ b/app/apps/transactions/tests/test_views.py @@ -275,8 +275,9 @@ class TransactionConvertViewTests(TestCase): recurring = RecurringTransaction.all_objects.get() self.transaction.refresh_from_db() self.assertEqual(self.transaction.recurring_transaction, recurring) - # Paid amount is preserved - self.assertEqual(self.transaction.amount, 50) + # The form's amount applies even though the original was paid + self.assertEqual(self.transaction.amount, 60) + self.assertTrue(self.transaction.is_paid) self.assertEqual( recurring.transactions.filter(date=date(2030, 1, 15)).count(), 1 ) From 3261e5f2661e5eabeda1f31bd48d3229a7c9f7d6 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Mon, 12 Oct 2026 02:41:14 -0300 Subject: [PATCH 2/2] fix(transactions): apply the form amount to a paid transaction converted into an installment plan --- app/apps/transactions/forms.py | 2 ++ app/apps/transactions/tests/test_views.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/apps/transactions/forms.py b/app/apps/transactions/forms.py index 5a2a582a..0855075c 100644 --- a/app/apps/transactions/forms.py +++ b/app/apps/transactions/forms.py @@ -895,6 +895,8 @@ class InstallmentPlanForm(forms.ModelForm): # The converted transaction becomes the first installment source_transaction.installment_plan = instance source_transaction.installment_id = instance.installment_start + # Take the amount set on the form, even if already paid + source_transaction.amount = instance.installment_amount source_transaction.save() instance.update_transactions() elif is_new: diff --git a/app/apps/transactions/tests/test_views.py b/app/apps/transactions/tests/test_views.py index 4fd7bc8d..32481e8e 100644 --- a/app/apps/transactions/tests/test_views.py +++ b/app/apps/transactions/tests/test_views.py @@ -289,7 +289,7 @@ class TransactionConvertViewTests(TestCase): { "account": self.account.id, "type": "EX", - "installment_amount": "50", + "installment_amount": "70", "description": "TV", "add_description_to_transaction": "on", "number_of_installments": 3, @@ -307,6 +307,10 @@ class TransactionConvertViewTests(TestCase): self.assertTrue(self.transaction.is_paid) self.assertEqual(self.transaction.description, "TV") self.assertEqual(plan.transactions.count(), 3) + # The form's amount applies to every installment, including the paid original + self.assertEqual( + set(plan.transactions.values_list("amount", flat=True)), {70} + ) def test_linked_transaction_cannot_be_converted_into_plan(self): self._post(