From: Raphael Michel Date: Mon, 3 Dec 2018 08:23:09 +0000 (+0100) Subject: Allow passing Decimals to FloatField X-Git-Tag: v2.0.0~1^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f44cedeba4466a94f50ab31c6262dd03f85ad408;p=thirdparty%2Fpython-fints.git Allow passing Decimals to FloatField --- diff --git a/fints/fields.py b/fints/fields.py index 93c0821..20600ff 100644 --- a/fints/fields.py +++ b/fints/fields.py @@ -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):