]> git.rmz.io Git - dotfiles.git/blobdiff - bin/starling.py
zsh: don't do task-quote-magic on global aliases
[dotfiles.git] / bin / starling.py
index 669cf06f678fd37325b4e0043c891a01e2ac8b6f..7f4615071c77e142d72a8638584d6651b8b393b0 100755 (executable)
@@ -12,7 +12,9 @@ class FeedError(Exception):
 
 def read_feed_item(i):
     try:
-        date = datetime.strptime(i["transactionTime"], "%Y-%m-%dT%H:%M:%S.%fZ")
+        if i.get("status", "") == "DECLINED":
+            return
+        date = datetime.strptime(i["transactionTime"], "%Y-%m-%dT%H:%M:%S.%f%z")
         amount = i["amount"]["minorUnits"] / 100
         if i["direction"] == "OUT":
             amount = -amount
@@ -25,7 +27,7 @@ def read_feed_item(i):
                 description=reference,
                 notes=reference))
         elif outformat == "qif":
-            print("D{:%Y-%m-%d}".format(date))
+            print("D{:%Y-%m-%d}".format(date.astimezone(None)))
             print("T{}".format(amount))
             print("P{}".format(payee))
             print("M{}".format(reference))
@@ -37,6 +39,9 @@ def read_feed_item(i):
 
 if __name__ == "__main__":
     if outformat == "qif":
+        print("!Account")
+        print("NCurrent Accounts:Starling")
+        print("^")
         print("!Type:Bank")
     cnt = 1
     with open(sys.argv[1], 'r') if len(sys.argv) > 1 else sys.stdin as fp: