From 637c62319b0b474fefb2f557b21db35daf6bbab0 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sun, 14 Sep 2025 01:23:49 -0300 Subject: [PATCH] feat(transactions): Try to convert amount to the expected Decimal if it is a str, int or float --- app/apps/transactions/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/apps/transactions/models.py b/app/apps/transactions/models.py index cdbb069..7f56229 100644 --- a/app/apps/transactions/models.py +++ b/app/apps/transactions/models.py @@ -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 )