compute
A function which returns the tax amount for the requested tax, passing all parameter information in a single call.
value = compute ( $taxname, $earnings, $ytdearnings, $filingstatus, $exemptions, $stateexemptions, $payperiods, $paydate, $misc, $aux, $ytdtax )
- value - A float result.
- $taxname - A string naming the specific tax from the table to be computed.
- $earnings - Gross earnings for the current pay period.
- $ytdearnings - Year-to-date earnings prior to the current pay period.
- $filingstatus - Numeric value representing the employee's filing status for this tax. (see filingstatus)
- $exemptions - Total from Form W-4 Step 3, line 3.
- $stateexemptions - State exemptions claimed by the employee.
- $payperiods - Number representing the total number of pay periods in a year.
- $paydate - A Date object representing the check date. Default is current date.
- $misc - A numeric value required by some formulas. When this field is required, the tax object will have specific instructions in the $miscellaneous_instructions field. (see tax)
- $aux - A numeric value required by some formulas. When this field is required, the tax object will have specific instructions in the $auxiliary_instructions field. (see tax)
- $ytdtax - Year-to-date tax amount withheld for this tax prior to the current period.
Examples
Ohio state tax for a married employee:
<?phpinclude 'taxes.php';// take the default for most parameters:$amt = compute('OH', // tax name 2000, // gross earnings 0, // ytd earnings $filingMarried);// filing statusprint $amt;?>
Federal is a litte more complicated, because it need most of the parameters. This example assumes the employee has signed a 2020 or later W-4:
<?phpinclude 'taxes.php';$amt = compute('Federal Income Tax', 2000, // earnings this period 6000, // ytd earnings $filingMarried, 2500, // exemptions=W-4 total credits 0, // state exemptions. use -1 for // nonresident alien 24, // bi-monthly 0, // paydate (take default) 1000, // misc = step 4(a) - 4(b) 1, // aux = step 2(b), multiple jobs 1130.01 // ytd tax withheld );print $amt;?>
For employees who haven’t signed a 2020 or later W-4, use the following:
<?phpinclude 'taxes.php';$amt = compute('FIT', 2000, // earnings this period 6000, // ytd earnings $filingMarried, 4, // exemptions=W-4 exemptions 0, // state exemptions not used 24, // bi-monthly 0, // paydate (take default) 0, // misc for supplemental ytdearnings 0, // aux for resident alien 1130.01 // ytd tax withheld );print $amt;?>