]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
Fix amount fields may might not contain a decimal sign 67/head
authorDaniel Molkentin <daniel@molkentin.de>
Thu, 2 May 2019 18:47:45 +0000 (20:47 +0200)
committerDaniel Molkentin <daniel@molkentin.de>
Thu, 2 May 2019 19:26:37 +0000 (21:26 +0200)
Otherwise, this breaks with Deutsche Bank

Previously accepted:

1000,
1000,1

Now accepted:

1000
1000,
1000,1

fints/fields.py

index 47d61392329e3e672ace5a91c7ab4d896f768031..39dcc33f45945a357dabb45d5c3b898fbb6c201f 100644 (file)
@@ -150,8 +150,8 @@ class AmountField(FixedLengthMixin, DataElementField):
             return value
 
         _value = str(value)
-        if not re.match(r'^(?:0|[1-9]\d*),(?:\d*[1-9]|)$', _value):
-            raise TypeError("Only digits and ',' allowed for value of type 'float', no superfluous leading or trailing zeroes allowed: {!r}".format(value))
+        if not re.match(r'^(?:0|[1-9]\d*)(?:,)?(?:\d*[1-9]|)$', _value):
+            raise TypeError("Only digits and ',' allowed for value of type 'decimal', no superfluous leading or trailing zeroes allowed: {!r}".format(value))
 
         return decimal.Decimal(_value.replace(",", "."))