File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 7
7
8
8
from .forms import UploadForm
9
9
from .importer import NDAImporter
10
+ from .parser import parseLine
11
+ from .models import UploadedTransaction
10
12
11
13
12
14
class NordeaUploadView (FormView ):
@@ -32,6 +34,24 @@ def form_valid(self, form):
32
34
h = NDAImporter (f )
33
35
transactions = h .import_transactions (transactions_handler )
34
36
37
+ # parse the file again for the last transaction timestamp
38
+ last_stamp = None
39
+ with open (tmp .name ) as fp :
40
+ for line in fp :
41
+ nt = parseLine (line )
42
+ if not nt :
43
+ continue
44
+ if not last_stamp :
45
+ last_stamp = nt .timestamp
46
+ if nt .timestamp > last_stamp :
47
+ last_stamp = nt .timestamp
48
+
49
+ UploadedTransaction (
50
+ last_transaction = last_stamp ,
51
+ file = self .request .FILES ['ndafile' ],
52
+ user = self .request .user
53
+ ).save ()
54
+
35
55
# Done with the temp file, get rid of it
36
56
os .unlink (tmp .name )
37
57
You can’t perform that action at this time.
0 commit comments