feat(transactions): Try to convert amount to the expected Decimal if it is a str, int or float

This commit is contained in:
Herculino Trotta
2025-09-14 01:23:49 -03:00
parent 9eb1818a20
commit 637c62319b

View File

@@ -1,3 +1,4 @@
import decimal
import logging
from copy import deepcopy
@@ -381,6 +382,9 @@ class Transaction(OwnedObject):
default_manager_name = "objects"
def clean_fields(self, *args, **kwargs):
if isinstance(self.amount, (str, int, float)):
self.amount = decimal.Decimal(str(self.amount))
self.amount = truncate_decimal(
value=self.amount, decimal_places=self.account.currency.decimal_places
)