diff --git a/python/arbeitsstundenzettel.py b/python/arbeitsstundenzettel.py index db035082e7a1c6504ecd655580327946330d1a0d..b1cd5813999cabf41db147b6116f68861482b23d 100644 --- a/python/arbeitsstundenzettel.py +++ b/python/arbeitsstundenzettel.py @@ -128,7 +128,7 @@ def move_filled_week(list_of_workinghours, workingday_list_position, list_of_fil def make_up_workinghours(month, start, end, workhours_per_week, workdays_per_week, already_worked = 0): - + full_months = diff_full_months(start, end) months = diff_months(start, end) weeks = diff_weeks(start, end) @@ -150,7 +150,7 @@ def make_up_workinghours(month, start, end, workhours_per_week, workdays_per_wee print("Urlaubsanspruch in Stunden: ", holidayhours_total) print("Urlaubstage: ", holidaydays_total) print("") - + full_date_list = [start + dt.timedelta( days = x ) for x in range(0, days)] holiday_list = holidays.Holidays(start.year, 'BY').get_holiday_list()[0] + holidays.Holidays(end.year, 'BY').get_holiday_list()[0] @@ -158,12 +158,20 @@ def make_up_workinghours(month, start, end, workhours_per_week, workdays_per_wee global start_time_earliest global start_time_latest global preferred_weekdays - + timestep = 0.5 start_time_earliest = 9 start_time_latest = 12 preferred_weekdays = [0,1,2,3,4] - + # fixed working times, eg work every friday 9:00-12:00 -> [[4, 9, 12]] + fixed_times = [[4, 9, 12]] + fixed_days = [tframe[0] for tframe in fixed_times] + fixed_start_hours = [tframe[1] for tframe in fixed_times] + fixed_end_hours = [tframe[2] for tframe in fixed_times] + + + # advanced_settings = True + if advanced_settings: timestep = int(input( '''Working hours are distributed over random days @@ -228,17 +236,26 @@ Example: 0 1 2 = Monday, Tuesday and Wednesday print("") break - made_up_workinghours = [] make_up_workinghours = [] - + made_up_workinghours = [] + used_workinghours = 0.0 + + # on first run add the wanted working hours and add some random working hours for i in range(len(date_list)): - workingday = date_list[i] - make_up_start_time = random.randint(start_time_earliest,start_time_latest) - make_up_end_time = random.randint(16,20) - make_up_duration = 0.0 - make_up_break = sp.random.choice([0, 0.25, 0.5, 0.75, 1.0], p=[0.8, 0.05, 0.05, 0.05, 0.05]) - + if workingday.weekday() in fixed_days: + idx = [i for i,x in enumerate(fixed_days) if x == workingday.weekday()][0] + make_up_start_time = fixed_start_hours[idx] + make_up_end_time = fixed_end_hours[idx] + make_up_duration = float(make_up_end_time-make_up_start_time) + used_workinghours += make_up_duration + make_up_break = 0 + else: + make_up_start_time = random.randint(start_time_earliest,start_time_latest) + make_up_end_time = random.randint(16,20) + make_up_duration = 0.0 + make_up_break = sp.random.choice([0, 0.25, 0.5, 0.75, 1.0], p=[0.8, 0.05, 0.05, 0.05, 0.05]) + make_up_workinghours.append([workingday]) make_up_workinghours[i].append(workingday.strftime("%d.%m.%Y")) make_up_workinghours[i].append(cal.day_abbr[workingday.weekday()])