Ejemplo n.º 1
0
    def duty_beyond_nine_hours(shift):
        twelve_hours_duty = TimeSheet.get_shift_start(shift) + timedelta(
            hours=12)
        nine_hours_duty = TimeSheet.get_shift_start(shift) + timedelta(hours=9)
        break_start = TimeSheet.get_break_start(shift)
        break_end = TimeSheet.get_break_end(shift)

        # break STARTS and ENDS AFTER 9hrs and BEFORE 12hrs
        if (break_start > nine_hours_duty and
                break_end > nine_hours_duty) and break_end < twelve_hours_duty:
            duty_beyond_nine_hours = TimeSheet.get_break_end(
                shift) - nine_hours_duty
            return duty_beyond_nine_hours

        # break STARTS AFTER 9hrs and ENDS AFTER 12hrs
        elif break_start > nine_hours_duty and break_end > twelve_hours_duty:
            duty_beyond_nine_hours = TimeSheet.get_break_start(
                shift) - nine_hours_duty
            return duty_beyond_nine_hours

        # break STARTS BEFORE 9hrs and ENDS AFTER 9hrs duty
        elif break_start < nine_hours_duty < break_end < twelve_hours_duty:
            duty_beyond_nine_hours = TimeSheet.get_break_end(
                shift) - nine_hours_duty
            return duty_beyond_nine_hours

        else:  # if no break between 9hrs and 12hrs duty, use the full 3hrs
            duty_beyond_nine_hours = timedelta(hours=3)
            return duty_beyond_nine_hours
Ejemplo n.º 2
0
    def hours_after_six_and_less_than_nine(shift):
        six_pm = TimeSheet.get_shift_end(shift).replace(hour=18, minute=0)
        duty_beyond_twelve = Weekday.duty_beyond_twelve_hours(shift)
        duty_beyond_nine = Weekday.duty_beyond_nine_hours(shift)
        overtime_duty = duty_beyond_twelve + duty_beyond_nine
        duty_remainder = TimeSheet.get_shift_length(shift) - overtime_duty
        start_plus_remainder = TimeSheet.get_shift_start(
            shift) + duty_remainder
        break_start = TimeSheet.get_break_start(shift)
        break_end = TimeSheet.get_break_end(shift)

        if TimeSheet.get_shift_start(shift) + duty_remainder > six_pm:
            if break_start and break_end < six_pm:  # break STARTS and ENDS BEFORE 6pm
                hours_after_six_pm = (start_plus_remainder - six_pm
                                      ) - TimeSheet.get_break_duration(shift)
                return hours_after_six_pm

            elif break_start < six_pm < break_end:  # break STARTS BEFORE and ENDS AFTER 6pm
                break_after_six_pm = TimeSheet.get_break_end(shift) - six_pm
                hours_after_six_pm = (start_plus_remainder -
                                      six_pm) - break_after_six_pm
                return hours_after_six_pm

            else:  # no break spanning AFTER 6pm
                hours_after_six_pm = timedelta(hours=0, minutes=0)
                return hours_after_six_pm

        else:  # no break within the reminder of duty up to 9hrs
            hours_after_six_pm = timedelta(hours=0, minutes=0)
            return hours_after_six_pm
Ejemplo n.º 3
0
    def hours_before_six_and_less_than_nine(shift):
        six_pm = TimeSheet.get_shift_end(shift).replace(hour=18, minute=0)
        break_start = TimeSheet.get_break_start(shift)
        break_end = TimeSheet.get_break_end(shift)

        # shifts where 6pm comes BEFORE 9 hours duty
        if (TimeSheet.get_shift_start(shift) + timedelta(hours=9)) > TimeSheet.get_shift_end(shift) \
                .replace(hour=18, minute=0) < TimeSheet.get_shift_end(shift).replace(hour=12, minute=0):
            if break_start and break_end < six_pm:  # break STARTS and ENDS BEFORE 6pm
                hours_before_six_pm = (
                    TimeSheet.get_shift_start(shift) +
                    six_pm) - TimeSheet.get_break_duration(shift)
                return hours_before_six_pm

            elif break_start < six_pm < break_end:  # break STARTS BEFORE and ENDS AFTER 6pm
                break_before_six_pm = six_pm - TimeSheet.get_break_start(shift)
                hours_before_six_pm = (
                    six_pm -
                    TimeSheet.get_shift_start(shift)) - break_before_six_pm
                return hours_before_six_pm

            else:  # no break spanning BEFORE 6pm
                hours_before_six_pm = TimeSheet.get_shift_end(shift).replace(hour=18, minute=0) - \
                                      TimeSheet.get_shift_start(shift)
                return hours_before_six_pm

        else:  # no break BEFORE 6pm up to 9hrs
            hours_before_six_pm = TimeSheet.get_shift_end(shift).replace(hour=18, minute=0) - \
                                  TimeSheet.get_shift_start(shift)
            return hours_before_six_pm
Ejemplo n.º 4
0
    def duty_beyond_twelve_hours(shift):
        twelve_hours_duty = TimeSheet.get_shift_start(shift) + timedelta(
            hours=12)
        break_start = TimeSheet.get_break_start(shift)
        break_end = TimeSheet.get_break_end(shift)

        # break STARTS and ENDS AFTER 12hrs duty
        if break_start and break_end > twelve_hours_duty:
            duty_beyond_twelve_hours = (TimeSheet.get_shift_length(shift) - timedelta(hours=12)) - \
                                       TimeSheet.get_break_duration(shift)
            return duty_beyond_twelve_hours

        # break STARTS BEFORE and ENDS AFTER 12hrs duty
        elif break_start < twelve_hours_duty < break_end:
            duty_beyond_twelve_hours = TimeSheet.get_break_end(shift) - \
                                       (TimeSheet.get_shift_start(shift) + timedelta(hours=12))
            return duty_beyond_twelve_hours

        else:  # no break spanning AFTER 12hrs
            duty_beyond_twelve_hours = TimeSheet.get_shift_length(
                shift) - timedelta(hours=12)
            return duty_beyond_twelve_hours