-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBillSplitter.py
36 lines (27 loc) · 891 Bytes
/
BillSplitter.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
import datetime
import time
from paypal_me import paypal_me_url
players = {
'Basti': '20:15-21:41',
'Dani': '18:46-21:41',
'Felix': '18:46-21:41',
'Toni': '18:46-21:41',
}
# 10 percent tip
bill = 36.8 * 1.1
player_list = players.keys()
player_time = {}
overall_time = datetime.timedelta()
for p in player_list:
s, e = players[p].split('-')
start = datetime.datetime.strptime(s, '%H:%M').time()
end = datetime.datetime.strptime(e, '%H:%M').time()
delta = datetime.datetime.combine(datetime.date.today(), end) - datetime.datetime.combine(datetime.date.today(), start)
overall_time += delta
player_time[p] = delta
bill_sum = 0
for p in player_list:
b = round(player_time[p] / overall_time * bill, 2)
bill_sum += b
print(f'{p} {players[p]}: {paypal_me_url}/{b}')
print(f'Felix bleibt auf so viel sitzen: {round(bill_sum - bill, 2)}')