-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollaborator.py
More file actions
59 lines (48 loc) · 2.03 KB
/
Collaborator.py
File metadata and controls
59 lines (48 loc) · 2.03 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
52
53
54
55
56
57
58
59
from datetime import datetime, timedelta
class Collaborator(object):
def __init__(self, name, hour_per_week, rest_between_turn=60) -> None:
self.name = name
self.hour_per_week = hour_per_week
self.hour_worked_week = 0
self.work_today = True
self.last_turn = datetime.now()
self.rest_between_turn = timedelta(minutes = rest_between_turn)
def disponibility_to_work(self):
if self.work_today:
pass
elif datetime.now() - self.last_turn > self.rest_between_turn:
self.work_today=True
else:
left_time_rest = self.rest_between_turn - (datetime.now() - self.last_turn)
print(f"Colaborador no puede entrar aun debe descansar: {left_time_rest}")
self.work_today = False
return self.work_today
def work(self, hours=3):
# Crear alerta que avise cuando se aproxima la hora extra
if self.disponibility_to_work() == False:
return False
else:
if hours<0:
print("las horas no puedes ser negativas")
return False
elif hours<3:
print("El trabajador no puede trabajar menos de 3 horas")
return False
elif hours>12:
print("El colaborador no puede trabajar más de 12 horas")
return False
else:
self.hour_worked_week += hours
self.work_today = False
return True
def reset_week(self):
print(f"El colaborador realizao {self.hour_worked_week} horas en la semana")
self.hour_worked_week = 0
def compesation_hour(self):
extra_hour = max(self.hour_worked_week - self.hour_per_week, 0)
if extra_hour > 0:
print(f"Colaborador realizo: {extra_hour} hora extra")
self.hour_per_week -= extra_hour
else:
print("sin horas extras")
self.reset_week()