0 && $taxableIncome <= 9525) ||
(($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome <= 38700) ||
(($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome <= 82500 ) ||
(($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 200000 && $taxableIncome <= 500000) ||
($taxableIncome - $taxableWinnings) > 500000
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9525) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 9525 && $taxableIncome <= 38700) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 38700 && $taxableIncome <= 82500 ) ||
(($taxableIncome - $taxableWinnings) > 38700 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 82500 && ($taxableIncome - $taxableWinnings) <= 157500 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 157500 && ($taxableIncome - $taxableWinnings) <= 200000 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 200000 && ($taxableIncome - $taxableWinnings) <= 500000 && $taxableIncome > 500000)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9525 && $taxableIncome <= 38700) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 38700 && $taxableIncome <= 82500 ) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 38700 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 82500 && ($taxableIncome - $taxableWinnings) <= 157500 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 157500 && ($taxableIncome - $taxableWinnings) <= 200000 && $taxableIncome > 500000)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 38700 && $taxableIncome <= 82500 ) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 38700 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 82500 && ($taxableIncome - $taxableWinnings) <= 157500 && $taxableIncome > 500000)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 38700 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 500000)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 500000)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 500000)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 500000)
) {$span = 7;}
return $span;
}
if ($filingStatus == 2 || $filingStatus == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 19050) ||
(($taxableIncome - $taxableWinnings) > 19050 && $taxableIncome <= 77400) ||
(($taxableIncome - $taxableWinnings) > 77400&& $taxableIncome <= 165000 ) ||
(($taxableIncome - $taxableWinnings) > 165000 && $taxableIncome <= 315000) ||
(($taxableIncome - $taxableWinnings) > 315000 && $taxableIncome <= 400000) ||
(($taxableIncome - $taxableWinnings) > 400000 && $taxableIncome <= 600000) ||
($taxableIncome - $taxableWinnings) > 600000
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 19050) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19050 && $taxableIncome > 19050 && $taxableIncome <= 77400) ||
(($taxableIncome - $taxableWinnings) > 19050 && ($taxableIncome - $taxableWinnings) <= 77400 && $taxableIncome > 77400 && $taxableIncome <= 165000 ) ||
(($taxableIncome - $taxableWinnings) > 77400 && ($taxableIncome - $taxableWinnings) <= 165000 && $taxableIncome > 165000 && $taxableIncome <= 315000) ||
(($taxableIncome - $taxableWinnings) > 165000 && ($taxableIncome - $taxableWinnings) <= 315000 && $taxableIncome > 315000 && $taxableIncome <= 400000) ||
(($taxableIncome - $taxableWinnings) > 315000 && ($taxableIncome - $taxableWinnings) <= 400000 && $taxableIncome > 400000 && $taxableIncome <= 600000) ||
(($taxableIncome - $taxableWinnings) > 400000 && ($taxableIncome - $taxableWinnings) <= 600000 && $taxableIncome > 600000)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 19050 && $taxableIncome <= 77400) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19050 && $taxableIncome > 77400 && $taxableIncome <= 165000 ) ||
(($taxableIncome - $taxableWinnings) > 19050 && ($taxableIncome - $taxableWinnings) <= 77400 && $taxableIncome > 165000 && $taxableIncome <= 315000) ||
(($taxableIncome - $taxableWinnings) > 77400 && ($taxableIncome - $taxableWinnings) <= 165000 && $taxableIncome > 315000 && $taxableIncome <= 400000) ||
(($taxableIncome - $taxableWinnings) > 165000 && ($taxableIncome - $taxableWinnings) <= 315000 && $taxableIncome > 400000 && $taxableIncome <= 600000) ||
(($taxableIncome - $taxableWinnings) > 315000 && ($taxableIncome - $taxableWinnings) <= 400000 && $taxableIncome > 600000)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 77400 && $taxableIncome <= 165000) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19050 && $taxableIncome > 165000 && $taxableIncome <= 315000) ||
(($taxableIncome - $taxableWinnings) > 19050 && ($taxableIncome - $taxableWinnings) <= 77400 && $taxableIncome > 315000 && $taxableIncome <= 400000) ||
(($taxableIncome - $taxableWinnings) > 77400 && ($taxableIncome - $taxableWinnings) <= 165000 && $taxableIncome > 400000 && $taxableIncome <= 600000 ) ||
(($taxableIncome - $taxableWinnings) > 165000 && ($taxableIncome - $taxableWinnings) <= 315000 && $taxableIncome > 600000)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 165000 && $taxableIncome <= 315000) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19050 && $taxableIncome > 315000 && $taxableIncome <= 400000) ||
(($taxableIncome - $taxableWinnings) > 19050 && ($taxableIncome - $taxableWinnings) <= 77400 && $taxableIncome > 400000 && $taxableIncome <= 600000) ||
(($taxableIncome - $taxableWinnings) > 77400 && ($taxableIncome - $taxableWinnings) <= 165000 && $taxableIncome > 600000)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 315000 && $taxableIncome <= 400000) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19050 && $taxableIncome > 400000 && $taxableIncome <= 600000 ) ||
(($taxableIncome - $taxableWinnings) > 19050 && ($taxableIncome - $taxableWinnings) <= 77400 && $taxableIncome > 600000)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 400000 && $taxableIncome <= 600000 ) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19050 && $taxableIncome > 600000)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 600000)
) {$span = 7;}
return $span;
}
if ($filingStatus == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9525) ||
(($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome <= 38700) ||
(($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome <= 82500 ) ||
(($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 200000 && $taxableIncome <= 300000) ||
($taxableIncome - $taxableWinnings) > 300000
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9525) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 9525 && $taxableIncome <= 38700) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 38700 && $taxableIncome <= 82500 ) ||
(($taxableIncome - $taxableWinnings) > 38700 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 82500 && ($taxableIncome - $taxableWinnings) <= 157500 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 157500 && ($taxableIncome - $taxableWinnings) <= 200000 && $taxableIncome > 200000 && $taxableIncome <= 300000) ||
(($taxableIncome - $taxableWinnings) > 200000 && ($taxableIncome - $taxableWinnings) <= 300000 && $taxableIncome > 300000)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9525 && $taxableIncome <= 38700) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 38700 && $taxableIncome <= 82500 ) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 38700 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 82500 && ($taxableIncome - $taxableWinnings) <= 157500 && $taxableIncome > 200000 && $taxableIncome <= 300000) ||
(($taxableIncome - $taxableWinnings) > 157500 && ($taxableIncome - $taxableWinnings) <= 200000 && $taxableIncome > 300000)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 38700 && $taxableIncome <= 82500 ) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 38700 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 200000 && $taxableIncome <= 300000) ||
(($taxableIncome - $taxableWinnings) > 82500 && ($taxableIncome - $taxableWinnings) <= 157500 && $taxableIncome > 300000)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 200000 && $taxableIncome <= 300000) ||
(($taxableIncome - $taxableWinnings) > 38700 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 300000)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 200000 && $taxableIncome <= 300000) ||
(($taxableIncome - $taxableWinnings) > 9525 && ($taxableIncome - $taxableWinnings) <= 38700 && $taxableIncome > 300000)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 200000 && $taxableIncome <= 300000) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9525 && $taxableIncome > 300000)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 300000)
) {$span = 7;}
return $span;
}
if ($filingStatus == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 13600) ||
(($taxableIncome - $taxableWinnings) > 13600 && $taxableIncome <= 51800) ||
(($taxableIncome - $taxableWinnings) > 51800 && $taxableIncome <= 82500) ||
(($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 200000 && $taxableIncome <= 500000) ||
($taxableIncome - $taxableWinnings) > 500000
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 13600) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13600 && $taxableIncome > 13600 && $taxableIncome <= 51800) ||
(($taxableIncome - $taxableWinnings) > 13600 && ($taxableIncome - $taxableWinnings) <= 51800 && $taxableIncome > 51800 && $taxableIncome <= 82500) ||
(($taxableIncome - $taxableWinnings) > 51800 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 82500 && ($taxableIncome - $taxableWinnings) <= 157500 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 157500 && ($taxableIncome - $taxableWinnings) <= 200000 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 200000 && ($taxableIncome - $taxableWinnings) <= 500000 && $taxableIncome > 500000)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 13600 && $taxableIncome <= 51800) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13600 && $taxableIncome > 51800 && $taxableIncome <= 82500) ||
(($taxableIncome - $taxableWinnings) > 13600 && ($taxableIncome - $taxableWinnings) <= 51800 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 51800 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 82500 && ($taxableIncome - $taxableWinnings) <= 157500 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 157500 && ($taxableIncome - $taxableWinnings) <= 200000 && $taxableIncome > 500000)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 51800 && $taxableIncome <= 82500) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13600 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 13600 && ($taxableIncome - $taxableWinnings) <= 51800 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 51800 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 82500 && ($taxableIncome - $taxableWinnings) <= 157500 && $taxableIncome > 500000)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 82500 && $taxableIncome <= 157500) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13600 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 13600 && ($taxableIncome - $taxableWinnings) <= 51800 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 51800 && ($taxableIncome - $taxableWinnings) <= 82500 && $taxableIncome > 500000)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 157500 && $taxableIncome <= 200000) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13600 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 13600 && ($taxableIncome - $taxableWinnings) <= 51800 && $taxableIncome > 500000)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 200000 && $taxableIncome <= 500000) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13600 && $taxableIncome > 500000)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 500000)
) {$span = 7;}
return $span;
}
}
/*
******************************************************************************************
* *
* Function: Span Calculator for Itemized Deductions Phase-out *
* *
* *
* The calculation of the tax on the gambling winnings is conceptually different from *
* that for the phase-outs. The gambling winnings are the last income upon which income *
* tax is paid, so the marginal, or the tax rate of the last tax bracket, is used to *
* compute the tax. Itemized deductions is taken before the computation of the tax on *
* gambling winnings. So the reduction in itemized deductions is also taken before the *
* tax on gambling winnings. *
* *
* The span begins at the level of taxable income excluding the taxable gambling *
* winnings. While that is conceptually the same as for the gambling winnings, the span *
* calulator for the gambling winnings does not allow the same for the phase-out. This *
* function adapts the span calculator for gambling winnings by assuring that first *
* dollar of phase-out occurs in the tax bracket of the last non-gambling taxable *
* income. *
* *
* There are different tax brackets for each filing status. Except, "Married - Jointly" *
* and "Qualified Widow(er)" have the same tax brackets in 2018. *
* *
* This function takes 4 independent variables, the last of which is labelled *
* 'variable'. The tax value of the itemized deduction phase-out amount is computed *
* using the same functions as for the income tax of gambling winnings. The tax value *
* of the itemized deduction phase-out amount is represented by this fourth independent *
* variable. *
* *
* The span value is needed for both entities; the income tax on gambling winnings, the *
* itemized deduction phase-out. *
* *
******************************************************************************************
*/
function altspancalc($filingStatus, $taxableIncome, $taxableWinnings, $variable) {
$altTaxable = $taxableIncome - $taxableWinnings;
if ($filingStatus == 1) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 9525) ||
(($altTaxable - $variable) > 9525 && $altTaxable <= 38700) ||
(($altTaxable - $variable) > 38700 && $altTaxable <= 82500 ) ||
(($altTaxable - $variable) > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 200000 && $altTaxable <= 500000) ||
($altTaxable - $variable) > 500000
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9525) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 9525 && $altTaxable <= 38700) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 38700 && $altTaxable <= 82500 ) ||
(($altTaxable - $variable) > 38700 && ($altTaxable - $variable) <= 82500 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 82500 && ($altTaxable - $variable) <= 157500 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 157500 && ($altTaxable - $variable) <= 200000 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 200000 && ($altTaxable - $variable) <= 500000 && $altTaxable > 500000)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 9525 && $altTaxable <= 38700) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 38700 && $altTaxable <= 82500 ) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 38700 && ($altTaxable - $variable) <= 82500 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 82500 && ($altTaxable - $variable) <= 157500 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 157500 && ($altTaxable - $variable) <= 200000 && $altTaxable > 500000)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 38700 && $altTaxable <= 82500 ) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 38700 && ($altTaxable - $variable) <= 82500 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 82500 && ($altTaxable - $variable) <= 157500 && $altTaxable > 500000)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 38700 && ($altTaxable - $variable) <= 82500 && $altTaxable > 500000)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 500000)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 500000)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 500000)
) {$span = 7;}
return $span;
}
if ($filingStatus == 2 || $filingStatus == 5) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 19050) ||
(($altTaxable - $variable) > 19050 && $altTaxable <= 77400) ||
(($altTaxable - $variable) > 77400&& $altTaxable <= 165000 ) ||
(($altTaxable - $variable) > 165000 && $altTaxable <= 315000) ||
(($altTaxable - $variable) > 315000 && $altTaxable <= 400000) ||
(($altTaxable - $variable) > 400000 && $altTaxable <= 600000) ||
($altTaxable - $variable) > 600000
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 19050) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19050 && $altTaxable > 19050 && $altTaxable <= 77400) ||
(($altTaxable - $variable) > 19050 && ($altTaxable - $variable) <= 77400 && $altTaxable > 77400 && $altTaxable <= 165000 ) ||
(($altTaxable - $variable) > 77400 && ($altTaxable - $variable) <= 165000 && $altTaxable > 165000 && $altTaxable <= 315000) ||
(($altTaxable - $variable) > 165000 && ($altTaxable - $variable) <= 315000 && $altTaxable > 315000 && $altTaxable <= 400000) ||
(($altTaxable - $variable) > 315000 && ($altTaxable - $variable) <= 400000 && $altTaxable > 400000 && $altTaxable <= 600000) ||
(($altTaxable - $variable) > 400000 && ($altTaxable - $variable) <= 600000 && $altTaxable > 600000)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 19050 && $altTaxable <= 77400) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19050 && $altTaxable > 77400 && $altTaxable <= 165000 ) ||
(($altTaxable - $variable) > 19050 && ($altTaxable - $variable) <= 77400 && $altTaxable > 165000 && $altTaxable <= 315000) ||
(($altTaxable - $variable) > 77400 && ($altTaxable - $variable) <= 165000 && $altTaxable > 315000 && $altTaxable <= 400000) ||
(($altTaxable - $variable) > 165000 && ($altTaxable - $variable) <= 315000 && $altTaxable > 400000 && $altTaxable <= 600000) ||
(($altTaxable - $variable) > 315000 && ($altTaxable - $variable) <= 400000 && $altTaxable > 600000)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 77400 && $altTaxable <= 165000) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19050 && $altTaxable > 165000 && $altTaxable <= 315000) ||
(($altTaxable - $variable) > 19050 && ($altTaxable - $variable) <= 77400 && $altTaxable > 315000 && $altTaxable <= 400000) ||
(($altTaxable - $variable) > 77400 && ($altTaxable - $variable) <= 165000 && $altTaxable > 400000 && $altTaxable <= 600000 ) ||
(($altTaxable - $variable) > 165000 && ($altTaxable - $variable) <= 315000 && $altTaxable > 600000)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 165000 && $altTaxable <= 315000) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19050 && $altTaxable > 315000 && $altTaxable <= 400000) ||
(($altTaxable - $variable) > 19050 && ($altTaxable - $variable) <= 77400 && $altTaxable > 400000 && $altTaxable <= 600000) ||
(($altTaxable - $variable) > 77400 && ($altTaxable - $variable) <= 165000 && $altTaxable > 600000)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 315000 && $altTaxable <= 400000) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19050 && $altTaxable > 400000 && $altTaxable <= 600000 ) ||
(($altTaxable - $variable) > 19050 && ($altTaxable - $variable) <= 77400 && $altTaxable > 600000)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 400000 && $altTaxable <= 600000 ) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19050 && $altTaxable > 600000)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 600000)
) {$span = 7;}
return $span;
}
if ($filingStatus == 3) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 9525) ||
(($altTaxable - $variable) > 9525 && $altTaxable <= 38700) ||
(($altTaxable - $variable) > 38700 && $altTaxable <= 82500 ) ||
(($altTaxable - $variable) > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 200000 && $altTaxable <= 300000) ||
($altTaxable - $variable) > 300000
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9525) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 9525 && $altTaxable <= 38700) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 38700 && $altTaxable <= 82500 ) ||
(($altTaxable - $variable) > 38700 && ($altTaxable - $variable) <= 82500 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 82500 && ($altTaxable - $variable) <= 157500 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 157500 && ($altTaxable - $variable) <= 200000 && $altTaxable > 200000 && $altTaxable <= 300000) ||
(($altTaxable - $variable) > 200000 && ($altTaxable - $variable) <= 300000 && $altTaxable > 300000)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 9525 && $altTaxable <= 38700) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 38700 && $altTaxable <= 82500 ) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 38700 && ($altTaxable - $variable) <= 82500 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 82500 && ($altTaxable - $variable) <= 157500 && $altTaxable > 200000 && $altTaxable <= 300000) ||
(($altTaxable - $variable) > 157500 && ($altTaxable - $variable) <= 200000 && $altTaxable > 300000)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 38700 && $altTaxable <= 82500 ) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 38700 && ($altTaxable - $variable) <= 82500 && $altTaxable > 200000 && $altTaxable <= 300000) ||
(($altTaxable - $variable) > 82500 && ($altTaxable - $variable) <= 157500 && $altTaxable > 300000)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 200000 && $altTaxable <= 300000) ||
(($altTaxable - $variable) > 38700 && ($altTaxable - $variable) <= 82500 && $altTaxable > 300000)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 200000 && $altTaxable <= 300000) ||
(($altTaxable - $variable) > 9525 && ($altTaxable - $variable) <= 38700 && $altTaxable > 300000)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 200000 && $altTaxable <= 300000) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9525 && $altTaxable > 300000)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 300000)
) {$span = 7;}
return $span;
}
if ($filingStatus == 4) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 13600) ||
(($altTaxable - $variable) > 13600 && $altTaxable <= 51800) ||
(($altTaxable - $variable) > 51800 && $altTaxable <= 82500) ||
(($altTaxable - $variable) > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 200000 && $altTaxable <= 500000) ||
($altTaxable - $variable) > 500000
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 13600) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13600 && $altTaxable > 13600 && $altTaxable <= 51800) ||
(($altTaxable - $variable) > 13600 && ($altTaxable - $variable) <= 51800 && $altTaxable > 51800 && $altTaxable <= 82500) ||
(($altTaxable - $variable) > 51800 && ($altTaxable - $variable) <= 82500 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 82500 && ($altTaxable - $variable) <= 157500 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 157500 && ($altTaxable - $variable) <= 200000 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 200000 && ($altTaxable - $variable) <= 500000 && $altTaxable > 500000)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 13600 && $altTaxable <= 51800) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13600 && $altTaxable > 51800 && $altTaxable <= 82500) ||
(($altTaxable - $variable) > 13600 && ($altTaxable - $variable) <= 51800 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 51800 && ($altTaxable - $variable) <= 82500 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 82500 && ($altTaxable - $variable) <= 157500 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 157500 && ($altTaxable - $variable) <= 200000 && $altTaxable > 500000)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 51800 && $altTaxable <= 82500) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13600 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 13600 && ($altTaxable - $variable) <= 51800 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 51800 && ($altTaxable - $variable) <= 82500 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 82500 && ($altTaxable - $variable) <= 157500 && $altTaxable > 500000)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 82500 && $altTaxable <= 157500) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13600 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 13600 && ($altTaxable - $variable) <= 51800 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 51800 && ($altTaxable - $variable) <= 82500 && $altTaxable > 500000)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 157500 && $altTaxable <= 200000) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13600 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 13600 && ($altTaxable - $variable) <= 51800 && $altTaxable > 500000)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 200000 && $altTaxable <= 500000) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13600 && $altTaxable > 500000)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 500000)
) {$span = 7;}
return $span;
}
}
/*
******************************************************************************************
* *
* Function: Income Tax Calculator *
* *
* *
* This function computes the income tax on gambling income. It also computes the tax *
* impact of the one phase-out amount, (for itemized deductions). The code is *
* straightforward, but some explanation will be provided anyway. *
* *
* When the span value is zero, meaning the gambling winnings upon which tax is to be *
* paid falls into one tax bracket in its entirety, the income tax on the winnings is *
* the tax rate of that bracket times the amount of the taxable winnings. *
* *
* When the span value is one, it means the gambling winnings upon which tax is to be *
* paid falls partly into one tax bracket and the remainder into the next higher *
* bracket. The income tax on the winnings is the tax rate of the first, or lower, *
* bracket times the amount of the taxable winnings that falls into that bracket, plus *
* the tax rate of the second, or higher, bracket times the remainder of the winnings *
* that falls into it. *
* *
* When the span value is greater than one, it means the gambling winnings upon which *
* tax is to be paid falls partly into one tax bracket, the lowest, partly into one or *
* more middle brackets, and the remainder into the last, the highest bracket. The *
* income tax on the winnings is the tax rate of the lowest bracket, times the amount *
* of the taxable winnings that falls into that bracket. Plus the tax rate of the first *
* middle bracket times the income span of that bracket. Plus the tax rate of the *
* second middle bracket, if any, times the income span of that bracket. And so on, *
* until all the middle brackets are exhausted. Plus the tax rate of the highest *
* bracket times the remainder of the winnings that falls into it. *
* *
* There are, again different tax brackets for each filing status. Again, the exception *
* is "Married - Jointly" and "Qualified Widow(er)" which have the same tax brackets *
* in 2018. *
* *
******************************************************************************************
*/
function taxcalc($span, $filingStatus, $taxableIncome, $taxableWinnings) {
if ($filingStatus == 1) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9525) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome <= 38700) {$tax = 0.12 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome <= 82500 ) {$tax = 0.22 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome <= 157500) {$tax = 0.24 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome <= 200000) {$tax = 0.32 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 200000 && $taxableIncome <= 500000) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 500000) {$tax = 0.37 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9525)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9525 && $taxableIncome <= 38700)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 0.12 * ($taxableIncome - 9525);}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 38700 && $taxableIncome <= 82500 )
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 0.22 * ($taxableIncome - 38700);}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 0.24 * ($taxableIncome - 82500 );}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.24 * (157500 - ($taxableIncome - $taxableWinnings)) + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.32 * (200000 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 500000 && $taxableIncome > 500000)
{$tax = 0.35 * (500000 - ($taxableIncome - $taxableWinnings)) + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9525 && $taxableIncome <= 38700)
{$tax = 952.5 + 0.12 * ($taxableIncome - 9525);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9525 && $taxableIncome <= 82500 )
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 0.22 * ($taxableIncome - 38700);}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 9636.0 + 0.24 * ($taxableIncome - 82500 );}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.24 * (157500 - ($taxableIncome - $taxableWinnings)) + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome > 500000)
{$tax = 0.32 * (200000 - ($taxableIncome - $taxableWinnings)) + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 38700 && $taxableIncome <= 82500 )
{$tax = 952.5 + 3501.0 + 0.22 * ($taxableIncome - 38700);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 9636.0 + 0.24 * ($taxableIncome - 82500 );}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 9636.0 + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome > 500000)
{$tax = 0.24 * (157500 - ($taxableIncome - $taxableWinnings)) + 74266.5 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 952.5 + 3501.0 + 9636.0 + 0.24 * ($taxableIncome - 82500);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 9636.0 + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 9636.0 + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome > 500000)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 18000 + 13600 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 9636.0 + 18000 + 13600 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 500000)
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 9636.0 + 18000 + 13600 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 500000)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 9636.0 + 18000 + 13600 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 500000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 13600 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
}
if ($filingStatus == 2 || $filingStatus == 5) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 19050) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 19050 && $taxableIncome <= 77400) {$tax = 0.12 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 77400 && $taxableIncome <= 165000) {$tax = 0.22 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 165000 && $taxableIncome <= 315000) {$tax = 0.24 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 315000 && $taxableIncome <= 400000) {$tax = 0.32 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 400000 && $taxableIncome <= 600000) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 600000) {$tax = 0.37 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 19050)
{$tax = 0.10 * $taxableIncome; }
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 19050 && $taxableIncome <= 77400)
{$tax = 0.10 * (19050 - ($taxableIncome - $taxableWinnings)) + 0.12 * ($taxableIncome - 19050);}
elseif (($taxableIncome - $taxableWinnings) > 19050 && $taxableIncome > 77400 && $taxableIncome <= 165000)
{$tax = 0.12 * (77400 - ($taxableIncome - $taxableWinnings)) + 0.22 * ($taxableIncome - 77400);}
elseif (($taxableIncome - $taxableWinnings) > 77400 && $taxableIncome > 165000 && $taxableIncome <= 315000)
{$tax = 0.22 * (165000 - ($taxableIncome - $taxableWinnings)) + 0.24 * ($taxableIncome - 165000);}
elseif (($taxableIncome - $taxableWinnings) > 165000 && $taxableIncome > 315000 && $taxableIncome <= 400000)
{$tax = 0.24 * (315000 - ($taxableIncome - $taxableWinnings)) + 0.32 * ($taxableIncome - 315000);}
elseif (($taxableIncome - $taxableWinnings) > 315000 && $taxableIncome > 400000 && $taxableIncome <= 600000)
{$tax = 0.32 * (400000 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 400000);}
elseif (($taxableIncome - $taxableWinnings) > 400000 && $taxableIncome > 600000 )
{$tax = 0.35 * (600000 - ($taxableIncome - $taxableWinnings)) + 0.37 * ($taxableIncome - 600000);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 19050 && $taxableIncome <= 77400)
{$tax = 1905 + 0.12 * ($taxableIncome - 19050);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 19050 && $taxableIncome <= 165000)
{$tax = 0.10 * (19050 - ($taxableIncome - $taxableWinnings)) + 7002 + 0.22 * ($taxableIncome - 77400);}
elseif (($taxableIncome - $taxableWinnings) > 19050 && $taxableIncome > 165000 && $taxableIncome <= 315000)
{$tax = 0.12 * (77400 - ($taxableIncome - $taxableWinnings)) + 19272 + 0.24 * ($taxableIncome - 165000 );}
elseif (($taxableIncome - $taxableWinnings) > 77400 && $taxableIncome > 315000 && $taxableIncome <= 400000)
{$tax = 0.22 * (165000 - ($taxableIncome - $taxableWinnings)) + 36000 + 0.32 * ($taxableIncome - 315000);}
elseif (($taxableIncome - $taxableWinnings) > 165000 && $taxableIncome > 400000 && $taxableIncome <= 600000)
{$tax = 0.24 * (315000 - ($taxableIncome - $taxableWinnings)) + 27200 + 0.35 * ($taxableIncome - 400000);}
elseif (($taxableIncome - $taxableWinnings) > 315000 && $taxableIncome > 600000)
{$tax = 0.32 * (400000 - ($taxableIncome - $taxableWinnings)) + 70000 + 0.37 * ($taxableIncome - 600000 );}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 77400 && $taxableIncome <= 165000)
{$tax = 1905 + 7002 + 0.22 * ($taxableIncome - 77400);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 165000 && $taxableIncome <= 315000)
{$tax = 0.10 * (19050 - ($taxableIncome - $taxableWinnings)) + 7002 + 19272 + 0.24 * ($taxableIncome - 165000);}
elseif (($taxableIncome - $taxableWinnings) > 19050 && $taxableIncome > 315000 && $taxableIncome <= 400000)
{$tax = 0.12 * (77400 - ($taxableIncome - $taxableWinnings)) + 19272 + 36000 + 0.32 * ($taxableIncome - 315000);}
elseif (($taxableIncome - $taxableWinnings) > 77400 && $taxableIncome > 400000 && $taxableIncome <= 600000)
{$tax = 0.22 * (165000 - ($taxableIncome - $taxableWinnings)) + 36000 + 27200 + 0.35 * ($taxableIncome - 400000);}
elseif (($taxableIncome - $taxableWinnings) > 165000 && $taxableIncome > 600000)
{$tax = 0.24 * (315000 - ($taxableIncome - $taxableWinnings)) + 27200 + 70000 + 0.37 * ($taxableIncome - 600000);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 165000 && $taxableIncome <= 315000)
{$tax = 1905 + 7002 + 19272 + 0.24 * ($taxableIncome - 165000);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 315000 && $taxableIncome <= 400000)
{$tax = 0.10 * (19050 - ($taxableIncome - $taxableWinnings)) + 7002 + 19272 + 36000 + 0.32 * ($taxableIncome - 315000);}
elseif (($taxableIncome - $taxableWinnings) > 19050 && $taxableIncome > 400000 && $taxableIncome <= 600000)
{$tax = 0.12 * (77400 - ($taxableIncome - $taxableWinnings)) + 19272 + 36000 + 27200 + 0.35 * ($taxableIncome - 400000);}
elseif (($taxableIncome - $taxableWinnings) > 77400 && $taxableIncome > 600000)
{$tax = 0.22 * (165000 - ($taxableIncome - $taxableWinnings)) + 36000 + 27200 + 70000 + 0.37 * ($taxableIncome - 600000 );}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 315000 && $taxableIncome <= 400000)
{$tax = 1905 + 7002 + 19272 + 36000 + 0.32 * ($taxableIncome - 315000);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 400000 && $taxableIncome <= 600000)
{$tax = 0.10 * (19050 - ($taxableIncome - $taxableWinnings)) + 7002 + 19272 + 36000 + 27200 + 0.35 * ($taxableIncome - 400000);}
elseif (($taxableIncome - $taxableWinnings) > 19050 && $taxableIncome > 600000)
{$tax = 0.12 * (77400 - ($taxableIncome - $taxableWinnings)) + 19272 + 36000 + 27200 + 70000 + 0.37 * ($taxableIncome - 600000);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 400000 && $taxableIncome <= 600000)
{$tax = 1905 + 7002 + 19272 + 36000 + 27200 + 0.35 * ($taxableIncome - 400000);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 600000)
{$tax = 0.10 * (19050 - ($taxableIncome - $taxableWinnings)) + 7002 + 19272 + 36000 + 27200 + 70000 + 0.37 * ($taxableIncome - 600000);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 600000)
{$tax = 1905 + 7002 + 19272 + 36000 + 27200 + 70000 + 0.37 * ($taxableIncome - 600000);}
return $tax;
}
}
if ($filingStatus == 3) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9525) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome <= 38700) {$tax = 0.12 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome <= 82500 ) {$tax = 0.22 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome <= 157500) {$tax = 0.24 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome <= 200000) {$tax = 0.32 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 200000 && $taxableIncome <= 300000) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 300000) {$tax = 0.37 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9525)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9525 && $taxableIncome <= 38700)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 0.12 * ($taxableIncome - 9525);}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 38700 && $taxableIncome <= 82500 )
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 0.22 * ($taxableIncome - 38700);}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 0.24 * ($taxableIncome - 82500 );}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.24 * (157500 - ($taxableIncome - $taxableWinnings)) + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome > 200000 && $taxableIncome <= 300000)
{$tax = 0.32 * (200000 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 300000 && $taxableIncome > 300000)
{$tax = 0.35 * (300000 - ($taxableIncome - $taxableWinnings)) + 0.37 * ($taxableIncome - 300000);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9525 && $taxableIncome <= 38700)
{$tax = 952.5 + 0.12 * ($taxableIncome - 9525);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9525 && $taxableIncome <= 82500 )
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 0.22 * ($taxableIncome - 38700);}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 9636.0 + 0.24 * ($taxableIncome - 82500 );}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome > 200000 && $taxableIncome <= 300000)
{$tax = 0.24 * (157500 - ($taxableIncome - $taxableWinnings)) + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome > 300000)
{$tax = 0.32 * (200000 - ($taxableIncome - $taxableWinnings)) + 35000 + 0.37 * ($taxableIncome - 300000);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 38700 && $taxableIncome <= 82500 )
{$tax = 952.5 + 3501.0 + 0.22 * ($taxableIncome - 38700);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 9636.0 + 0.24 * ($taxableIncome - 82500 );}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 9636.0 + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome > 200000 && $taxableIncome <= 300000)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome > 300000)
{$tax = 0.24 * (157500 - ($taxableIncome - $taxableWinnings)) + 13600 + 35000 + 0.37 * ($taxableIncome - 300000);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 952.5 + 3501.0 + 9636.0 + 0.24 * ($taxableIncome - 82500);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 9636.0 + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 200000 && $taxableIncome <= 300000)
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 9636.0 + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 38700 && $taxableIncome > 300000)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 18000 + 13600 + 35000 + 0.37 * ($taxableIncome - 300000);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 200000 && $taxableIncome <= 300000)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 9636.0 + 18000 + 13600 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 300000)
{$tax = 0.12 * (38700 - ($taxableIncome - $taxableWinnings)) + 9636.0 + 18000 + 13600 + 35000 + 0.37 * ($taxableIncome - 300000);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 200000 && $taxableIncome <= 300000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 300000)
{$tax = 0.10 * (9525 - ($taxableIncome - $taxableWinnings)) + 3501.0 + 9636.0 + 18000 + 13600 + 35000 + 0.37 * ($taxableIncome - 300000);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 300000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 13600 + 35000 + 0.37 * ($taxableIncome - 300000);}
return $tax;
}
}
if ($filingStatus == 4) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 13600) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 13600 && $taxableIncome <= 51800) {$tax = 0.12 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 51800 && $taxableIncome <= 82500) {$tax = 0.22 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome <= 157500) {$tax = 0.24 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome <= 200000) {$tax = 0.32 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 200000 && $taxableIncome <= 500000) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 500000) {$tax = 0.37 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 13600)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 13600 && $taxableIncome <= 51800)
{$tax = 0.10 * (13600- ($taxableIncome - $taxableWinnings)) + 0.12 * ($taxableIncome - 13600);}
elseif (($taxableIncome - $taxableWinnings) > 13600 && $taxableIncome > 51800 && $taxableIncome <= 82500)
{$tax = 0.12 * (51800 - ($taxableIncome - $taxableWinnings)) + 0.22 * ($taxableIncome - 51800);}
elseif (($taxableIncome - $taxableWinnings) > 51800 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 0.24 * ($taxableIncome - 82500);}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.24 * (157500 - ($taxableIncome - $taxableWinnings)) + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 157500 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.32 * (200000 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 200000 && $taxableIncome > 500000)
{$tax = 0.35 * (500000 - ($taxableIncome - $taxableWinnings)) + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 13600 && $taxableIncome <= 51800)
{$tax = 1360 + 0.12 * ($taxableIncome - 13600);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 51800 && $taxableIncome <= 82500)
{$tax = 0.10 * (13600- ($taxableIncome - $taxableWinnings)) + 4584 + 0.22 * ($taxableIncome - 51800);}
elseif (($taxableIncome - $taxableWinnings) > 13600 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 0.12 * (51800 - ($taxableIncome - $taxableWinnings)) + 6754 + 0.24 * ($taxableIncome - 82500);}
elseif (($taxableIncome - $taxableWinnings) > 51800 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.24 * (157500 - ($taxableIncome - $taxableWinnings)) + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 200000 && $taxableIncome > 500000)
{$tax = 0.32 * (200000 - ($taxableIncome - $taxableWinnings)) + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 51800 && $taxableIncome <= 82500)
{$tax = 1360 + 4584 + 0.22 * ($taxableIncome - 51800);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 0.10 * (13600- ($taxableIncome - $taxableWinnings)) + 4584 + 6754 + 0.24 * ($taxableIncome - 82500);}
elseif (($taxableIncome - $taxableWinnings) > 9525 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.12 * (51800 - ($taxableIncome - $taxableWinnings)) + 6754 + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 51800 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 82500 && $taxableIncome > 500000)
{$tax = 0.24 * (157500 - ($taxableIncome - $taxableWinnings)) + 13600 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 82500 && $taxableIncome <= 157500)
{$tax = 1360 + 4584 + 6754 + 0.24 * ($taxableIncome - 82500);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 0.10 * (13600- ($taxableIncome - $taxableWinnings)) + 4584 + 6754 + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 13600 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.12 * (51800 - ($taxableIncome - $taxableWinnings)) + 6754 + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 51800 && $taxableIncome > 500000)
{$tax = 0.22 * (82500 - ($taxableIncome - $taxableWinnings)) + 18000 + 13600 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 157500 && $taxableIncome <= 200000)
{$tax = 1360 + 4584 + 6754 + 18000 + 0.32 * ($taxableIncome - 157500);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 0.10 * (13600- ($taxableIncome - $taxableWinnings)) + 4584 + 6754 + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 13600 && $taxableIncome > 500000)
{$tax = 0.12 * (51800 - ($taxableIncome - $taxableWinnings)) + 6754 + 18000 + 13600 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 200000 && $taxableIncome <= 500000)
{$tax = 1360 + 4584 + 6754 + 18000 + 13600 + 0.35 * ($taxableIncome - 200000);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 500000)
{$tax = 0.10 * (13600 - ($taxableIncome - $taxableWinnings)) + 4584 + 6754 + 18000 + 13600 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 500000)
{$tax = 1360 + 4584 + 6754 + 18000 + 13600 + 105000 + 0.37 * ($taxableIncome - 500000);}
return $tax;
}
}
}
/*
******************************************************************************************
* *
* Function: Income Tax Calculator for the Itemized Deductions Phase-out *
* *
* *
* As explained in the comment for the span calculator function, the calculation of the *
* tax on the gambling winnings is conceptually different from that for the phase-out. *
* *
* The lowest tax bracket for the phase-outs is at the level of taxable income excluding *
* the taxable gambling winnings. Again, while that is conceptually the same as for *
* the gambling winnings, the income tax calulator for the gambling winnings does not *
* allow the same for the phase-outs. This function adapts the tax calculator for *
* gambling winnings by assuring that first dollar of phase-out occurs in the tax *
* bracket of last dollar of non-gambling taxable income. *
* *
* When the span value is greater than one, it means the phase-out amount, upon which a *
* tax effect is to be computed, falls partly into one tax bracket, the lowest, partly *
* into one or more middle brackets, and the remainder into the last, the highest *
* bracket. The income tax on the phase-out amount is the tax rate of the lowest *
* bracket, times the amount of the phase-out that falls into that bracket. Plus the *
* tax rate of the first middle bracket times the income span of that bracket. Plus *
* the tax rate of the second middle bracket, if any, times the income span of that *
* bracket. And so on, until the middle brackets are exhausted. Plus the tax rate of *
* the highest bracket times the remainder of the winnings that falls into it. *
* *
* There are, again different tax brackets for each filing status. Again, the exception *
* is "Married - Jointly" and "Qualified Widow(er)" which have the same tax brackets *
* in 2018. *
* *
* This function takes 5 independent variables, the last of which is labelled *
* 'variable'. The reason is the same as that for the span calculator function. *
* *
******************************************************************************************
*/
function alttaxcalc($span, $filingStatus, $taxableIncome, $taxableWinnings, $variable) {
$altTaxable = $taxableIncome - $taxableWinnings;
if ($filingStatus == 1) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 9525) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 9525 && $altTaxable <= 38700) {$tax = 0.12 * $variable;}
elseif (($altTaxable - $variable) > 38700 && $altTaxable <= 82500 ) {$tax = 0.22 * $variable;}
elseif (($altTaxable - $variable) > 82500 && $altTaxable <= 157500) {$tax = 0.24 * $variable;}
elseif (($altTaxable - $variable) > 157500 && $altTaxable <= 200000) {$tax = 0.32 * $variable;}
elseif (($altTaxable - $variable) > 200000 && $altTaxable <= 500000) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 500000) {$tax = 0.37 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9525)
{$tax = 0.10 * $altTaxable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9525 && $altTaxable <= 38700)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 0.12 * ($altTaxable - 9525);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 38700 && $altTaxable <= 82500 )
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 0.22 * ($altTaxable - 38700);}
elseif (($altTaxable - $variable) > 38700 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 0.24 * ($altTaxable - 82500 );}
elseif (($altTaxable - $variable) > 82500 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.24 * (157500 - ($altTaxable - $variable)) + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 157500 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.32 * (200000 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 500000 && $altTaxable > 500000)
{$tax = 0.35 * (500000 - ($altTaxable - $variable)) + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 9525 && $altTaxable <= 38700)
{$tax = 952.5 + 0.12 * ($altTaxable - 9525);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9525 && $altTaxable <= 82500)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 0.22 * ($altTaxable - 38700);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 9636.0 + 0.24 * ($altTaxable - 82500 );}
elseif (($altTaxable - $variable) > 38700 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 82500 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.24 * (157500 - ($altTaxable - $variable)) + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 157500 && $altTaxable > 500000)
{$tax = 0.32 * (200000 - ($altTaxable - $variable)) + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 38700 && $altTaxable <= 82500)
{$tax = 952.5 + 3501.0 + 0.22 * ($altTaxable - 38700);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 9636.0 + 0.24 * ($altTaxable - 82500 );}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 9636.0 + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 38700 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 82500 && $altTaxable > 500000)
{$tax = 0.24 * (157500 - ($altTaxable - $variable)) + 74266.5 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 952.5 + 3501.0 + 9636.0 + 0.24 * ($altTaxable - 82500);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 9636.0 + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 9636.0 + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 38700 && $altTaxable > 500000)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 18000 + 13600 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 9636.0 + 18000 + 13600 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 500000)
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 9636.0 + 18000 + 13600 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 500000)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 9636.0 + 18000 + 13600 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 500000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 13600 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
}
if ($filingStatus == 2 || $filingStatus == 5) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 19050) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 19050 && $altTaxable <= 77400) {$tax = 0.12 * $variable;}
elseif (($altTaxable - $variable) > 77400 && $altTaxable <= 165000) {$tax = 0.22 * $variable;}
elseif (($altTaxable - $variable) > 165000 && $altTaxable <= 315000) {$tax = 0.24 * $variable;}
elseif (($altTaxable - $variable) > 315000 && $altTaxable <= 400000) {$tax = 0.32 * $variable;}
elseif (($altTaxable - $variable) > 400000 && $altTaxable <= 600000) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 600000) {$tax = 0.37 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 19050)
{$tax = 0.10 * $altTaxable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 19050 && $altTaxable <= 77400)
{$tax = 0.10 * (19050 - ($altTaxable - $variable)) + 0.12 * ($altTaxable - 19050);}
elseif (($altTaxable - $variable) > 19050 && $altTaxable > 77400 && $altTaxable <= 165000)
{$tax = 0.12 * (77400 - ($altTaxable - $variable)) + 0.22 * ($altTaxable - 77400);}
elseif (($altTaxable - $variable) > 77400 && $altTaxable > 165000 && $altTaxable <= 315000)
{$tax = 0.22 * (165000 - ($altTaxable - $variable)) + 0.24 * ($altTaxable - 165000);}
elseif (($altTaxable - $variable) > 165000 && $altTaxable > 315000 && $altTaxable <= 400000)
{$tax = 0.24 * (315000 - ($altTaxable - $variable)) + 0.32 * ($altTaxable - 315000);}
elseif (($altTaxable - $variable) > 315000 && $altTaxable > 400000 && $altTaxable <= 600000)
{$tax = 0.32 * (400000 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 400000);}
elseif (($altTaxable - $variable) > 400000 && $altTaxable > 600000 )
{$tax = 0.35 * (600000 - ($altTaxable - $variable)) + 0.37 * ($altTaxable - 600000);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 19050 && $altTaxable <= 77400)
{$tax = 1905 + 0.12 * ($altTaxable - 19050);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 19050 && $altTaxable <= 165000)
{$tax = 0.10 * (19050 - ($altTaxable - $variable)) + 7002 + 0.22 * ($altTaxable - 77400);}
elseif (($altTaxable - $variable) > 19050 && $altTaxable > 165000 && $altTaxable <= 315000)
{$tax = 0.12 * (77400 - ($altTaxable - $variable)) + 19272 + 0.24 * ($altTaxable - 165000 );}
elseif (($altTaxable - $variable) > 77400 && $altTaxable > 315000 && $altTaxable <= 400000)
{$tax = 0.22 * (165000 - ($altTaxable - $variable)) + 36000 + 0.32 * ($altTaxable - 315000);}
elseif (($altTaxable - $variable) > 165000 && $altTaxable > 400000 && $altTaxable <= 600000)
{$tax = 0.24 * (315000 - ($altTaxable - $variable)) + 27200 + 0.35 * ($altTaxable - 400000);}
elseif (($altTaxable - $variable) > 315000 && $altTaxable > 600000)
{$tax = 0.32 * (400000 - ($altTaxable - $variable)) + 70000 + 0.37 * ($altTaxable - 600000 );}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 77400 && $altTaxable <= 165000)
{$tax = 1905 + 7002 + 0.22 * ($altTaxable - 77400);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 165000 && $altTaxable <= 315000)
{$tax = 0.10 * (19050 - ($altTaxable - $variable)) + 7002 + 19272 + 0.24 * ($altTaxable - 165000);}
elseif (($altTaxable - $variable) > 19050 && $altTaxable > 315000 && $altTaxable <= 400000)
{$tax = 0.12 * (77400 - ($altTaxable - $variable)) + 19272 + 36000 + 0.32 * ($altTaxable - 315000);}
elseif (($altTaxable - $variable) > 77400 && $altTaxable > 400000 && $altTaxable <= 600000)
{$tax = 0.22 * (165000 - ($altTaxable - $variable)) + 36000 + 27200 + 0.35 * ($altTaxable - 400000);}
elseif (($altTaxable - $variable) > 165000 && $altTaxable > 600000)
{$tax = 0.24 * (315000 - ($altTaxable - $variable)) + 27200 + 70000 + 0.37 * ($altTaxable - 600000);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 165000 && $altTaxable <= 315000)
{$tax = 1905 + 7002 + 19272 + 0.24 * ($altTaxable - 165000);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 315000 && $altTaxable <= 400000)
{$tax = 0.10 * (19050 - ($altTaxable - $variable)) + 7002 + 19272 + 36000 + 0.32 * ($altTaxable - 315000);}
elseif (($altTaxable - $variable) > 19050 && $altTaxable > 400000 && $altTaxable <= 600000)
{$tax = 0.12 * (77400 - ($altTaxable - $variable)) + 19272 + 36000 + 27200 + 0.35 * ($altTaxable - 400000);}
elseif (($altTaxable - $variable) > 77400 && $altTaxable > 600000)
{$tax = 0.22 * (165000 - ($altTaxable - $variable)) + 36000 + 27200 + 70000 + 0.37 * ($altTaxable - 600000 );}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 315000 && $altTaxable <= 400000)
{$tax = 1905 + 7002 + 19272 + 36000 + 0.32 * ($altTaxable - 315000);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 400000 && $altTaxable <= 600000)
{$tax = 0.10 * (19050 - ($altTaxable - $variable)) + 7002 + 19272 + 36000 + 27200 + 0.35 * ($altTaxable - 400000);}
elseif (($altTaxable - $variable) > 19050 && $altTaxable > 600000)
{$tax = 0.12 * (77400 - ($altTaxable - $variable)) + 19272 + 36000 + 27200 + 70000 + 0.37 * ($altTaxable - 600000);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 400000 && $altTaxable <= 600000)
{$tax = 1905 + 7002 + 19272 + 36000 + 27200 + 0.35 * ($altTaxable - 400000);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 600000)
{$tax = 0.10 * (19050 - ($altTaxable - $variable)) + 7002 + 19272 + 36000 + 27200 + 70000 + 0.37 * ($altTaxable - 600000);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 600000)
{$tax = 1905 + 7002 + 19272 + 36000 + 27200 + 70000 + 0.37 * ($altTaxable - 600000);}
return $tax;
}
}
if ($filingStatus == 3) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 9525) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 9525 && $altTaxable <= 38700) {$tax = 0.12 * $variable;}
elseif (($altTaxable - $variable) > 38700 && $altTaxable <= 82500 ) {$tax = 0.22 * $variable;}
elseif (($altTaxable - $variable) > 82500 && $altTaxable <= 157500) {$tax = 0.24 * $variable;}
elseif (($altTaxable - $variable) > 157500 && $altTaxable <= 200000) {$tax = 0.32 * $variable;}
elseif (($altTaxable - $variable) > 200000 && $altTaxable <= 300000) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 300000) {$tax = 0.37 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9525)
{$tax = 0.10 * $altTaxable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9525 && $altTaxable <= 38700)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 0.12 * ($altTaxable - 9525);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 38700 && $altTaxable <= 82500)
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 0.22 * ($altTaxable - 38700);}
elseif (($altTaxable - $variable) > 38700 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 0.24 * ($altTaxable - 82500 );}
elseif (($altTaxable - $variable) > 82500 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.24 * (157500 - ($altTaxable - $variable)) + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 157500 && $altTaxable > 200000 && $altTaxable <= 300000)
{$tax = 0.32 * (200000 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 300000 && $altTaxable > 300000)
{$tax = 0.35 * (300000 - ($altTaxable - $variable)) + 0.37 * ($altTaxable - 300000);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 9525 && $altTaxable <= 38700)
{$tax = 952.5 + 0.12 * ($altTaxable - 9525);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9525 && $altTaxable <= 82500)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 0.22 * ($altTaxable - 38700);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 9636.0 + 0.24 * ($altTaxable - 82500 );}
elseif (($altTaxable - $variable) > 38700 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 82500 && $altTaxable > 200000 && $altTaxable <= 300000)
{$tax = 0.24 * (157500 - ($altTaxable - $variable)) + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 157500 && $altTaxable > 300000)
{$tax = 0.32 * (200000 - ($altTaxable - $variable)) + 35000 + 0.37 * ($altTaxable - 300000);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 38700 && $altTaxable <= 82500)
{$tax = 952.5 + 3501.0 + 0.22 * ($altTaxable - 38700);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 9636.0 + 0.24 * ($altTaxable - 82500);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 9636.0 + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 38700 && $altTaxable > 200000 && $altTaxable <= 300000)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 82500 && $altTaxable > 300000)
{$tax = 0.24 * (157500 - ($altTaxable - $variable)) + 13600 + 35000 + 0.37 * ($altTaxable - 300000);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 952.5 + 3501.0 + 9636.0 + 0.24 * ($altTaxable - 82500);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 9636.0 + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 200000 && $altTaxable <= 300000)
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 9636.0 + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 38700 && $altTaxable > 300000)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 18000 + 13600 + 35000 + 0.37 * ($altTaxable - 300000);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 200000 && $altTaxable <= 300000)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 9636.0 + 18000 + 13600 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 300000)
{$tax = 0.12 * (38700 - ($altTaxable - $variable)) + 9636.0 + 18000 + 13600 + 35000 + 0.37 * ($altTaxable - 300000);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 200000 && $altTaxable <= 300000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 300000)
{$tax = 0.10 * (9525 - ($altTaxable - $variable)) + 3501.0 + 9636.0 + 18000 + 13600 + 35000 + 0.37 * ($altTaxable - 300000);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 300000)
{$tax = 952.5 + 3501.0 + 9636.0 + 18000 + 13600 + 35000 + 0.37 * ($altTaxable - 300000);}
return $tax;
}
}
if ($filingStatus == 4) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 13600) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 13600 && $altTaxable <= 51800) {$tax = 0.12 * $variable;}
elseif (($altTaxable - $variable) > 51800 && $altTaxable <= 82500) {$tax = 0.22 * $variable;}
elseif (($altTaxable - $variable) > 82500 && $altTaxable <= 157500) {$tax = 0.24 * $variable;}
elseif (($altTaxable - $variable) > 157500 && $altTaxable <= 200000) {$tax = 0.32 * $variable;}
elseif (($altTaxable - $variable) > 200000 && $altTaxable <= 500000) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 500000) {$tax = 0.37 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 13600)
{$tax = 0.10 * $altTaxable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 13600 && $altTaxable <= 51800)
{$tax = 0.10 * (13600- ($altTaxable - $variable)) + 0.12 * ($altTaxable - 13600);}
elseif (($altTaxable - $variable) > 13600 && $altTaxable > 51800 && $altTaxable <= 82500)
{$tax = 0.12 * (51800 - ($altTaxable - $variable)) + 0.22 * ($altTaxable - 51800);}
elseif (($altTaxable - $variable) > 51800 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 0.24 * ($altTaxable - 82500);}
elseif (($altTaxable - $variable) > 82500 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.24 * (157500 - ($altTaxable - $variable)) + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 157500 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.32 * (200000 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 200000 && $altTaxable > 500000)
{$tax = 0.35 * (500000 - ($altTaxable - $variable)) + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 13600 && $altTaxable <= 51800)
{$tax = 1360 + 0.12 * ($altTaxable - 13600);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 51800 && $altTaxable <= 82500)
{$tax = 0.10 * (13600- ($altTaxable - $variable)) + 4584 + 0.22 * ($altTaxable - 51800);}
elseif (($altTaxable - $variable) > 13600 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 0.12 * (51800 - ($altTaxable - $variable)) + 6754 + 0.24 * ($altTaxable - 82500);}
elseif (($altTaxable - $variable) > 51800 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 82500 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.24 * (157500 - ($altTaxable - $variable)) + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 200000 && $altTaxable > 500000)
{$tax = 0.32 * (200000 - ($altTaxable - $variable)) + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 51800 && $altTaxable <= 82500)
{$tax = 1360 + 4584 + 0.22 * ($altTaxable - 51800);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 0.10 * (13600- ($altTaxable - $variable)) + 4584 + 6754 + 0.24 * ($altTaxable - 82500);}
elseif (($altTaxable - $variable) > 9525 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.12 * (51800 - ($altTaxable - $variable)) + 6754 + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 51800 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 82500 && $altTaxable > 500000)
{$tax = 0.24 * (157500 - ($altTaxable - $variable)) + 13600 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 82500 && $altTaxable <= 157500)
{$tax = 1360 + 4584 + 6754 + 0.24 * ($altTaxable - 82500);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 0.10 * (13600- ($altTaxable - $variable)) + 4584 + 6754 + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 13600 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.12 * (51800 - ($altTaxable - $variable)) + 6754 + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 51800 && $altTaxable > 500000)
{$tax = 0.22 * (82500 - ($altTaxable - $variable)) + 18000 + 13600 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 157500 && $altTaxable <= 200000)
{$tax = 1360 + 4584 + 6754 + 18000 + 0.32 * ($altTaxable - 157500);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 0.10 * (13600- ($altTaxable - $variable)) + 4584 + 6754 + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 13600 && $altTaxable > 500000)
{$tax = 0.12 * (51800 - ($altTaxable - $variable)) + 6754 + 18000 + 13600 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 200000 && $altTaxable <= 500000)
{$tax = 1360 + 4584 + 6754 + 18000 + 13600 + 0.35 * ($altTaxable - 200000);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 500000)
{$tax = 0.10 * (13600 - ($altTaxable - $variable)) + 4584 + 6754 + 18000 + 13600 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 500000)
{$tax = 1360 + 4584 + 6754 + 18000 + 13600 + 105000 + 0.37 * ($altTaxable - 500000);}
return $tax;
}
}
}
/*
******************************************************************************************
* *
* Function Calls *
* *
* *
* This section calls the functions described above and computes the total income tax *
* impact of gambling winning on the taxpayer. *
* *
* Array Annotation *
* *
* Itemized[0] => the total itemized deductions computed for the taxpayer, or if *
* greater, the standard deduction appropriate to the taxpayer's filing *
* status. *
* *
* Itemized[1] => the amount of gambling winnings, net of allowable gambling losses, *
* that is subject to tax. *
* *
* Itemized[2] => the amount of itemizable expenses that is needed to breach the *
* standard deduction threashold so gambling losses can offset gambling *
* winnings. *
* *
* Itemized[3] => the amount of phase-out for itemized deductions. *
* *
* *
******************************************************************************************
*/
if (isset($_POST['submitted'])) {
if (is_numeric($winnings) && is_numeric($losses) && is_numeric($otherIncome) && is_numeric($otherAdjustments) &&
is_numeric($medicalExpenses) && is_numeric($mortgageInterest) && is_numeric($charity) && is_numeric($stateTaxes) &&
is_numeric($miscellaneous) && is_numeric($filingStatus) && is_numeric($spouseItemizing) &&
$winnings >= 0 && $losses >= 0 && $otherIncome >= 0 && $otherAdjustments >= 0 && $medicalExpenses >= 0 &&
$mortgageInterest >= 0 && $charity >= 0 && $stateTaxes >= 0 && $miscellaneous >= 0 && $spouseItemizing >= 0 &&
$filingStatus > 0 && $filingStatus < 6)
{
$medicalExpensesThresholdRate = 0.075;
$cashCharitableDonationsLimitRate = 0.60;
$agi = $otherIncome - $otherAdjustments + $winnings;
$Itemized = itemizeddeductionscalc($filingStatus, $spouseItemizing, $agi, $winnings, $losses, $medicalExpenses,
$medicalExpensesThresholdRate, $charity, $cashCharitableDonationsLimitRate,
$mortgageInterest, $stateTaxes, $miscellaneous);
$taxableIncome = $agi - $Itemized[0];
$span = spancalc($filingStatus, $taxableIncome, $Itemized[1]);
$tax = taxcalc($span, $filingStatus, $taxableIncome, $Itemized[1]);
if ($Itemized[3] > 0) {
$spanID = altspancalc($filingStatus, $taxableIncome, $Itemized[1], $Itemized[3]);
$taxID = alttaxcalc($spanID, $filingStatus, $taxableIncome, $Itemized[1], $Itemized[3]);
}
// The adjustment to taxable income to reduce it by the amount of the exemption phase-out for the correct computation
// of the itemized deduction phase-out tax effect amount is not necessary because the personal and dependent
// exemption deduction has been repealed.
$taxTotal = $tax + $taxID;
} else {echo '
Please enter valid (non-negative and numeric) dollar values.
';}
}
?>
For Taxpayers with Non-Complex Tax Returns for the 2018 Tax Year
Nota Bene:
This calculator computes only an estimate of the income tax on gambing winnings for individuals with fairly straightforward tax situations.
This calculator is not appropriate for individuals who are aged 65 years or more, have dividend or capital gains income, rental property income, self-employment income, farming income,
who receive Social Security benefits, or have made contributions to a traditional IRA. Nor is it appropriate for individuals with casualty or theft losses, or investment interest deductions.
There is an enhanced version of this calculator which meets the needs of indivduals with such tax situations.
In addition, this calculator does not factor in the impact of gambling winnings on tax credits. Some tax credits, such as the child tax credit, are reduced or eliminated for higher income families.
Should gamblings winnings push a family's income beyond the phase-out threshold, then reduced or eliminated tax credits will increase the impact on taxes beyond that from higher taxable income due
to the gambling winnings. In those situations, this calculator under-estimates the tax impact of gambling winnings. Furthermore, the alternative minimum tax (AMT)
is not accounted for in the computation of the estimated tax. If your tax situation is such that gambling winnings trigger the AMT, this calculator will not detect that or show that additional tax.
Nor does this calculator address Net Operating Losses (NOL). If your tax situation includes an NOL, this calculator will not show the reduction in tax.