400 && ($seEarnings + $wages) <= 127200) {
$seTax = 0.153 * $seEarnings;
$seTaxDeduction = $seTax * 0.50;
}
elseif ($seEarnings + $wages > 127200) {
$seTax = 0.124 * (127200 - $wages) + 0.029 * $seEarnings;
$seTaxDeduction = $seTax * 0.50;
}
$SelfEmployment[0] = $seTax;
$SelfEmployment[1] = $seTaxDeduction;
$SelfEmployment[2] = $seEarnings;
return $SelfEmployment;
}
/*
******************************************************************************************
* *
* Function: Adjusted Gross Income Calculator *
* *
* *
* This function computes an interim value for Adjusted Gross Income (AGI). It is *
* interim because it does not account for the possible changes in the values of some *
* income or adjustment items due to the level of AGI. *
* *
* The main task of this function is to limit deductible capital losses to $3,000 of *
* AGI. Other income or adjustment items that need to change their values will do so *
* through other functions later in this program. *
* *
******************************************************************************************
*/
function adjustedgrossincomecalc($wages, $profit, $investment, $dividend, $shortCapital, $longCapital, $retire, $rent, $alimonyReceived, $unemployment,
$ssi, $kayone, $otherAdjustments, $traditionalIRA, $studentLoanInterest, $alimonyPaid,
$seTaxDeduction, $winnings) {
$totalIncome = $wages + $profit + $investment + $dividend + max(($shortCapital + $longCapital), -3000) + $retire + $rent + $alimonyReceived +
$kayone + $unemployment + $ssi + $winnings;
$totalAdjustments = $alimonyPaid + $traditionalIRA + $studentLoanInterest + $seTaxDeduction + $otherAdjustments;
$agi = $totalIncome - $totalAdjustments;
return $agi;
}
/*
******************************************************************************************
* *
* Function: Long-Term Capital Gains Tax Calculator *
* *
* *
* This function computes the capital gains tax for long-term capital gains and *
* qualified dividends. These income items are not taxed at the rates for ordinary *
* income and have their own rate schedule. *
* *
* This function also computes the increase in the capital gains tax caused by the *
* gambling winnings. The capital gains tax is related to the ordinary income tax in *
* that as certain ordinary income tax brackets fill with taxable income, certain *
* capital gains tax brackets also fill. Gambling winnings, in effect, crowd out *
* capital gains income into higher tax brackets leading to higher capital gains tax. *
* *
* This tax increase has two sources. One is direct; the actual winnings push capital *
* gains into higher tax brackets and higher tax rates. The other is indirect; *
* gambling winnings cause a reduction in deductions (itemized deductions, student loan *
* interest, IRA contributions) or an increase in income (Social Security benefits) due *
* to the increase in Adjusted Gross Income (AGI). This crowd out of capital gains due *
* to the phase-out items that reduce AGI serves to increase the tax rate on capital *
* gains by pushing capital gains into a higher tax bracket. *
* *
******************************************************************************************
*/
function longcapitalgainstaxcalc($filingStatus, $shortCapital, $longCapital, $dividend, $taxableIncome, $taxableWinnings, $idPhaseOut, $exPhaseOut, $sliPhaseOut, $IRAPhaseOut, $SSIPhaseOut) {
$capital = $dividend + min(max($shortCapital + $longCapital, 0), max($longCapital, 0));
$taxableIncomeLessWinnings = $taxableIncome - $taxableWinnings - $idPhaseOut - $exPhaseOut - $sliPhaseOut - $IRAPhaseOut - $SSIPhaseOut;
if ($filingStatus == 1) {
if ($taxableIncome <= 37950) {$longCapitalGainsTax = 0;}
elseif ($taxableIncome > 37950 && ($taxableIncome - $capital) <= 37950 && $taxableIncome <= 418400)
{$longCapitalGainsTax = 0.15 * ($capital - (37950 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 37950 && $taxableIncome <= 418400)
{$longCapitalGainsTax = 0.15 * $capital;}
elseif ($taxableIncome > 418400 && ($taxableIncome - $capital) <= 418400)
{$longCapitalGainsTax = 0.15 * (418400 - ($taxableIncome - $capital)) + 0.20 * ($capital - (418400 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 418400)
{$longCapitalGainsTax = 0.20 * $capital;}
if ($taxableIncomeLessWinnings <= 37950) {$longCapitalGainsTaxLessWinnings = 0;}
elseif ($taxableIncomeLessWinnings > 37950 && ($taxableIncomeLessWinnings - $capital) <= 37950 && $taxableIncomeLessWinnings <= 418400)
{$longCapitalGainsTaxLessWinnings = 0.15 * ($capital - (37950 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 37950 && $taxableIncomeLessWinnings <= 418400)
{$longCapitalGainsTaxLessWinnings = 0.15 * $capital;}
elseif ($taxableIncomeLessWinnings > 418400 && ($taxableIncomeLessWinnings - $capital) <= 37950)
{$longCapitalGainsTaxLessWinnings = 0.15 * (418400 - ($taxableIncomeLessWinnings - $capital)) + 0.20 * ($capital - (418400 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 418400)
{$longCapitalGainsTaxLessWinnings = 0.20 * $capital;}
$LongGains[0] = $longCapitalGainsTax;
$LongGains[1] = $capital;
$LongGains[2] = $longCapitalGainsTax - $longCapitalGainsTaxLessWinnings;
$LongGains[3] = 0.10 * ($taxableIncomeLessWinnings - $capital);
// The $LongGains[3] variable represents the amount of taxable income (negative) that is available for gambling winnings before the 10% of the first income tax bracket is reached.
// It comes about when the amount long-term capital gains and qualified dividends, taxed at special rates, exceed other income taxed at ordinary income rates.
// If the magnitude of this variable is sufficiently large, then the 15% rate of the next income tax bracket will be reached.
// This program assumes that the 15% bracket will never be reached. It is believed that very small number of potential users who reach the 15% bracket do not provide a benefit
// that exceeds the high cost of the research and testing to develop the code that will accomodate the remaining income tax brackets.
return $LongGains;
}
if ($filingStatus == 2 || $filingStatus == 5) {
if ($taxableIncome <= 75900) {$longCapitalGainsTax = 0;}
elseif ($taxableIncome > 75900 && ($taxableIncome - $capital) <= 75900 && $taxableIncome <= 470700)
{$longCapitalGainsTax = 0.15 * ($capital - (75900 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 75900 && $taxableIncome <= 470700)
{$longCapitalGainsTax = 0.15 * $capital;}
elseif ($taxableIncome > 470700 && ($taxableIncome - $capital) <= 75900)
{$longCapitalGainsTax = 0.15 * (470700 - ($taxableIncome - $capital)) + 0.20 * ($capital - (470700 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 470700)
{$longCapitalGainsTax = 0.20 * $capital;}
if ($taxableIncomeLessWinnings <= 75900) {$longCapitalGainsTaxLessWinnings = 0;}
elseif ($taxableIncomeLessWinnings > 75900 && ($taxableIncomeLessWinnings - $capital) <= 75900 && $taxableIncomeLessWinnings <= 470700)
{$longCapitalGainsTaxLessWinnings = 0.15 * ($capital - (75900 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 75900 && $taxableIncomeLessWinnings <= 470700)
{$longCapitalGainsTaxLessWinnings = 0.15 * $capital;}
elseif ($taxableIncomeLessWinnings > 470700 && ($taxableIncomeLessWinnings - $capital) <= 75900)
{$longCapitalGainsTaxLessWinnings = 0.15 * (470700 - ($taxableIncomeLessWinnings - $capital)) + 0.20 * ($capital - (470700 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 470700)
{$longCapitalGainsTaxLessWinnings = 0.20 * $capital;}
$LongGains[0] = $longCapitalGainsTax;
$LongGains[1] = $capital;
$LongGains[2] = $longCapitalGainsTax - $longCapitalGainsTaxLessWinnings;
$LongGains[3] = 0.10 * ($taxableIncomeLessWinnings - $capital);
return $LongGains;
}
if ($filingStatus == 3) {
if ($taxableIncome <= 37950) {$longCapitalGainsTax = 0;}
elseif ($taxableIncome > 37950 && ($taxableIncome - $capital) <= 37950 && $taxableIncome <= 235350)
{$longCapitalGainsTax = 0.15 * ($capital - (37950 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 37950 && $taxableIncome <= 235350)
{$longCapitalGainsTax = 0.15 * $capital;}
elseif ($taxableIncome > 235350 && ($taxableIncome - $capital) <= 235350)
{$longCapitalGainsTax = 0.15 * (235350 - ($taxableIncome - $capital)) + 0.20 * ($capital - (235350 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 235350)
{$longCapitalGainsTax = 0.20 * $capital;}
if ($taxableIncomeLessWinnings <= 37950) {$longCapitalGainsTaxLessWinnings = 0;}
elseif ($taxableIncomeLessWinnings > 37950 && ($taxableIncomeLessWinnings - $capital) <= 37950 && $taxableIncomeLessWinnings <= 235350)
{$longCapitalGainsTaxLessWinnings = 0.15 * ($capital - (37950 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 37950 && $taxableIncomeLessWinnings <= 235350)
{$longCapitalGainsTaxLessWinnings = 0.15 * $capital;}
elseif ($taxableIncomeLessWinnings > 235350 && ($taxableIncomeLessWinnings - $capital) <= 37950)
{$longCapitalGainsTaxLessWinnings = 0.15 * (235350 - ($taxableIncomeLessWinnings - $capital)) + 0.20 * ($capital - (235350 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 235350)
{$longCapitalGainsTaxLessWinnings = 0.20 * $capital;}
$LongGains[0] = $longCapitalGainsTax;
$LongGains[1] = $capital;
$LongGains[2] = $longCapitalGainsTax - $longCapitalGainsTaxLessWinnings;
$LongGains[3] = 0.10 * ($taxableIncomeLessWinnings - $capital);
return $LongGains;
}
if ($filingStatus == 4) {
if (($taxableIncome - $taxableWinnings) <= 50800) {$longCapitalGainsTax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 50800 && (($taxableIncome - $taxableWinnings) - $capital) <= 50800 && ($taxableIncome - $taxableWinnings) <= 444550)
{$longCapitalGainsTax = 0.15 * ($taxableIncome - 50800);}
elseif (($taxableIncome - $capital) > 50800 && $taxableIncome <= 444550)
{$longCapitalGainsTax = 0.15 * $capital;}
elseif (($taxableIncome - $taxableWinnings) > 444550 && (($taxableIncome - $taxableWinnings) - $capital) <= 50800)
{$longCapitalGainsTax = 59062.5 + 0.20 * (($taxableIncome - $taxableWinnings) - 444550);}
elseif ((($taxableIncome - $taxableWinnings) - $capital) > 444550)
{$longCapitalGainsTax = 0.20 * $capital;}
if (($taxableIncome - $taxableWinnings) <= 50800) {$longCapitalGainsTaxLessWinnings = 0;}
elseif (($taxableIncome - $taxableWinnings) > 50800 && (($taxableIncome - $taxableWinnings) - $capital) <= 50800 && ($taxableIncome - $taxableWinnings) <= 444550)
{$longCapitalGainsTaxLessWinnings = 0.15 * ($taxableIncome - 50800);}
elseif ((($taxableIncome - $taxableWinnings) - $capital) > 50800 && ($taxableIncome - $taxableWinnings) <= 444550)
{$longCapitalGainsTaxLessWinnings = 0.15 * $capital;}
elseif (($taxableIncome - $taxableWinnings) > 444550 && (($taxableIncome - $taxableWinnings) - $capital) <= 50800)
{$longCapitalGainsTaxLessWinnings = 59062.5 + 0.20 * (($taxableIncome - $taxableWinnings) - 444550);}
elseif ((($taxableIncome - $taxableWinnings) - $capital) > 444550)
{$longCapitalGainsTaxLessWinnings = 0.20 * $capital;}
$LongGains[0] = $longCapitalGainsTax;
$LongGains[1] = $capital;
$LongGains[2] = $longCapitalGainsTax - $longCapitalGainsTaxLessWinnings;
$LongGains[3] = 0.10 * ($taxableIncomeLessWinnings - $capital);
return $LongGains;
}
}
/*
******************************************************************************************
* *
* Function: Traditional IRA Deduction Calculator *
* *
* *
* This function computes the deduction for contributions to IRAs. This particular *
* IRA calculator is for taxpayers filing as Married - jointly. *
* *
* This function can accommodate the taxpayer making contributions only to his or her *
* own IRA. It can also accommodate the spouse making contributions only to his or her *
* own IRA. It can accommodate contributions to both IRAs should each spouse have one *
* and both spouses have sufficient income. *
* *
* For expediency, this function reduces the maximum age for making a traditional IRA *
* contribution from 70.5 years to 65 years. This saves creating a variable just for *
* reaching 70.5 years of age. It is believed that the number of taxpayers aged between *
* 65 and 70.5 years who also make traditional IRA contributions is very small. *
* *
* This function cannot accommodate the spousal IRA. The spousal IRA is the making of *
* contributions, by a working spouse, to the IRA of a non-working spouse. The *
* accommodation of the spousal IRA requires income amounts for each spouse (zero for *
* the non-working spouse) and contribution amounts into each spouse's IRA. The *
* additional variables and the additional computations of the contribution limits for *
* each spouse were too onerous for this program when compared to the number of *
* potential users who might use spousal IRA feature. *
* *
* The variable named 'spousal IRA' is only an approximation of the true spousal IRA. *
* It allows a taxpayer to make IRA contributions to the IRS of his or her spouse *
* without regard for the limitations of the true spousal IRA. The contributions are *
* greater than allowed and therefore overstate the tax liability. Testing found the *
* overstatement to be small in relation to the additonal tax on greater than modest *
* winnings. *
* *
* This function also computes the decrease in IRA deductible contribution (if any) due *
* to the gambling winnings, as they increase AGI. This increase in AGI leads to an *
* increase in taxable income and taxes, which is indirectly attributable to the *
* gambling winnings. *
* *
* Note that Roth IRA contributions are ignored. It is left to the taxpayer to reduce *
* his or her traditional IRA contribution amount by the amount of any Roth IRA *
* contribution. *
* *
******************************************************************************************
*/
function traditionaliramfjcalc($filingStatus, $aged50Years, $spouseAged50Years, $senior, $spouseSenior, $coveredByEmployer,
$spouseCoveredByEmployer, $traditionalIRA, $studentLoanInterest, $wages, $profit, $alimonyReceived,
$seTaxDeduction, $agi, $winnings, $spousalIRA) {
$magiTraditionalIRA = $agi + $studentLoanInterest + $traditionalIRA;
$traditionalIRA = min($traditionalIRA, $wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction);
if ($filingStatus == 2 && $spousalIRA == 0 && $senior == 0) {
if ($aged50Years == 0 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 5500);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 6500);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 119000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 99000 && $magiTraditionalIRA <= 119000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(5500 * ((119000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 99000) {$traditionalIRAB = min($traditionalIRA, 5500);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 119000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 99000 && $magiTraditionalIRA <= 119000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6500 * ((119000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 99000) {$traditionalIRAB = min($traditionalIRA, 6500);}
}
if ($aged50Years == 0 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRA > 196000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 186000 && $magiTraditionalIRA <= 196000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(5500 * ((196000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 186000) {$traditionalIRAB = min($traditionalIRA, 5500);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRA > 196000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 186000 && $magiTraditionalIRA <= 196000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6500 * ((196000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 186000) {$traditionalIRAB = min($traditionalIRA, 6500);}
}
$magiTraditionalIRALessWinnings = $agi + $studentLoanInterest + $traditionalIRA - $winnings;
if ($aged50Years == 0 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 5500);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 6500);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 119000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 99000 && $magiTraditionalIRALessWinnings <= 119000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(5500 * ((119000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 99000) {$traditionalIRALessWinnings = min($traditionalIRA, 5500);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 119000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 99000 && $magiTraditionalIRALessWinnings <= 119000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(6500 * ((119000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 99000) {$traditionalIRALessWinnings = min($traditionalIRA, 6500);}
}
if ($aged50Years == 0 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 196000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 186000 && $magiTraditionalIRALessWinnings <= 196000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(5500 * ((196000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 186000) {$traditionalIRAB = min($traditionalIRA, 5500);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 196000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 186000 && $magiTraditionalIRALessWinnings <= 196000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(6500 * ((196000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 186000) {$traditionalIRALessWinnings = min($traditionalIRA, 6500);}
}
$TraditionalIRA[0] = $traditionalIRAB;
$TraditionalIRA[1] = $traditionalIRALessWinnings - $traditionalIRAB;
return $TraditionalIRA;
}
if ($filingStatus == 2 && $spousalIRA == 0 && $senior == 1) {
$TraditionalIRA[0] = 0;
$TraditionalIRA[1] = 0;
$TraditionalIRA[2] = 0;
return $TraditionalIRA;
}
if ($filingStatus == 2 && $spousalIRA == 1 && $spouseSenior == 0) {
if ($aged50Years + $spouseAged50Years == 0 && $coveredByEmployer + $spouseCoveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 11000);}
elseif ($aged50Years + $spouseAged50Years == 1 && $coveredByEmployer + $spouseCoveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 12000);}
elseif ($aged50Years + $spouseAged50Years == 2 && $coveredByEmployer + $spouseCoveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 13000);}
if ($aged50Years + $spouseAged50Years == 0 && $coveredByEmployer + $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRA > 196000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 186000 && $magiTraditionalIRA <= 196000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(11000 * ((196000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 186000) {$traditionalIRAB = min($traditionalIRA, 11000);}
}
if ($aged50Years + $spouseAged50Years == 1 && $coveredByEmployer + $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRA > 196000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 186000 && $magiTraditionalIRA <= 196000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(12000 * ((196000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 186000) {$traditionalIRAB = min($traditionalIRA, 12000);}
}
if ($aged50Years + $spouseAged50Years == 2 && $coveredByEmployer + $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRA > 196000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 186000 && $magiTraditionalIRA <= 196000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(13000 * ((196000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 186000) {$traditionalIRAB = min($traditionalIRA, 13000);}
}
if ($aged50Years + $spouseAged50Years == 0 && $coveredByEmployer + $spouseCoveredByEmployer == 2) {
if ($magiTraditionalIRA > 119000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 99000 && $magiTraditionalIRA <= 119000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(11000 * ((119000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 99000) {$traditionalIRAB = min($traditionalIRA, 11000);}
}
if ($aged50Years + $spouseAged50Years == 1 && $coveredByEmployer + $spouseCoveredByEmployer == 2) {
if ($magiTraditionalIRA > 119000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 99000 && $magiTraditionalIRA <= 119000) {$traditionalIRAB = min($traditionalIRA,10 * ceil(12000 * ((119000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 99000) {$traditionalIRAB = min($traditionalIRA, 12000);}
}
if ($aged50Years + $spouseAged50Years == 2 && $coveredByEmployer + $spouseCoveredByEmployer == 2) {
if ($magiTraditionalIRA > 119000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 99000 && $magiTraditionalIRA <= 119000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(13000 * ((119000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 99000) {$traditionalIRAB = min($traditionalIRA, 13000);}
}
$magiTraditionalIRALessWinnings = $agi + $studentLoanInterest + $traditionalIRA - $winnings;
if ($aged50Years + $spouseAged50Years == 0 && $coveredByEmployer + $spouseCoveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 11000);}
elseif ($aged50Years + $spouseAged50Years == 1 && $coveredByEmployer + $spouseCoveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 12000);}
elseif ($aged50Years + $spouseAged50Years == 2 && $coveredByEmployer + $spouseCoveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 13000);}
if ($aged50Years + $spouseAged50Years == 0 && $coveredByEmployer + $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 196000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 186000 && $magiTraditionalIRALessWinnings <= 196000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(11000 * ((196000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 186000) {$traditionalIRALessWinnings = min($traditionalIRA, 11000);}
}
if ($aged50Years + $spouseAged50Years == 1 && $coveredByEmployer + $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 196000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 186000 && $magiTraditionalIRALessWinnings <= 196000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(12000 * ((196000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 186000) {$traditionalIRALessWinnings = min($traditionalIRA, 12000);}
}
if ($aged50Years + $spouseAged50Years == 2 && $coveredByEmployer + $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 196000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 186000 && $magiTraditionalIRALessWinnings <= 196000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(13000 * ((196000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 186000) {$traditionalIRALessWinnings = min($traditionalIRA, 13000);}
}
if ($aged50Years + $spouseAged50Years == 0 && $coveredByEmployer + $spouseCoveredByEmployer == 2) {
if ($magiTraditionalIRALessWinnings > 119000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 99000 && $magiTraditionalIRALessWinnings <= 119000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(11000 * ((119000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 99000) {$traditionalIRALessWinnings = min($traditionalIRA, 11000);}
}
if ($aged50Years + $spouseAged50Years == 1 && $coveredByEmployer + $spouseCoveredByEmployer == 2) {
if ($magiTraditionalIRALessWinnings > 119000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 99000 && $magiTraditionalIRALessWinnings <= 119000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(12000 * ((119000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 99000) {$traditionalIRALessWinnings = min($traditionalIRA, 12000);}
}
if ($aged50Years + $spouseAged50Years == 2 && $coveredByEmployer + $spouseCoveredByEmployer == 2) {
if ($magiTraditionalIRALessWinnings > 119000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 99000 && $magiTraditionalIRALessWinnings <= 119000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(13000 * ((119000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 99000) {$traditionalIRALessWinnings = min($traditionalIRA, 13000);}
}
$TraditionalIRA[0] = $traditionalIRAB;
$TraditionalIRA[1] = $traditionalIRALessWinnings - $traditionalIRAB;
return $TraditionalIRA;
}
if ($filingStatus == 2 && $spousalIRA == 1 && $spouseSenior == 1) {
$TraditionalIRA[0] = 0;
$TraditionalIRA[1] = 0;
$TraditionalIRA[2] = 0;
return $TraditionalIRA;
}
}
/*
******************************************************************************************
* *
* Function: Traditional IRA Deduction Calculator *
* *
* *
* This function computes the deduction for contributions to IRAs. This particular *
* IRA calculator is for taxpayers filing as Married - separately and lived together *
* for the entire year. *
* *
* This function also computes the decrease in IRA deductible contribution (if any) due *
* to the gambling winnings, as they increase AGI. This increase in AGI leads to an *
* increase in taxable income and taxes, which is indirectly attributable to the *
* gambling winnings. *
* *
******************************************************************************************
*/
function traditionaliramfscalc($filingStatus, $aged50Years, $coveredByEmployer, $traditionalIRA, $studentLoanInterest, $wages, $profit,
$alimonyReceived, $seTaxDeduction, $agi, $winnings) {
$magiTraditionalIRA = $agi + $studentLoanInterest + $traditionalIRA;
$traditionalIRA = min($traditionalIRA, $wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction);
if ($filingStatus == 3) {
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 10000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 0 && $magiTraditionalIRA <= 10000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(5500 * ((10000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 0) {$traditionalIRAB = 0;}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 10000) {$TraditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 0 && $magiTraditionalIRA <= 10000) {$traditionalIRA = min($traditionalIRAB, 10 * ceil(6500 * ((10000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 0) {$traditionalIRAB = 0;}
}
$magiTraditionalIRALessWinnings = $agi + $studentLoanInterest + $traditionalIRA - $winnings;
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 10000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 0 && $magiTraditionalIRALessWinnings <= 10000) {$traditionalIRALessWinnings = min($traditionalIRA, 10 * ceil(5500 * ((10000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 0) {$traditionalIRALessWinnings = 0;}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 10000) {$TraditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 0 && $magiTraditionalIRALessWinnings <= 72000) {$traditionalIRALessWinnings = min($traditionalIRA, 10 * ceil(6500 * ((10000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRLessWinningsA <= 0) {$traditionalIRALessWinnings = 0;}
}
$TraditionalIRA[0] = $traditionalIRAB;
$TraditionalIRA[1] = $traditionalIRALessWinnings - $traditionalIRAB;
return $TraditionalIRA;
}
}
/*
******************************************************************************************
* *
* Function: Traditional IRA Deduction Calculator *
* *
* *
* This function computes the deduction for contributions to IRAs. This particular *
* IRA calculator is for taxpayers not filing as Married - jointly. It is appropriate *
* for taxpayers filing as Married - separately who did not live together for the entire *
* year. *
* *
* This function also computes the decrease in IRA deductible contribution (if any) due *
* to the gambling winnings, as they increase AGI. This increase in AGI leads to an *
* increase in taxable income and taxes, which is indirectly attributable to the *
* gambling winnings. *
* *
******************************************************************************************
*/
function traditionaliracalc($filingStatus, $aged50Years, $coveredByEmployer, $traditionalIRA, $studentLoanInterest, $wages, $profit,
$alimonyReceived, $seTaxDeduction, $agi, $winnings) {
$traditionalIRA = min($traditionalIRA, $wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction);
$magiTraditionalIRA = $agi + $studentLoanInterest + $traditionalIRA;
if ($filingStatus == 1 || $filingStatus == 3 || $filingStatus == 4) {
if ($aged50Years == 0 && $coveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 5500);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 6500);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 72000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 62000 && $magiTraditionalIRA <= 72000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(5500 * ((72000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 62000) {$traditionalIRAB = min($traditionalIRA, 5500);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 72000) {$TraditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 62000 && $magiTraditionalIRA <= 72000) {$traditionalIRA = min($traditionalIRAB, 10 * ceil(6500 * ((72000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 62000) {$traditionalIRAB = min($traditionalIRA, 6500);}
}
$magiTraditionalIRALessWinnings = $agi + $studentLoanInterest + $traditionalIRA - $winnings;
if ($aged50Years == 0 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 5500);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 6500);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 72000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 62000 && $magiTraditionalIRALessWinnings <= 72000) {$traditionalIRALessWinnings = min($traditionalIRA, 10 * ceil(5500 * ((72000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 62000) {$traditionalIRALessWinnings = min($traditionalIRA, 5500);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 72000) {$TraditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 62000 && $magiTraditionalIRALessWinnings <= 72000) {$traditionalIRALessWinnings = min($traditionalIRA, 10 * ceil(6500 * ((72000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 62000) {$traditionalIRALessWinnings = min($traditionalIRA, 6500);}
}
$TraditionalIRA[0] = $traditionalIRAB;
$TraditionalIRA[1] = $traditionalIRALessWinnings - $traditionalIRAB;
return $TraditionalIRA;
}
if ($filingStatus == 5) {
if ($aged50Years == 0 && $coveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 5500);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 6500);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 119000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 99000 && $magiTraditionalIRA <= 119000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(5500 * ((119000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 99000) {$traditionalIRAB = min($traditionalIRA, 5500);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 119000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 99000 && $magiTraditionalIRA <= 119000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6500 * ((119000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 99000) {$traditionalIRAB = min($traditionalIRA, 6500);}
}
$magiTraditionalIRALessWinnings = $agi + $traditionalIRA - $winnings;
if ($aged50Years == 0 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 5500);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 6500);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 119000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 99000 && $magiTraditionalIRALessWinnings <= 119000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(5500 * ((119000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 99000) {$traditionalIRALessWinnings = min($traditionalIRA, 5500);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 119000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 99000 && $magiTraditionalIRALessWinnings <= 119000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(6500 * ((119000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 99000) {$traditionalIRALessWinnings = min($traditionalIRA, 6500);}
}
$TraditionalIRA[0] = $traditionalIRAB;
$TraditionalIRA[1] = $traditionalIRALessWinnings - $traditionalIRAB;
return $TraditionalIRA;
}
}
/*
******************************************************************************************
* *
* Function: Student Loan Interest Deduction Calculator *
* *
* *
* This function computes the deduction for the interest paid on student loans. *
* *
* This function also computes the decrease in the interest deduction due to the *
* gambling winnings, as they increase AGI. This increase in AGI leads to an increase *
* in taxable income and taxes, which is indirectly attributable to the gambling *
* winnings. *
* *
* Note that the filing status of Married - separately (MFS) is omitted from the *
* function because taxpayers filing as MFS are not eligible to claim the student loan *
* interest deduction. *
* *
******************************************************************************************
*/
function studentloaninterestcalc($filingStatus, $studentLoanInterest, $traditionalIRA, $agi, $winnings) {
$agiLessWinnings = $agi - $winnings;
if ($filingStatus == 1 || $filingStatus == 4 || $filingStatus == 5) {
$magiStudentLoanInterest = $agi + $traditionalIRA + $studentLoanInterest;
if ($magiStudentLoanInterest > 80000) {$studentLoanInterestA = 0;}
elseif ($magiStudentLoanInterest > 65000 && $magiStudentLoanInterest <= 80000) {$studentLoanInterestA = min($studentLoanInterest, 2500) *
(1 - ($magiStudentLoanInterest - 65000) / 15000);}
elseif ($magiStudentLoanInterest <= 65000) {$studentLoanInterestA = min($studentLoanInterest, 2500);}
$magiStudentLoanInterestLessWinnings = $agi + $traditionalIRA + $studentLoanInterest - $winnings;
if ($magiStudentLoanInterestLessWinnings > 80000) {$studentLoanInterestLessWinnings = 0;}
elseif ($magiStudentLoanInterestLessWinnings > 65000 && $magiStudentLoanInterestLessWinnings <= 80000) {$studentLoanInterestLessWinnings =
min($studentLoanInterest, 2500) * (1 - ($magiStudentLoanInterestLessWinnings - 65000) / 15000);}
elseif ($magiStudentLoanInterestLessWinnings <= 65000) {$studentLoanInterestLessWinnings = min($studentLoanInterest, 2500);}
$StudentLoanInterest[0] = $studentLoanInterestA;
$StudentLoanInterest[1] = $studentLoanInterestLessWinnings - $studentLoanInterestA;
return $StudentLoanInterest;
}
if ($filingStatus == 2) {
$magiStudentLoanInterest = $agi + $traditionalIRA + $studentLoanInterest;
if ($magiStudentLoanInterest > 165000) {$studentLoanInterestA = 0;}
elseif ($magiStudentLoanInterest > 135000 && $magiStudentLoanInterest <= 165000) {$studentLoanInterestA = min($studentLoanInterest, 2500) *
(1 - ($magiStudentLoanInterest - 135000) / 30000);}
elseif ($magiStudentLoanInterest <= 135000) {$studentLoanInterestA = min($studentLoanInterest, 2500);}
$magiStudentLoanInterestLessWinnings = $agi + $traditionalIRA + $studentLoanInterest - $winnings;
if ($magiStudentLoanInterestLessWinnings > 165000) {$studentLoanInterestLessWinnings = 0;}
elseif ($magiStudentLoanInterestLessWinnings > 135000 && $magiStudentLoanInterestLessWinnings <= 165000) {$studentLoanInterestLessWinnings =
min($studentLoanInterest, 2500) * (1 - ($magiStudentLoanInterestLessWinnings - 135000) / 30000);}
elseif ($magiStudentLoanInterestLessWinnings <= 135000) {$studentLoanInterestLessWinnings = min($studentLoanInterest, 2500);}
$StudentLoanInterest[0] = $studentLoanInterestA;
$StudentLoanInterest[1] = $studentLoanInterestLessWinnings - $studentLoanInterestA;
return $StudentLoanInterest;
}
}
/*
******************************************************************************************
* *
* Function: Taxable Social Security Benefits Calculator *
* *
* *
* This function computes the amount of Social Security benefits (SSB) that must be *
* included in income and taxed. *
* *
* This function also computes the increase in the includable SSB due to the gambling *
* winnings, as they increase AGI (and modified AGI). This increase in included SSB *
* leads to an increase in taxable income and taxes, which is indirectly attributable *
* to the gambling winnings. *
* *
******************************************************************************************
*/
function includablessicalc($filingStatus, $agi, $ssi, $studentLoanInterest, $exempt, $winnings) {
$magiSSI = ($agi - $ssi) + $exempt + $studentLoanInterest + .5 * $ssi;
$magiSSILessWinnings = ($agi - $ssi) + $exempt + $studentLoanInterest + .5 * $ssi - $winnings;
if ($filingStatus != 2) {
if ($magiSSI <= 25000) {$includableSSI = 0;}
if ($magiSSI > 25000 && $magiSSI <= 34000) {$includableSSI = min(0.5 * $ssi, 0.5 * ($magiSSI - 25000));}
if ($magiSSI > 34000) {$includableSSI = min(0.85 * $ssi, 4500 + 0.85 * ($magiSSI - 34000));}
if ($magiSSILessWinnings <= 25000) {$includableSSILessWinnings = 0;}
if ($magiSSILessWinnings > 25000 && $magiSSILessWinnings <= 34000) {$includableSSILessWinnings = min(0.5 * $ssi, 0.5 * ($magiSSILessWinnings - 25000));}
if ($magiSSILessWinnings > 34000) {$includableSSILessWinnings = min(0.85 * $ssi, 4500 + 0.85 * ($magiSSILessWinnings - 34000));}
$IncludableSSI[0] = $includableSSI;
$IncludableSSI[1] = $includableSSI - $includableSSILessWinnings;
return $IncludableSSI;
}
if ($filingStatus == 2) {
if ($magiSSI <= 32000) {$includableSSI = 0;}
if ($magiSSI > 32000 && $magiSSI <= 44000) {$includableSSI = min(0.5 * $ssi, 0.5 * ($magiSSI - 32000));}
if ($magiSSI > 44000) {$includableSSI = min(0.85 * $ssi, 6000 + 0.85 * ($magiSSI - 44000));}
if ($magiSSILessWinnings <= 32000) {$includableSSILessWinnings = 0;}
if ($magiSSILessWinnings > 32000 && $magiSSILessWinnings <= 44000) {$includableSSILessWinnings = min(0.5 * $ssi, 0.5 * ($magiSSILessWinnings - 32000));}
if ($magiSSILessWinnings > 44000) {$includableSSILessWinnings = min(0.85 * $ssi, 6000 + 0.85 * ($magiSSILessWinnings - 44000));}
$IncludableSSI[0] = $includableSSI;
$IncludableSSI[1] = $includableSSI - $includableSSILessWinnings;
return $IncludableSSI;
}
}
/*
******************************************************************************************
* *
* Function: Itemized Deductions Calculator *
* *
* *
* This function computes the total itemized deductions and compares it to the standard *
* deduction, selecting the larger, as part of the calculation of taxable income. *
* *
* When total itemized deductions are less than the standard deduction, this function *
* computes the difference. This difference represents the additonal itemizable *
* expenses the taxpayer needs to claim in order for gambling losses to start to be *
* deductible. This deficiency of itemizable expenses is reported with the tax on *
* gambling income. *
* *
* When total itemized deductions exceed the standard deduction, gambling losses can be *
* used to reduce gambling winnings. This function computes the net amount of gambling *
* winnings that are subject to taxation when gambling losses are claimable. *
* *
* In addition, this function computes the decrease in itemized deduction amount that *
* is due to the increase in Adjusted Gross Income (AGI) due to the gambling winnings. *
* *
* This occurs in two ways: *
* *
* 1) *
* Some itemized deductions have floors determined by the AGI. The deductible amount is *
* the excess of the expense over this floor. For this program, medical expenses and *
* miscellaneous expenses have such floors, of 7.5% of AGI and 2.0% of AGI, respectively.*
* When AGI increases due to gambling winnings, this floor increases and the amount of *
* the expense which is deductible decreases. *
* *
* 2) *
* Certain itemized deductions are subject to a limit determined by AGI (called the *
* Pease Limitations). When the taxpayer's income from non-gambling sources is high *
* enough that the gambling winnings push AGI over the phase-out threshold, those items *
* are reduced in amount and total itemized deductions declines. *
* *
* The tax impact of this itemized deduction phase-out is reported alone and as part of *
* the total tax liability increase due to the gambling winnings. *
* *
* Note that the phase-out impact of 1) is present at all levels of total AGI. Whereas, *
* the phase-out impact of 2) is not present when total AGI is less than the lower *
* phase-out threshold, or when non-gambling AGI (AGI without the gambling winnings) *
* is greater than the upper phase-out threshold. *
* *
* The itemized deductions phase-out amount is expressed in the fourth element of the *
* return array, i.e. Deductions[3]. *
* *
******************************************************************************************
*/
function itemizeddeductionscalc($filingStatus, $agi, $winnings, $losses, $senior, $blind, $spouseSenior, $spouseBlind, $medicalExpenses,
$medicalExpensesThresholdRate, $stateTaxes, $mortgageInterest, $charity, $cashCharitableDonationsLimitRate,
$casualtyLoss, $casualtyLossThresholdRate, $jobExpenses, $miscellaneousExpensesThresholdRate,
$miscellaneous, $studentLoanInterestPhaseOut, $SSIPhaseOut, $IRAPhaseOut, $spouseItemizing) {
if ($medicalExpenses > 0 && $jobExpenses == 0) {$totalPhaseOut = 0.075 * ($studentLoanInterestPhaseOut + $SSIPhaseOut + $IRAPhaseOut);}
elseif ($medicalExpenses == 0 && $jobExpenses > 0) {$totalPhaseOut = 0.02 * ($studentLoanInterestPhaseOut + $SSIPhaseOut + $IRAPhaseOut);}
elseif ($medicalExpenses > 0 && $jobExpenses > 0) {$totalPhaseOut = 0.095 * ($studentLoanInterestPhaseOut + $SSIPhaseOut + $IRAPhaseOut);}
else {$totalPhaseOut = 0;}
if ($filingStatus == 1) {
$standard = 6350 + 1550 * ($senior + $blind);
$allowableLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$jobExpensesA = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agi, 0);
$casualtyLossA = max($casualtyLoss - $casualtyLossThresholdRate * $agi - 100, 0);
$itemizedLimitA = $stateTaxes + $jobExpensesA + $charityA + $mortgageInterest + $miscellaneous;
$itemizedNoLimitA = $medicalExpensesA + $casualtyLossA + $allowableLosses;
$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA;
if ($agi > 261500) {$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA - min(0.80 * $itemizedLimitA, 0.03 * ($agi - 261500));}
if ($standard <= $itemizedTotalA - $allowableLosses) {
$deductibleLosses = $allowableLosses;
$deficiency = 0;
} else {
$deductibleLosses = max($itemizedTotalA - $standard, 0);
$deficiency = max($standard - $itemizedTotalA, 0);
}
$taxableWinnings = $winnings - $deductibleLosses;
$agiLessWinnings = $agi - $winnings;
$medicalExpensesLessWinnings = max($medicalExpenses - $medicalExpensesThresholdRate * $agiLessWinnings, 0);
$charityLessWinnings = min($charity, $cashCharitableDonationsLimitRate * $agiLessWinnings);
$jobExpensesLessWinnings = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agiLessWinnings, 0);
$casualtyLossLessWinnings = max($casualtyLoss - $casualtyLossThresholdRate * $agiLessWinnings - 100, 0);
$itemizedLimitLessWinnings = $stateTaxes + $jobExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$itemizedNoLimitLessWinnings = $medicalExpensesLessWinnings + $casualtyLossLessWinnings;
$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings;
if ($agiLessWinnings > 261500) {$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings -
min(0.80 * $itemizedLimitLessWinnings, 0.03 * ($agiLessWinnings - 261500));}
$Deductions[0] = max($itemizedTotalA, $standard);
$Deductions[1] = $taxableWinnings;
$Deductions[2] = $deficiency;
$Deductions[3] = max(($itemizedTotalLessWinnings - max($itemizedTotalA - $allowableLosses, $standard) + $totalPhaseOut), 0);
return $Deductions;
}
if ($filingStatus == 2) {
$standard = 12700 + 1250 * ($senior + $spouseSenior + $blind + $spouseBlind);
$allowableLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$jobExpensesA = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agi, 0);
$casualtyLossA = max($casualtyLoss - $casualtyLossThresholdRate * $agi - 100, 0);
$itemizedLimitA = $stateTaxes + $jobExpensesA + $charityA + $mortgageInterest + $miscellaneous;
$itemizedNoLimitA = $medicalExpensesA + $casualtyLossA + $allowableLosses;
$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA;
if ($agi > 313800) {$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA - min(0.80 * $itemizedLimitA, 0.03 * ($agi - 313800));}
if ($standard <= $itemizedTotalA - $allowableLosses) {
$deductibleLosses = $allowableLosses;
$deficiency = 0;
} else {
$deductibleLosses = max($itemizedTotalA - $standard, 0);
$deficiency = max($standard - $itemizedTotalA, 0);
}
$taxableWinnings = $winnings - $deductibleLosses;
$agiLessWinnings = $agi - $winnings;
$medicalExpensesLessWinnings = max($medicalExpenses - $medicalExpensesThresholdRate * $agiLessWinnings, 0);
$charityLessWinnings = min($charity, $cashCharitableDonationsLimitRate * $agiLessWinnings);
$jobExpensesLessWinnings = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agiLessWinnings, 0);
$casualtyLossLessWinnings = max($casualtyLoss - $casualtyLossThresholdRate * $agiLessWinnings - 100, 0);
$itemizedLimitLessWinnings = $stateTaxes + $jobExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$itemizedNoLimitLessWinnings = $medicalExpensesLessWinnings + $casualtyLossLessWinnings;
$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings;
if ($agiLessWinnings > 313800) {$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings -
min(0.80 * $itemizedLimitLessWinnings, 0.03 * ($agiLessWinnings - 313800));}
$Deductions[0] = max($itemizedTotalA, $standard);
$Deductions[1] = $taxableWinnings;
$Deductions[2] = $deficiency;
$Deductions[3] = max(($itemizedTotalLessWinnings - max($itemizedTotalA - $allowableLosses, $standard) + $totalPhaseOut), 0);
return $Deductions;
}
if ($filingStatus == 3) {
if ($spouseItemizing == 1) {
$allowableLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$jobExpensesA = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agi, 0);
$casualtyLossA = max($casualtyLoss - $casualtyLossThresholdRate * $agi - 100, 0);
$itemizedLimitA = $stateTaxes + $jobExpensesA + $charityA + $mortgageInterest + $miscellaneous;
$itemizedNoLimitA = $medicalExpensesA + $casualtyLossA + $allowableLosses;
$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA;
if ($agi > 156900) {$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA - min(0.80 * $itemizedLimitA, 0.03 * ($agi - 156900));}
$deductibleLosses = $allowableLosses;
$deficiency = 0;
$taxableWinnings = $winnings - $deductibleLosses;
$agiLessWinnings = $agi - $winnings;
$medicalExpensesLessWinnings = max($medicalExpenses - $medicalExpensesThresholdRate * $agiLessWinnings, 0);
$charityLessWinnings = min($charity, $cashCharitableDonationsLimitRate * $agiLessWinnings);
$jobExpensesLessWinnings = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agiLessWinnings, 0);
$casualtyLossLessWinnings = max($casualtyLoss - $casualtyLossThresholdRate * $agiLessWinnings - 100, 0);
$itemizedLimitLessWinnings = $stateTaxes + $jobExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$itemizedNoLimitLessWinnings = $medicalExpensesLessWinnings + $casualtyLossLessWinnings;
$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings;
if ($agiLessWinnings > 156900) {$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings -
min(0.80 * $itemizedLimitLessWinnings, 0.03 * ($agiLessWinnings - 156900));}
$Deductions[0] = $itemizedTotalA;
$Deductions[1] = $taxableWinnings;
$Deductions[2] = $deficiency;
$Deductions[3] = max(($itemizedTotalLessWinnings - ($itemizedTotalA - $allowableLosses) + $totalPhaseOut), 0);
} else {
$Deductions[0] = 6350 + 1250 * ($senior + $blind);
$Deductions[1] = $winnings;
$Deductions[2] = 6350;
$Deductions[3] = 0;
}
return $Deductions;
}
if ($filingStatus == 4) {
$standard = 9350 + 1550 * ($senior + $blind);
$allowableLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$jobExpensesA = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agi, 0);
$casualtyLossA = max($casualtyLoss - $casualtyLossThresholdRate * $agi - 100, 0);
$itemizedLimitA = $stateTaxes + $jobExpensesA + $charityA + $mortgageInterest + $miscellaneous;
$itemizedNoLimitA = $medicalExpensesA + $casualtyLossA + $allowableLosses;
$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA;
if ($agi > 287650) {$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA - min(0.80 * $itemizedLimitA, 0.03 * ($agi - 287650));}
if ($standard <= $itemizedTotalA - $allowableLosses) {
$deductibleLosses = $allowableLosses;
$deficiency = 0;
} else {
$deductibleLosses = max($itemizedTotalA - $standard, 0);
$deficiency = max($standard - $itemizedTotalA, 0);
}
$taxableWinnings = $winnings - $deductibleLosses;
$agiLessWinnings = $agi - $winnings;
$medicalExpensesLessWinnings = max($medicalExpenses - $medicalExpensesThresholdRate * $agiLessWinnings, 0);
$charityLessWinnings = min($charity, $cashCharitableDonationsLimitRate * $agiLessWinnings);
$jobExpensesLessWinnings = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agiLessWinnings, 0);
$casualtyLossLessWinnings = max($casualtyLoss - $casualtyLossThresholdRate * $agiLessWinnings - 100, 0);
$itemizedLimitLessWinnings = $stateTaxes + $jobExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$itemizedNoLimitLessWinnings = $medicalExpensesLessWinnings + $casualtyLossLessWinnings;
$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings;
if ($agiLessWinnings > 287650) {$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings -
min(0.80 * $itemizedLimitLessWinnings, 0.03 * ($agiLessWinnings - 287650));}
$Deductions[0] = max($itemizedTotalA, $standard);
$Deductions[1] = $taxableWinnings;
$Deductions[2] = $deficiency;
$Deductions[3] = max(($itemizedTotalLessWinnings - max($itemizedTotalA - $allowableLosses, $standard) + $totalPhaseOut), 0);
return $Deductions;
}
if ($filingStatus == 5) {
$standard = 12700 + 1250 * ($senior + $blind);
$allowableLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$jobExpensesA = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agi, 0);
$casualtyLossA = max($casualtyLoss - $casualtyLossThresholdRate * $agi - 100, 0);
$itemizedLimitA = $stateTaxes + $jobExpensesA + $charityA + $mortgageInterest + $miscellaneous;
$itemizedNoLimitA = $medicalExpensesA + $casualtyLossA + $allowableLosses;
$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA;
if ($agi > 313800) {$itemizedTotalA = $itemizedLimitA + $itemizedNoLimitA - min(0.80 * $itemizedLimitA, 0.03 * ($agi - 313800));}
if ($standard <= $itemizedTotalA - $allowableLosses) {
$deductibleLosses = $allowableLosses;
$deficiency = 0;
} else {
$deductibleLosses = max($itemizedTotalA - $standard, 0);
$deficiency = max($standard - $itemizedTotalA, 0);
}
$taxableWinnings = $winnings - $deductibleLosses;
$agiLessWinnings = $agi - $winnings;
$medicalExpensesLessWinnings = max($medicalExpenses - $medicalExpensesThresholdRate * $agiLessWinnings, 0);
$charityLessWinnings = min($charity, $cashCharitableDonationsLimitRate * $agiLessWinnings);
$jobExpensesLessWinnings = max($jobExpenses - $miscellaneousExpensesThresholdRate * $agiLessWinnings, 0);
$casualtyLossLessWinnings = max($casualtyLoss - $casualtyLossThresholdRate * $agiLessWinnings - 100, 0);
$itemizedLimitLessWinnings = $stateTaxes + $jobExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$itemizedNoLimitLessWinnings = $medicalExpensesLessWinnings + $casualtyLossLessWinnings;
$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings;
if ($agiLessWinnings > 313800) {
$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings -
min(0.80 * $itemizedLimitLessWinnings, 0.03 * ($agiLessWinnings - 313800));
} else {
$itemizedTotalLessWinnings = $itemizedLimitLessWinnings + $itemizedNoLimitLessWinnings;
}
$Deductions[0] = max($itemizedTotalA, $standard);
$Deductions[1] = $taxableWinnings;
$Deductions[2] = $deficiency;
$Deductions[3] = max(($itemizedTotalLessWinnings - max($itemizedTotalA - $allowableLosses, $standard) + $totalPhaseOut), 0);
return $Deductions;
}
}
/*
******************************************************************************************
* *
* Function: Exemptions Calculator *
* *
* *
* This function computes the total deduction for personal and dependent exemptions as *
* part of the calculation of taxable income. *
* *
* In addition, this function computes the decrease in exemption amount that is due to *
* the increase in Adjusted Gross Income (AGI) due to the gambling winnings. This *
* occurs when the taxpayer's income from non-gambling sources is high enough that the *
* gambling winnings push AGI over the phase-out threshold. The tax impact of this *
* exemption phase-out is reported alone and as part of the total tax liability *
* increase due to the gambling winnings. *
* *
* Note that this phase-out impact is not present when total AGI is less than the lower *
* phase-out threshold, or when non-gambling AGI (AGI less without the gambling *
* winnings) is greater than the upper phase-out threshold. The taxpayer enjoys the *
* full exemption deduction when total AGI falls below the lower threshold. But has a *
* zero exemption amount when non-gambling AGI falls above the upper threshold. *
* *
******************************************************************************************
*/
function exemptionscalc($filingStatus, $dependents, $agi, $winnings) {
$agiLessWinnings = $agi - $winnings;
if ($filingStatus == 1) {
if ($agi <= 261500) {$exemption = 4050 * (1 + $dependents);}
elseif ($agi > 261500 && $agi <= 384000) {
$exemption = 4050 * (1 + $dependents) * (1 - ((ceil(($agi - 261500) / 2500)) * 0.02));}
elseif ($agi > 384000) {$exemption = 0;}
if ($agiLessWinnings <= 261500) {$exemptionLessWinnings = 4050 * (1 + $dependents);}
elseif ($agiLessWinnings > 261500 && $agiLessWinnings <= 384000) {$exemptionLessWinnings = 4050 *
(1 + $dependents) * (1 - ((ceil(($agiLessWinnings - 261500) / 2500)) * 0.02));}
elseif ($agiLessWinnings > 384000) {$exemptionLessWinnings = 0;}
$Exemptions[0] = $exemption;
$Exemptions[1] = $exemptionLessWinnings;
$Exemptions[2] = $exemptionLessWinnings - $exemption;
return $Exemptions;
}
if ($filingStatus == 2) {
if ($agi <= 313800) {$exemption = 4050 * (2 + $dependents);}
elseif ($agi > 313800 && $agi <= 436300) {$exemption = 4050 * (2 + $dependents) * (1 - ((ceil(($agi - 313800) / 2500)) * 0.02));}
elseif ($agi > 436300) {$exemption = 0;}
if ($agiLessWinnings <= 313800) {$exemptionLessWinnings = 4050 * (2 + $dependents);}
elseif ($agiLessWinnings > 313800 && $agiLessWinnings <= 436300) {$exemptionLessWinnings = 4050 *
(2 + $dependents) * (1 - ((ceil(($agiLessWinnings - 313800) / 2500)) * 0.02));}
elseif ($agiLessWinnings > 436300) {$exemptionLessWinnings = 0;}
$Exemptions[0] = $exemption;
$Exemptions[1] = $exemptionLessWinnings;
$Exemptions[2] = $exemptionLessWinnings - $exemption;
return $Exemptions;
}
if ($filingStatus == 3) {
if ($agi <= 156900) {$exemption = 4050 * (1 + $dependents);}
elseif ($agi > 156900 && $agi <= 218150) {$exemption = 4050 * (1 + $dependents) * (1 - ((ceil(($agi - 156900) / 1250)) * 0.02));}
elseif ($agi > 218150) {$exemption = 0;}
if ($agiLessWinnings <= 156900) {$exemptionLessWinnings = 4050 * (1 + $dependents);}
elseif ($agiLessWinnings > 156900 && $agiLessWinnings <= 218150) {$exemptionLessWinnings = 4050 *
(1 + $dependents) * (1 - ((ceil(($agiLessWinnings - 156900) / 2500)) * 0.02));}
elseif ($agiLessWinnings > 218150) {$exemptionLessWinnings = 0;}
$Exemptions[0] = $exemption;
$Exemptions[1] = $exemptionLessWinnings;
$Exemptions[2] = $exemptionLessWinnings - $exemption;
return $Exemptions;
}
if ($filingStatus == 4) {
if ($agi <= 287650) {$exemption = 4050 * (1 + $dependents);}
elseif ($agi > 287650 && $agi <= 410150) {$exemption = 4050 * (1 + $dependents) * (1 - ((ceil(($agi - 287650) / 2500)) * 0.02));}
elseif ($agi > 410150) {$exemption = 0;}
if ($agiLessWinnings <= 287650) {$exemptionLessWinnings = 4050 * (1 + $dependents);}
elseif ($agiLessWinnings > 287650 && $agiLessWinnings <= 410150) {$exemptionLessWinnings = 4050 *
(1 + $dependents) * (1 - ((ceil(($agiLessWinnings - 287650) / 2500)) * 0.02));}
elseif ($agiLessWinnings > 410150) {$exemptionLessWinnings = 0;}
$Exemptions[0] = $exemption;
$Exemptions[1] = $exemptionLessWinnings;
$Exemptions[2] = $exemptionLessWinnings - $exemption;
return $Exemptions;
}
if ($filingStatus == 5) {
if ($agi <= 313800) {$exemption = 4050 * (1 + $dependents);}
elseif ($agi > 313800 && $agi <= 436300) {$exemption = 4050 * (1 + $dependents) * (1 - ((ceil(($agi - 313800) / 2500)) * 0.02));}
elseif ($agi > 436300) {$exemption = 0;}
if ($agiLessWinnings <= 313800) {$exemptionLessWinnings = 4050 * (1 + $dependents);}
elseif ($agiLessWinnings > 313800 && $agiLessWinnings <= 436300) {$exemptionLessWinnings = 4050 *
(1 + $dependents) * (1 - ((ceil(($agiLessWinnings - 313800) / 2500)) * 0.02));}
elseif ($agiLessWinnings > 436300) {$exemptionLessWinnings = 0;}
$Exemptions[0] = $exemption;
$Exemptions[1] = $exemptionLessWinnings;
$Exemptions[2] = $exemptionLessWinnings - $exemption;
return $Exemptions;
}
}
/*
******************************************************************************************
* *
* Function: Additional Medicare Tax Calculator *
* *
* *
* This function computes a very simplified version of the additional Medicare taxes on *
* earned income and net investment income. The challenge of accommodating the full *
* complexity of this tax law was not worth the likely very small number of taxpayers *
* who might make use of the omitted features. *
* *
* There will not be any additional tax on earned income since gambling winnings are not *
* earned income, do not affect other income that is earned, and the tax is triggered *
* only by earned income. There will be additional tax on investment income because *
* that tax is triggered by Adjusted Gross Income (AGI). The amount of investment *
* income is relevant only in that it must be greater than zero. *
* *
* When AGI without gambling winnings is less than the Medicare tax thresholds, gambling *
* winnings can push AGI above the threshold and trigger the tax on investment income, *
* should the taxpayer have any. When AGI without gambling winnings is greater than the *
* Medicare tax thresholds, then the tax on any investment income has already been *
* triggered. Additional income in the form of gambling winnings will not increase the *
* tax. *
* *
******************************************************************************************
*/
function additionalmedicaretaxcalc($filingStatus, $wages, $seEarnings, $investment, $dividend, $shortCapital, $longCapital, $rent, $kayone, $agi) {
if ($filingStatus == 1 || $filingStatus == 4 || $filingStatus == 5) {$addMedicare = 0.009 * max(($wages + $seEarnings - 200000), 0);}
if ($filingStatus == 2) {$addMedicare = 0.009 * max(($wages + $seEarnings - 250000), 0);}
if ($filingStatus == 3) {$addMedicare = 0.009 * max(($wages + $seEarnings - 125000), 0);}
if ($filingStatus == 1 || $filingStatus == 4) {$NII = 0.038 * min(max(($investment + $dividend + $shortCapital + $longCapital + $rent + $kayone), 0), max(($agi - 200000), 0));}
if ($filingStatus == 2 || $filingStatus == 5) {$NII = 0.038 * min(max(($investment + $dividend + $shortCapital + $longCapital + $rent + $kayone), 0), max(($agi - 250000), 0));}
if ($filingStatus == 3) {$NII = 0.038 * min(max(($investment + $dividend + $shortCapital + $longCapital + $rent + $kayone), 0), max(($agi - 125000), 0));}
$MedicareTax[0] = $addMedicare;
$MedicareTax[1] = $NII;
return $MedicareTax;
}
/*
******************************************************************************************
* *
* Function: Span Calculator for Income Tax *
* *
* *
* If gambling winnings (net of deductible gambling losses) are sufficiently large, the *
* first and last dollars of gambling income may fall in different tax brackets. This *
* function computes the number of tax brackets into which gambling income falls, *
* or spans. It has values from zero, when taxable gambling winnings start and stop *
* within the same bracket, to seven, when taxable gambling income starts in the first *
* tax bracket and stops in the last. This number is used to compute the additional *
* income tax on the taxable gambling winnings. *
* *
* There are different tax brackets for each filing status. Except, "Married - Jointly" *
* and "Qualified Widow(er)" have the same tax brackets in 2017. *
* *
******************************************************************************************
*/
function spancalc($filingStatus, $taxableIncome, $taxableWinnings) {
if ($filingStatus == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9325) ||
(($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome <= 37950) ||
(($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome <= 91900) ||
(($taxableIncome - $taxableWinnings) > 91900 && $taxableIncome <= 191650) ||
(($taxableIncome - $taxableWinnings) > 191650 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome <= 418400) ||
($taxableIncome - $taxableWinnings) > 418400
){$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9325) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 9325 && $taxableIncome <= 37950) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 37950 && $taxableIncome <= 91900) ||
(($taxableIncome - $taxableWinnings) > 37950 && ($taxableIncome - $taxableWinnings) <= 91900 && $taxableIncome > 91900 && $taxableIncome <= 191650) ||
(($taxableIncome - $taxableWinnings) > 91900 && ($taxableIncome - $taxableWinnings) <= 191650 && $taxableIncome > 191650 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 191650 && ($taxableIncome - $taxableWinnings) <= 416700 && $taxableIncome > 416700 && $taxableIncome <= 418400) ||
(($taxableIncome - $taxableWinnings) > 416700 && ($taxableIncome - $taxableWinnings) <= 418400 && $taxableIncome > 418400)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9325 && $taxableIncome <= 37950) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 37950 && $taxableIncome <= 91900) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 91900 && $taxableIncome <= 191650) ||
(($taxableIncome - $taxableWinnings) > 37950 && ($taxableIncome - $taxableWinnings) <= 91900 && $taxableIncome > 191650 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 91900 && ($taxableIncome - $taxableWinnings) <= 191650 && $taxableIncome > 416700 && $taxableIncome <= 418400) ||
(($taxableIncome - $taxableWinnings) > 191650 && ($taxableIncome - $taxableWinnings) <= 416700 && $taxableIncome > 418400)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 37950 && $taxableIncome <= 91900) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 91900 && $taxableIncome <= 191650) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 191650 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 37950 && ($taxableIncome - $taxableWinnings) <= 91900 && $taxableIncome > 416700 && $taxableIncome <= 418400) ||
(($taxableIncome - $taxableWinnings) > 91900 && ($taxableIncome - $taxableWinnings) <= 191650 && $taxableIncome > 418400)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 91900 && $taxableIncome <= 191650) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 191650 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 416700 && $taxableIncome <= 418400) ||
(($taxableIncome - $taxableWinnings) > 37950 && ($taxableIncome - $taxableWinnings) <= 91900 && $taxableIncome > 418400)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 191650 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 416700 && $taxableIncome <= 418400) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 418400)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 416700 && $taxableIncome <= 418400) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 418400)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 418400)
) {$span = 7;}
return $span;
}
if ($filingStatus == 2 || $filingStatus == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 18650) ||
(($taxableIncome - $taxableWinnings) > 18650 && $taxableIncome <= 75900) ||
(($taxableIncome - $taxableWinnings) > 75900 && $taxableIncome <= 153100) ||
(($taxableIncome - $taxableWinnings) > 153100 && $taxableIncome <= 233350) ||
(($taxableIncome - $taxableWinnings) > 233350 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome <= 470700) ||
($taxableIncome - $taxableWinnings) > 470700
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 18650) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 18650 && $taxableIncome > 18650 && $taxableIncome <= 75900) ||
(($taxableIncome - $taxableWinnings) > 18650 && ($taxableIncome - $taxableWinnings) <= 75900 && $taxableIncome > 75900 && $taxableIncome <= 153100) ||
(($taxableIncome - $taxableWinnings) > 75900 && ($taxableIncome - $taxableWinnings) <= 153100 && $taxableIncome > 153100 && $taxableIncome <= 233350) ||
(($taxableIncome - $taxableWinnings) > 153100 && ($taxableIncome - $taxableWinnings) <= 233350 && $taxableIncome > 233350 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 233350 && ($taxableIncome - $taxableWinnings) <= 416700 && $taxableIncome > 416700 && $taxableIncome <= 470700) ||
(($taxableIncome - $taxableWinnings) > 416700 && ($taxableIncome - $taxableWinnings) <= 470700 && $taxableIncome > 470700)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 18650 && $taxableIncome <= 75900) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 18650 && $taxableIncome > 75900 && $taxableIncome <= 153100) ||
(($taxableIncome - $taxableWinnings) > 18650 && ($taxableIncome - $taxableWinnings) <= 75900 && $taxableIncome > 153100 && $taxableIncome <= 233350) ||
(($taxableIncome - $taxableWinnings) > 75900 && ($taxableIncome - $taxableWinnings) <= 153100 && $taxableIncome > 233350 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 153100 && ($taxableIncome - $taxableWinnings) <= 233350 && $taxableIncome > 416700 && $taxableIncome <= 470700) ||
(($taxableIncome - $taxableWinnings) > 233350 && ($taxableIncome - $taxableWinnings) <= 416700 && $taxableIncome > 470700)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 75900 && $taxableIncome <= 153100) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 18650 && $taxableIncome > 153100 && $taxableIncome <= 233350) ||
(($taxableIncome - $taxableWinnings) > 18650 && ($taxableIncome - $taxableWinnings) <= 75900 && $taxableIncome > 233350 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 75900 && ($taxableIncome - $taxableWinnings) <= 153100 && $taxableIncome > 416700 && $taxableIncome <= 470700) ||
(($taxableIncome - $taxableWinnings) > 153100 && ($taxableIncome - $taxableWinnings) <= 233350 && $taxableIncome > 470700)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 153100 && $taxableIncome <= 233350) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 18650 && $taxableIncome > 233350 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 18650 && ($taxableIncome - $taxableWinnings) <= 75900 && $taxableIncome > 416700 && $taxableIncome <= 470700) ||
(($taxableIncome - $taxableWinnings) > 75900 && ($taxableIncome - $taxableWinnings) <= 153100 && $taxableIncome > 470700)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 233350 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 18650 && $taxableIncome > 416700 && $taxableIncome <= 470700) ||
(($taxableIncome - $taxableWinnings) > 18650 && ($taxableIncome - $taxableWinnings) <= 75900 && $taxableIncome > 470700)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 416700 && $taxableIncome <= 470700) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 18650 && $taxableIncome > 470700)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 470700)
) {$span = 7;}
return $span;
}
if ($filingStatus == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9325) ||
(($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome <= 37950) ||
(($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome <= 76550) ||
(($taxableIncome - $taxableWinnings) > 76550 && $taxableIncome <= 116675) ||
(($taxableIncome - $taxableWinnings) > 116675 && $taxableIncome <= 208350) ||
(($taxableIncome - $taxableWinnings) > 208350 && $taxableIncome <= 235350) ||
($taxableIncome - $taxableWinnings) > 235350
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9325) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 9325 && $taxableIncome <= 37950) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 37950 && $taxableIncome <= 76550) ||
(($taxableIncome - $taxableWinnings) > 37950 && ($taxableIncome - $taxableWinnings) <= 76550 && $taxableIncome > 76550 && $taxableIncome <= 116675) ||
(($taxableIncome - $taxableWinnings) > 76550 && ($taxableIncome - $taxableWinnings) <= 116675 && $taxableIncome > 116675 && $taxableIncome <= 208350) ||
(($taxableIncome - $taxableWinnings) > 116675 && ($taxableIncome - $taxableWinnings) <= 208350 && $taxableIncome > 208350 && $taxableIncome <= 235350) ||
(($taxableIncome - $taxableWinnings) > 208350 && ($taxableIncome - $taxableWinnings) <= 235350 && $taxableIncome > 235350)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9325 && $taxableIncome <= 37950) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 37950 && $taxableIncome <= 76550) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 76550 && $taxableIncome <= 116675) ||
(($taxableIncome - $taxableWinnings) > 37950 && ($taxableIncome - $taxableWinnings) <= 76550 && $taxableIncome > 116675 && $taxableIncome <= 208350) ||
(($taxableIncome - $taxableWinnings) > 76550 && ($taxableIncome - $taxableWinnings) <= 116675 && $taxableIncome > 208350 && $taxableIncome <= 235350) ||
(($taxableIncome - $taxableWinnings) > 116675 && ($taxableIncome - $taxableWinnings) <= 208350 && $taxableIncome > 235350)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 37950 && $taxableIncome <= 76550) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 76550 && $taxableIncome <= 116675) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 116675 && $taxableIncome <= 208350) ||
(($taxableIncome - $taxableWinnings) > 37950 && ($taxableIncome - $taxableWinnings) <= 76550 && $taxableIncome > 208350 && $taxableIncome <= 235350) ||
(($taxableIncome - $taxableWinnings) > 76550 && ($taxableIncome - $taxableWinnings) <= 116675 && $taxableIncome > 235350)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 76550 && $taxableIncome <= 191650) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 116675 && $taxableIncome <= 208350) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 208350 && $taxableIncome <= 235350) ||
(($taxableIncome - $taxableWinnings) > 37950 && ($taxableIncome - $taxableWinnings) <= 76550 && $taxableIncome > 235350)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 116675 && $taxableIncome <= 208350) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 208350 && $taxableIncome <= 235350) ||
(($taxableIncome - $taxableWinnings) > 9325 && ($taxableIncome - $taxableWinnings) <= 37950 && $taxableIncome > 235350)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 208350 && $taxableIncome <= 235350) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9325 && $taxableIncome > 235350)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 235350)
) {$span = 7;}
return $span;
}
if ($filingStatus == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 13350) ||
(($taxableIncome - $taxableWinnings) > 13350 && $taxableIncome <= 50800) ||
(($taxableIncome - $taxableWinnings) > 50800 && $taxableIncome <= 131200) ||
(($taxableIncome - $taxableWinnings) > 131200 && $taxableIncome <= 212500) ||
(($taxableIncome - $taxableWinnings) > 212500 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome <= 444550) ||
($taxableIncome - $taxableWinnings) > 444550
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 13350) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13350 && $taxableIncome > 13350 && $taxableIncome <= 50800) ||
(($taxableIncome - $taxableWinnings) > 13350 && ($taxableIncome - $taxableWinnings) <= 50800 && $taxableIncome > 50800 && $taxableIncome <= 131200) ||
(($taxableIncome - $taxableWinnings) > 50800 && ($taxableIncome - $taxableWinnings) <= 131200 && $taxableIncome > 131200 && $taxableIncome <= 212500) ||
(($taxableIncome - $taxableWinnings) > 131200 && ($taxableIncome - $taxableWinnings) <= 212500 && $taxableIncome > 212500 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 212500 && ($taxableIncome - $taxableWinnings) <= 416700 && $taxableIncome > 416700 && $taxableIncome <= 444550) ||
(($taxableIncome - $taxableWinnings) > 416700 && ($taxableIncome - $taxableWinnings) <= 444550 && $taxableIncome > 444550)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 13350 && $taxableIncome <= 50800) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13350 && $taxableIncome > 50800 && $taxableIncome <= 131200) ||
(($taxableIncome - $taxableWinnings) > 13350 && ($taxableIncome - $taxableWinnings) <= 50800 && $taxableIncome > 91900 && $taxableIncome <= 212500) ||
(($taxableIncome - $taxableWinnings) > 50800 && ($taxableIncome - $taxableWinnings) <= 131200 && $taxableIncome > 212500 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 131200 && ($taxableIncome - $taxableWinnings) <= 212500 && $taxableIncome > 416700 && $taxableIncome <= 444550) ||
(($taxableIncome - $taxableWinnings) > 212500 && ($taxableIncome - $taxableWinnings) <= 416700 && $taxableIncome > 444550)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 50800 && $taxableIncome <= 131200) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13350 && $taxableIncome > 131200 && $taxableIncome <= 191650) ||
(($taxableIncome - $taxableWinnings) > 13350 && ($taxableIncome - $taxableWinnings) <= 50800 && $taxableIncome > 212500 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 50800 && ($taxableIncome - $taxableWinnings) <= 131200 && $taxableIncome > 416700 && $taxableIncome <= 444550) ||
(($taxableIncome - $taxableWinnings) > 131200 && ($taxableIncome - $taxableWinnings) <= 212500 && $taxableIncome > 444550)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 131200 && $taxableIncome <= 212500) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13350 && $taxableIncome > 212500 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 13350 && ($taxableIncome - $taxableWinnings) <= 50800 && $taxableIncome > 416700 && $taxableIncome <= 444550) ||
(($taxableIncome - $taxableWinnings) > 50800 && ($taxableIncome - $taxableWinnings) <= 131200 && $taxableIncome > 444550)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 212500 && $taxableIncome <= 416700) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13350 && $taxableIncome > 416700 && $taxableIncome <= 444550) ||
(($taxableIncome - $taxableWinnings) > 13350 && ($taxableIncome - $taxableWinnings) <= 50800 && $taxableIncome > 444550)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 416700 && $taxableIncome <= 444550) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13350 && $taxableIncome > 444550)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 444550)
) {$span = 7;}
return $span;
}
}
/*
******************************************************************************************
* *
* Function: Span Calculator for Deductions and Exemptions Phase-outs *
* *
* *
* 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 and exemption deductions are taken before the *
* computation of the tax on gambling winnings. So the reduction in itemized deductions *
* and exemption deductions are 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-outs. 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 2017. *
* *
* This function takes 4 independent variables, the last of which is labelled *
* 'variable'. The tax value of the exemption phase-out and itemized deduction *
* phase-out amounts is computed using the same functions as for the income tax of *
* gambling winnings. The tax values of both the exemption phase-out and itemized *
* deduction phase-out amounts are represented by this fourth independent variable. *
* The span value is needed for all three entities; the income tax on gambling winnings, *
* the itemized deduction phase-out, and the personal and dependent exemptions *
* phase-out. *
* *
******************************************************************************************
*/
function altspancalc($filingStatus, $taxableIncome, $taxableWinnings, $variable) {
$altTaxable = $taxableIncome - $taxableWinnings;
if ($filingStatus == 1) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 9325) ||
(($altTaxable - $variable) > 9325 && $altTaxable <= 37950) ||
(($altTaxable - $variable) > 37950 && $altTaxable <= 91900) ||
(($altTaxable - $variable) > 91900 && $altTaxable <= 191650) ||
(($altTaxable - $variable) > 191650 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 416700 && $altTaxable <= 418400) ||
($altTaxable - $variable) > 418400
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable <= 0) ||
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9325) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 9325 && $altTaxable <= 37950) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <= 37950 && $altTaxable > 37950 && $altTaxable <= 91900) ||
(($altTaxable - $variable) > 37950 && ($altTaxable - $variable) <= 91900 && $altTaxable > 91900 && $altTaxable <= 191650) ||
(($altTaxable - $variable) > 91900 && ($altTaxable - $variable) <= 191650 && $altTaxable > 191650 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 191650 && ($altTaxable - $variable) <= 416700 && $altTaxable > 416700 && $altTaxable <= 418400) ||
(($altTaxable - $variable) > 416700 && ($altTaxable - $variable) <= 418400 && $altTaxable > 418400)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 9325 && $altTaxable <= 37950) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 37950 && $altTaxable <= 91900) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <= 37950 && $altTaxable > 91900 && $altTaxable <= 191650) ||
(($altTaxable - $variable) > 37950 && ($altTaxable - $variable) <= 91900 && $altTaxable > 191650 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 91900 && ($altTaxable - $variable) <= 191650 && $altTaxable > 416700 && $altTaxable <= 418400) ||
(($altTaxable - $variable) > 191650 && ($altTaxable - $variable) <= 416700 && $altTaxable > 418400)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 37950 && $altTaxable <= 91900) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 91900 && $altTaxable <= 191650) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <= 37950 && $altTaxable > 191650 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 37950 && ($altTaxable - $variable) <= 91900 && $altTaxable > 416700 && $altTaxable <= 418400) ||
(($altTaxable - $variable) > 91900 && ($altTaxable - $variable) <= 191650 && $altTaxable > 418400)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 91900 && $altTaxable <= 191650) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 191650 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <= 37950 && $altTaxable > 416700 && $altTaxable <= 418400) ||
(($altTaxable - $variable) > 37950 && ($altTaxable - $variable) <= 91900 && $altTaxable > 418400)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 191650 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 416700 && $altTaxable <= 418400) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <= 37950 && $altTaxable > 418400)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 416700 && $altTaxable <= 418400) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 418400)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 418400)
) {$span = 7;}
return $span;
}
if ($filingStatus == 2 || $filingStatus == 5) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 18650) ||
(($altTaxable - $variable) > 18650 && $altTaxable <= 75900) ||
(($altTaxable - $variable) > 75900 && $altTaxable <= 153100) ||
(($altTaxable - $variable) > 153100 && $altTaxable <= 233350) ||
(($altTaxable - $variable) > 233350 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 416700 && $altTaxable <= 470700) ||
($altTaxable - $variable) > 470700
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable <= 0) ||
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 18650) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 18650 && $altTaxable > 18650 && $altTaxable <= 75900) ||
(($altTaxable - $variable) > 18650 && ($altTaxable - $variable) <= 75900 && $altTaxable > 75900 && $altTaxable <= 153100) ||
(($altTaxable - $variable) > 75900 && ($altTaxable - $variable) <= 153100 && $altTaxable > 153100 && $altTaxable <= 233350) ||
(($altTaxable - $variable) > 153100 && ($altTaxable - $variable) <= 233350 && $altTaxable > 233350 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 233350 && ($altTaxable - $variable) <= 416700 && $altTaxable > 416700 && $altTaxable <= 470700) ||
(($altTaxable - $variable) > 416700 && ($altTaxable - $variable) <= 470700 && $altTaxable > 470700)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 18650 && $altTaxable <= 75900) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 18650 && $altTaxable > 75900 && $altTaxable <= 153100) ||
(($altTaxable - $variable) > 18650 && ($altTaxable - $variable) <= 75900 && $altTaxable > 153100 && $altTaxable <= 233350) ||
(($altTaxable - $variable) > 75900 && ($altTaxable - $variable) <= 153100 && $altTaxable > 233350 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 153100 && ($altTaxable - $variable) <= 233350 && $altTaxable > 416700 && $altTaxable <= 470700) ||
(($altTaxable - $variable) > 233350 && ($altTaxable - $variable) <= 416700 && $altTaxable > 470700)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 75900 && $altTaxable <= 153100) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 18650 && $altTaxable > 153100 && $altTaxable <= 233350) ||
(($altTaxable - $variable) > 18650 && ($altTaxable - $variable) <= 75900 && $altTaxable > 233350 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 75900 && ($altTaxable - $variable) <= 153100 && $altTaxable > 416700 && $altTaxable <= 470700) ||
(($altTaxable - $variable) > 153100 && ($altTaxable - $variable) <= 233350 && $altTaxable > 470700)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 153100 && $altTaxable <= 233350) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 18650 && $altTaxable > 233350 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 18650 && ($altTaxable - $variable) <= 75900 && $altTaxable > 416700 && $altTaxable <= 470700) ||
(($altTaxable - $variable) > 75900 && ($altTaxable - $variable) <= 153100 && $altTaxable > 470700)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 233350 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 18650 && $altTaxable > 416700 && $altTaxable <= 470700) ||
(($altTaxable - $variable) > 18650 && ($altTaxable - $variable) <= 75900 && $altTaxable > 470700)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 416700 && $altTaxable <= 470700) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 18650 && $altTaxable > 470700)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 470700)
) {$span = 7;}
return $span;
}
if ($filingStatus == 3) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 9325) ||
(($altTaxable - $variable) > 9325 && $altTaxable <= 37950) ||
(($altTaxable - $variable) > 37950 && $altTaxable <= 76550) ||
(($altTaxable - $variable) > 76550 && $altTaxable <= 116675) ||
(($altTaxable - $variable) > 116675 && $altTaxable <= 208350) ||
(($altTaxable - $variable) > 208350 && $altTaxable <= 235350) ||
($altTaxable - $variable) > 235350
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable <= 0) ||
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9325) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 9325 && $altTaxable <= 37950) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <= 37950 && $altTaxable > 37950 && $altTaxable <= 76550) ||
(($altTaxable - $variable) > 37950 && ($altTaxable - $variable) <= 76550 && $altTaxable > 76550 && $altTaxable <= 116675) ||
(($altTaxable - $variable) > 76550 && ($altTaxable - $variable) <= 116675 && $altTaxable > 116675 && $altTaxable <= 208350) ||
(($altTaxable - $variable) > 116675 && ($altTaxable - $variable) <= 208350 && $altTaxable > 208350 && $altTaxable <= 235350) ||
(($altTaxable - $variable) > 208350 && ($altTaxable - $variable) <= 235350 && $altTaxable > 235350)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 9325 && $altTaxable <= 37950) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 37950 && $altTaxable <= 76550) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <= 37950 && $altTaxable > 76550 && $altTaxable <= 116675) ||
(($altTaxable - $variable) > 37950 && ($altTaxable - $variable) <= 76550 && $altTaxable > 116675 && $altTaxable <= 208350) ||
(($altTaxable - $variable) > 76550 && ($altTaxable - $variable) <= 116675 && $altTaxable > 208350 && $altTaxable <= 235350) ||
(($altTaxable - $variable) > 116675 && ($altTaxable - $variable) <= 208350 && $altTaxable > 235350)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 37950 && $altTaxable <= 76550) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 76550 && $altTaxable <= 116675) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <= 37950 && $altTaxable > 116675 && $altTaxable <= 208350) ||
(($altTaxable - $variable) > 37950 && ($altTaxable - $variable) <= 76550 && $altTaxable > 208350 && $altTaxable <= 235350) ||
(($altTaxable - $variable) > 76550 && ($altTaxable - $variable) <= 116675 && $altTaxable > 235350)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 76550 && $altTaxable <= 191650) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 116675 && $altTaxable <= 208350) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <= 37950 && $altTaxable > 208350 && $altTaxable <= 235350) ||
(($altTaxable - $variable) > 37950 && ($altTaxable - $variable) <= 76550 && $altTaxable > 235350)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 116675 && $altTaxable <= 208350) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 208350 && $altTaxable <= 235350) ||
(($altTaxable - $variable) > 9325 && ($altTaxable - $variable) <=37950 && $altTaxable > 235350)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 208350 && $altTaxable <= 235350) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9325 && $altTaxable > 235350)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 235350)
) {$span = 7;}
return $span;
}
if ($filingStatus == 4) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 13350) ||
(($altTaxable - $variable) > 13350 && $altTaxable <= 50800) ||
(($altTaxable - $variable) > 50800 && $altTaxable <= 131200) ||
(($altTaxable - $variable) > 131200 && $altTaxable <= 212500) ||
(($altTaxable - $variable) > 212500 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 416700 && $altTaxable <= 444550) ||
($altTaxable - $variable) > 444550
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable <= 0) ||
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 13350) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13350 && $altTaxable > 13350 && $altTaxable <= 50800) ||
(($altTaxable - $variable) > 13350 && ($altTaxable - $variable) <= 50800 && $altTaxable > 50800 && $altTaxable <= 131200) ||
(($altTaxable - $variable) > 50800 && ($altTaxable - $variable) <= 131200 && $altTaxable > 131200 && $altTaxable <= 212500) ||
(($altTaxable - $variable) > 131200 && ($altTaxable - $variable) <= 212500 && $altTaxable > 212500 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 212500 && ($altTaxable - $variable) <= 416700 && $altTaxable > 416700 && $altTaxable <= 444550) ||
(($altTaxable - $variable) > 416700 && ($altTaxable - $variable) <= 444550 && $altTaxable > 444550)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 13350 && $altTaxable <= 50800) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13350 && $altTaxable > 50800 && $altTaxable <= 131200) ||
(($altTaxable - $variable) > 13350 && ($altTaxable - $variable) <= 50800 && $altTaxable > 91900 && $altTaxable <= 212500) ||
(($altTaxable - $variable) > 50800 && ($altTaxable - $variable) <= 131200 && $altTaxable > 212500 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 131200 && ($altTaxable - $variable) <= 212500 && $altTaxable > 416700 && $altTaxable <= 444550) ||
(($altTaxable - $variable) > 212500 && ($altTaxable - $variable) <= 416700 && $altTaxable > 444550)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 50800 && $altTaxable <= 131200) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13350 && $altTaxable > 131200 && $altTaxable <= 191650) ||
(($altTaxable - $variable) > 13350 && ($altTaxable - $variable) <= 50800 && $altTaxable > 212500 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 50800 && ($altTaxable - $variable) <= 131200 && $altTaxable > 416700 && $altTaxable <= 444550) ||
(($altTaxable - $variable) > 131200 && ($altTaxable - $variable) <= 212500 && $altTaxable > 444550)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 131200 && $altTaxable <= 212500) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13350 && $altTaxable > 212500 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 13350 && ($altTaxable - $variable) <= 50800 && $altTaxable > 416700 && $altTaxable <= 444550) ||
(($altTaxable - $variable) > 50800 && ($altTaxable - $variable) <= 131200 && $altTaxable > 444550)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 212500 && $altTaxable <= 416700) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13350 && $altTaxable > 416700 && $altTaxable <= 444550) ||
(($altTaxable - $variable) > 13350 && ($altTaxable - $variable) <= 50800 && $altTaxable > 444550)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 416700 && $altTaxable <= 444550) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13350 && $altTaxable > 444550)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 444550)
) {$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 two phase-out amounts, (exemptions and 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 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 2017. *
* *
******************************************************************************************
*/
function taxcalc($span, $filingStatus, $taxableIncome, $taxableWinnings) {
if ($filingStatus == 1) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9325) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome <= 37950) {$tax = 0.15 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome <= 91900) {$tax = 0.25 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 91900 && $taxableIncome <= 191650) {$tax = 0.28 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 191650 && $taxableIncome <= 416700) {$tax = 0.33 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome <= 418400) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 418400) {$tax = 0.396 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9325)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9325 && $taxableIncome <= 37950)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 0.15 * ($taxableIncome - 9325);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 37950 && $taxableIncome <= 91900)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 0.25 * ($taxableIncome - 37950);}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome > 91900 && $taxableIncome <= 191650)
{$tax = 0.25 * (91900 - ($taxableIncome - $taxableWinnings)) + 0.28 * ($taxableIncome - 91900);}
elseif (($taxableIncome - $taxableWinnings) > 91900 && $taxableIncome > 191650 && $taxableIncome <= 416700)
{$tax = 0.28 * (191650 - ($taxableIncome - $taxableWinnings)) + 0.33 * ($taxableIncome - 191650);}
elseif (($taxableIncome - $taxableWinnings) > 191650 && $taxableIncome > 416700 && $taxableIncome <= 418400)
{$tax = 0.33 * (416700 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome > 418400)
{$tax = 0.35 * (418400 - ($taxableIncome - $taxableWinnings)) + 0.396 * ($taxableIncome - 418400);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9325 && $taxableIncome <= 37950)
{$tax = 932.5 + 0.15 * ($taxableIncome - 9325);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9325 && $taxableIncome <= 91900)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 0.25 * ($taxableIncome - 37950);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 91900 && $taxableIncome <= 191650)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 13487.5 + 0.28 * ($taxableIncome - 91900);}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome > 191650 && $taxableIncome <= 416700)
{$tax = 0.25 * (91900 - ($taxableIncome - $taxableWinnings)) + 27930 + 0.33 * ($taxableIncome - 191650);}
elseif (($taxableIncome - $taxableWinnings) > 91900 && $taxableIncome > 416700 && $taxableIncome <= 418400)
{$tax = 0.28 * (191650 - ($taxableIncome - $taxableWinnings)) + 74266.5 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 191650 && $taxableIncome > 418400)
{$tax = 0.33 * (416700 - ($taxableIncome - $taxableWinnings)) + 595 + 0.396 * ($taxableIncome - 418400);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 37950 && $taxableIncome <= 91900)
{$tax = 932.5 + 4293.75 + 0.25 * ($taxableIncome - 37950);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 91900 && $taxableIncome <= 191650)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 13487.5 + 0.28 * ($taxableIncome - 91900);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 191650 && $taxableIncome <= 416700)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 13487.5 + 27930 + 0.33 * ($taxableIncome - 191650);}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome > 416700 && $taxableIncome <= 418400)
{$tax = 0.25 * (91900 - ($taxableIncome - $taxableWinnings)) + 27930 + 74266.5 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 91900 && $taxableIncome > 418400)
{$tax = 0.28 * (191650 - ($taxableIncome - $taxableWinnings)) + 74266.5 + 595 + 0.396 * ($taxableIncome - 418400);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 91900 && $taxableIncome <= 191650)
{$tax = 932.5 + 4293.75 + 13487.5 + 0.28 * ($taxableIncome - 91900);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 191650 && $taxableIncome <= 416700)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 13487.5 + 27930 + 0.33 * ($taxableIncome - 191650);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 416700 && $taxableIncome <= 418400)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 13487.5 + 27930 + 74266.5 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome > 418400)
{$tax = 0.25 * (91900 - ($taxableIncome - $taxableWinnings)) + 27930 + 74266.5 + 595 + 0.396 * ($taxableIncome - 418400);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 191650 && $taxableIncome <= 416700)
{$tax = 932.5 + 4293.75 + 13487.5 + 27930 + 0.33 * ($taxableIncome - 191650);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 416700 && $taxableIncome <= 418400)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 13487.5 + 27930 + 74266.5 + 0.33 * ($taxableIncome - 191650);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 418400)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 13487.5 + 27930 + 74266.5 + 595 + 0.396 * ($taxableIncome - 418400);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 416700 && $taxableIncome <= 418400)
{$tax = 932.5 + 4293.75 + 13487.5 + 27930 + 74266.5 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 418400)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 13487.5 + 27930 + 74266.5 + 595 + 0.396 * ($taxableIncome - 418400);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 418400)
{$tax = 932.5 + 4293.75 + 13487.5 + 27930 + 74266.5 + 595 + 0.396 * ($taxableIncome - 418400);}
return $tax;
}
}
if ($filingStatus == 2 || $filingStatus == 5) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 18650) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 18650 && $taxableIncome <= 75900) {$tax = 0.15 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 75900 && $taxableIncome <= 153100) {$tax = 0.25 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 153100 && $taxableIncome <= 233350) {$tax = 0.28 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 233350 && $taxableIncome <= 416700) {$tax = 0.33 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome <= 470700) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 470700) {$tax = 0.396 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 18650)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 18650 && $taxableIncome <= 75900)
{$tax = 0.10 * (18650 - ($taxableIncome - $taxableWinnings)) + 0.15 * ($taxableIncome - 18650);}
elseif (($taxableIncome - $taxableWinnings) > 18650 && $taxableIncome > 75900 && $taxableIncome <= 153100)
{$tax = 0.15 * (75900 - ($taxableIncome - $taxableWinnings)) + 0.25 * ($taxableIncome - 75900);}
elseif (($taxableIncome - $taxableWinnings) > 75900 && $taxableIncome > 153100 && $taxableIncome <= 191650)
{$tax = 0.25 * (153100 - ($taxableIncome - $taxableWinnings)) + 0.28 * ($taxableIncome - 153100);}
elseif (($taxableIncome - $taxableWinnings) > 153100 && $taxableIncome > 233350 && $taxableIncome <= 416700)
{$tax = 0.28 * (233350 - ($taxableIncome - $taxableWinnings)) + 0.33 * ($taxableIncome - 233350);}
elseif (($taxableIncome - $taxableWinnings) > 233350 && $taxableIncome > 416700 && $taxableIncome <= 470700)
{$tax = 0.33 * (416700 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome > 470700)
{$tax = 0.35 * (470700 - ($taxableIncome - $taxableWinnings)) + 0.396 * ($taxableIncome - 470700);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 18650 && $taxableIncome <= 75900)
{$tax = 1865 + 0.15 * ($taxableIncome - 18650);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 18650 && $taxableIncome <= 153100)
{$tax = 0.10 * (18650 - ($taxableIncome - $taxableWinnings)) + 8587.5 + 0.25 * ($taxableIncome - 75900);}
elseif (($taxableIncome - $taxableWinnings) > 18650 && $taxableIncome > 153100 && $taxableIncome <= 233350)
{$tax = 0.15 * (75900 - ($taxableIncome - $taxableWinnings)) + 19300 + 0.28 * ($taxableIncome - 153100);}
elseif (($taxableIncome - $taxableWinnings) > 75900 && $taxableIncome > 233350 && $taxableIncome <= 416700)
{$tax = 0.25 * (153100 - ($taxableIncome - $taxableWinnings)) + 22470 + 0.33 * ($taxableIncome - 233350);}
elseif (($taxableIncome - $taxableWinnings) > 153100 && $taxableIncome > 416700 && $taxableIncome <= 470700)
{$tax = 0.28 * (233350 - ($taxableIncome - $taxableWinnings)) + 60505.5 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 233350 && $taxableIncome > 470700)
{$tax = 0.33 * (416700 - ($taxableIncome - $taxableWinnings)) + 18900 + 0.396 * ($taxableIncome - 470700);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 75900 && $taxableIncome <= 153100)
{$tax = 1865 + 8587.5 + 0.25 * ($taxableIncome - 75900);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 153100 && $taxableIncome <= 233350)
{$tax = 0.10 * (18650 - ($taxableIncome - $taxableWinnings)) + 8587.5 + 19300 + 0.28 * ($taxableIncome - 153100);}
elseif (($taxableIncome - $taxableWinnings) > 18650 && $taxableIncome > 233350 && $taxableIncome <= 416700)
{$tax = 0.15 * (75900 - ($taxableIncome - $taxableWinnings)) + 19300 + 22470 + 0.33 * ($taxableIncome - 233350);}
elseif (($taxableIncome - $taxableWinnings) > 75900 && $taxableIncome > 416700 && $taxableIncome <= 470700)
$tax = 0.25 * (153100 - ($taxableIncome - $taxableWinnings)) + 22470 + 60505.5 + 0.35 * ($taxableIncome - 416700);
elseif (($taxableIncome - $taxableWinnings) > 153100 && $taxableIncome > 470700)
{$tax = 0.28 * (233350 - ($taxableIncome - $taxableWinnings)) + 60505.5 + 18900 + 0.396 * ($taxableIncome - 470700);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 153100 && $taxableIncome <= 233350)
{$tax = 1865 + 8587.5 + 19300 + 0.28 * ($taxableIncome - 153100);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 233350 && $taxableIncome <= 416700)
{$tax = 0.10 * (18650 - ($taxableIncome - $taxableWinnings)) + 8587.5 + 19300 + 22470 + 0.33 * ($taxableIncome - 233350);}
elseif (($taxableIncome - $taxableWinnings) > 18650 && $taxableIncome > 416700 && $taxableIncome <= 470700)
{$tax = 0.15 * (75900 - ($taxableIncome - $taxableWinnings)) + 19300 + 22470 + 60505.5 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 75900 && $taxableIncome > 470700)
{$tax = 0.25 * (153100 - ($taxableIncome - $taxableWinnings)) + 22470 + 60505.5 + 18900 + 0.396 * ($taxableIncome - 470700);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 233350 && $taxableIncome <= 416700)
{$tax = 1865 + 8587.5 + 19300 + 22470 + 0.33 * ($taxableIncome - 233350);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 416700 && $taxableIncome <= 470700)
{$tax = 0.10 * (18650 - ($taxableIncome - $taxableWinnings)) + 8587.5 + 19300 + 22470 + 60505.5 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 18650 && $taxableIncome > 470700)
{$tax = 0.15 * (75900 - ($taxableIncome - $taxableWinnings)) + 19300 + 22470 + 60505.5 + 18900 + 0.396 * ($taxableIncome - 470700);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 416700 && $taxableIncome <= 470700)
{$tax = 1865 + 8587.5 + 19300 + 22470 + 60505.5 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 470700)
{$tax = 0.10 * (18650 - ($taxableIncome - $taxableWinnings)) + 8587.5 + 19300 + 22470 + 60505.5 + 18900 + 0.396 * ($taxableIncome - 470700);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 470700)
{$tax = 1865 + 8587.5 + 19300 + 22470 + 60505.5 + 18900 + 0.396 * ($taxableIncome - 470700);}
return $tax;
}
}
if ($filingStatus == 3) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9325) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome <= 37950) {$tax = 0.15 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome <= 76550) {$tax = 0.25 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 76550 && $taxableIncome <= 116675) {$tax = 0.28 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 116675 && $taxableIncome <= 208350) {$tax = 0.33 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 208350 && $taxableIncome <= 235350) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 235350) {$tax = 0.396 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9325)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9325 && $taxableIncome <= 37950)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 0.15 * ($taxableIncome - 9325);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 37950 && $taxableIncome <= 76550)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 0.25 * ($taxableIncome - 37950);}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome > 76550 && $taxableIncome <= 116675)
{$tax = 0.25 * (76550 - ($taxableIncome - $taxableWinnings)) + 0.28 * ($taxableIncome - 76550);}
elseif (($taxableIncome - $taxableWinnings) > 76550 && $taxableIncome > 116675 && $taxableIncome <= 208350)
{$tax = 0.28 * (116675 - ($taxableIncome - $taxableWinnings)) + 0.33 * ($taxableIncome - 116675);}
elseif (($taxableIncome - $taxableWinnings) > 116675 && $taxableIncome > 208350 && $taxableIncome <= 235350)
{$tax = 0.33 * (208350 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 208350);}
elseif (($taxableIncome - $taxableWinnings) > 208350 && $taxableIncome > 235350)
{$tax = 0.35 * (235350 - ($taxableIncome - $taxableWinnings)) + 0.396 * ($taxableIncome - 235350);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9325 && $taxableIncome <= 37950)
{$tax = 932.5 + 0.15 * ($taxableIncome - 9325);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 37950 && $taxableIncome <= 76550)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 0.25 * ($taxableIncome - 37950);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 76550 && $taxableIncome <= 116675)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 9650 + 0.28 * ($taxableIncome - 76550);}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome > 116675 && $taxableIncome <= 208350)
{$tax = 0.25 * (76550 - ($taxableIncome - $taxableWinnings)) + 11235 + 0.33 * ($taxableIncome - 116675);}
elseif (($taxableIncome - $taxableWinnings) > 76550 && $taxableIncome > 208350 && $taxableIncome <= 235350)
{$tax = 0.28 * (116675 - ($taxableIncome - $taxableWinnings)) + 30252.75 + 0.35 * ($taxableIncome - 208350);}
elseif (($taxableIncome - $taxableWinnings) > 116675 && $taxableIncome > 235350)
{$tax = 0.33 * (208350 - ($taxableIncome - $taxableWinnings)) + 9450 + 0.396 * ($taxableIncome - 235350);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 37950 && $taxableIncome <= 76550)
{$tax = 932.5 + 4293.75 + 0.25 * ($taxableIncome - 37950);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 76550 && $taxableIncome <= 116675)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 9650 + 0.28 * ($taxableIncome - 76550);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 116675 && $taxableIncome <= 208350)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 9650 + 11235 + 0.33 * ($taxableIncome - 116675);}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome > 208350 && $taxableIncome <= 235350)
{$tax = 0.25 * (76550 - ($taxableIncome - $taxableWinnings)) + 11235 + 30252.75 + 0.35 * ($taxableIncome - 208350);}
elseif (($taxableIncome - $taxableWinnings) > 76550 && $taxableIncome > 235350)
{$tax = 0.28 * (116675 - ($taxableIncome - $taxableWinnings)) + 30252.75 + 9380 + 0.396 * ($taxableIncome - 235350);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 76550 && $taxableIncome <= 116675)
{$tax = 932.5 + 4293.75 + 9650 + 0.28 * ($taxableIncome - 76550);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 116675 && $taxableIncome <206675)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 9650 + 11235 + 0.33 * ($taxableIncome - 116675);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 208350 && $taxableIncome <= 235350)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 9650 + 11235 + 30252.75 + 0.35 * ($taxableIncome - 208350);}
elseif (($taxableIncome - $taxableWinnings) > 37950 && $taxableIncome > 235350)
{$tax = 0.25 * (76550 - ($taxableIncome - $taxableWinnings)) + 11235 + 30252.75 + 9450 + 0.396 * ($taxableIncome - 235350);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 116675 && $taxableIncome <= 208350)
{$tax = 932.5 + 4293.75 + 9650 + 11235 + 0.33 * ($taxableIncome - 116675);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 208350 && $taxableIncome <= 235350)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 9650 + 11235 + 30252.75 + 0.35 * ($taxableIncome - 208350);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 235350)
{$tax = 0.15 * (37950 - ($taxableIncome - $taxableWinnings)) + 9650 + 11235 + 30252.75 + 9450 + 0.396 * ($taxableIncome - 235350);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 208350 && $taxableIncome <= 235350)
{$tax = 932.5 + 4293.75 + 9650 + 11235 + 30252.75 + 0.35 * ($taxableIncome - 208350);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 235350)
{$tax = 0.10 * (9325 - ($taxableIncome - $taxableWinnings)) + 4293.75 + 9650 + 11235 + 30252.75 + 9450 + 0.396 * ($taxableIncome - 235350);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 235350)
{$tax = 932.5 + 4293.75 + 9650 + 11235 + 30252.75 + 9450 + 0.396 * ($taxableIncome - 235350);}
return $tax;
}
}
if ($filingStatus == 4) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 13350) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 13350 && $taxableIncome <= 50800) {$tax = 0.15 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 50800 && $taxableIncome <= 131200) {$tax = 0.25 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 131200 && $taxableIncome <= 212500) {$tax = 0.28 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 212500 && $taxableIncome <= 416700) {$tax = 0.33 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome <= 444550) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 444550) {$tax = 0.396 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 13350)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 13350 && $taxableIncome <= 50800)
{$tax = 0.10 * (13350 - ($taxableIncome - $taxableWinnings)) + 0.15 * ($taxableIncome - 13350);}
elseif (($taxableIncome - $taxableWinnings) > 13350 && $taxableIncome > 50800 && $taxableIncome <= 131200)
{$tax = 0.15 * (50800 - ($taxableIncome - $taxableWinnings)) + 0.25 * ($taxableIncome - 50800);}
elseif (($taxableIncome - $taxableWinnings) > 50800 && $taxableIncome > 131200 && $taxableIncome <= 212500)
{$tax = 0.25 * (131200 - ($taxableIncome - $taxableWinnings)) + 0.28 * ($taxableIncome - 131200);}
elseif (($taxableIncome - $taxableWinnings) > 131200 && $taxableIncome > 212500 && $taxableIncome <= 416700)
{$tax = 0.28 * (212500 - ($taxableIncome - $taxableWinnings)) + 0.33 * ($taxableIncome - 212500);}
elseif (($taxableIncome - $taxableWinnings) > 212500 && $taxableIncome > 416700 && $taxableIncome <= 444550)
{$tax = 0.33 * (416700 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome > 444550)
{$tax = 0.35 * (444550 - ($taxableIncome - $taxableWinnings)) + 0.396 * ($taxableIncome - 444550);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 13350 && $taxableIncome <= 50800)
{$tax = 1335 + 0.15 * ($taxableIncome - 13350);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 50800 && $taxableIncome <= 131200)
{$tax = 0.10 * (13350 - ($taxableIncome - $taxableWinnings)) + 5617.50 + 0.25 * ($taxableIncome - 50800);}
elseif (($taxableIncome - $taxableWinnings) > 13350 && $taxableIncome > 131200 && $taxableIncome <= 212500)
{$tax = 0.15 * (50800 - ($taxableIncome - $taxableWinnings)) + 20100 + 0.28 * ($taxableIncome - 131200);}
elseif (($taxableIncome - $taxableWinnings) > 50800 && $taxableIncome > 212500 && $taxableIncome <= 416700)
{$tax = 0.25 * (131200 - ($taxableIncome - $taxableWinnings)) + 22764 + 0.33 * ($taxableIncome - 212500);}
elseif (($taxableIncome - $taxableWinnings) > 131200 && $taxableIncome > 416700 && $taxableIncome <= 444550)
{$tax = 0.28 * (212500 - ($taxableIncome - $taxableWinnings)) + 67386 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 416700 && $taxableIncome > 444550)
{$tax = 0.33 * (416700 - ($taxableIncome - $taxableWinnings)) + 9747.5 + 0.396 * ($taxableIncome - 444550);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 50800 && $taxableIncome <= 131200)
{$tax = 1335 + 5617.50 + 0.25 * ($taxableIncome - 50800);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 131200 && $taxableIncome <= 212500)
{$tax = 0.10 * (13350 - ($taxableIncome - $taxableWinnings)) + 5617.50 + 20100 + 0.28 * ($taxableIncome - 131200);}
elseif (($taxableIncome - $taxableWinnings) > 9325 && $taxableIncome > 212500 && $taxableIncome <= 416700)
{$tax = 0.15 * (50800 - ($taxableIncome - $taxableWinnings)) + 20100 + 22764 + 0.33 * ($taxableIncome - 212500);}
elseif (($taxableIncome - $taxableWinnings) > 50800 && $taxableIncome > 416700 && $taxableIncome <= 444550)
{$tax = 0.25 * (131200 - ($taxableIncome - $taxableWinnings)) + 22764 + 67386 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 131200 && $taxableIncome > 444550)
{$tax = 0.28 * (212500 - ($taxableIncome - $taxableWinnings)) + 67386 + 9747.5 + 0.396 * ($taxableIncome - 444550);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 131200 && $taxableIncome <= 212500)
{$tax = 1335 + 5617.50 + 20100 + 0.28 * ($taxableIncome - 131200);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 212500 && $taxableIncome <= 416700)
{$tax = 0.10 * (13350 - ($taxableIncome - $taxableWinnings)) + 5617.50 + 20100 + 22764 + 0.33 * ($taxableIncome - 212500);}
elseif (($taxableIncome - $taxableWinnings) > 13350 && $taxableIncome > 416700 && $taxableIncome <= 444550)
{$tax = 0.15 * (50800 - ($taxableIncome - $taxableWinnings)) + 20100 + 22764 + 67386 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 50800 && $taxableIncome > 444550)
{$tax = 0.25 * (131200 - ($taxableIncome - $taxableWinnings)) + 22764 + 67386 + 9747.5 + 0.396 * ($taxableIncome - 444550);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 212500 && $taxableIncome <= 416700)
{$tax = 1335 + 5617.50 + 20100 + 22764 + 0.33 * ($taxableIncome - 212500);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 416700 && $taxableIncome <= 444550)
{$tax = 0.10 * (13350 - ($taxableIncome - $taxableWinnings)) + 5617.50 + 20100 + 22764 + 67386 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 13350 && $taxableIncome > 444550)
{$tax = 0.15 * (50800 - ($taxableIncome - $taxableWinnings)) + 20100 + 22764 + 67386 + 9747.5 + 0.396 * ($taxableIncome - 444550);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 416700 && $taxableIncome <= 444550)
{$tax = 1335 + 5617.50 + 20100 + 22764 + 67386 + 0.35 * ($taxableIncome - 416700);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 444550)
{$tax = 0.10 * (13350 - ($taxableIncome - $taxableWinnings)) + 5617.50 + 20100 + 22764 + 67386 + 9747.5 + 0.396 * ($taxableIncome - 444550);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 444550)
{$tax = 1335 + 5617.50 + 20100 + 22764 + 67386 + 9747.5 + 0.396 * ($taxableIncome - 444550);}
return $tax;
}
}
}
/*
******************************************************************************************
* *
* Function: Income Tax Calculator for Deductions and Exemptions Phase-outs *
* *
* *
* 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-outs. *
* *
* 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 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 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 2017. *
* *
* 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 <= 9325) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 9325 && $altTaxable <= 37950) {$tax = 0.15 * $variable;}
elseif (($altTaxable - $variable) > 37950 && $altTaxable <= 91900) {$tax = 0.25 * $variable;}
elseif (($altTaxable - $variable) > 91900 && $altTaxable <= 191650) {$tax = 0.28 * $variable;}
elseif (($altTaxable - $variable) > 191650 && $altTaxable <= 416700) {$tax = 0.33 * $variable;}
elseif (($altTaxable - $variable) > 416700 && $altTaxable <= 418400) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 418400) {$tax = 0.396 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable < 0)
{$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9325)
{$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9325 && $altTaxable <= 37950)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 0.15 * ($altTaxable - 9325);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 37950 && $altTaxable <= 91900)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 0.25 * ($altTaxable - 37950);}
elseif (($altTaxable - $variable) > 37950 && $altTaxable > 91900 && $altTaxable <= 191650)
{$tax = 0.25 * (91900 - ($altTaxable - $variable)) + 0.28 * ($altTaxable - 91900);}
elseif (($altTaxable - $variable) > 91900 && $altTaxable > 191650 && $altTaxable <= 416700)
{$tax = 0.28 * (191650 - ($altTaxable - $variable)) + 0.33 * ($altTaxable - 191650);}
elseif (($altTaxable - $variable) > 191650 && $altTaxable > 416700 && $altTaxable <= 418400)
{$tax = 0.33 * (416700 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 416700 && $altTaxable > 418400)
{$tax = 0.35 * (418400 - ($altTaxable - $variable)) + 0.396 * ($altTaxable - 418400);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 9325 && $altTaxable <= 37950)
{$tax = 932.5 + 0.15 * ($altTaxable - 9325);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9325 && $altTaxable <= 91900)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 0.25 * ($altTaxable - 37950);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 91900 && $altTaxable <= 191650)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 13487.5 + 0.28 * ($altTaxable - 91900);}
elseif (($altTaxable - $variable) > 37950 && $altTaxable > 191650 && $altTaxable <= 416700)
{$tax = 0.25 * (91900 - ($altTaxable - $variable)) + 27930 + 0.33 * ($altTaxable - 191650);}
elseif (($altTaxable - $variable) > 91900 && $altTaxable > 416700 && $altTaxable <= 418400)
{$tax = 0.28 * (191650 - ($altTaxable - $variable)) + 74266.5 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 191650 && $altTaxable > 418400)
{$tax = 0.33 * (416700 - ($altTaxable - $variable)) + 595 + 0.396 * ($altTaxable - 418400);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 37950 && $altTaxable <= 91900)
{$tax = 932.5 + 4293.75 + 0.25 * ($altTaxable - 37950);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 91900 && $altTaxable <= 191650)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 13487.5 + 0.28 * ($altTaxable - 91900);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 191650 && $altTaxable <= 416700)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 13487.5 + 27930 + 0.33 * ($altTaxable - 191650);}
elseif (($altTaxable - $variable) > 37950 && $altTaxable > 416700 && $altTaxable <= 418400)
{$tax = 0.25 * (91900 - ($altTaxable - $variable)) + 27930 + 74266.5 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 91900 && $altTaxable > 418400)
{$tax = 0.28 * (191650 - ($altTaxable - $variable)) + 74266.5 + 595 + 0.396 * ($altTaxable - 418400);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 91900 && $altTaxable <= 191650)
{$tax = 932.5 + 4293.75 + 13487.5 + 0.28 * ($altTaxable - 91900);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 191650 && $altTaxable <= 416700)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 13487.5 + 27930 + 0.33 * ($altTaxable - 191650);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 416700 && $altTaxable <= 418400)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 13487.5 + 27930 + 74266.5 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 37950 && $altTaxable > 418400)
{$tax = 0.25 * (91900 - ($altTaxable - $variable)) + 27930 + 74266.5 + 595 + 0.396 * ($altTaxable - 418400);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 191650 && $altTaxable <= 416700)
{$tax = 932.5 + 4293.75 + 13487.5 + 27930 + 0.33 * ($altTaxable - 191650);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 416700 && $altTaxable <= 418400)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 13487.5 + 27930 + 74266.5 + 0.33 * ($altTaxable - 191650);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 418400)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 13487.5 + 27930 + 74266.5 + 595 + 0.396 * ($altTaxable - 418400);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 416700 && $altTaxable <= 418400)
{$tax = 932.5 + 4293.75 + 13487.5 + 27930 + 74266.5 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $taxableWinnings - $variable) > 0 && $altTaxable > 418400)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 13487.5 + 27930 + 74266.5 + 595 + 0.396 * ($altTaxable - 418400);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 418400)
{$tax = 932.5 + 4293.75 + 13487.5 + 27930 + 74266.5 + 595 + 0.396 * ($altTaxable - 418400);}
return $tax;
}
}
if ($filingStatus == 2 || $filingStatus == 5) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 18650) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 18650 && $altTaxable <= 75900) {$tax = 0.15 * $variable;}
elseif (($altTaxable - $variable) > 75900 && $altTaxable <= 153100) {$tax = 0.25 * $variable;}
elseif (($altTaxable - $variable) > 153100 && $altTaxable <= 233350) {$tax = 0.28 * $variable;}
elseif (($altTaxable - $variable) > 233350 && $altTaxable <= 416700) {$tax = 0.33 * $variable;}
elseif (($altTaxable - $variable) > 416700 && $altTaxable <= 470700) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 470700) {$tax = 0.396 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable < 0)
{$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 18650)
{$tax = 0.10 * $altTaxable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 18650 && $altTaxable <= 75900)
{$tax = 0.10 * (18650 - ($altTaxable - $variable)) + 0.15 * ($altTaxable - 18650);}
elseif (($altTaxable - $variable) > 18650 && $altTaxable > 75900 && $altTaxable <= 153100)
{$tax = 0.15 * (75900 - ($altTaxable - $variable)) + 0.25 * ($altTaxable - 75900);}
elseif (($altTaxable - $variable) > 75900 && $altTaxable > 153100 && $altTaxable <= 191650)
{$tax = 0.25 * (153100 - ($altTaxable - $variable)) + 0.28 * ($altTaxable - 153100);}
elseif (($altTaxable - $variable) > 153100 && $altTaxable > 233350 && $altTaxable <= 416700)
{$tax = 0.28 * (233350 - ($altTaxable - $variable)) + 0.33 * ($altTaxable - 233350);}
elseif (($altTaxable - $variable) > 233350 && $altTaxable > 416700 && $altTaxable <= 470700)
{$tax = 0.33 * (416700 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 416700 && $altTaxable > 470700)
{$tax = 0.35 * (470700 - ($altTaxable - $variable)) + 0.396 * ($altTaxable - 470700);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 18650 && $altTaxable <= 75900)
{$tax = 1865 + 0.15 * ($altTaxable - 18650);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 18650 && $altTaxable <= 153100)
{$tax = 0.10 * (18650 - ($altTaxable - $variable)) + 8587.5 + 0.25 * ($altTaxable - 75900);}
elseif (($altTaxable - $variable) > 18650 && $altTaxable > 153100 && $altTaxable <= 233350)
{$tax = 0.15 * (75900 - ($altTaxable - $variable)) + 19300 + 0.28 * ($altTaxable - 153100);}
elseif (($altTaxable - $variable) > 75900 && $altTaxable > 233350 && $altTaxable <= 416700)
{$tax = 0.25 * (153100 - ($altTaxable - $variable)) + 22470 + 0.33 * ($altTaxable - 233350);}
elseif (($altTaxable - $variable) > 153100 && $altTaxable > 416700 && $altTaxable <= 470700)
{$tax = 0.28 * (233350 - ($altTaxable - $variable)) + 60505.5 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 233350 && $altTaxable > 470700)
{$tax = 0.33 * (416700 - ($altTaxable - $variable)) + 18900 + 0.396 * ($altTaxable - 470700);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 75900 && $altTaxable <= 153100)
{$tax = 1865 + 8587.5 + 0.25 * ($altTaxable - 75900);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 153100 && $altTaxable <= 233350)
{$tax = 0.10 * (18650 - ($altTaxable - $variable)) + 8587.5 + 19300 + 0.28 * ($altTaxable - 153100);}
elseif (($altTaxable - $variable) > 18650 && $altTaxable > 233350 && $altTaxable <= 416700)
{$tax = 0.15 * (75900 - ($altTaxable - $variable)) + 19300 + 22470 + 0.33 * ($altTaxable - 233350);}
elseif (($altTaxable - $variable) > 75900 && $altTaxable > 416700 && $altTaxable <= 470700)
$tax = 0.25 * (153100 - ($altTaxable - $variable)) + 22470 + 60505.5 + 0.35 * ($altTaxable - 416700);
elseif (($altTaxable - $variable) > 153100 && $altTaxable > 470700)
{$tax = 0.28 * (233350 - ($altTaxable - $variable)) + 60505.5 + 18900 + 0.396 * ($altTaxable - 470700);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 153100 && $altTaxable <= 233350)
{$tax = 1865 + 8587.5 + 19300 + 0.28 * ($altTaxable - 153100);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 233350 && $altTaxable <= 416700)
{$tax = 0.10 * (18650 - ($altTaxable - $variable)) + 8587.5 + 19300 + 22470 + 0.33 * ($altTaxable - 233350);}
elseif (($altTaxable - $variable) > 18650 && $altTaxable > 416700 && $altTaxable <= 470700)
{$tax = 0.15 * (75900 - ($altTaxable - $variable)) + 19300 + 22470 + 60505.5 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 75900 && $altTaxable > 470700)
{$tax = 0.25 * (153100 - ($altTaxable - $variable)) + 22470 + 60505.5 + 18900 + 0.396 * ($altTaxable - 470700);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 233350 && $altTaxable <= 416700)
{$tax = 1865 + 8587.5 + 19300 + 22470 + 0.33 * ($altTaxable - 233350);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 416700 && $altTaxable <= 470700)
{$tax = 0.10 * (18650 - ($altTaxable - $variable)) + 8587.5 + 19300 + 22470 + 60505.5 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 18650 && $altTaxable > 470700)
{$tax = 0.15 * (75900 - ($altTaxable - $variable)) + 19300 + 22470 + 60505.5 + 18900 + 0.396 * ($altTaxable - 470700);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 416700 && $altTaxable <= 470700)
{$tax = 1865 + 8587.5 + 19300 + 22470 + 60505.5 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 470700)
{$tax = 0.10 * (18650 - ($altTaxable - $variable)) + 8587.5 + 19300 + 22470 + 60505.5 + 18900 + 0.396 * ($altTaxable - 470700);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 470700)
{$tax = 1865 + 8587.5 + 19300 + 22470 + 60505.5 + 18900 + 0.396 * ($altTaxable - 470700);}
return $tax;
}
}
if ($filingStatus == 3) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 9325) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 9325 && $altTaxable <= 37950) {$tax = 0.15 * $variable;}
elseif (($altTaxable - $variable) > 37950 && $altTaxable <= 76550) {$tax = 0.25 * $variable;}
elseif (($altTaxable - $variable) > 76550 && $altTaxable <= 116675) {$tax = 0.28 * $variable;}
elseif (($altTaxable - $variable) > 116675 && $altTaxable <= 208350) {$tax = 0.33 * $variable;}
elseif (($altTaxable - $variable) > 208350 && $altTaxable <= 235350) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 235350) {$tax = 0.396 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable < 0)
{$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9325)
{$tax = 0.10 * $taxableIncome;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9325 && $altTaxable <= 37950)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 0.15 * ($altTaxable - 9325);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 37950 && $altTaxable <= 76550)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 0.25 * ($altTaxable - 37950);}
elseif (($altTaxable - $variable) > 37950 && $altTaxable > 76550 && $altTaxable <= 116675)
{$tax = 0.25 * (76550 - ($altTaxable - $variable)) + 0.28 * ($altTaxable - 76550);}
elseif (($altTaxable - $variable) > 76550 && $altTaxable > 116675 && $altTaxable <= 208350)
{$tax = 0.28 * (116675 - ($altTaxable - $variable)) + 0.33 * ($altTaxable - 116675);}
elseif (($altTaxable - $variable) > 116675 && $altTaxable > 208350 && $altTaxable <= 235350)
{$tax = 0.33 * (208350 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 208350);}
elseif (($altTaxable - $variable) > 208350 && $altTaxable > 235350)
{$tax = 0.35 * (235350 - ($altTaxable - $variable)) + 0.396 * ($altTaxable - 235350);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 9325 && $altTaxable <= 37950)
{$tax = 932.5 + 0.15 * ($altTaxable - 9325);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 37950 && $altTaxable <= 76550)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 0.25 * ($altTaxable - 37950);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 76550 && $altTaxable <= 116675)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 9650 + 0.28 * ($altTaxable - 76550);}
elseif (($altTaxable - $variable) > 37950 && $altTaxable > 116675 && $altTaxable <= 208350)
{$tax = 0.25 * (76550 - ($altTaxable - $variable)) + 11235 + 0.33 * ($altTaxable - 116675);}
elseif (($altTaxable - $variable) > 76550 && $altTaxable > 208350 && $altTaxable <= 235350)
{$tax = 0.28 * (116675 - ($altTaxable - $variable)) + 30252.75 + 0.35 * ($altTaxable - 208350);}
elseif (($altTaxable - $variable) > 116675 && $altTaxable > 235350)
{$tax = 0.33 * (208350 - ($altTaxable - $variable)) + 9450 + 0.396 * ($altTaxable - 235350);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 37950 && $altTaxable <= 76550)
{$tax = 932.5 + 4293.75 + 0.25 * ($altTaxable - 37950);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 76550 && $altTaxable <= 116675)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 9650 + 0.28 * ($altTaxable - 76550);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 116675 && $altTaxable <= 208350)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 9650 + 11235 + 0.33 * ($altTaxable - 116675);}
elseif (($altTaxable - $variable) > 37950 && $altTaxable > 208350 && $altTaxable <= 235350)
{$tax = 0.25 * (76550 - ($altTaxable - $variable)) + 11235 + 30252.75 + 0.35 * ($altTaxable - 208350);}
elseif (($altTaxable - $variable) > 76550 && $altTaxable > 235350)
{$tax = 0.28 * (116675 - ($altTaxable - $variable)) + 30252.75 + 9380 + 0.396 * ($altTaxable - 235350);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 76550 && $altTaxable <= 116675)
{$tax = 932.5 + 4293.75 + 9650 + 0.28 * ($altTaxable - 76550);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 116675 && $altTaxable <206675)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 9650 + 11235 + 0.33 * ($altTaxable - 116675);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 208350 && $altTaxable <= 235350)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 9650 + 11235 + 30252.75 + 0.35 * ($altTaxable - 208350);}
elseif (($altTaxable - $variable) > 37950 && $altTaxable > 235350)
{$tax = 0.25 * (76550 - ($altTaxable - $variable)) + 11235 + 30252.75 + 9450 + 0.396 * ($altTaxable - 235350);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 116675 && $altTaxable <= 208350)
{$tax = 932.5 + 4293.75 + 9650 + 11235 + 0.33 * ($altTaxable - 116675);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 208350 && $altTaxable <= 235350)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 9650 + 11235 + 30252.75 + 0.35 * ($altTaxable - 208350);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 235350)
{$tax = 0.15 * (37950 - ($altTaxable - $variable)) + 9650 + 11235 + 30252.75 + 9450 + 0.396 * ($altTaxable - 235350);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 208350 && $altTaxable <= 235350)
{$tax = 932.5 + 4293.75 + 9650 + 11235 + 30252.75 + 0.35 * ($altTaxable - 208350);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 235350)
{$tax = 0.10 * (9325 - ($altTaxable - $variable)) + 4293.75 + 9650 + 11235 + 30252.75 + 9450 + 0.396 * ($altTaxable - 235350);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 235350)
{$tax = 932.5 + 4293.75 + 9650 + 11235 + 30252.75 + 9450 + 0.396 * ($altTaxable - 235350);}
return $tax;
}
}
if ($filingStatus == 4) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 13350) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 13350 && $altTaxable <= 50800) {$tax = 0.15 * $variable;}
elseif (($altTaxable - $variable) > 50800 && $altTaxable <= 131200) {$tax = 0.25 * $variable;}
elseif (($altTaxable - $variable) > 131200 && $altTaxable <= 212500) {$tax = 0.28 * $variable;}
elseif (($altTaxable - $variable) > 212500 && $altTaxable <= 416700) {$tax = 0.33 * $variable;}
elseif (($altTaxable - $variable) > 416700 && $altTaxable <= 444550) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 444550) {$tax = 0.396 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable < 0)
{$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 13350)
{$tax = 0.10 * $taxableIncome;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 13350 && $altTaxable <= 50800)
{$tax = 0.10 * (13350 - ($altTaxable - $variable)) + 0.15 * ($altTaxable - 13350);}
elseif (($altTaxable - $variable) > 13350 && $altTaxable > 50800 && $altTaxable <= 131200)
{$tax = 0.15 * (50800 - ($altTaxable - $variable)) + 0.25 * ($altTaxable - 50800);}
elseif (($altTaxable - $variable) > 50800 && $altTaxable > 131200 && $altTaxable <= 212500)
{$tax = 0.25 * (131200 - ($altTaxable - $variable)) + 0.28 * ($altTaxable - 131200);}
elseif (($altTaxable - $variable) > 131200 && $altTaxable > 212500 && $altTaxable <= 416700)
{$tax = 0.28 * (212500 - ($altTaxable - $variable)) + 0.33 * ($altTaxable - 212500);}
elseif (($altTaxable - $variable) > 212500 && $altTaxable > 416700 && $altTaxable <= 444550)
{$tax = 0.33 * (416700 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 416700 && $altTaxable > 444550)
{$tax = 0.35 * (444550 - ($altTaxable - $variable)) + 0.396 * ($altTaxable - 444550);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 13350 && $altTaxable <= 50800)
{$tax = 1335 + 0.15 * ($altTaxable - 13350);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 50800 && $altTaxable <= 131200)
{$tax = 0.10 * (13350 - ($altTaxable - $variable)) + 5617.50 + 0.25 * ($altTaxable - 50800);}
elseif (($altTaxable - $variable) > 13350 && $altTaxable > 131200 && $altTaxable <= 212500)
{$tax = 0.15 * (50800 - ($altTaxable - $variable)) + 20100 + 0.28 * ($altTaxable - 131200);}
elseif (($altTaxable - $variable) > 50800 && $altTaxable > 212500 && $altTaxable <= 416700)
{$tax = 0.25 * (131200 - ($altTaxable - $variable)) + 22764 + 0.33 * ($altTaxable - 212500);}
elseif (($altTaxable - $variable) > 131200 && $altTaxable > 416700 && $altTaxable <= 444550)
{$tax = 0.28 * (212500 - ($altTaxable - $variable)) + 67386 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 416700 && $altTaxable > 444550)
{$tax = 0.33 * (416700 - ($altTaxable - $variable)) + 9747.5 + 0.396 * ($altTaxable - 444550);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 50800 && $altTaxable <= 131200)
{$tax = 1335 + 5617.50 + 0.25 * ($altTaxable - 50800);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 131200 && $altTaxable <= 212500)
{$tax = 0.10 * (13350 - ($altTaxable - $variable)) + 5617.50 + 20100 + 0.28 * ($altTaxable - 131200);}
elseif (($altTaxable - $variable) > 9325 && $altTaxable > 212500 && $altTaxable <= 416700)
{$tax = 0.15 * (50800 - ($altTaxable - $variable)) + 20100 + 22764 + 0.33 * ($altTaxable - 212500);}
elseif (($altTaxable - $variable) > 50800 && $altTaxable > 416700 && $altTaxable <= 444550)
{$tax = 0.25 * (131200 - ($altTaxable - $variable)) + 22764 + 67386 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 131200 && $altTaxable > 444550)
{$tax = 0.28 * (212500 - ($altTaxable - $variable)) + 67386 + 9747.5 + 0.396 * ($altTaxable - 444550);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 131200 && $altTaxable <= 212500)
{$tax = 1335 + 5617.50 + 20100 + 0.28 * ($altTaxable - 131200);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 212500 && $altTaxable <= 416700)
{$tax = 0.10 * (13350 - ($altTaxable - $variable)) + 5617.50 + 20100 + 22764 + 0.33 * ($altTaxable - 212500);}
elseif (($altTaxable - $variable) > 13350 && $altTaxable > 416700 && $altTaxable <= 444550)
{$tax = 0.15 * (50800 - ($altTaxable - $variable)) + 20100 + 22764 + 67386 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 50800 && $altTaxable > 444550)
{$tax = 0.25 * (131200 - ($altTaxable - $variable)) + 22764 + 67386 + 9747.5 + 0.396 * ($altTaxable - 444550);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 212500 && $altTaxable <= 416700)
{$tax = 1335 + 5617.50 + 20100 + 22764 + 0.33 * ($altTaxable - 212500);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 416700 && $altTaxable <= 444550)
{$tax = 0.10 * (13350 - ($altTaxable - $variable)) + 5617.50 + 20100 + 22764 + 67386 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 13350 && $altTaxable > 444550)
{$tax = 0.15 * (50800 - ($altTaxable - $variable)) + 20100 + 22764 + 67386 + 9747.5 + 0.396 * ($altTaxable - 444550);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 416700 && $altTaxable <= 444550)
{$tax = 1335 + 5617.50 + 20100 + 22764 + 67386 + 0.35 * ($altTaxable - 416700);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 444550)
{$tax = 0.10 * (13350 - ($altTaxable - $variable)) + 5617.50 + 20100 + 22764 + 67386 + 9747.5 + 0.396 * ($altTaxable - 444550);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 444550)
{$tax = 1335 + 5617.50 + 20100 + 22764 + 67386 + 9747.5 + 0.396 * ($altTaxable - 444550);}
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 *
* *
* Self-Employment[0] => the amount of self-employment tax. *
* *
* Self-Employment[1] => the amount of the self-employment tax deduction. *
* *
* Self-Employment[2] => the amount of self-employment earnings. *
* *
* LongGains[0] => the amount of capital gains tax on qualified dividends and long-term *
* capital gains. *
* *
* LongGains[1] => the amount of qualified dividends and long-term capital gains upon *
* which the capital gains tax is computed. *
* *
* LongGains[2] => the amount of additional capital gains tax that is due to the *
* gambling winnings pushing capital into higher tax brackets, *
* i.e. capital gains phase-in. *
* *
* LongGains[3] => the amount of "negative" taxable income due to qualified dividends *
* and long-term capital gains exceeding ordinary income. *
* *
* TraditionalIRA[0] => the amount of allowable IRA deduction. *
* *
* TraditionalIRA[1] => the amount of phase-out for the IRA deduction. *
* *
* StudentLoanInterest[0] => the amount of allowable student loan interest deduction. *
* *
* StudentLoanInterest[1] => the amount of phase-out for the student loan interest *
* deduction. *
* *
* IncludableSSI[0] => the amount of allowable Social Security benefits that are *
* included in income. *
* *
* IncludableSSI[1] => the amount of phase-in for the Social Security benefits due to *
* additional income. *
* *
* MedicareTax[0] => the amount of additional Medicare tax on earned income. *
* *
* MedicareTax[1] => the amount of additional Medicare tax on investment income *
* *
* 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 threshold so gambling losses can offset gambling *
* winnings. *
* *
* Itemized[3] => the amount of phase-out for itemized deductions. *
* *
* *
* Exemptions[0] => the amount of exemptions deduction, given filing status, number of *
* dependents, and adjusted gross income. *
* *
* Exemptions[2] => the amount of phase-out for the exemptions deductions. *
* *
******************************************************************************************
*/
if (isset($_POST['submitted'])) {
if (
is_numeric($winnings) && is_numeric($losses) && is_numeric($filingStatus) && is_numeric($dependents) && is_numeric($senior) &&
is_numeric($spouseSenior) && is_numeric($blind) && is_numeric($spouseBlind) && is_numeric($wages) && is_numeric($investment) &&
is_numeric($dividend) && is_numeric($alimonyReceived) && is_numeric($profit) && is_numeric($shortCapital) &&
is_numeric($longCapital) && is_numeric($retire) && is_numeric($rent) && is_numeric($kayone) && is_numeric($unemployment) &&
is_numeric($ssi) && is_numeric($exempt) && is_numeric($alimonyPaid) && is_numeric($traditionalIRA) && is_numeric($spousalIRA) &&
is_numeric($studentLoanInterest) && is_numeric($otherAdjustments) && is_numeric($aged50Years) && is_numeric($spouseAged50Years) &&
is_numeric($coveredByEmployer) && is_numeric($spouseCoveredByEmployer) && is_numeric($together) &&
is_numeric($medicalExpenses) && is_numeric($stateTaxes) && is_numeric($mortgageInterest) && is_numeric($charity) &&
is_numeric($casualtyLoss) && is_numeric($jobExpenses) && is_numeric($miscellaneous) && is_numeric($spouseItemizing) &&
$winnings >= 0 && $losses >= 0 && $filingStatus > 0 && $filingStatus < 6 && $dependents >= 0 && $senior >= 0 &&
$spouseSenior >= 0 && $blind >= 0 && $spouseBlind >= 0 && $wages >= 0 && $investment >= 0 && $dividend >= 0 &&
$alimonyReceived >= 0 && $retire >= 0 && $unemployment >= 0 && $ssi >= 0 && $exempt >= 0 && $alimonyPaid >= 0 &&
$traditionalIRA >= 0 && $spousalIRA >= 0 && $studentLoanInterest >= 0 && $otherAdjustments >= 0 && $aged50Years >= 0 &&
$spouseAged50Years >= 0 && $coveredByEmployer >= 0 && $spouseCoveredByEmployer >= 0 && $together >= 0 &&
$medicalExpenses >= 0 && $stateTaxes >= 0 && $mortgageInterest >= 0 && $charity >= 0 && $casualtyLoss >= 0 &&
$jobExpenses >= 0 && $miscellaneous >= 0 && $spouseItemizing >= 0
){
$medicalExpensesThresholdRate = 0.075;
$cashCharitableDonationsLimitRate = 0.50;
$casualtyLossThresholdRate = 0.10;
$miscellaneousExpensesThresholdRate = 0.02;
if ($profit > 0) {
$SelfEmployment = setaxdeductioncalc($profit, $wages);
} else {
$SelfEmployment[0] = 0;
$SelfEmployment[1] = 0;
$SelfEmployment[2] = 0;
}
$agi = adjustedgrossincomecalc($wages, $profit, $investment, $dividend, $shortCapital, $longCapital, $retire, $rent, $alimonyReceived, $unemployment,
$ssi, $kayone, $otherAdjustments, $traditionalIRA, $studentLoanInterest, $alimonyPaid,
$SelfEmployment[1], $winnings);
if ($ssi > 0) {
$IncludableSSI = includablessicalc($filingStatus, $agi, $ssi, $studentLoanInterest, $exempt, $winnings);
$agi = $agi - $ssi + $IncludableSSI[0];
} else {
$IncludableSSI[0] = 0;
$IncludableSSI[1] = 0;
}
if ($studentLoanInterest > 0) {
$StudentLoanInterest = studentloaninterestcalc($filingStatus, $studentLoanInterest, $traditionalIRA, $agi, $winnings);
$agi = $agi + $studentLoanInterest - $StudentLoanInterest[0];
} else {
$StudentLoanInterest[0] = 0;
$StudentLoanInterest[1] = 0;
}
if ($traditionalIRA > 0 && ($filingStatus == 1 || $filingStatus == 4 || $filingStatus == 5) && $senior == 0) {
$TraditionalIRA = traditionaliracalc($filingStatus, $aged50Years, $coveredByEmployer, $traditionalIRA, $studentLoanInterest, $wages, $profit,
$alimonyReceived, $SelfEmployment[1], $agi, $winnings);
$agi = $agi + $traditionalIRA - $TraditionalIRA[0];
} elseif ($traditionalIRA > 0 && $filingStatus == 3 && $together == 1 && $senior == 0) {
$TraditionalIRA = traditionaliramfscalc($filingStatus, $aged50Years, $coveredByEmployer, $traditionalIRA, $studentLoanInterest, $wages, $profit,
$alimonyReceived, $SelfEmployment[1], $agi, $winnings);
$agi = $agi + $traditionalIRA - $TraditionalIRA[0];
} elseif ($traditionalIRA > 0 && $filingStatus == 3 && $together == 0 && $senior == 0) {
$TraditionalIRA = traditionaliracalc($filingStatus, $aged50Years, $coveredByEmployer, $traditionalIRA, $wages, $profit,
$alimonyReceived, $SelfEmployment[1], $agi, $winnings);
$agi = $agi + $traditionalIRA - $TraditionalIRA[0];
} elseif ($traditionalIRA > 0 && $filingStatus == 2 && ($senior + $spouseSenior < 2)) {
$TraditionalIRA = traditionaliramfjcalc($filingStatus, $aged50Years, $spouseAged50Years, $senior, $spouseSenior,
$coveredByEmployer, $spouseCoveredByEmployer, $traditionalIRA, $studentLoanInterest,
$wages, $profit, $alimonyReceived, $SelfEmployment[1], $agi, $winnings, $spousalIRA);
$agi = $agi + $traditionalIRA - $TraditionalIRA[0];
} else {
$TraditionalIRA[0] = 0;
$TraditionalIRA[1] = 0;
}
$Exemptions = exemptionscalc($filingStatus, $dependents, $agi, $winnings);
$Itemized = itemizeddeductionscalc($filingStatus, $agi, $winnings, $losses, $senior, $blind, $spouseSenior, $spouseBlind,
$medicalExpenses, $medicalExpensesThresholdRate, $stateTaxes, $mortgageInterest,
$charity, $cashCharitableDonationsLimitRate, $casualtyLoss, $casualtyLossThresholdRate,
$jobExpenses, $miscellaneousExpensesThresholdRate, $miscellaneous, $StudentLoanInterest[1], $IncludableSSI[1],
$TraditionalIRA[1], $spouseItemizing);
$taxableIncomeA = $agi - $Itemized[0] - $Exemptions[0];
if ($shortCapital > 0 || $longCapital > 0 || $dividend > 0) {
$LongGains = longcapitalgainstaxcalc($filingStatus, $shortCapital, $longCapital, $dividend, $taxableIncomeA,
$Itemized[1], $Itemized[3], $Exemptions[2], $StudentLoanInterest[1], $TraditionalIRA[1], $IncludableSSI[1]);
} else {
$LongGains[0] = 0;
$LongGains[1] = 0;
$LongGains[2] = 0;
$LongGains[3] = 0;
}
if (($filingStatus == 1 || $filingStatus == 4 || $filingStatus == 5) && $agi > 200000) {
$MedicareTax = additionalmedicaretaxcalc($filingStatus, $wages, $SelfEmployment[2], $investment, $dividend, $shortCapital, $longCapital, $rent,
$kayone, $agi);
} elseif ($filingStatus == 2 && $agi > 250000) {
$MedicareTax = additionalmedicaretaxcalc($filingStatus, $wages, $SelfEmployment[2], $investment, $dividend, $shortCapital, $longCapital, $rent,
$kayone, $agi);
} elseif ($filingStatus == 3 && $agi > 125000) {
$MedicareTax = additionalmedicaretaxcalc($filingStatus, $wages, $SelfEmployment[2], $investment, $dividend, $shortCapital, $longCapital, $rent,
$kayone, $agi);
} else {
$MedicareTax[0] = 0;
$MedicareTax[1] = 0;
}
$taxableIncome = $agi - $Itemized[0] - $Exemptions[0] - $LongGains[1];
$taxableIncomeLessWinnings = $taxableIncome - $Itemized[1] - $Itemized[3] - $IncludableSSI[1] - $StudentLoanInterest[1] - $TraditionalIRA[1] - $Exemptions[2];
$taxableIncomeB = $taxableIncome - $Exemptions[2];
// To reduce the taxable income by the amount of exemption phase-out.
// I don't know why this adjustment works, but it is needed to reconcile the calculator with the tax preparation software.
$taxableIncomeC = $taxableIncome - $Itemized[3];
// To reduce the taxable income by the amount of itemized deduction phase-out.
// I don't know why this adjustment works, but it is needed to reconcile the calculator with the tax preparation software.
$span = spancalc($filingStatus, $taxableIncome, $Itemized[1]);
$tax = taxcalc($span, $filingStatus, $taxableIncome, $Itemized[1]);
if ($IncludableSSI[1] > 0) {
$spanSSI = altspancalc($filingStatus, $taxableIncomeB, $Itemized[1], $IncludableSSI[1]);
$taxSSI = alttaxcalc($spanSSI, $filingStatus, $taxableIncomeB, $Itemized[1], $IncludableSSI[1]);
}
// In some instances for the correct computation of the tax impact of the Social Security benefits phase-in amount,
// taxable income needs to be reduced by the amount of the itemized deductions phase-out amount, yielding the $taxableIncomeC variable.
// In other instances for the correct computation of the tax impact of the Social Security benefits phase-in amount,
// taxable income needs to be reduced by the amount of the exemptions phase-out amount, yielding the $taxableIncomeB variable.
// In yet other instances for the correct computation of the tax impact of the Social Security benefits phase-in amount,
// taxable income needs no adjustment at all, yielding the $taxableIncome variable.
// It is not clear to me how to predict which adjustment is needed or when an adjustment is needed at all.
// The testing results indicate that the amount of the tax mistatement when there is no adjustment to taxable income to correct
// tax impact of the Social Security benefits phase-in amount is small in relation to the additional tax on gambling wininngs.
// The relative size of the income tax mistatement is in the order of 0.10% or less of the additional tax on gambling wininngs.
if ($TraditionalIRA[1] > 0) {
$spanIRA = altspancalc($filingStatus, $taxableIncome, $Itemized[1], $TraditionalIRA[1]);
$taxIRA = alttaxcalc($spanIRA, $filingStatus, $taxableIncome, $Itemized[1], $TraditionalIRA[1]);
}
if ($StudentLoanInterest[1] > 0 && $taxableIncome > 0) {
$spanSLI = altspancalc($filingStatus, $taxableIncome, $taxableWinningsB, $StudentLoanInterest[1]);
$taxSLI = alttaxcalc($spanSLI, $filingStatus, $taxableIncome, $taxableWinningsB, $StudentLoanInterest[1]);
}
if ($Itemized[3] > 0) {
$spanID = altspancalc($filingStatus, $taxableIncomeB, $Itemized[1], $Itemized[3]);
$taxID = alttaxcalc($spanID, $filingStatus, $taxableIncomeB, $Itemized[1], $Itemized[3]);
}
if ($Exemptions[2] > 0 && $taxableIncome > 0) {
$spanEx = altspancalc($filingStatus, $taxableIncome, $Itemized[1], $Exemptions[2]);
$taxEx = alttaxcalc($spanEx, $filingStatus, $taxableIncome, $Itemized[1], $Exemptions[2]);
}
$taxTotal = $tax + $taxEx + $taxSLI + $taxIRA + $LongGains[2] + $taxSSI + $taxID + $MedicareTax[1] + $LongGains[3];
}
else
{ echo '
Please enter valid (non-negative and numeric) dollar values.
Except, values for self-employment losses, rental property losses, capital losses,
and business losses from S-corporations or partnerships can be negative.
';}
}
?>
For Taxpayers with Complex Tax Returns for the 2017 Tax Year
Nota Bene:
This calculator computes only an estimate of the income tax on gambing winnings for individuals with fairly complex tax situations.
This calculator is best for individuals who 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. There is a basic version of this calculator which meets the needs of indivduals with simpler 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.