This commit is contained in:
Ross
2021-01-17 10:07:02 +00:00
parent c2cee02158
commit 68738a2cfe
+7
View File
@@ -50,6 +50,9 @@ class Worker:
else:
days_to_work = (self.end_date - Rota.start_date).days
if days_to_work < 0:
days_to_work = 0
# add unavalabilities
for weeks_days in Rota.weeks_days_product[days_to_work:]:
week, day = weeks_days
@@ -62,12 +65,16 @@ class Worker:
end_oop_date = datetime.datetime.strptime(end_oop,
"%Y/%m/%d").date()
# ignore oops if they finish before the 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.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