---
# System prepended metadata

title: Auth Interceptor

---

# Auth Interceptor
* should be created
* should add an Authorization header to /accountsettings
* should log a user out when the api returns a 401 and send them back to /login route
* should not call logout if error status isn't a 401

# Conflicts service
### isInvalidEmployeeTime
* is valid when employeeTimes is not set
* is valid when employeeTimes is an empty array
* is invalid when the new start time would be the earliest time and doesnt belong to the first task
* is valid when the new start time would be the earliest time and belongs to the first task
* is invalid when the new endTime would be the latest time and doesnt belong to the last task
* is valid when the new end time would be the latest time and belongs to the last task
* is valid when closing the gap between 2 tasks by setting 2nd task startTime = 1st task endTime
* is invalid when later tasks startTime is set before earlier tasks startTime
* is valid when closing the gap between 2 tasks by setting the 1st task endTime = 2nd task startTime
* is invalid when later tasks startTime is set before earlier tasks startTime
* is valid when an open task has its start time changed to be earlier
* is invalid when the new startTime overlaps with another startTime
* is invalid when the new endTime overlaps with another endTime
* is valid when there are no overlaps
* is valid when new endTime belongs to first task and is less than the endTime
* is valid when new endTime does not belong to first task and is less than the endTime
* is invalid when new start time does not belong to first task and is the earliest startTime
* is invalid when new endTime belongs to the first task and the new time is the latest time
* is invalid when new endTime is not the first task and the new time is the latest time


### getConflictedCrew
* has no conflicts when newStartTime is after all the pre-existing startTimes and endTimes
* has no conflicts when newStartTime is after all the pre-existing startTimes and is the same time as an endTime
* has no conflicts when newStartTime is after all the pre-existing startTimes and is equal to now wherein the endTimes are null
* has conflicts when newStartTime is after all the pre-existing startTimes but overlaps an endTime

### resolveCrew
* adjusts new task startTime conflict when ConflictResolutionType is AdjustThisTask
* adjusts pre-existing task endTime conflict when ConflictResolutionType is AdjustConflictTask
* removes the conflicting task when ConflictResolutionType is Cancel
* adjusts the resolved task times with the specified latitude and longitude

# Crew Service
### getCrew
* appends an ALL_STAFF staff group with an ID of 0
* only saves crew members that are in the employee access list if it is not empty
* saves all crew members if the employee access list is empty

### searchCrew
* finds the employee if the search is a substring of their first name
* finds the employee if the search is a substring of their last name
* does not find an employee if neither their first or last name are matched
* only returns the found employee if they are in the access list
* only returns the found employee if they are in the access list

### filterByStaffGroup
* returns all employees if staffGroupId is ALL_STAFF_ID
* returns all employees from the access list if staffGroupId is ALL_STAFF_ID
* returns employees that belong to the staffGroupId
* returns employees in the access list that belong to the staffGroupId

# NotificationService
### getWeekdaysRelativeToDate
* should return five unique weekdays excluding today when `now` is equal to `when`
* should return five unique weekdays including today
* should return five unique weekdays excluding today which is the weekend
* should throw when given invalid Date
 
### getWeekendRelativeToDate
* should return two unique weekend days excluding today
* should return two unique weekend days including today
* should return two unique weekend days when `now` is a weekday
* should throw when given invalid Date

### rescheduleNotifications
* should cancel all pending notification and schedule none
* schedules Start Timesheet notifications for each weekday
* schedules Submit Timesheet notifications for each weekday
* schedules Start & Submit Timesheet notifications for each weekday
* schedules Start & Submit Timesheet notifications for each day


# SearchComponent
* should emit correct search params when the user enters a search query after a delay
* should emit an empty search event when the user enters an empty string

# Add Crew Service
### getAddCrewPageData
* filters timesheet employees
* filters inactive employees
* filters absent employees
### addTaskTime
* creates a copied taskTime from the copied employee task time


# Employee Time Service
### adjustTaskForUpdatedTaskTimes
* sets the task StartTime to the earliest TaskTime start
* sets the task EndTime to the latest TaskTime end
* sets both StartTime and EndTime to the earliest/latest task times respectively
* does not modify the times if start/end are not earlier/later than the earliest/latest task time
### deleteEmployeeTaskTimeFromTimesheet
* removes the employee from the timesheet if they only belong to one task
* does not remove the employee from the timesheet if they have other tasks
### resetEmployeeLunch
* resets the lunch of the provided employee if they exist in the timesheet and/or task times
### getAdjustedTaskTimes
* only updates the specified employeeId
* sets endTime taskTime properties when manualEndTimeEdit is true
* sets startTime taskTime properties when manualStartTimeEdit is true

# Lunch break service
### lunchTimeIsValid
* is invalid when the lunch startTime is before the tasks earliest start time
* is invalid when the lunch endTime is after the tasks latest end time
* is valid when the lunch startTime is equal to the tasks earliest start time
* is valid when the lunch endTime is equal to the tasks latest end time
* is valid when the lunch startTime is after the tasks earliest start time
* is valid when the lunch endTime is before the tasks latest end time
* is invalid when the lunch time range overlaps a gap between tasks
* is invalid when the lunch time range partially overlaps a gap between tasks
* is valid when the lunch time range is split between two tasks with no gap
* is valid when the lunch time range occurs during one task
* is valid when two separate tasks occur during the same time range
* is valid when two separate tasks overlap a time range
* is invalid when two separate tasks overlapping a time range have a lunch that occurs during an endTime gap for one of those tasks
* is invalid when two separate tasks overlapping a time range have a lunch that occurs during a startTime gap for one of those tasks
* is valid when you have different timezones being sorted
* is valid when the lunch applies to a date range only applicable to selected employees
* is invalid when the lunch applies to a date range not only applicable to selected employees
* is valid when the lunch applies to a date range only applicable to selected employees across multiple tasks
* is invalid when the lunch applies to a date range not applicable to selected employees across multiple tasks
* is invalid when an employee task time is outside of a lunch boundary while the parent task is within the lunch boundary

### removeLunchAdjustmentFromEmployeeTaskTime
* sets LunchAdjustment to 0 for the given employeeId

### addLunchAdjustmentToEmployeeTaskTime
* applies a lunch adjustment to the correct task with the correct duration when only one task exists
* splits a lunch adjustment when lunch range overlaps two tasks
* applies lunch adjustments only to employees that have started their first task before lunch time

### removeLunchAdjustmentFromEmployeeTaskTime
* sets taskTime LunchAdjustment to 0 for all taskTimes belonging to employeeId

### addLunchAdjustmentToEmployeeTaskTime
* sets taskTime LunchAdjustment to 0 if the lunch is not within the employee's taskTime date range
* sets taskTime LunchAdjustment to 0 if the lunch duration is 0
* sets taskTime LunchAdjustment to duration if the lunch's date range falls within a task's date range
* splits taskTime LunchAdjustment when the lunch's date range overlaps the startTime and endTime of two tasks
* splits taskTime LunchAdjustment when the lunch's date range overlaps the startTime and endTime of two tasks with a time gap between them
* splits taskTime LunchAdjustment when the lunch's date range overlaps three tasks PENDING WITH MESSAGE: Temporarily disabled with xit

### addLunchToTimesheetEmployee
* sets the employee object lunch properties when an employee taskTime has a LunchAdjustment
* does not set the employee object lunch properties when an employee taskTime does not have a LunchAdjustment

### removeLunchFromTimesheetEmployee
* sets the employee object lunch properties for no lunch being applied

### updateEmployeesOnLunchApplied
* sets your lunch duration to the sum of your tasks lunchAdjustments lunch is contained within a single task
* sets your lunch duration to the sum of your tasks lunchAdjustments when spanning two tasks
* only updates selected employees

### updateEmployeesOnNoLunchApplied
* only updates selected employees

### updateEmployeesOnLunchAppliedForSubmit
* applies lunch adjustments for selected employees, independent of their prior lunch adjustments
* applies no-break lunch adjustment for non selected employees who have no prior lunch adjustment
* does not apply lunch adjustment for non selected employees who have prior lunch adjustments

### updateEmployeesOnNoLunchAppliedForSubmit
* applies no-break lunch adjustment for selected employees, independent of their prior lunch adjustments
* applies no-break lunch adjustment for non selected employees who have no prior lunch adjustment
* does not apply no-break lunch adjustment for non selected employees who have prior lunch adjustments

# Punch In Service

### setStartTime
* should set the startTime to current date/time if timesheet is today
* should set the startTime to current date/time if timesheet is yesterday
* should set the startTime to 12:00 AM if difference in days between timesheet date and current date is greater than one
* should set the startTime to the next task time from punch out when available

### addEmployee
* should set the default crew with the default props
* should set any employees isSelected to false when their marked as absent
* should set any employees added via the add crew tab to the default props
* should set any employees added via the add crew tab to the current props

### taskChange
* should change selected task for all employees
* should appply employee.SelectedJobRateID as 0 when jobsite rates are empty to all employees
* should appply employee.SelectedJobRateID as selectedJobRateId when jobsite rates is > 0 to all employees
* should appply employee.isTM as true when jobsite.task.isTM is true (hourlyBilled) to all employees

### singleTaskChange
* should only change selected task for individual employee
* should appply employee.SelectedJobRateID as 0 when jobsite rates are empty
* should appply employee.SelectedJobRateID as selectedJobRateId when jobsite rates is > 0
* should appply employee.isTM as true when jobsite.task.isTM is true (hourlyBilled)

### ratesChange
* should apply rates to all crew members

### addTask
* should apply single task with all crew to timesheet
* should apply multiple task with crew on different tasks to timesheet
* should append the latest tasks EquipmentNotes the new task/s
* should apply the current weather notes based on your location to tasks WeatherNotes

### addTaskTimes
* should set manual edit to true when date/time picker has been changed
* should set the employees start times to start of minute
* should apply rate props to employees task time if task & materials (isTM) and the jobsite rates length > 0

### addTimesheetEmployees
* should add all employees when TimesheetEmployees is empty
* should add only new employees to the timesheet when TimesheetEmployees > 0
* should set the correct lunch props by default

# Punch Out Service
### getSelectedCrewFromTasks
* filters out task times that have an end time set
* uses the employee first/last name on the TaskTime object

### everyTaskNoteHasContent
* returns true if all note fields required by the job type are set
* returns false if note fields required by the job type are not set
* returns false for required notes with whitespace-only values

### setTaskServices
* flattens the TaskServices and re-assigns them to the timesheet task
* only maps Selected services

### validateTaskTimes
* only validates selected task times

### setTaskTimeNullEndTimes
* only modifies selected task times
* sets the EndTime of task times with null end times to the supplied end time
* sets ManualStopTime to the "now" if manualEdit is true
* sets EditStopLatitude/EditStopLongitude to the supplied lat/lng if manualEdit is true
* sets EditStopLatitude/EditStopLongitude to 0 if manualEdit is false


# Review Timesheets Service
### getReviewTimesheetData
* sets TimesheetApproved to false when timesheet.TimesheetStatusId is 1
* sets TimesheetApproved to true when timesheet.TimesheetStatusId is not 1
* sets timesheetDate to timesheet.TimesheetDate
* sets absentEmployees to all employees marked absent
* sets employees only to employees who are not absent
* sets an employee's start time to their earliest start time, end time to their latest end time, and total time
* sets the TotalTime for each task
* sets the RateHours for each rate

# Select Crew Service
### getDefaultSelectedEmployees
* sets selected to true for non absent and non-clocked-in employees, false otherwise

### getNonDefaultEmployees
* sets selected to true for non absent and non-clocked-in employees, false otherwise

### isEmployeeSelectionValid
* is valid when at least one employee is selected
* is invalid when no employees are selected

### getFilteredEmployeesForStaffSelection
* is not filtered when the staffGroupId is 0
* filters employees based on staffGroupId


# Timesheet Service
### getTasksOnDateChanged
* returns an empty array when provided a timesheet with no tasks
* sets a new task startTime and endTime when date changes
* sets a startTime and endTime on all taskTimes when date changes
* does not change task endTime when endTime is null (pending task)
* does not change taskTime endTime when endTime is null (pending task)

### getTimesheetEmployeesOnDateChanged
* returns an empty array when provided a timesheet with no timesheet employees
* sets a new LunchStartTime when a lunch has been applied
* does not modify LunchStartTime when no lunch has been applied

# Timesheets Service
### removeDuplicateTimesheetData
* should retain all unique timesheet employees by EmployeeID

# Tracking Service
### getEmployeeTracking$
* filters the response employees to only the ones present in the access list
* sets the employees "as-is" if there are no IDs in the employeeaccesslist

# Utilities service
### validateDates
* should resolve when startTime and endTime do not belong to the same 60 second interval
* should reject when startTime and endTime belong to the same minute
* should resolve when startTime or endTime is not in the future and AllowFutureClockout is false
* should reject when startTime or endTime is in the future and AllowFutureClockout is false
* should resolve when endTime is in the future and AllowFutureClockout is true
* should reject when startTime is after endTime
* should reject when difference between times is > 48 hours
* should reject when difference between first task time and startTime or endTime is > 48 hours
* should reject when the startTime is > 24 hours from timesheetDate
* should reject when the endTime is > 24 hours from timesheetDate
* should resolve when the startTime is <= 24 hours from timesheetDate
* should resolve when the endTime is <= 24 hours from timesheetDate
* should reject when the startTime and endTime have more than 48 hours difference between them
* should resolve when the startTime and endTime have <= 48 hours difference between them
* should resolve when the startTime is earlier than the firstTaskStartTime on an open task
* should resolve when the endTime is null
