fix(transactions): apply the form amount to a paid transaction converted into an installment plan

This commit is contained in:
Herculino Trotta committed 2026-10-12 02:41:14 -03:00
1 parent 35ef1dd716
commit 3261e5f266
2 files changed
+7 -1

No files matched your search

+2
View File
@@ -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:
+5 -1
View File
@@ -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(