X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/5be6cca599e67d8fb8213ab76989271b873118a5..fdd63454b51a35418ec23d3489cf20ae66a2299d:/bin/starling.py diff --git a/bin/starling.py b/bin/starling.py index 0941cbb..ed745ee 100755 --- a/bin/starling.py +++ b/bin/starling.py @@ -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))