Manuel Barkhau avatar Manuel Barkhau committed d114a58

Sort transactions

Comments (0)

Files changed (1)

lib1822direkt/ui.py

 
 PICKLEPATH = os.path.join(APP_DIR, 'transactions.pkl')
 
+def date_key(e):
+  day, mon, year = e['date'].split(".")
+  return year + mon + day
+
 class Gui:
 
   def __init__(self):
       if not _has_transaction(combined, t):
         combined.append(t)
 
+    combined = sorted(combined, key=date_key)
     self._transactions[account['number']] = combined
 
     if os.path.isfile(PICKLEPATH):
       self._liststore.append(row)
 
       if self._transactions.has_key(a['number']):
-        for j, t in enumerate(self._transactions[a['number']]):
+        transactions = sorted(self._transactions[a['number']],
+                              key=date_key)
+        transactions.reverse()
+        for j, t in enumerate(transactions):
           if j > TRANSACTION_COUNT:
             break
           row = [t['date'], t['person'], t['ammount']]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.