mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-02 02:51:40 +02:00
Merge pull request #375
feat(transactions): Try to convert amount to the expected Decimal if it is a str, int or float
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import decimal
|
||||||
import logging
|
import logging
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
@@ -381,6 +382,9 @@ class Transaction(OwnedObject):
|
|||||||
default_manager_name = "objects"
|
default_manager_name = "objects"
|
||||||
|
|
||||||
def clean_fields(self, *args, **kwargs):
|
def clean_fields(self, *args, **kwargs):
|
||||||
|
if isinstance(self.amount, (str, int, float)):
|
||||||
|
self.amount = decimal.Decimal(str(self.amount))
|
||||||
|
|
||||||
self.amount = truncate_decimal(
|
self.amount = truncate_decimal(
|
||||||
value=self.amount, decimal_places=self.account.currency.decimal_places
|
value=self.amount, decimal_places=self.account.currency.decimal_places
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user