-
Notifications
You must be signed in to change notification settings - Fork 0
/
formule.py
123 lines (85 loc) · 3.17 KB
/
formule.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
from google.appengine.api import users
from models import Salary
def year(self, leto):
current_user = users.get_current_user()
if current_user:
salary = Salary.query(Salary.user == current_user.nickname(), Salary.y == leto).order(Salary.m).fetch()
daily = []
for item in salary:
daily.append(item.daily)
daily = [w.replace(',', '.') for w in daily]
daily = map(float, daily)
month_total_daily = sum(daily)
dailywtax = []
for item in salary:
dailywtax.append(item.dailywtax)
dailywtax = [w.replace(',', '.') for w in dailywtax]
dailywtax = map(float, dailywtax)
month_total_dailywtax = sum(dailywtax)
total_hrs = []
for item in salary:
(h, m) = item.total_hrs.split(":")
result = int(h) * 3600 + int(m) * 60
total_hrs.append(result)
result = sum(total_hrs)
result = float(result) / 3600.0
result = str(result)
(h, m) = result.split(".")
h = str(h)
m = str(m)
m = ("0.%s") % m
m = float(m)
m = m * 60.0
m = round(m)
m = int(m)
m = str(m)
if len(m) < 2:
m = ("0%s") % (m)
month_total_hrs = ("%s:%s") % (h, m)
params = {"salary": salary, "month_total_daily": month_total_daily,
"month_total_dailywtax": month_total_dailywtax, "month_total_hrs": month_total_hrs}
self.render_template("/leto2015/l2015.html", params)
else:
return self.render_template("/leto2015/l2015.html")
def month(self, mesec, leto, mesec_html):
current_user = users.get_current_user()
if current_user:
salary = Salary.query(Salary.user == current_user.nickname(), Salary.m == mesec,
Salary.y == leto).order(Salary.date).fetch()
daily = []
for item in salary:
daily.append(item.daily)
daily = [w.replace(',', '.') for w in daily]
daily = map(float, daily)
month_total_daily = sum(daily)
dailywtax = []
for item in salary:
dailywtax.append(item.dailywtax)
dailywtax = [w.replace(',', '.') for w in dailywtax]
dailywtax = map(float, dailywtax)
month_total_dailywtax = sum(dailywtax)
total_hrs = []
for item in salary:
(h, m) = item.total_hrs.split(":")
result = int(h) * 3600 + int(m) * 60
total_hrs.append(result)
result = sum(total_hrs)
result = float(result) / 3600.0
result = str(result)
(h, m) = result.split(".")
h = str(h)
m = str(m)
m = ("0.%s") % m
m = float(m)
m = m * 60.0
m = round(m)
m = int(m)
m = str(m)
if len(m) < 2:
m = ("0%s") % (m)
month_total_hrs = ("%s:%s") % (h, m)
params = {"salary": salary, "month_total_daily": month_total_daily,
"month_total_dailywtax": month_total_dailywtax, "month_total_hrs": month_total_hrs}
self.render_template(mesec_html, params)
else:
return self.render_template(mesec_html)