
Payroll Math Has More Edge Cases Than Most Software
Running payroll sounds like simple multiplication. Hours times rate equals gross pay. Subtract taxes. Done. Then you encounter overtime on multiple rates bonus tax withholding supplemental wages mid-year salary changes and multi-state employees. The basic calculation function grossPay ( hourlyRate , regularHours , overtimeHours ) { return ( hourlyRate * regularHours ) + ( hourlyRate * 1.5 * overtimeHours ); } function netPay ( gross , federalTax , stateTax , socialSecurity , medicare , deductions ) { return gross - federalTax - stateTax - socialSecurity - medicare - deductions ; } The edge cases Mid-period hire. An employee who starts on Wednesday of a bi-weekly pay period gets prorated pay. But proration of salary (daily rate = annual / 260 or annual / 365) is not standardized and affects benefit eligibility. Multiple pay rates. An employee who works 20 hours at $15 in one department and 25 hours at $18 in another. The weighted average regular rate is ($15*20 + $18*25) / 45 = $16.67.
Continue reading on Dev.to Tutorial
Opens in a new tab



