This commit is contained in:
Ross
2021-06-24 21:02:18 +01:00
parent 01005176a5
commit ab73ead7c1
8 changed files with 689 additions and 545 deletions
+23 -13
View File
@@ -20,7 +20,8 @@ class Worker:
pref_not_to_work=None,
work_requests=None,
proc_site="plymouth",
previous_shifts={}
previous_shifts={},
pair=0
):
self.id = id
self.name = name
@@ -31,6 +32,7 @@ class Worker:
self.fte = fte
self.nwd = nwd
self.proportion_rota_to_work = 1
self.pair = pair
self.proc_site = proc_site
if proc_site == "plymouth" or proc_site == "":
@@ -72,24 +74,28 @@ class Worker:
# ignore oops if they finish before the rota start date
print(end_oop_date, Rota.start_date)
if end_oop_date > Rota.start_date:
if end_oop_date > Rota.rota_end_date:
end_oop_date = Rota.rota_end_date
if start_oop_date > Rota.rota_end_date:
pass
else:
if end_oop_date > Rota.rota_end_date:
end_oop_date = Rota.rota_end_date
if start_oop_date < Rota.start_date:
start_oop_date = Rota.start_date
if start_oop_date < Rota.start_date:
start_oop_date = Rota.start_date
oop_length = (end_oop_date - start_oop_date).days
days_to_work = days_to_work - oop_length
oop_length = (end_oop_date - start_oop_date).days
days_to_work = days_to_work - oop_length
days_until_oop = (start_oop_date - Rota.start_date).days
days_until_oop = (start_oop_date - Rota.start_date).days
for weeks_days in Rota.weeks_days_product[
days_until_oop:days_until_oop + oop_length]:
week, day = weeks_days
Rota.unavailable_to_work.add((self.id, week, day))
Rota.unavailable_to_work_reason[(self.id, week, day)] = "OOP ()".format(oop)
for weeks_days in Rota.weeks_days_product[
days_until_oop:days_until_oop + oop_length]:
week, day = weeks_days
Rota.unavailable_to_work.add((self.id, week, day))
Rota.unavailable_to_work_reason[(self.id, week, day)] = "OOP ()".format(oop)
if pref_not_to_work is not None:
# loop throught dates converting to week / day combination
@@ -127,11 +133,15 @@ class Worker:
day = Rota.days[(days_from_start % 7)]
Rota.work_requests.add((self.id, week, day, shift))
print(days_to_work, Rota.rota_days_length)
self.proportion_rota_to_work = days_to_work / Rota.rota_days_length
# We had to adjust the full time equivalent for people who CCT / leave the rota early
self.fte_adj = self.fte * self.proportion_rota_to_work
if self.fte_adj > 100:
raise ValueError("{} : fte_ajd = {}".format(self.name, self.fte_adj))
# print(self.name, self.nwd)
def __lt__(self, other):