~dricottone/fmg-timesheets

fmg-timesheets/analysis/totals.py -rw-r--r-- 971 bytes
b10830e9Dominic Ricottone README updates 2 years ago
                                                                                
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
#!/usr/bin/env python3

def totals(timesheets):
    projects = {}

    for timesheet in timesheets:
        for entry in timesheet:
            key = entry.project
            if entry.time_code in ("HOL", "OTU", "VAC", "OPL", ):
                key = entry.time_code

            if key not in projects.keys():
                projects[key] = {}
                projects[key]["name"] = entry.label
                projects[key]["hours"] = 0

            for hours in entry.data.values():
                projects[key]["hours"] += hours

    for project, data in projects.items():
        print(f"{project:20} {data['name']:100} {data['hours']}")

def total_ocps2020(timesheets):
    total = 0
    for timesheet in timesheets:
        for entry in timesheet:
            if entry.project == "20032.001.20.005":
                for date, hours in entry.data.items():
                    total += hours
                break
    print(f"{total} hours spent on OCPS 2020")