]>
git.rmz.io Git - dotfiles.git/blob - bin/monzo.py
9f404ef0b50c33eccd7a9cf1a2e58a02e0f4b8e7
3 from datetime
import datetime
10 if __name__
== "__main__":
11 if outformat
== "qif":
13 print("NCurrent Accounts:Monzo")
17 with open(sys
.argv
[1], 'r') if len(sys
.argv
) > 1 else sys
.stdin
as fp
:
19 for t
in data
.get("transactions"):
21 date
= datetime
.strptime(t
["created"], "%Y-%m-%dT%H:%M:%S.%fZ")
23 date
= datetime
.strptime(t
["created"], "%Y-%m-%dT%H:%M:%SZ")
24 amount
= t
["amount"] / 100
25 if "name" in t
.get("counterparty", {}):
26 payee
= t
["counterparty"]["name"]
27 elif t
["merchant"] is None:
28 payee
= t
["description"]
30 payee
= t
["merchant"]["name"]
31 memo
= t
["description"]
32 memo
+= "\n{local_amount} {local_currency}".format(**t
)
34 if outformat
== "csv":
35 print('{date:%Y-%m-%d},{amount},"{payee}","{description}","{notes}"'.format(date
=date
,
39 elif outformat
== "qif":
40 print("D{:%Y-%m-%d}".format(date
))
41 print("T{}".format(amount
))
42 print("P{}".format(payee
))
43 print("M{}".format(memo
))
44 print("#{}".format(t
['id']))