Add trailing '?' for employee time sheet when hours are incomplete

This commit is contained in:
Lance Edgar 2017-03-14 12:31:10 -05:00
parent 693c2dce57
commit 9a8fa43c6a

View file

@ -372,6 +372,7 @@ class TimeSheetView(View):
employee.weekdays = [{} for day in weekdays] employee.weekdays = [{} for day in weekdays]
setattr(employee, '{}_hours'.format(shift_type), datetime.timedelta(0)) setattr(employee, '{}_hours'.format(shift_type), datetime.timedelta(0))
setattr(employee, '{}_hours_display'.format(shift_type), '0') setattr(employee, '{}_hours_display'.format(shift_type), '0')
hours_incomplete = False
for i, day in enumerate(weekdays): for i, day in enumerate(weekdays):
empday = { empday = {
@ -391,6 +392,8 @@ class TimeSheetView(View):
empday['{}_hours'.format(shift_type)] += shift.length empday['{}_hours'.format(shift_type)] += shift.length
setattr(employee, '{}_hours'.format(shift_type), setattr(employee, '{}_hours'.format(shift_type),
getattr(employee, '{}_hours'.format(shift_type)) + shift.length) getattr(employee, '{}_hours'.format(shift_type)) + shift.length)
else:
hours_incomplete = True
del employee_shifts[0] del employee_shifts[0]
else: else:
break break
@ -402,8 +405,10 @@ class TimeSheetView(View):
hours = getattr(employee, '{}_hours'.format(shift_type)) hours = getattr(employee, '{}_hours'.format(shift_type))
if hours: if hours:
setattr(employee, '{}_hours_display'.format(shift_type), display = pretty_hours(hours)
pretty_hours(hours)) if hours_incomplete:
display = '{} ?'.format(display)
setattr(employee, '{}_hours_display'.format(shift_type), display)
@classmethod @classmethod
def defaults(cls, config): def defaults(cls, config):