-
Notifications
You must be signed in to change notification settings - Fork 5
/
GetStatementsAllAccounts.py
38 lines (29 loc) · 1.27 KB
/
GetStatementsAllAccounts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import csv
from sbanken.Sbanken import Sbanken
from helpers.Helpers import getAccounts, getTransactionDate, getPayee, getMemo, getOut, getIn
def main():
# enable_debug_logging()
import api_settings
import pprint
sbanken = Sbanken(api_settings.CUSTOMERID, api_settings.CLIENTID, api_settings.SECRET)
accounts = getAccounts(sbanken)
for account in accounts:
transactions = sbanken.GetTransactions(account['accountId'],1)
# pprint.pprint(transactions)
with open(account['name']+'_'+account['accountNumber']+'.csv', 'w', encoding='utf-8') as csvfile:
ktowriter = csv.writer(
csvfile,
delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
ktowriter.writerow(['Date', 'Payee', 'Memo', 'Outflow', 'Inflow'])
for item in transactions:
date = getTransactionDate(item)
payee = getPayee(item)
memo = getMemo(item)
outflow = getOut(item)
inflow = getIn(item)
ktowriter.writerow([date, payee, memo, outflow, inflow])
# if item['transactionTypeCode'] == 710:
# print(date, payee, memo, outflow, inflow)
if __name__ == "__main__":
main()