-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
51 lines (40 loc) · 1.5 KB
/
util.py
File metadata and controls
51 lines (40 loc) · 1.5 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
import money
import pendulum
def prep_account(account, key_name):
name = account['name'] if account['official_name'] is None else account['official_name']
a = (account['account_id'], name, account['type'], account['subtype'], key_name)
print('\t', a)
return a
def prep_balances(account):
cur = money.Money(
0 if account['balances']['current'] is None else account['balances']['current'],
account['balances']['iso_currency_code']
)
avail = money.Money(
0 if account['balances']['available'] is None else account['balances']['available'],
account['balances']['iso_currency_code']
)
lim = money.Money(
0 if account['balances']['limit'] is None else account['balances']['limit'],
account['balances']['iso_currency_code']
)
print('\t', 'cur\tavail\tlim')
print('\t', '\t'.join([cur.format(), avail.format(), lim.format()]))
return [
('cur', account['account_id'], cur),
('avail', account['account_id'], avail),
('lim', account['account_id'], lim),
]
def prep_balance(bal):
formatted = []
for b in bal:
db_amount = b[0]
if b[4] == 'credit':
db_amount = db_amount * -1
amount = money.Money(db_amount / 100, 'USD')
db_at = b[1]
gmt_at = pendulum.parse(db_at)
tz = pendulum.timezone('US/Eastern')
est_at = tz.convert(gmt_at)
formatted.append([amount.format(), str(est_at), b[2], b[3], b[4], b[5]])
return formatted