]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
Allow passing Decimals to FloatField
authorRaphael Michel <mail@raphaelmichel.de>
Mon, 3 Dec 2018 08:23:09 +0000 (09:23 +0100)
committerRaphael Michel <mail@raphaelmichel.de>
Mon, 3 Dec 2018 18:35:36 +0000 (19:35 +0100)
fints/fields.py

index 93c0821014497e5d03be1297428597fafbe489a4..20600ffb3414d98bc3b4e00351bff7dad7d0ce70 100644 (file)
@@ -1,4 +1,5 @@
 import datetime
+import decimal
 import re
 import warnings
 
@@ -118,6 +119,9 @@ class FloatField(DataElementField):
     def _parse_value(self, value):
         if isinstance(value, float):
             return value
+        
+        if isinstance(value, decimal.Decimal):
+            value = str(value.normalize()).replace(".", ",")
 
         _value = str(value)
         if not re.match(r'^(?:0|[1-9]\d*),(?:\d*[1-9]|)$', _value):