Implement the new API for bank file uploads
authorMagnus Hagander <[email protected]>
Thu, 30 Jan 2020 11:11:49 +0000 (12:11 +0100)
committerMagnus Hagander <[email protected]>
Thu, 30 Jan 2020 11:11:49 +0000 (12:11 +0100)
In particular, this moves the decoding of the character set into this
implementation, and update that one to use iso-8859-1 which is what CM
uses.

code/pgeusite/cmutuel/util.py

index 0f5a5450477c163b316f73e4c83415aba78e84bd..8b5801817e02fe7153a21751597f2ae332372305 100644 (file)
@@ -56,7 +56,8 @@ Download a reasonable range of transactions, typically with a few days overlap.
             'invoice': invoice,
         })
 
-    def parse_uploaded_file(self, contents):
+    def parse_uploaded_file(self, f):
+        contents = f.read().decode('iso-8859-1')
         reader = csv.reader(contents.splitlines(), delimiter=';')
 
         # Write everything to the database
@@ -116,4 +117,4 @@ Download a reasonable range of transactions, typically with a few days overlap.
                 # Re-raise but including the full row information
                 raise Exception("Exception '{0}' when parsing row {1}".format(e, row))
 
-        return (numrows, numtrans, numpending)
+        return (contents, numrows, numtrans, numpending)