From 3261e5f2661e5eabeda1f31bd48d3229a7c9f7d6 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Mon, 12 Oct 2026 02:41:14 -0300 Subject: [PATCH] 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(