Computing FLSA Overtime in Code: Regular Rate, Bonuses, and Dual-Rate Weeks
Implementing U.S. weekly overtime looks like max(0, hours - 40) * rate * 1.5 until an employee receives a non-discretionary bonus or works at two different pay rates in the same workweek.
Why the Regular Rate Includes Non-Discretionary Bonuses
Under the Fair Labor Standards Act (FLSA), overtime for non-exempt employees is based on the regular rate, not merely the base hourly wage:
total_straight_pay = base_hours * base_rate + bonus regular_rate = total_straight_pay / total_hours overtime_premium = max(0, total_hours - 40) * regular_rate * 0.5 gross_pay = total_straight_pay + overtime_premium For 45 hours at $24/hr plus a $120 production bonus:
total_straight_pay = 45 * 24 + 120 = 1200.00 regular_rate = 1200.00 / 45 = 26.6667 overtime_premium = 5 * 26.6667 * 0.5 = 66.67 gross_pay = 1266.67 Multiplying 5 * 1.5 * 24 ($1,260.00) undercalculates by $6.67 because the bonus raises the hourly value of every hour worked that week, including the 5 overtime hours.
Weighted Average for Two Rates in One Week
When an employee works 30h at $20/hr ($600) and 20h at $30/hr ($600), total hours are 50 and weighted regular_rate = $1,200 / 50 = $24/hr. The 10 overtime hours receive an extra 0.5 * $24 = $12/hr premium ($1,320 gross). State rules (such as California daily overtime past 8 hours and double-time past 12 hours) layer on top of the weekly floor.
To test weekly regular and overtime pay interactively with step-by-step numbers, check the Miryori Overtime Calculator.
Related reading
YMYL note: examples above illustrate standard FLSA arithmetic only and are not legal or payroll advice; confirm state daily overtime rules and exemption status separately.