]> git.rmz.io Git - dotfiles.git/blobdiff - bin/starling.py
bin: differentiate between personal and joint account payees
[dotfiles.git] / bin / starling.py
index 0941cbb2f69b163fcfbd7fe8d2a52ca7ac3dda9d..ed745eef38dfc430f779747671c877cd4c958b38 100755 (executable)
@@ -12,11 +12,15 @@ 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
         payee = i["counterPartyName"]
+        if "counterPartySubEntityName" in i:
+            payee += " ({})".format(i["counterPartySubEntityName"])
         reference = i.get("reference", payee)
         if outformat == "csv":
             print('{date:%Y-%m-%d},{amount},"{payee}","{description}","{notes}"'.format(date=date,
@@ -25,7 +29,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))