| 1234567891011121314151617181920212223242526272829 |
- const overtime = (hours, priorHours, terminal) => {
- switch (terminal) {
- case 'LAX':
- case 'SFO':
- return californiaRules(hours)
- break
- case 'LAS':
- case 'PHX':
- return federalRules(hours, priorHours)
- break
- default:
- throw new Error(`Overtime rules not implemented for ${terminal}.`)
- }
- }
- const californiaRules = (hours) => {
- const regularHours = Math.min(hours, 8)
- const overtimeHours = Math.min(Math.max(hours - 8, 0), 4)
- const doubletimeHours = Math.max(hours - 12, 0)
- return {regularHours, overtimeHours, doubletimeHours}
- }
- const federalRules = (hours, priorHours) => {
- const regularHours = Math.max(Math.min(40 - priorHours, hours), 0)
- const overtimeHours = hours - regularHours
- return {regularHours, overtimeHours, doubletimeHours: 0}
- }
- module.exports = overtime
|