-
Notifications
You must be signed in to change notification settings - Fork 0
/
milestone.py
51 lines (39 loc) · 1.51 KB
/
milestone.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
__author__ = 'Rod Jacka'
__copyright__ = 'Copyright 2017, Panalysis PTY LTD'
import datetime
from distutils.util import strtobool
class Milestone(object):
milestones = {}
def __init__(self, data={}):
self.id = 0
self.local_id=0
self.project_id=0
self.title = ""
self.date_due = None
self.description = ""
self.complete = False
self.tasks = {}
if 'id' in data and data['id'] is not None:
self.id = int(data['id'])
if 'localid' in data and data['localid'] is not None:
self.local_id = int(data['localid'])
if 'projectid' in data and data['projectid'] is not None:
self.project_id = int(data['projectid'])
if 'complete' in data:
self.complete = strtobool(data['complete'])
if 'title' in data:
self.title = data['title']
if 'description' in data:
self.description = data['description']
Milestone.milestones[self.id] = self
def get_time_summary_by_consultant(self):
data = {}
for k,task in self.tasks.items():
for p,t in task.consultant_time.items():
if p not in data.keys(): data[p] = {'billable': 0, 'non-billable': 0}
for i in t:
if i.billable:
data[p]['billable'] = data[p]['billable'] + i.time
else:
data[p]['non-billable'] = data[p]['non-billable'] + i.time
return data