]> git.rmz.io Git - dotfiles.git/blobdiff - bin/starling.py
lazyvim: absorb snacks notifier
[dotfiles.git] / bin / starling.py
index 471cd1438310ff95f18affb11c8a6083feafbf8b..ed745eef38dfc430f779747671c877cd4c958b38 100755 (executable)
@@ -14,11 +14,13 @@ def read_feed_item(i):
     try:
         if i.get("status", "") == "DECLINED":
             return
-        date = datetime.strptime(i["transactionTime"], "%Y-%m-%dT%H:%M:%S.%fZ")
+        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,
@@ -27,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))