400 && ($seEarnings + $wages) <= 132900) {
$seTax = 0.153 * $seEarnings;
$seTaxDeduction = $seTax * 0.50;
}
elseif ($seEarnings + $wages > 132900) {
$seTax = 0.124 * (132900 - $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, $traditionalIRASpouse, $tuitionAndFees, $studentLoanInterest, $alimonyPaid,
$seTaxDeduction, $winnings) {
$totalIncome = $wages + $profit + $investment + $dividend + max(($shortCapital + $longCapital), -3000) + $retire + $rent + $alimonyReceived +
$kayone + $unemployment + $ssi + $winnings;
$totalAdjustments = $alimonyPaid + $traditionalIRA + $traditionalIRASpouse + $studentLoanInterest + $tuitionAndFees + $seTaxDeduction + $otherAdjustments;
$adjustedGrossIncome = $totalIncome - $totalAdjustments;
$AGI[0] = $adjustedGrossIncome;
$AGI[1] = $totalIncome;
$AGI[2] = $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, $sliPhaseOut, $tafPhaseOut, $IRAPhaseOut, $SSIPhaseOut, $PSEPhaseOut) {
$capital = $dividend + min(max($shortCapital + $longCapital, 0), max($longCapital, 0));
$taxableIncomeLessWinnings = $taxableIncome - $taxableWinnings - $idPhaseOut - $sliPhaseOut - $tafPhaseOut - $IRAPhaseOut -
$SSIPhaseOut - $PSEPhaseOut;
if ($filingStatus == 1) {
if ($taxableIncome <= 39350) {$longCapitalGainsTax = 0;}
elseif ($taxableIncome > 39350 && ($taxableIncome - $capital) <= 39350 && $taxableIncome <= 434550)
{$longCapitalGainsTax = 0.15 * ($capital - (39350 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 39350 && $taxableIncome <= 434550)
{$longCapitalGainsTax = 0.15 * $capital;}
elseif ($taxableIncome > 434550 && ($taxableIncome - $capital) <= 434550)
{$longCapitalGainsTax = 0.15 * (425800 - ($taxableIncome - $capital)) + 0.20 * ($capital - (434550 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 434550)
{$longCapitalGainsTax = 0.20 * $capital;}
if ($taxableIncomeLessWinnings <= 39350) {$longCapitalGainsTaxLessWinnings = 0;}
elseif ($taxableIncomeLessWinnings > 39350 && ($taxableIncomeLessWinnings - $capital) <= 39350 && $taxableIncomeLessWinnings <= 434550)
{$longCapitalGainsTaxLessWinnings = 0.15 * ($capital - (39350 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 39350 && $taxableIncomeLessWinnings <= 434550)
{$longCapitalGainsTaxLessWinnings = 0.15 * $capital;}
elseif ($taxableIncomeLessWinnings > 434550 && ($taxableIncomeLessWinnings - $capital) <= 39350)
{$longCapitalGainsTaxLessWinnings = 0.15 * (434550 - ($taxableIncomeLessWinnings - $capital)) + 0.20 * ($capital - (434550 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 434550)
{$longCapitalGainsTaxLessWinnings = 0.20 * $capital;}
$LongGains[0] = $longCapitalGainsTax;
$LongGains[1] = $capital;
$LongGains[2] = $longCapitalGainsTax - $longCapitalGainsTaxLessWinnings;
$LongGains[3] = min(0.10 * ($taxableIncomeLessWinnings - $capital), 0);
// 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 <= 78750) {$longCapitalGainsTax = 0;}
elseif ($taxableIncome > 78750 && ($taxableIncome - $capital) <= 78750 && $taxableIncome <= 488850)
{$longCapitalGainsTax = 0.15 * ($capital - (78750 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 78750 && $taxableIncome <= 488850)
{$longCapitalGainsTax = 0.15 * $capital;}
elseif ($taxableIncome > 488850 && ($taxableIncome - $capital) <= 78750)
{$longCapitalGainsTax = 0.15 * (488850 - ($taxableIncome - $capital)) + 0.20 * ($capital - (488850 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 488850)
{$longCapitalGainsTax = 0.20 * $capital;}
if ($taxableIncomeLessWinnings <= 78750) {$longCapitalGainsTaxLessWinnings = 0;}
elseif ($taxableIncomeLessWinnings > 78750 && ($taxableIncomeLessWinnings - $capital) <= 78750 && $taxableIncomeLessWinnings <= 488850)
{$longCapitalGainsTaxLessWinnings = 0.15 * ($capital - (78750 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 78750 && $taxableIncomeLessWinnings <= 488850)
{$longCapitalGainsTaxLessWinnings = 0.15 * $capital;}
elseif ($taxableIncomeLessWinnings > 488850 && ($taxableIncomeLessWinnings - $capital) <= 78750)
{$longCapitalGainsTaxLessWinnings = 0.15 * (488850 - ($taxableIncomeLessWinnings - $capital)) + 0.20 * ($capital - (488850 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 488850)
{$longCapitalGainsTaxLessWinnings = 0.20 * $capital;}
$LongGains[0] = $longCapitalGainsTax;
$LongGains[1] = $capital;
$LongGains[2] = $longCapitalGainsTax - $longCapitalGainsTaxLessWinnings;
$LongGains[3] = min(0.10 * ($taxableIncomeLessWinnings - $capital), 0);
return $LongGains;
}
if ($filingStatus == 3) {
if ($taxableIncome <= 39350) {$longCapitalGainsTax = 0;}
elseif ($taxableIncome > 39350 && ($taxableIncome - $capital) <= 39350 && $taxableIncome <= 244400)
{$longCapitalGainsTax = 0.15 * ($capital - (39350 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 39350 && $taxableIncome <= 244400)
{$longCapitalGainsTax = 0.15 * $capital;}
elseif ($taxableIncome > 244400 && ($taxableIncome - $capital) <= 244400)
{$longCapitalGainsTax = 0.15 * (244400 - ($taxableIncome - $capital)) + 0.20 * ($capital - (244400 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 244400)
{$longCapitalGainsTax = 0.20 * $capital;}
if ($taxableIncomeLessWinnings <= 39350) {$longCapitalGainsTaxLessWinnings = 0;}
elseif ($taxableIncomeLessWinnings > 39350 && ($taxableIncomeLessWinnings - $capital) <= 39350 && $taxableIncomeLessWinnings <= 244400)
{$longCapitalGainsTaxLessWinnings = 0.15 * ($capital - (39350 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 39350 && $taxableIncomeLessWinnings <= 244400)
{$longCapitalGainsTaxLessWinnings = 0.15 * $capital;}
elseif ($taxableIncomeLessWinnings > 244400 && ($taxableIncomeLessWinnings - $capital) <= 39350)
{$longCapitalGainsTaxLessWinnings = 0.15 * (244400 - ($taxableIncomeLessWinnings - $capital)) + 0.20 * ($capital - (244400 - ($taxableIncomeLessWinnings - $capital)));}
elseif (($taxableIncomeLessWinnings - $capital) > 244400)
{$longCapitalGainsTaxLessWinnings = 0.20 * $capital;}
$LongGains[0] = $longCapitalGainsTax;
$LongGains[1] = $capital;
$LongGains[2] = $longCapitalGainsTax - $longCapitalGainsTaxLessWinnings;
$LongGains[3] = min(0.10 * ($taxableIncomeLessWinnings - $capital), 0);
return $LongGains;
}
if ($filingStatus == 4) {
if (($taxableIncome - $taxableWinnings) <= 52750) {$longCapitalGainsTax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 52750 && (($taxableIncome - $taxableWinnings) - $capital) <= 52750 && ($taxableIncome - $taxableWinnings) <= 461700)
{$longCapitalGainsTax = 0.15 * ($capital - (52750 - ($taxableIncome - $capital)));}
elseif (($taxableIncome - $capital) > 52750 && $taxableIncome <= 461700)
{$longCapitalGainsTax = 0.15 * $capital;}
elseif (($taxableIncome - $taxableWinnings) > 461700 && (($taxableIncome - $taxableWinnings) - $capital) <= 52750)
{$longCapitalGainsTax = 0.15 * (461700 - ($taxableIncome - $capital)) + 0.20 * ($capital - (461700 - ($taxableIncome - $capital)));}
elseif ((($taxableIncome - $taxableWinnings) - $capital) > 461700)
{$longCapitalGainsTax = 0.20 * $capital;}
if (($taxableIncome - $taxableWinnings) <= 52750) {$longCapitalGainsTaxLessWinnings = 0;}
elseif (($taxableIncome - $taxableWinnings) > 52750 && (($taxableIncome - $taxableWinnings) - $capital) <= 52750 && ($taxableIncome - $taxableWinnings) <= 461700)
{$longCapitalGainsTaxLessWinnings = 0.15 * ($capital - (51700 - ($taxableIncomeLessWinnings - $capital)));}
elseif ((($taxableIncome - $taxableWinnings) - $capital) > 51700 && ($taxableIncome - $taxableWinnings) <= 461700)
{$longCapitalGainsTaxLessWinnings = 0.15 * $capital;}
elseif (($taxableIncome - $taxableWinnings) > 461700 && (($taxableIncome - $taxableWinnings) - $capital) <= 52750)
{$longCapitalGainsTaxLessWinnings = 0.15 * (461700 - ($taxableIncomeLessWinnings - $capital)) + 0.20 * ($capital - (461700 - ($taxableIncomeLessWinnings - $capital)));}
elseif ((($taxableIncome - $taxableWinnings) - $capital) > 461700)
{$longCapitalGainsTaxLessWinnings = 0.20 * $capital;}
$LongGains[0] = $longCapitalGainsTax;
$LongGains[1] = $capital;
$LongGains[2] = $longCapitalGainsTax - $longCapitalGainsTaxLessWinnings;
$LongGains[3] = min(0.10 * ($taxableIncomeLessWinnings - $capital), 0);
return $LongGains;
}
}
/*
******************************************************************************************
* *
* 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, $alimonyPaid, $otherAdjustments,
$wages, $profit, $alimonyReceived, $seTaxDeduction, $agi, $winnings) {
$traditionalIRA = min($traditionalIRA, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction));
$magiTraditionalIRA = $agi - $alimonyPaid - $otherAdjustments - $seTaxDeduction;
$magiTraditionalIRALessWinnings = $magiTraditionalIRA - $winnings;
if ($filingStatus == 1 || $filingStatus == 3 || $filingStatus == 4) {
if ($aged50Years == 0 && $coveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 6000);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 7000);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 74000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 64000 && $magiTraditionalIRA <= 74000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6000 * ((74000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 64000) {$traditionalIRAB = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 74000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 64000 && $magiTraditionalIRA <= 74000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(7000 * ((74000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 64000) {$traditionalIRAB = min($traditionalIRA, 7000);}
}
if ($aged50Years == 0 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 6000);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 6500);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 74000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 64000 && $magiTraditionalIRALessWinnings <= 74000) {$traditionalIRALessWinnings = min($traditionalIRA, 10 * ceil(6000 * ((74000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 64000) {$traditionalIRALessWinnings = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 74000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 64000 && $magiTraditionalIRALessWinnings <= 74000) {$traditionalIRALessWinnings = min($traditionalIRA, 10 * ceil(7000 * ((74000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 64000) {$traditionalIRALessWinnings = min($traditionalIRA, 7000);}
}
$TraditionalIRA[0] = $traditionalIRAB;
$TraditionalIRA[1] = $traditionalIRALessWinnings - $traditionalIRAB;
$TraditionalIRA[2] = $magiTraditionalIRA;
return $TraditionalIRA;
}
if ($filingStatus == 5) {
if ($aged50Years == 0 && $coveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 6000);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 7000);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 123000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRAB = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 123000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(7000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRAB = min($traditionalIRA, 7000);}
}
if ($aged50Years == 0 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 6000);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 7000);}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(6000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRALessWinnings = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(7000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRALessWinnings = min($traditionalIRA, 7000);}
}
$TraditionalIRA[0] = $traditionalIRAB;
$TraditionalIRA[1] = $traditionalIRALessWinnings - $traditionalIRAB;
$TraditionalIRA[2] = $magiTraditionalIRA;
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 - 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 make traditional IRA contributions and have gambling winnings *
* is very small. *
* *
* This function only partly accommodates the spousal IRA. The spousal IRA is the *
* making of contributions, by a working spouse, to the IRA of a non-working spouse or *
* lower income spouse. This program assumes that the spouse's income is zero, *
* attributing all joint income to the spouse identified as the primary taxpayer. *
* In the vast majority of cases, this limitation should not result in an overstatement *
* of tax on the gambling 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, $traditionalIRASpouse, $alimonyPaid, $otherAdjustments, $wages,
$profit, $alimonyReceived, $seTaxDeduction, $agi, $winnings, $spousalIRA) {
$traditionalIRA = min($traditionalIRA, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction));
$magiTraditionalIRA = $agi - $alimonyPaid - $otherAdjustments - $seTaxDeduction;
$magiTraditionalIRALessWinnings = $magiTraditionalIRA - $winnings;
if ($filingStatus == 2 && $spousalIRA == 0 && $senior == 0) {
if ($aged50Years == 0 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 6000);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 0) {$traditionalIRAB = min($traditionalIRA, 7000);}
if ($aged50Years == 0 && $coveredByEmployer == 1 && $spouseCoveredByEmployer == 0) {
if ($magiTraditionalIRA > 123000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRAB = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1 && $spouseCoveredByEmployer == 0) {
if ($magiTraditionalIRA > 123000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(7000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRAB = min($traditionalIRA, 7000);}
}
if ($aged50Years == 0 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRA > 203000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 193000 && $magiTraditionalIRA <= 203000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6000 * ((203000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 193000) {$traditionalIRAB = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRA > 203000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 193000 && $magiTraditionalIRA <= 203000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(7000 * ((203000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 193000) {$traditionalIRAB = min($traditionalIRA, 7000);}
}
if ($aged50Years == 0 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 6000);}
elseif ($aged50Years == 1 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 0) {$traditionalIRALessWinnings = min($traditionalIRA, 7000);}
if ($aged50Years == 0 && $coveredByEmployer == 1 && $spouseCoveredByEmployer == 0) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(6000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRALessWinnings = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1 && $spouseCoveredByEmployer == 0) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(7000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRALessWinnings = min($traditionalIRA, 7000);}
}
if ($aged50Years == 0 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 203000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 193000 && $magiTraditionalIRALessWinnings <= 203000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(6000 * ((203000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 193000) {$traditionalIRAB = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 0 && $spouseCoveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 203000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 193000 && $magiTraditionalIRALessWinnings <= 203000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(7000 * ((203000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 193000) {$traditionalIRALessWinnings = min($traditionalIRA, 7000);}
}
$TraditionalIRA[0] = $traditionalIRAB;
$TraditionalIRA[1] = $traditionalIRALessWinnings - $traditionalIRAB;
$TraditionalIRA[2] = $magiTraditionalIRA + 1;
$TraditionalIRA[3] = 0;
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) {
// This section is for the cases where neither the taxpayer nor the spouse participates in an employer-sponsored retirement plan.
if ($coveredByEmployer == 0 && $spouseCoveredByEmployer == 0) {
if ($aged50Years == 0) {$traditionalIRAB = min($traditionalIRA, 6000);}
elseif ($aged50Years == 1) {$traditionalIRAB = min($traditionalIRA, 7000);}
$traditionalIRASpouse = min($traditionalIRASpouse, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction - $traditionalIRAB));
if ($spouseAged50Years == 0) {$traditionalIRABSpouse = min($traditionalIRASpouse, 6000);}
elseif ($spouseAged50Years == 1) {$traditionalIRABSpouse = min($traditionalIRASpouse, 7000);}
$TraditionalIRA[0] = $traditionalIRAB + $traditionalIRASpouse;
$TraditionalIRA[1] = 0; // There is no phase-out. There is no income limit on the deduction because there is no employer-sponosored plan.
$TraditionalIRA[2] = $magiTraditionalIRA + 2;
$TraditionalIRA[3] = $traditionalIRABSpouse;
return $TraditionalIRA;
}
// This section is for the cases where only the taxpayer participates in an employer-sponsored retirement plan.
if ($coveredByEmployer == 1 && $spouseCoveredByEmployer == 0) {
if ($aged50Years == 0) {
if ($magiTraditionalIRA > 123000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRAB = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1) {
if ($magiTraditionalIRA > 123000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(7000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRAB = min($traditionalIRA, 7000);}
}
$traditionalIRASpouse = min($traditionalIRASpouse, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction - $traditionalIRAB));
if ($spouseAged50Years == 0) {
if ($magiTraditionalIRA > 203000) {$traditionalIRABSpouse = 0;}
elseif ($magiTraditionalIRA > 193000 && $magiTraditionalIRA <= 203000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 10 * ceil(6000 * ((203000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 193000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 6000);}
}
elseif ($spouseAged50Years == 1) {
if ($magiTraditionalIRA > 203000) {$traditionalIRABSpouse = 0;}
elseif ($magiTraditionalIRA > 193000 && $magiTraditionalIRA <= 203000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 10 * ceil(7000 * ((203000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 193000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 7000);}
}
if ($aged50Years == 0) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(6000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRALessWinnings = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(7000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRALessWinnings = min($traditionalIRA, 7000);}
}
$traditionalIRASpouse = min($traditionalIRASpouse, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction - $traditionalIRALessWinnings));
if ($spouseAged50Years == 0) {
if ($magiTraditionalIRALessWinnings > 203000) {$traditionalIRASpouseLessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 193000 && $magiTraditionalIRALessWinnings <= 203000) {$traditionalIRASpouseLessWinnings =
min($traditionalIRASpouse, 10 * ceil(6000 * ((203000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 193000) {$traditionalIRASpouseLessWinnings = min($traditionalIRASpouse, 6000);}
}
elseif ($spouseAged50Years == 1) {
if ($magiTraditionalIRALessWinnings > 203000) {$traditionalIRASpouseLessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 193000 && $magiTraditionalIRALessWinnings <= 203000) {$traditionalIRASpouseLessWinnings =
min($traditionalIRASpouse, 10 * ceil(7000 * ((203000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 193000) {$traditionalIRASpouseLessWinnings = min($traditionalIRASpouse, 7000);}
}
if ($spouseSenior == 1) {$traditionalIRABSpouse = 0;}
$TraditionalIRA[0] = $traditionalIRAB + $traditionalIRABSpouse;
$TraditionalIRA[1] = $traditionalIRALessWinnings + $traditionalIRASpouseLessWinnings - $traditionalIRAB - $traditionalIRABSpouse;
$TraditionalIRA[2] = $magiTraditionalIRA + 3;
$TraditionalIRA[3] = $traditionalIRABSpouse;
return $TraditionalIRA;
}
// This section is for the cases where only the spouse participates in an employer-sponsored retirement plan.
if ($coveredByEmployer == 0 && $spouseCoveredByEmployer == 1) {
if ($aged50Years == 0) {
if ($magiTraditionalIRA > 203000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 193000 && $magiTraditionalIRA <= 203000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6000 * ((203000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 193000) {$traditionalIRAB = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1) {
if ($magiTraditionalIRA > 203000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 193000 && $magiTraditionalIRA <= 203000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(7000 * ((203000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 193000) {$traditionalIRAB = min($traditionalIRA, 7000);}
}
$traditionalIRASpouse = min($traditionalIRASpouse, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction - $traditionalIRAB));
if ($spouseAged50Years == 0) {
if ($magiTraditionalIRA > 123000) {$traditionalIRABSpouse = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 10 * ceil(6000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 6000);}
}
elseif ($spouseAged50Years == 1) {
if ($magiTraditionalIRA > 123000) {$traditionalIRABSpouse = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 10 * ceil(7000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 7000);}
}
if ($aged50Years == 0) {
if ($magiTraditionalIRALessWinnings > 203000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 193000 && $magiTraditionalIRALessWinnings <= 203000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(6000 * ((203000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 193000) {$traditionalIRALessWinnings = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1) {
if ($magiTraditionalIRALessWinnings > 203000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 193000 && $magiTraditionalIRALessWinnings <= 203000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(7000 * ((203000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 193000) {$traditionalIRALessWinnings = min($traditionalIRA, 7000);}
}
$traditionalIRASpouse = min($traditionalIRASpouse, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction - $traditionalIRAB));
if ($spouseAged50Years == 0) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRASpouseLessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRASpouseLessWinnings =
min($traditionalIRASpouse, 10 * ceil(6000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRASpouseLessWinnings = min($traditionalIRASpouse, 6000);}
}
elseif ($spouseAged50Years == 1) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRASpouseLessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRASpouseLessWinnings =
min($traditionalIRASpouse, 10 * ceil(7000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRASpouseLessWinnings = min($traditionalIRASpouse, 7000);}
}
if ($spouseSenior == 1) {$traditionalIRABSpouse = 0;}
$TraditionalIRA[0] = $traditionalIRAB + $traditionalIRABSpouse;
$TraditionalIRA[1] = $traditionalIRALessWinnings + $traditionalIRASpouseLessWinnings - $traditionalIRAB - $traditionalIRABSpouse;
$TraditionalIRA[2] = $magiTraditionalIRA + 4;
$TraditionalIRA[3] = $traditionalIRABSpouse;
return $TraditionalIRA;
}
// This section is for the cases where both the taxpayer and the spouse participate in an employer-sponsored retirement plans.
if ($coveredByEmployer == 1 && $spouseCoveredByEmployer == 1) {
if ($aged50Years == 0) {
if ($magiTraditionalIRA > 123000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRAB = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1) {
if ($magiTraditionalIRA > 123000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(7000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRAB = min($traditionalIRA, 7000);}
}
$traditionalIRASpouse = min($traditionalIRASpouse, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction - $traditionalIRAB));
if ($spouseAged50Years == 0) {
if ($magiTraditionalIRA > 123000) {$traditionalIRABSpouse = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 10 * ceil(6000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 6000);}
}
elseif ($spouseAged50Years == 1) {
if ($magiTraditionalIRA > 123000) {$traditionalIRABSpouse = 0;}
elseif ($magiTraditionalIRA > 103000 && $magiTraditionalIRA <= 123000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 10 * ceil(7000 * ((123000 - $magiTraditionalIRA) / 20000) / 10));}
elseif ($magiTraditionalIRA <= 103000) {$traditionalIRABSpouse = min($traditionalIRASpouse, 7000);}
}
if ($aged50Years == 0) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(6000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRALessWinnings = min($traditionalIRA, 6000);}
}
elseif ($aged50Years == 1) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRALessWinnings =
min($traditionalIRA, 10 * ceil(7000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRALessWinnings = min($traditionalIRA, 7000);}
}
$traditionalIRASpouse = min($traditionalIRASpouse, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction - $traditionalIRALessWinnings));
if ($spouseAged50Years == 0) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRASpouseLessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRASpouseLessWinnings =
min($traditionalIRASpouse, 10 * ceil(6000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRASpouseLessWinnings = min($traditionalIRASpouse, 6000);}
}
elseif ($spouseAged50Years == 1) {
if ($magiTraditionalIRALessWinnings > 123000) {$traditionalIRASpouseLessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 103000 && $magiTraditionalIRALessWinnings <= 123000) {$traditionalIRASpouseLessWinnings =
min($traditionalIRASpouse, 10 * ceil(7000 * ((123000 - $magiTraditionalIRALessWinnings) / 20000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 103000) {$traditionalIRASpouseLessWinnings = min($traditionalIRASpouse, 7000);}
}
if ($spouseSenior == 1) {$traditionalIRABSpouse = 0;}
$TraditionalIRA[0] = $traditionalIRAB + $traditionalIRABSpouse;
$TraditionalIRA[1] = $traditionalIRALessWinnings + $traditionalIRA_SPLessWinnings - $traditionalIRAB - $traditionalIRABSpouse;
$TraditionalIRA[2] = $magiTraditionalIRA + 5;
$TraditionalIRA[3] = $traditionalIRABSpouse;
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, $alimonyPaid, $otherAdjustments,
$wages, $profit, $alimonyReceived, $seTaxDeduction, $agi, $winnings) {
$traditionalIRA = min($traditionalIRA, ($wages + max($profit, 0) + $alimonyReceived - $seTaxDeduction));
$magiTraditionalIRA = $agi - $alimonyPaid - $otherAdjustments - $seTaxDeduction;
$magiTraditionalIRALessWinnings = $magiTraditionalIRA - $winnings;
if ($filingStatus == 3) {
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRA > 10000) {$traditionalIRAB = 0;}
elseif ($magiTraditionalIRA > 0 && $magiTraditionalIRA <= 10000) {$traditionalIRAB = min($traditionalIRA, 10 * ceil(6000 * ((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(7000 * ((10000 - $magiTraditionalIRA) / 10000) / 10));}
elseif ($magiTraditionalIRA <= 0) {$traditionalIRAB = 0;}
}
if ($aged50Years == 0 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 10000) {$traditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 0 && $magiTraditionalIRALessWinnings <= 10000) {$traditionalIRALessWinnings = min($traditionalIRA, 10 * ceil(6000 * ((10000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRALessWinnings <= 0) {$traditionalIRALessWinnings = 0;}
}
elseif ($aged50Years == 1 && $coveredByEmployer == 1) {
if ($magiTraditionalIRALessWinnings > 10000) {$TraditionalIRALessWinnings = 0;}
elseif ($magiTraditionalIRALessWinnings > 0 && $magiTraditionalIRALessWinnings <= 10000) {$traditionalIRALessWinnings = min($traditionalIRA, 10 * ceil(7000 * ((10000 - $magiTraditionalIRALessWinnings) / 10000) / 10));}
elseif ($magiTraditionalIRLessWinningsA <= 0) {$traditionalIRALessWinnings = 0;}
}
$TraditionalIRA[0] = $traditionalIRAB;
$TraditionalIRA[1] = $traditionalIRALessWinnings - $traditionalIRAB;
$TraditionalIRA[2] = $magiTraditionalIRA;
return $TraditionalIRA;
}
}
/*
******************************************************************************************
* *
* Function: Tuition and Fees Deduction Calculator *
* *
* *
* This function computes the deduction for the costs, (tuition and other fees), *
* incurred taking certain educational or training related courses and seminars. These *
* courses are of the type usually not eligible for other education related tax *
* benefits. *
* *
* This function also computes the decrease in the allowable 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 tuition and *
* fees deduction. *
* *
******************************************************************************************
*/
function tuitionandfeescalc($filingStatus, $tuitionAndFees, $studentLoanInterest, $alimonyPaid, $otherAdjustments, $traditionalIRA,
$seTaxDeduction, $agi, $winnings) {
$magiTuitionAndFees = $agi - $alimonyPaid - $otherAdjustments - $seTaxDeduction - $traditionalIRA - $studentLoanInterest;
$magiTuitionAndFeesLessWinnings = $magiTuitionAndFees - $winnings;
if ($filingStatus == 1 || $filingStatus == 4 || $filingStatus == 5) {
if ($magiTuitionAndFees > 80000) {$tuitionAndFeesA = 0;}
elseif ($magiTuitionAndFees > 65000 && $magiTuitionAndFees <= 80000) {$tuitionAndFeesA = min($tuitionAndFees, 2000);}
elseif ($magiTuitionAndFees <= 65000) {$tuitionAndFeesA = min($tuitionAndFees, 4000);}
if ($magiTuitionAndFeesLessWinnings > 80000) {$tuitionAndFeesLessWinnings = 0;}
elseif ($magiTuitionAndFeesLessWinnings > 65000 && $magiTuitionAndFeesLessWinnings <= 80000) {$tuitionAndFeesLessWinnings = min($tuitionAndFees, 2000);}
elseif ($magiTuitionAndFeesLessWinnings <= 65000) {$tuitionAndFeesLessWinnings = min($tuitionAndFees, 4000);}
$TuitionAndFees[0] = $tuitionAndFeesA;
$TuitionAndFees[1] = $tuitionAndFeesLessWinnings - $tuitionAndFeesA;
$TuitionAndFees[2] = $magiTuitionAndFees;
return $TuitionAndFees;
}
if ($filingStatus == 2) {
if ($magiTuitionAndFees > 160000) {$tuitionAndFeesA = 0;}
elseif ($magiTuitionAndFees > 130000 && $magiTuitionAndFees <= 160000) {$tuitionAndFeesA = min($tuitionAndFees, 2000);}
elseif ($magiTuitionAndFees <= 130000) {$tuitionAndFeesA = min($tuitionAndFees, 4000);}
if ($magiTuitionAndFeesLessWinnings > 160000) {$tuitionAndFeesLessWinnings = 0;}
elseif ($magiTuitionAndFeesLessWinnings > 130000 && $magiTuitionAndFeesLessWinnings <= 160000) {$tuitionAndFeesLessWinnings = min($tuitionAndFees, 2000);}
elseif ($magiTuitionAndFeesLessWinnings <= 130000) {$tuitionAndFeesLessWinnings = min($tuitionAndFees, 4000);}
$TuitionAndFees[0] = $tuitionAndFeesA;
$TuitionAndFees[1] = $tuitionAndFeesLessWinnings - $tuitionAndFeesA;
$TuitionAndFees[2] = $magiTuitionAndFees;
return $TuitionAndFees;
}
}
/*
******************************************************************************************
* *
* 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, $alimonyPaid, $otherAdjustments, $traditionalIRA,
$seTaxDeduction, $agi, $winnings) {
$magiStudentLoanInterest = $agi - $alimonyPaid - $otherAdjustments - $seTaxDeduction - $traditionalIRA;
$magiStudentLoanInterestLessWinnings = $magiStudentLoanInterest - $winnings;
if ($filingStatus == 1 || $filingStatus == 4 || $filingStatus == 5) {
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);}
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;
$StudentLoanInterest[2] = $magiStudentLoanInterest;
return $StudentLoanInterest;
}
if ($filingStatus == 2) {
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);}
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;
$StudentLoanInterest[2] = $magiStudentLoanInterest;
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, $exempt, $winnings) {
$magiSSI = $agi + $exempt - .5 * $ssi;
$magiSSILessWinnings = $magiSSI - $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;
$IncludableSSI[2] = $magiSSI;
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;
$IncludableSSI[2] = $magiSSI;
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. *
* *
* For the 2019 tax year, this occurs in only one way: *
* *
* Some itemized deductions have floors determined by the AGI. The deductible amount is *
* the excess of the expense over this floor. For this program, only medical expenses *
* has such a floor at 10.0% of AGI. When AGI increases due to gambling winnings, this *
* floor increases and the amount of the expense which is deductible decreases. *
* *
* The limitation on total itemized deductions (called the Pease Limitations) has been *
* repealed for 2019. *
* *
* The tax impact of this itemized deduction phase-out is reported both alone and as *
* part of the total tax liability increase due to the gambling winnings. *
* *
* Note that the phase-out of the new Pass-Through Entity (PSE) deduction does not play *
* a part in the Itemized Deductions phase-out. That is because that deduction does *
* net affect AGI. The PSE deduction is taken after itemized deductions are subtracted *
* from AGI. The PSE deduction affects taxable income but not AGI. *
* *
* The itemized deductions phase-out amount is expressed in the fourth element of the *
* return array, i.e. Deductions[3]. *
* *
******************************************************************************************
*/
function itemizeddeductionscalc($filingStatus, $spouseItemizing, $agi, $winnings, $losses, $senior, $blind, $spouseSenior, $spouseBlind, $medicalExpenses,
$medicalExpensesThresholdRate, $stateTaxes, $mortgageInterest, $charity, $cashCharitableDonationsLimitRate,
$miscellaneous, $SLIPhaseOut, $SSIPhaseOut, $IRAPhaseOut, $TAFPhaseOut) {
if ($medicalExpenses > 0) {$totalPhaseOut = $medicalExpensesThresholdRate * ($SLIPhaseOut + $SSIPhaseOut + $IRAPhaseOut + $TAFPhaseOut);}
else {$totalPhaseOut = 0;}
if ($filingStatus == 1) {
$standard = 12200 + 1650 * ($senior + $blind);
$allowableLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$stateTaxesA = min($stateTaxes, 10000);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$itemizedTotalA = $medicalExpensesA + $stateTaxesA + $mortgageInterest + $charityA + $allowableLosses;
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);
$itemizedTotalLessWinnings = $stateTaxesA + $medicalExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$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 = 24400 + 1300 * ($senior + $spouseSenior + $blind + $spouseBlind);
$allowableLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$stateTaxesA = min($stateTaxes, 10000);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$itemizedTotalA = $medicalExpensesA + $stateTaxesA + $mortgageInterest + $charityA + $allowableLosses;
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);
$itemizedTotalLessWinnings = $stateTaxesA + $medicalExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$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) {
$deductibleLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$stateTaxesA = min($stateTaxes, 5000);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$itemizedTotalA = $medicalExpensesA + $stateTaxesA + $mortgageInterest + $charityA + $deductibleLosses;
$taxableWinnings = $winnings - $deductibleLosses;
$agiLessWinnings = $agi - $winnings;
$medicalExpensesLessWinnings = max($medicalExpenses - $medicalExpensesThresholdRate * $agiLessWinnings, 0);
$charityLessWinnings = min($charity, $cashCharitableDonationsLimitRate * $agiLessWinnings);
$itemizedTotalLessWinnings = $stateTaxesA + $medicalExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$Deductions[0] = $itemizedTotalA;
$Deductions[1] = $taxableWinnings;
$Deductions[2] = 0;
$Deductions[3] = max(($itemizedTotalLessWinnings - ($itemizedTotalA - $deductibleLosses) + $totalPhaseOut), 0);
} else {
$Deductions[0] = 12200 + 1300 * ($senior + $blind);
$Deductions[1] = $winnings;
$Deductions[2] = 12200;
$Deductions[3] = 0;
}
return $Deductions;
}
if ($filingStatus == 4) {
$standard = 18350 + 1650 * ($senior + $blind);
$allowableLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$stateTaxesA = min($stateTaxes, 10000);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$itemizedTotalA = $medicalExpensesA + $stateTaxesA + $mortgageInterest + $charityA + $allowableLosses;
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);
$itemizedTotalLessWinnings = $stateTaxesA + $medicalExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$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 = 24400 + 1300 * ($senior + $blind);
$allowableLosses = min($winnings, $losses);
$medicalExpensesA = max($medicalExpenses - $medicalExpensesThresholdRate * $agi, 0);
$stateTaxesA = min($stateTaxes, 10000);
$charityA = min($charity, $cashCharitableDonationsLimitRate * $agi);
$itemizedTotalA = $medicalExpensesA + $stateTaxesA + $mortgageInterest + $charityA + $allowableLosses;
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);
$itemizedTotalLessWinnings = $stateTaxesA + $medicalExpensesLessWinnings + $charityLessWinnings + $mortgageInterest + $miscellaneous;
$Deductions[0] = max($itemizedTotalA, $standard);
$Deductions[1] = $taxableWinnings;
$Deductions[2] = $deficiency;
$Deductions[3] = max(($itemizedTotalLessWinnings - max($itemizedTotalA - $allowableLosses, $standard) + $totalPhaseOut), 0);
return $Deductions;
}
}
/*
******************************************************************************************
* *
* Function: Pass-Through Entity (PSE) Deduction Calculator *
* *
* *
* This function computes the deduction eligible for income generated from sole *
* proprietorships, partnerships, S-corporations, trusts and estates, and the rental of *
* real property. The computation of this deduction is complex and we have disregarded *
* aspects of it for simplification. Specifically, we have omitted the limitation on *
* the deduction based on wages and property basis. We have also ignored the exclusion *
* of income earned from a "specified service trade or business" (SSTB) from *
* eligibility for the deduction. We leave it to the taxpayer to exclude such income *
* from the calculator. Finally, we have excluded the dividends from Real Estate *
* Investment Trusts (REIT) and the income from publicly traded partnerships (PTP). *
* *
* This function computes the deduction as the smaller of 20% of Qualfied Business *
* Income (QBI) and 20% of taxable income excluding income from long-term capital gains *
* and qualified dividends. The base of QBI, upon which the 20% rate is levied, is the *
* sum of the individual QBI amounts for each of the businesses from which the taxpayer *
* is receiving income. QBI must be positive, as must be modified taxable income. *
* There is no current deduction for negative QBI, or business losses. However, *
* losses can be carried forward and applied to reduce future QBI. *
* *
* This function does observe the Adjusted Gross Income (AGI) limitations of the PSE *
* deduction. As AGI increases due to gambling winnings, it can breach the threshold *
* for the phase-out of the deduction or the threshold for elimination of the deduction. *
* Hence, additional gambling winnings can lead to higher income tax liability due to *
* the reduction of this deduction. This function computes that phase-out amount. *
* *
* Unlike most other deductions, the PSE deduction is subject to a phase-in effect, in *
* addition to the phase-out effect. The deduction cannot reduce taxable income below *
* zero. The limitation that the deduction cannot exceed 20% of taxable income ensures *
* this. It is this limitation that causes the phase-in effect. When AGI is composed *
* mostly of QBI, it is possible for it to exceed taxable income. This leads to the *
* allowable deduction being less than 20% of QBI. As gambling winnings increase AGI, *
* the size of the allowable deduction increases and eventually exceeds the maximum *
* deduction of 20% of QBI. *
* *
* This function computes this phase-in effect which serves to reduce the income tax *
* liability due to gambling winnings. It is shown as a negative phase-out value. *
* *
* *
******************************************************************************************
*/
function passthroughdeductionscalc($filingStatus, $profit, $seTaxDeduction, $rent, $kayone, $taxableIncomeA, $taxableIncomeLessWinningsA, $capital) {
$qualifiedBusinessIncome = max(($profit - $seTaxDeduction + $rent + $kayone), 0);
$taxableIncome = max(($taxableIncomeA - $capital), 0);
$taxableIncomeLessWinnings = max(($taxableIncomeLessWinningsA - $capital), 0);
if ($filingStatus == 1 || $filingStatus == 4 || $filingStatus == 5) {
if ($taxableIncome > 210700) {$passThroughDeduction = 0;}
elseif ($taxableIncome > 160700 and $taxableIncome <= 210700) {
$passThroughDeduction = min((0.20 * $qualifiedBusinessIncome * (1 - ($taxableIncome - 160700) / 50000)), 0.20 * $taxableIncome);}
elseif ($taxableIncome <= 160700) {$passThroughDeduction = min(0.20 * $qualifiedBusinessIncome, 0.20 * $taxableIncome);}
if ($taxableIncomeLessWinnings > 210700) {$passThroughDeductionLessWinnings = 0;}
elseif ($taxableIncomeLessWinnings > 160700 and $taxableIncomeLessWinnings <= 210700) {
$passThroughDeductionLessWinnings = min((0.20 * $qualifiedBusinessIncome * (1 - ($taxableIncomeLessWinnings - 160700) / 50000)), 0.20 * $taxableIncomeLessWinnings);}
elseif ($taxableIncomeLessWinnings <= 160700) {$passThroughDeductionLessWinnings = min(0.20 * $qualifiedBusinessIncome, 0.20 * $taxableIncomeLessWinnings);}
$PSEDeduction[0] = $passThroughDeduction;
$PSEDeduction[1] = $passThroughDeductionLessWinnings - $passThroughDeduction;
return $PSEDeduction;
}
if ($filingStatus == 2) {
if ($taxableIncome > 421450) {$passThroughDeduction = 0;}
elseif ($taxableIncome > 321450 and $taxableIncome <= 421450) {
$passThroughDeduction = min((0.20 * $qualifiedBusinessIncome * (1 - ($taxableIncome - 321450) / 100000)), 0.20 * $taxableIncome);}
elseif ($taxableIncome <= 321450) {$passThroughDeduction = min(0.20 * $qualifiedBusinessIncome, 0.20 * $taxableIncome);}
if ($taxableIncomeLessWinnings > 421450) {$passThroughDeductionLessWinnings = 0;}
elseif ($taxableIncomeLessWinnings > 321450 and $taxableIncomeLessWinnings <= 421450) {
$passThroughDeductionLessWinnings = min((0.20 * $qualifiedBusinessIncome * (1 - ($taxableIncomeLessWinnings - 321450) / 100000)), 0.20 * $taxableIncomeLessWinnings);}
elseif ($taxableIncomeLessWinnings <= 321450) {$passThroughDeductionLessWinnings = min(0.20 * $qualifiedBusinessIncome, 0.20 * $taxableIncomeLessWinnings);}
$PSEDeduction[0] = $passThroughDeduction;
$PSEDeduction[1] = $passThroughDeductionLessWinnings - $passThroughDeduction;
return $PSEDeduction;
}
if ($filingStatus == 3) {
if ($taxableIncome > 210725) {$passThroughDeduction = 0;}
elseif ($taxableIncome > 160725 and $taxableIncome <= 210725) {
$passThroughDeduction = min((0.20 * $qualifiedBusinessIncome * (1 - ($taxableIncome - 160725) / 50000)), 0.20 * $taxableIncome);}
elseif ($taxableIncome <= 160725) {$passThroughDeduction = min(0.20 * $qualifiedBusinessIncome, 0.20 * $taxableIncome);}
if ($taxableIncomeLessWinnings > 210725) {$passThroughDeductionLessWinnings = 0;}
elseif ($taxableIncomeLessWinnings > 160725 and $taxableIncomeLessWinnings <= 210725) {
$passThroughDeductionLessWinnings = min((0.20 * $qualifiedBusinessIncome * (1 - ($taxableIncomeLessWinnings - 160725) / 50000)), 0.20 * $taxableIncomeLessWinnings);}
elseif ($taxableIncomeLessWinnings <= 160725) {$passThroughDeductionLessWinnings = min(0.20 * $qualifiedBusinessIncome, 0.20 * $taxableIncomeLessWinnings);}
$PSEDeduction[0] = $passThroughDeduction;
$PSEDeduction[1] = $passThroughDeductionLessWinnings - $passThroughDeduction;
return $PSEDeduction;
}
}
/*
******************************************************************************************
* *
* 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, $kayoneA, $materialParticipation, $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 ($materialParticipation == 1) {$kayoneA = 0;}
if ($filingStatus == 1 || $filingStatus == 4) {$NII = 0.038 * min(max(($investment + $dividend + $shortCapital + $longCapital + $rent + $kayoneA), 0), max(($agi - 200000), 0));}
if ($filingStatus == 2 || $filingStatus == 5) {$NII = 0.038 * min(max(($investment + $dividend + $shortCapital + $longCapital + $rent + $kayoneA), 0), max(($agi - 250000), 0));}
if ($filingStatus == 3) {$NII = 0.038 * min(max(($investment + $dividend + $shortCapital + $longCapital + $rent + $kayoneA), 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 2019. *
* *
******************************************************************************************
*/
function spancalc($filingStatus, $taxableIncome, $taxableWinnings) {
if ($filingStatus == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9700) ||
(($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome <= 39475) ||
(($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 204100 && $taxableIncome <= 510300) ||
($taxableIncome - $taxableWinnings) > 510300
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9700) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 9700 && $taxableIncome <= 39475) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 39475 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 39475 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 84200 && ($taxableIncome - $taxableWinnings) <= 160725 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 160725 && ($taxableIncome - $taxableWinnings) <= 204100 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 204100 && ($taxableIncome - $taxableWinnings) <= 510300 && $taxableIncome > 510300)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9700 && $taxableIncome <= 39475) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 39475 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 39475 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 84200 && ($taxableIncome - $taxableWinnings) <= 160725 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 160725 && ($taxableIncome - $taxableWinnings) <= 204100 && $taxableIncome > 510300)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 39475 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 39475 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 84200 && ($taxableIncome - $taxableWinnings) <= 160725 && $taxableIncome > 510300)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 39475 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 510300)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 510300)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 510300)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 510300)
) {$span = 7;}
return $span;
}
if ($filingStatus == 2 || $filingStatus == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 19400) ||
(($taxableIncome - $taxableWinnings) > 19400 && $taxableIncome <= 78950) ||
(($taxableIncome - $taxableWinnings) > 78950&& $taxableIncome <= 168400) ||
(($taxableIncome - $taxableWinnings) > 168400 && $taxableIncome <= 321450) ||
(($taxableIncome - $taxableWinnings) > 321450 && $taxableIncome <= 408200) ||
(($taxableIncome - $taxableWinnings) > 408200 && $taxableIncome <= 612350) ||
($taxableIncome - $taxableWinnings) > 612350
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 19400) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19400 && $taxableIncome > 19400 && $taxableIncome <= 78950) ||
(($taxableIncome - $taxableWinnings) > 19400 && ($taxableIncome - $taxableWinnings) <= 78950 && $taxableIncome > 78950 && $taxableIncome <= 168400) ||
(($taxableIncome - $taxableWinnings) > 78950 && ($taxableIncome - $taxableWinnings) <= 168400 && $taxableIncome > 168400 && $taxableIncome <= 321450) ||
(($taxableIncome - $taxableWinnings) > 168400 && ($taxableIncome - $taxableWinnings) <= 321450 && $taxableIncome > 321450 && $taxableIncome <= 408200) ||
(($taxableIncome - $taxableWinnings) > 321450 && ($taxableIncome - $taxableWinnings) <= 408200 && $taxableIncome > 408200 && $taxableIncome <= 612350) ||
(($taxableIncome - $taxableWinnings) > 408200 && ($taxableIncome - $taxableWinnings) <= 612350 && $taxableIncome > 612350)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 19400 && $taxableIncome <= 78950) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19400 && $taxableIncome > 78950 && $taxableIncome <= 168400) ||
(($taxableIncome - $taxableWinnings) > 19400 && ($taxableIncome - $taxableWinnings) <= 78950 && $taxableIncome > 168400 && $taxableIncome <= 321450) ||
(($taxableIncome - $taxableWinnings) > 78950 && ($taxableIncome - $taxableWinnings) <= 168400 && $taxableIncome > 321450 && $taxableIncome <= 408200) ||
(($taxableIncome - $taxableWinnings) > 168400 && ($taxableIncome - $taxableWinnings) <= 321450 && $taxableIncome > 408200 && $taxableIncome <= 612350) ||
(($taxableIncome - $taxableWinnings) > 321450 && ($taxableIncome - $taxableWinnings) <= 408200 && $taxableIncome > 612350)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 78950 && $taxableIncome <= 168400) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19400 && $taxableIncome > 168400 && $taxableIncome <= 321450) ||
(($taxableIncome - $taxableWinnings) > 19400 && ($taxableIncome - $taxableWinnings) <= 78950 && $taxableIncome > 321450 && $taxableIncome <= 408200) ||
(($taxableIncome - $taxableWinnings) > 78950 && ($taxableIncome - $taxableWinnings) <= 168400 && $taxableIncome > 408200 && $taxableIncome <= 612350 ) ||
(($taxableIncome - $taxableWinnings) > 168400 && ($taxableIncome - $taxableWinnings) <= 321450 && $taxableIncome > 612350)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 168400 && $taxableIncome <= 321450) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19400 && $taxableIncome > 321450 && $taxableIncome <= 408200) ||
(($taxableIncome - $taxableWinnings) > 19400 && ($taxableIncome - $taxableWinnings) <= 78950 && $taxableIncome > 408200 && $taxableIncome <= 612350) ||
(($taxableIncome - $taxableWinnings) > 78950 && ($taxableIncome - $taxableWinnings) <= 168400 && $taxableIncome > 612350)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 321450 && $taxableIncome <= 408200) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19400 && $taxableIncome > 408200 && $taxableIncome <= 612350) ||
(($taxableIncome - $taxableWinnings) > 19400 && ($taxableIncome - $taxableWinnings) <= 78950 && $taxableIncome > 612350)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 408200 && $taxableIncome <= 612350) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 19400 && $taxableIncome > 612350)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 612350)
) {$span = 7;}
return $span;
}
if ($filingStatus == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9700) ||
(($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome <= 39475) ||
(($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 204100 && $taxableIncome <= 306175) ||
($taxableIncome - $taxableWinnings) > 306175
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9700) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 9700 && $taxableIncome <= 39475) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 39475 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 39475 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 84200 && ($taxableIncome - $taxableWinnings) <= 160725 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 160725 && ($taxableIncome - $taxableWinnings) <= 204100 && $taxableIncome > 204100 && $taxableIncome <= 306175) ||
(($taxableIncome - $taxableWinnings) > 204100 && ($taxableIncome - $taxableWinnings) <= 306175 && $taxableIncome > 306175)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9700 && $taxableIncome <= 39475) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 39475 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 39475 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 84200 && ($taxableIncome - $taxableWinnings) <= 160725 && $taxableIncome > 204100 && $taxableIncome <= 306175) ||
(($taxableIncome - $taxableWinnings) > 160725 && ($taxableIncome - $taxableWinnings) <= 204100 && $taxableIncome > 306175)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 39475 && $taxableIncome <= 84200 ) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 39475 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 204100 && $taxableIncome <= 306175) ||
(($taxableIncome - $taxableWinnings) > 84200 && ($taxableIncome - $taxableWinnings) <= 160725 && $taxableIncome > 306175)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 84200 && $taxableIncome <= 160725) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 204100 && $taxableIncome <= 306175) ||
(($taxableIncome - $taxableWinnings) > 39475 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 306175)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 160725 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 204100 && $taxableIncome <= 306175) ||
(($taxableIncome - $taxableWinnings) > 9700 && ($taxableIncome - $taxableWinnings) <= 39475 && $taxableIncome > 306175)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 204100 && $taxableIncome <= 306175) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 9700 && $taxableIncome > 306175)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 306175)
) {$span = 7;}
return $span;
}
if ($filingStatus == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome <= 0) {$span = 0;}
if (
(($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 13850) ||
(($taxableIncome - $taxableWinnings) > 13850 && $taxableIncome <= 52850) ||
(($taxableIncome - $taxableWinnings) > 52850 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome <= 160700) ||
(($taxableIncome - $taxableWinnings) > 160700 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 204100 && $taxableIncome <= 510300) ||
($taxableIncome - $taxableWinnings) > 510300
) {$span = 0;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 13850) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13850 && $taxableIncome > 13850 && $taxableIncome <= 52850) ||
(($taxableIncome - $taxableWinnings) > 13850 && ($taxableIncome - $taxableWinnings) <= 52850 && $taxableIncome > 52850 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 52850 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 84200 && $taxableIncome <= 160700) ||
(($taxableIncome - $taxableWinnings) > 84200 && ($taxableIncome - $taxableWinnings) <= 160700 && $taxableIncome > 160700 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 160700 && ($taxableIncome - $taxableWinnings) <= 204100 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 204100 && ($taxableIncome - $taxableWinnings) <= 510300 && $taxableIncome > 510300)
) {$span = 1;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 13850 && $taxableIncome <= 52850) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13850 && $taxableIncome > 52850 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 13850 && ($taxableIncome - $taxableWinnings) <= 52850 && $taxableIncome > 84200 && $taxableIncome <= 160700) ||
(($taxableIncome - $taxableWinnings) > 52850 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 160700 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 84200 && ($taxableIncome - $taxableWinnings) <= 160700 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 160700 && ($taxableIncome - $taxableWinnings) <= 204100 && $taxableIncome > 510300)
) {$span = 2;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 52850 && $taxableIncome <= 84200) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13850 && $taxableIncome > 84200 && $taxableIncome <= 160700) ||
(($taxableIncome - $taxableWinnings) > 13850 && ($taxableIncome - $taxableWinnings) <= 52850 && $taxableIncome > 160700 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 52850 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 84200 && ($taxableIncome - $taxableWinnings) <= 160700 && $taxableIncome > 510300)
) {$span = 3;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 84200 && $taxableIncome <= 160700) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13850 && $taxableIncome > 160700 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 13850 && ($taxableIncome - $taxableWinnings) <= 52850 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 52850 && ($taxableIncome - $taxableWinnings) <= 84200 && $taxableIncome > 510300)
) {$span = 4;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 160700 && $taxableIncome <= 204100) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13850 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 13850 && ($taxableIncome - $taxableWinnings) <= 52850 && $taxableIncome > 510300)
) {$span = 5;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 204100 && $taxableIncome <= 510300) ||
(($taxableIncome - $taxableWinnings) > 0 && ($taxableIncome - $taxableWinnings) <= 13850 && $taxableIncome > 510300)
) {$span = 6;}
elseif (
(($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 510300)
) {$span = 7;}
return $span;
}
}
/*
******************************************************************************************
* *
* Function: Span Calculator for Deductions 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 is taken before the computation of the tax on *
* gambling winnings. So the reduction in itemized deductions is also taken before the *
* tax on gambling winnings. *
* *
* The span begins at the level of taxable income excluding the taxable gambling *
* winnings. While that is conceptually the same as for the gambling winnings, the span *
* calulator for the gambling winnings does not allow the same for the phase-out. This *
* function adapts the span calculator for gambling winnings by assuring that the first *
* dollar of phase-out occurs in the same tax bracket of the dollar of 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 2019. *
* *
* This function takes 4 independent variables, the last of which is labelled *
* 'variable'. The tax value of the itemized deduction phase-out amount is computed *
* using the same functions as for the income tax of gambling winnings. The tax value *
* of the itemized deduction phase-out amount is represented by this fourth independent *
* variable. *
* *
* The span value is needed for both entities; the income tax on gambling winnings, the *
* itemized deduction phase-out. *
* *
******************************************************************************************
*/
function altspancalc($filingStatus, $taxableIncome, $taxableWinnings, $variable) {
$altTaxable = $taxableIncome - $taxableWinnings;
if ($filingStatus == 1) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 9700) ||
(($altTaxable - $variable) > 9700 && $altTaxable <= 39475) ||
(($altTaxable - $variable) > 39475 && $altTaxable <= 84200 ) ||
(($altTaxable - $variable) > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 204100 && $altTaxable <= 510300) ||
($altTaxable - $variable) > 510300
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9700) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 9700 && $altTaxable <= 39475) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 39475 && $altTaxable > 39475 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 39475 && ($altTaxable - $variable) <= 84200 && $altTaxable > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 84200 && ($altTaxable - $variable) <= 160725 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 160725 && ($altTaxable - $variable) <= 204100 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 204100 && ($altTaxable - $variable) <= 510300 && $altTaxable > 510300)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 9700 && $altTaxable <= 39475) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 39475 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 39475 && $altTaxable > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 39475 && ($altTaxable - $variable) <= 84200 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 84200 && ($altTaxable - $variable) <= 160725 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 160725 && ($altTaxable - $variable) <= 204100 && $altTaxable > 510300)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 39475 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 39475 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 39475 && ($altTaxable - $variable) <= 84200 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 84200 && ($altTaxable - $variable) <= 160725 && $altTaxable > 510300)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 39475 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 39475 && ($altTaxable - $variable) <= 84200 && $altTaxable > 510300)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 39475 && $altTaxable > 510300)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 510300)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 510300)
) {$span = 7;}
return $span;
}
if ($filingStatus == 2 || $filingStatus == 5) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 19400) ||
(($altTaxable - $variable) > 19400 && $altTaxable <= 78950) ||
(($altTaxable - $variable) > 78950 && $altTaxable <= 168400) ||
(($altTaxable - $variable) > 168400 && $altTaxable <= 321450) ||
(($altTaxable - $variable) > 321450 && $altTaxable <= 408200) ||
(($altTaxable - $variable) > 408200 && $altTaxable <= 612350) ||
($altTaxable - $variable) > 612350
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 19400) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19400 && $altTaxable > 19400 && $altTaxable <= 78950) ||
(($altTaxable - $variable) > 19400 && ($altTaxable - $variable) <= 78950 && $altTaxable > 78950 && $altTaxable <= 168400) ||
(($altTaxable - $variable) > 78950 && ($altTaxable - $variable) <= 168400 && $altTaxable > 168400 && $altTaxable <= 321450) ||
(($altTaxable - $variable) > 168400 && ($altTaxable - $variable) <= 321450 && $altTaxable > 321450 && $altTaxable <= 408200) ||
(($altTaxable - $variable) > 321450 && ($altTaxable - $variable) <= 408200 && $altTaxable > 408200 && $altTaxable <= 612350) ||
(($altTaxable - $variable) > 408200 && ($altTaxable - $variable) <= 612350 && $altTaxable > 612350)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 19400 && $altTaxable <= 78950) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19400 && $altTaxable > 78950 && $altTaxable <= 168400) ||
(($altTaxable - $variable) > 19400 && ($altTaxable - $variable) <= 78950 && $altTaxable > 168400 && $altTaxable <= 321450) ||
(($altTaxable - $variable) > 78950 && ($altTaxable - $variable) <= 168400 && $altTaxable > 321450 && $altTaxable <= 408200) ||
(($altTaxable - $variable) > 168400 && ($altTaxable - $variable) <= 321450 && $altTaxable > 408200 && $altTaxable <= 612350) ||
(($altTaxable - $variable) > 321450 && ($altTaxable - $variable) <= 408200 && $altTaxable > 612350)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 78950 && $altTaxable <= 168400) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19400 && $altTaxable > 168400 && $altTaxable <= 321450) ||
(($altTaxable - $variable) > 19400 && ($altTaxable - $variable) <= 78950 && $altTaxable > 321450 && $altTaxable <= 408200) ||
(($altTaxable - $variable) > 78950 && ($altTaxable - $variable) <= 168400 && $altTaxable > 408200 && $altTaxable <= 612350) ||
(($altTaxable - $variable) > 168400 && ($altTaxable - $variable) <= 321450 && $altTaxable > 612350)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 168400 && $altTaxable <= 321450) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19400 && $altTaxable > 321450 && $altTaxable <= 408200) ||
(($altTaxable - $variable) > 19400 && ($altTaxable - $variable) <= 78950 && $altTaxable > 408200 && $altTaxable <= 612350) ||
(($altTaxable - $variable) > 78950 && ($altTaxable - $variable) <= 168400 && $altTaxable > 612350)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 321450 && $altTaxable <= 408200) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19400 && $altTaxable > 408200 && $altTaxable <= 612350) ||
(($altTaxable - $variable) > 19400 && ($altTaxable - $variable) <= 78950 && $altTaxable > 612350)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 408200 && $altTaxable <= 612350) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 19400 && $altTaxable > 612350)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 612350)
) {$span = 7;}
return $span;
}
if ($filingStatus == 3) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 9700) ||
(($altTaxable - $variable) > 9700 && $altTaxable <= 39475) ||
(($altTaxable - $variable) > 39475 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 204100 && $altTaxable <= 306175) ||
($altTaxable - $variable) > 306175
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9700) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 9700 && $altTaxable <= 39475) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 39475 && $altTaxable > 39475 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 39475 && ($altTaxable - $variable) <= 84200 && $altTaxable > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 84200 && ($altTaxable - $variable) <= 160725 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 160725 && ($altTaxable - $variable) <= 204100 && $altTaxable > 204100 && $altTaxable <= 306175) ||
(($altTaxable - $variable) > 204100 && ($altTaxable - $variable) <= 306175 && $altTaxable > 306175)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 9700 && $altTaxable <= 39475) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 39475 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 37950 && $altTaxable > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 39475 && ($altTaxable - $variable) <= 84200 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 84200 && ($altTaxable - $variable) <= 160725 && $altTaxable > 204100 && $altTaxable <= 306175) ||
(($altTaxable - $variable) > 160725 && ($altTaxable - $variable) <= 204100 && $altTaxable > 306175)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 39475 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 39475 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 39475 && ($altTaxable - $variable) <= 84200 && $altTaxable > 204100 && $altTaxable <= 306175) ||
(($altTaxable - $variable) > 84200 && ($altTaxable - $variable) <= 160725 && $altTaxable > 306175)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 84200 && $altTaxable <= 160725) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 39475 && $altTaxable > 204100 && $altTaxable <= 306175) ||
(($altTaxable - $variable) > 39475 && ($altTaxable - $variable) <= 84200 && $altTaxable > 306175)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 160725 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 204100 && $altTaxable <= 306175) ||
(($altTaxable - $variable) > 9700 && ($altTaxable - $variable) <= 39475 && $altTaxable > 306175)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 204100 && $altTaxable <= 306175) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 9700 && $altTaxable > 306175)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 306175)
) {$span = 7;}
return $span;
}
if ($filingStatus == 4) {
if (
(($altTaxable - $variable) > 0 && $altTaxable <= 13850) ||
(($altTaxable - $variable) > 13850 && $altTaxable <= 52850) ||
(($altTaxable - $variable) > 52850 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 84200 && $altTaxable <= 160700) ||
(($altTaxable - $variable) > 160700 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 204100 && $altTaxable <= 510300) ||
($altTaxable - $variable) > 510300
) {$span = 0;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 13850) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13850 && $altTaxable > 13850 && $altTaxable <= 52850) ||
(($altTaxable - $variable) > 13850 && ($altTaxable - $variable) <= 52850 && $altTaxable > 52850 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 52850 && ($altTaxable - $variable) <= 84200 && $altTaxable > 84200 && $altTaxable <= 160700) ||
(($altTaxable - $variable) > 84200 && ($altTaxable - $variable) <= 160700 && $altTaxable > 160700 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 160700 && ($altTaxable - $variable) <= 204100 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 204100 && ($altTaxable - $variable) <= 510300 && $altTaxable > 510300)
) {$span = 1;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 13850 && $altTaxable <= 52850) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13850 && $altTaxable > 52850 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 13850 && ($altTaxable - $variable) <= 52850 && $altTaxable > 84200 && $altTaxable <= 160700) ||
(($altTaxable - $variable) > 52850 && ($altTaxable - $variable) <= 84200 && $altTaxable > 160700 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 84200 && ($altTaxable - $variable) <= 160700 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 160700 && ($altTaxable - $variable) <= 204100 && $altTaxable > 510300)
) {$span = 2;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 52850 && $altTaxable <= 84200) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13850 && $altTaxable > 84200 && $altTaxable <= 160700) ||
(($altTaxable - $variable) > 13850 && ($altTaxable - $variable) <= 52850 && $altTaxable > 160700 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 52850 && ($altTaxable - $variable) <= 84200 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 84200 && ($altTaxable - $variable) <= 160700 && $altTaxable > 510300)
) {$span = 3;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 84200 && $altTaxable <= 160700) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13850 && $altTaxable > 160700 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 13850 && ($altTaxable - $variable) <= 52850 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 52850 && ($altTaxable - $variable) <= 84200 && $altTaxable > 510300)
) {$span = 4;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 160700 && $altTaxable <= 204100) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13850 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 13850 && ($altTaxable - $variable) <= 52850 && $altTaxable > 510300)
) {$span = 5;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 204100 && $altTaxable <= 510300) ||
(($altTaxable - $variable) > 0 && ($altTaxable - $variable) <= 13850 && $altTaxable > 510300)
) {$span = 6;}
elseif (
(($altTaxable - $variable) <= 0 && $altTaxable > 510300)
) {$span = 7;}
return $span;
}
}
/*
******************************************************************************************
* *
* Function: Income Tax Calculator *
* *
* *
* This function computes the income tax on gambling income. The code is *
* straightforward, but some explanation will be provided anyway. *
* *
* When the span value is zero, meaning the gambling winnings upon which tax is to be *
* paid falls into one tax bracket in its entirety, the income tax on the winnings is *
* the tax rate of that bracket times the amount of the taxable winnings. *
* *
* When the span value is one, it means the gambling winnings upon which tax is to be *
* paid falls partly into one tax bracket and the remainder into the next higher *
* bracket. The income tax on the winnings is the tax rate of the first, or lower, *
* bracket times the amount of the taxable winnings that falls into that bracket, plus *
* the tax rate of the second, or higher, bracket times the remainder of the winnings *
* that falls into it. *
* *
* When the span value is greater than one, it means the gambling winnings upon which *
* tax is to be paid falls partly into one tax bracket, the lowest, partly into one or *
* more middle brackets, and the remainder into the last, the highest bracket. The *
* income tax on the winnings is the tax rate of the lowest bracket, times the amount *
* of the taxable winnings that falls into that bracket. Plus the tax rate of the first *
* middle bracket times the income span of that bracket. Plus the tax rate of the *
* second middle bracket, if any, times the income span of that bracket. And so on, *
* until all the middle brackets are exhausted. Plus the tax rate of the highest *
* bracket times the remainder of the winnings that falls into it. *
* *
* There are, again different tax brackets for each filing status. Again, the exception *
* is "Married - Jointly" and "Qualified Widow(er)" which have the same tax brackets *
* in 2019. *
* *
******************************************************************************************
*/
function taxcalc($span, $filingStatus, $taxableIncome, $taxableWinnings) {
if ($filingStatus == 1) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9700) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome <= 39475) {$tax = 0.12 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome <= 84200) {$tax = 0.22 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome <= 160725) {$tax = 0.24 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 160725 && $taxableIncome <= 204100) {$tax = 0.32 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 204100 && $taxableIncome <= 510300) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 510300) {$tax = 0.37 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9700)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9700 && $taxableIncome <= 39475)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 0.12 * ($taxableIncome - 9700);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 39475 && $taxableIncome <= 84200)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 0.22 * ($taxableIncome - 39475);}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome > 84200 && $taxableIncome <= 160725)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 0.24 * ($taxableIncome - 84200 );}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 0.24 * (160725 - ($taxableIncome - $taxableWinnings)) + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 160725 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.32 * (204100 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 510300 && $taxableIncome > 510300)
{$tax = 0.35 * (510300 - ($taxableIncome - $taxableWinnings)) + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9700 && $taxableIncome <= 39475)
{$tax = 970 + 0.12 * ($taxableIncome - 9700);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9700 && $taxableIncome <= 84200)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 0.22 * ($taxableIncome - 39475);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 84200 && $taxableIncome <= 160725)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 9839.5 + 0.24 * ($taxableIncome - 84200 );}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 18366 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.24 * (160725 - ($taxableIncome - $taxableWinnings)) + 13880 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 160725 && $taxableIncome > 510300)
{$tax = 0.32 * (204100 - ($taxableIncome - $taxableWinnings)) + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 39475 && $taxableIncome <= 84200)
{$tax = 970 + 9839.5 + 0.22 * ($taxableIncome - 39475);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 84200 && $taxableIncome <= 160725)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 9839.5 + 0.24 * ($taxableIncome - 84200);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 9839.5 + 18366 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 18366 + 13880 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome > 510300)
{$tax = 0.24 * (160725 - ($taxableIncome - $taxableWinnings)) + 74266.5 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 84200 && $taxableIncome <= 160725)
{$tax = 970 + 3573 + 9839.5 + 0.24 * ($taxableIncome - 84200);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 9839.5 + 18366 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 9839.5 + 18366 + 13880 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome > 510300)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 18366 + 13880 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 970 + 3573 + 9839.5 + 18366 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 9839.5 + 18366 + 13880 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 510300)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 9839.5 + 18366 + 13880 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 970 + 3573 + 9839.5 + 18366 + 13880 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 510300)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 9839.5 + 18366 + 13880 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 510300)
{$tax = 970 + 3573 + 9839.5 + 18366 + 13880 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
}
if ($filingStatus == 2 || $filingStatus == 5) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 19400) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 19400 && $taxableIncome <= 78950) {$tax = 0.12 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 78950 && $taxableIncome <= 168400) {$tax = 0.22 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 168400 && $taxableIncome <= 321450) {$tax = 0.24 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 321450 && $taxableIncome <= 408200) {$tax = 0.32 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 408200 && $taxableIncome <= 612350) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 612350) {$tax = 0.37 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 19400)
{$tax = 0.10 * $taxableIncome; }
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 19400 && $taxableIncome <= 78950)
{$tax = 0.10 * (19400 - ($taxableIncome - $taxableWinnings)) + 0.12 * ($taxableIncome - 19400);}
elseif (($taxableIncome - $taxableWinnings) > 19400 && $taxableIncome > 78950 && $taxableIncome <= 168400)
{$tax = 0.12 * (78950 - ($taxableIncome - $taxableWinnings)) + 0.22 * ($taxableIncome - 78950);}
elseif (($taxableIncome - $taxableWinnings) > 78950 && $taxableIncome > 168400 && $taxableIncome <= 321450)
{$tax = 0.22 * (168400 - ($taxableIncome - $taxableWinnings)) + 0.24 * ($taxableIncome - 168400);}
elseif (($taxableIncome - $taxableWinnings) > 168400 && $taxableIncome > 321450 && $taxableIncome <= 408200)
{$tax = 0.24 * (321450 - ($taxableIncome - $taxableWinnings)) + 0.32 * ($taxableIncome - 321450);}
elseif (($taxableIncome - $taxableWinnings) > 321450 && $taxableIncome > 408200 && $taxableIncome <= 612350)
{$tax = 0.32 * (408200 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 408200);}
elseif (($taxableIncome - $taxableWinnings) > 408200 && $taxableIncome > 612350 )
{$tax = 0.35 * (612350 - ($taxableIncome - $taxableWinnings)) + 0.37 * ($taxableIncome - 612350);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 19400 && $taxableIncome <= 78950)
{$tax = 1940 + 0.12 * ($taxableIncome - 19400);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 19400 && $taxableIncome <= 168400)
{$tax = 0.10 * (19400 - ($taxableIncome - $taxableWinnings)) + 7146 + 0.22 * ($taxableIncome - 78950);}
elseif (($taxableIncome - $taxableWinnings) > 19400 && $taxableIncome > 168400 && $taxableIncome <= 321450)
{$tax = 0.12 * (78950 - ($taxableIncome - $taxableWinnings)) + 19679 + 0.24 * ($taxableIncome - 168400 );}
elseif (($taxableIncome - $taxableWinnings) > 78950 && $taxableIncome > 321450 && $taxableIncome <= 408200)
{$tax = 0.22 * (168400 - ($taxableIncome - $taxableWinnings)) + 36732 + 0.32 * ($taxableIncome - 321450);}
elseif (($taxableIncome - $taxableWinnings) > 168400 && $taxableIncome > 408200 && $taxableIncome <= 612350)
{$tax = 0.24 * (321450 - ($taxableIncome - $taxableWinnings)) + 27760 + 0.35 * ($taxableIncome - 408200);}
elseif (($taxableIncome - $taxableWinnings) > 321450 && $taxableIncome > 612350)
{$tax = 0.32 * (408200 - ($taxableIncome - $taxableWinnings)) + 71452.5 + 0.37 * ($taxableIncome - 612350 );}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 78950 && $taxableIncome <= 168400)
{$tax = 1940 + 7146 + 0.22 * ($taxableIncome - 78950);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 168400 && $taxableIncome <= 321450)
{$tax = 0.10 * (19400 - ($taxableIncome - $taxableWinnings)) + 7146 + 19679 + 0.24 * ($taxableIncome - 168400);}
elseif (($taxableIncome - $taxableWinnings) > 19400 && $taxableIncome > 321450 && $taxableIncome <= 408200)
{$tax = 0.12 * (78950 - ($taxableIncome - $taxableWinnings)) + 19679 + 36732 + 0.32 * ($taxableIncome - 321450);}
elseif (($taxableIncome - $taxableWinnings) > 78950 && $taxableIncome > 408200 && $taxableIncome <= 612350)
{$tax = 0.22 * (168400 - ($taxableIncome - $taxableWinnings)) + 36732 + 27760 + 0.35 * ($taxableIncome - 408200);}
elseif (($taxableIncome - $taxableWinnings) > 168400 && $taxableIncome > 612350)
{$tax = 0.24 * (321450 - ($taxableIncome - $taxableWinnings)) + 27760 + 71452.5 + 0.37 * ($taxableIncome - 612350);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 168400 && $taxableIncome <= 321450)
{$tax = 1940 + 7146 + 19679 + 0.24 * ($taxableIncome - 168400);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 321450 && $taxableIncome <= 408200)
{$tax = 0.10 * (19400 - ($taxableIncome - $taxableWinnings)) + 7146 + 19679 + 36732 + 0.32 * ($taxableIncome - 321450);}
elseif (($taxableIncome - $taxableWinnings) > 19400 && $taxableIncome > 408200 && $taxableIncome <= 612350)
{$tax = 0.12 * (78950 - ($taxableIncome - $taxableWinnings)) + 19679 + 36732 + 27760 + 0.35 * ($taxableIncome - 408200);}
elseif (($taxableIncome - $taxableWinnings) > 78950 && $taxableIncome > 612350)
{$tax = 0.22 * (168400 - ($taxableIncome - $taxableWinnings)) + 36732 + 27760 + 71452.5 + 0.37 * ($taxableIncome - 612350 );}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 321450 && $taxableIncome <= 408200)
{$tax = 1940 + 7146 + 19679 + 36732 + 0.32 * ($taxableIncome - 321450);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 408200 && $taxableIncome <= 612350)
{$tax = 0.10 * (19400 - ($taxableIncome - $taxableWinnings)) + 7146 + 19679 + 36732 + 27760 + 0.35 * ($taxableIncome - 408200);}
elseif (($taxableIncome - $taxableWinnings) > 19400 && $taxableIncome > 612350)
{$tax = 0.12 * (78950 - ($taxableIncome - $taxableWinnings)) + 19679 + 36732 + 27760 + 71452.5 + 0.37 * ($taxableIncome - 612350);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 408200 && $taxableIncome <= 612350)
{$tax = 1940 + 7146 + 19679 + 36732 + 27760 + 0.35 * ($taxableIncome - 408200);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 612350)
{$tax = 0.10 * (19400 - ($taxableIncome - $taxableWinnings)) + 7146 + 19679 + 36732 + 27760 + 71452.5 + 0.37 * ($taxableIncome - 612350);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 612350)
{$tax = 1940 + 7146 + 19679 + 36732 + 27760 + 71452.5 + 0.37 * ($taxableIncome - 612350);}
return $tax;
}
}
if ($filingStatus == 3) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 9700) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome <= 39475) {$tax = 0.12 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome <= 84200 ) {$tax = 0.22 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome <= 160725) {$tax = 0.24 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 160725 && $taxableIncome <= 204100) {$tax = 0.32 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 204100 && $taxableIncome <= 306175) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 306175) {$tax = 0.37 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 9700)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9700 && $taxableIncome <= 39475)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 0.12 * ($taxableIncome - 9700);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 39475 && $taxableIncome <= 84200)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 0.22 * ($taxableIncome - 39475);}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome > 84200 & $taxableIncome <= 160725)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 0.24 * ($taxableIncome - 84200 );}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 0.24 * (160725 - ($taxableIncome - $taxableWinnings)) + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 160725 && $taxableIncome > 204100 && $taxableIncome <= 306175)
{$tax = 0.32 * (204100 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 306175 && $taxableIncome > 306175)
{$tax = 0.35 * (306175 - ($taxableIncome - $taxableWinnings)) + 0.37 * ($taxableIncome - 306175);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 9700 && $taxableIncome <= 39475)
{$tax = 970 + 0.12 * ($taxableIncome - 9700);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 9700 && $taxableIncome <= 84200)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 0.22 * ($taxableIncome - 39475);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 84200 && $taxableIncome <= 160725)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 9839.5 + 0.24 * ($taxableIncome - 84200);}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 18366 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome > 204100 && $taxableIncome <= 306175)
{$tax = 0.24 * (160725 - ($taxableIncome - $taxableWinnings)) + 13880 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 160725 && $taxableIncome > 306175)
{$tax = 0.32 * (204100 - ($taxableIncome - $taxableWinnings)) + 35726.25 + 0.37 * ($taxableIncome - 306175);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 39475 && $taxableIncome <= 84200)
{$tax = 970 + 3573 + 0.22 * ($taxableIncome - 39475);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 84200 && $taxableIncome <= 160725)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 9839.5 + 0.24 * ($taxableIncome - 84200);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 9839.5 + 18366 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome > 204100 && $taxableIncome <= 306175)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 18366 + 13880 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome > 306175)
{$tax = 0.24 * (160725 - ($taxableIncome - $taxableWinnings)) + 13880 + 35726.25 + 0.37 * ($taxableIncome - 306175);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 84200 && $taxableIncome <= 160725)
{$tax = 970 + 3573 + 9839.5 + 0.24 * ($taxableIncome - 84200);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 9839.5 + 18366 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 204100 && $taxableIncome <= 306175)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 9839.5 + 18366 + 13880 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 39475 && $taxableIncome > 306175)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 18366 + 13880 + 35726.25 + 0.37 * ($taxableIncome - 306175);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 160725 && $taxableIncome <= 204100)
{$tax = 970 + 3573 + 9839.5 + 18366 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 204100 && $taxableIncome <= 306175)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 9839.5 + 18366 + 13880 + 0.32 * ($taxableIncome - 160725);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 306175)
{$tax = 0.12 * (39475 - ($taxableIncome - $taxableWinnings)) + 9839.5 + 18366 + 13880 + 35726.25 + 0.37 * ($taxableIncome - 306175);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 204100 && $taxableIncome <= 306175)
{$tax = 970 + 3573 + 9839.5 + 18366 + 13880 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 306175)
{$tax = 0.10 * (9700 - ($taxableIncome - $taxableWinnings)) + 3573 + 9839.5 + 18366 + 13880 + 35726.25 + 0.37 * ($taxableIncome - 306175);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 306175)
{$tax = 970 + 3573 + 9839.5 + 18366 + 13880 + 35726.25 + 0.37 * ($taxableIncome - 306175);}
return $tax;
}
}
if ($filingStatus == 4) {
if ($span == 0) {
if ($taxableIncome <= 0) {$tax = 0;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome <= 13850) {$tax = 0.10 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 13850 && $taxableIncome <= 52850) {$tax = 0.12 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 52850 && $taxableIncome <= 84200) {$tax = 0.22 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome <= 160700) {$tax = 0.24 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 160700 && $taxableIncome <= 204100) {$tax = 0.32 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 204100 && $taxableIncome <= 510300) {$tax = 0.35 * $taxableWinnings;}
elseif (($taxableIncome - $taxableWinnings) > 510300) {$tax = 0.37 * $taxableWinnings;}
return $tax;
}
if ($span == 1) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 0 && $taxableIncome <= 13850)
{$tax = 0.10 * $taxableIncome;}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 13850 && $taxableIncome <= 52850)
{$tax = 0.10 * (13850- ($taxableIncome - $taxableWinnings)) + 0.12 * ($taxableIncome - 13850);}
elseif (($taxableIncome - $taxableWinnings) > 13850 && $taxableIncome > 52850 && $taxableIncome <= 84200)
{$tax = 0.12 * (52850 - ($taxableIncome - $taxableWinnings)) + 0.22 * ($taxableIncome - 52850);}
elseif (($taxableIncome - $taxableWinnings) > 52850 && $taxableIncome > 84200 && $taxableIncome <= 160700)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 0.24 * ($taxableIncome - 84200);}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome > 160700 && $taxableIncome <= 204100)
{$tax = 0.24 * (160700 - ($taxableIncome - $taxableWinnings)) + 0.32 * ($taxableIncome - 160700);}
elseif (($taxableIncome - $taxableWinnings) > 160700 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.32 * (204100 - ($taxableIncome - $taxableWinnings)) + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 204100 && $taxableIncome > 510300)
{$tax = 0.35 * (510300 - ($taxableIncome - $taxableWinnings)) + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 2) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 13888 && $taxableIncome <= 52850)
{$tax = 1385 + 0.12 * ($taxableIncome - 13888);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 52850 && $taxableIncome <= 84200)
{$tax = 0.10 * (13850- ($taxableIncome - $taxableWinnings)) + 4680 + 0.22 * ($taxableIncome - 52850);}
elseif (($taxableIncome - $taxableWinnings) > 13888 && $taxableIncome > 84200 && $taxableIncome <= 160700)
{$tax = 0.12 * (52850 - ($taxableIncome - $taxableWinnings)) + 6897 + 0.24 * ($taxableIncome - 84200);}
elseif (($taxableIncome - $taxableWinnings) > 52850 && $taxableIncome > 160700 && $taxableIncome <= 204100)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 18360 + 0.32 * ($taxableIncome - 160700);}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.24 * (160700 - ($taxableIncome - $taxableWinnings)) + 13888 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 204100 && $taxableIncome > 510300)
{$tax = 0.32 * (204100 - ($taxableIncome - $taxableWinnings)) + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 3) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 52850 && $taxableIncome <= 84200)
{$tax = 1385 + 4680 + 0.22 * ($taxableIncome - 52850);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 84200 && $taxableIncome <= 160700)
{$tax = 0.10 * (13850- ($taxableIncome - $taxableWinnings)) + 4680 + 6897 + 0.24 * ($taxableIncome - 84200);}
elseif (($taxableIncome - $taxableWinnings) > 9700 && $taxableIncome > 160700 && $taxableIncome <= 204100)
{$tax = 0.12 * (52850 - ($taxableIncome - $taxableWinnings)) + 6897 + 18360 + 0.32 * ($taxableIncome - 160700);}
elseif (($taxableIncome - $taxableWinnings) > 52850 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 18360 + 13888 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 84200 && $taxableIncome > 510300)
{$tax = 0.24 * (160700 - ($taxableIncome - $taxableWinnings)) + 13888 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 4) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 84200 && $taxableIncome <= 160700)
{$tax = 1385 + 4680 + 6897 + 0.24 * ($taxableIncome - 84200);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 160700 && $taxableIncome <= 204100)
{$tax = 0.10 * (13850- ($taxableIncome - $taxableWinnings)) + 4680 + 6897 + 18360 + 0.32 * ($taxableIncome - 160700);}
elseif (($taxableIncome - $taxableWinnings) > 13888 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.12 * (52850 - ($taxableIncome - $taxableWinnings)) + 6897 + 18360 + 13888 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 52850 && $taxableIncome > 510300)
{$tax = 0.22 * (84200 - ($taxableIncome - $taxableWinnings)) + 18360 + 13888 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 5) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 160700 && $taxableIncome <= 204100)
{$tax = 1385 + 4680 + 6897 + 18360 + 0.32 * ($taxableIncome - 160700);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 0.10 * (13850- ($taxableIncome - $taxableWinnings)) + 4680 + 6897 + 18360 + 13888 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 13888 && $taxableIncome > 510300)
{$tax = 0.12 * (52850 - ($taxableIncome - $taxableWinnings)) + 6897 + 18360 + 13888 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 6) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 204100 && $taxableIncome <= 510300)
{$tax = 1385 + 4680 + 6897 + 18360 + 13888 + 0.35 * ($taxableIncome - 204100);}
elseif (($taxableIncome - $taxableWinnings) > 0 && $taxableIncome > 510300)
{$tax = 0.10 * (13850 - ($taxableIncome - $taxableWinnings)) + 4680 + 6897 + 18360 + 13888 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
if ($span == 7) {
if (($taxableIncome - $taxableWinnings) <= 0 && $taxableIncome > 510300)
{$tax = 1385 + 4680 + 6897 + 18360 + 13888 + 107170 + 0.37 * ($taxableIncome - 510300);}
return $tax;
}
}
}
/*
******************************************************************************************
* *
* Function: Income Tax Calculator for the Deductions 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 same tax *
* bracket of last dollar of non-gambling taxable income. *
* *
* When the span value is greater than one, it means the phase-out amount, upon which a *
* tax effect is to be computed, falls partly into one tax bracket, the lowest, partly *
* into one or more middle brackets, and the remainder into the last, the highest *
* bracket. The income tax on the phase-out amount is the tax rate of the lowest *
* bracket, times the amount of the phase-out that falls into that bracket. Plus the *
* tax rate of the first middle bracket times the income span of that bracket. Plus *
* the tax rate of the second middle bracket, if any, times the income span of that *
* bracket. And so on, until the middle brackets are exhausted. Plus the tax rate of *
* the highest bracket times the remainder of the winnings that falls into it. *
* *
* There are, again different tax brackets for each filing status. Again, the exception *
* is "Married - Jointly" and "Qualified Widow(er)" which have the same tax brackets *
* in 2019. *
* *
* 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 <= 9700) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 9700 && $altTaxable <= 39475) {$tax = 0.12 * $variable;}
elseif (($altTaxable - $variable) > 39475 && $altTaxable <= 84200 ) {$tax = 0.22 * $variable;}
elseif (($altTaxable - $variable) > 84200 && $altTaxable <= 160725) {$tax = 0.24 * $variable;}
elseif (($altTaxable - $variable) > 160725 && $altTaxable <= 204100) {$tax = 0.32 * $variable;}
elseif (($altTaxable - $variable) > 204100 && $altTaxable <= 510300) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 510300) {$tax = 0.37 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9700)
{$tax = 0.10 * $altTaxable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9700 && $altTaxable <= 39475)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 0.12 * ($altTaxable - 9700);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 39475 && $altTaxable <= 84200)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 0.22 * ($altTaxable - 39475);}
elseif (($altTaxable - $variable) > 39475 && $altTaxable > 84200 && $altTaxable <= 160725)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 0.24 * ($altTaxable - 84200 );}
elseif (($altTaxable - $variable) > 84200 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 0.24 * (160725 - ($altTaxable - $variable)) + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 160725 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.32 * (204100 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 510300 && $altTaxable > 510300)
{$tax = 0.35 * (510300 - ($altTaxable - $variable)) + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 9700 && $altTaxable <= 39475)
{$tax = 970 + 0.12 * ($altTaxable - 9700);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9700 && $altTaxable <= 84200)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 0.22 * ($altTaxable - 39475);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 84200 && $altTaxable <= 160725)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 9839.5 + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 39475 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 18366 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 84200 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.24 * (160725 - ($altTaxable - $variable)) + 13880 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 160725 && $altTaxable > 510300)
{$tax = 0.32 * (204100 - ($altTaxable - $variable)) + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 39475 && $altTaxable <= 84200)
{$tax = 970 + 3573 + 0.22 * ($altTaxable - 39475);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 84200 && $altTaxable <= 160725)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 9839.5 + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 9839.5 + 18366 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 39475 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 18366 + 13880 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 84200 && $altTaxable > 510300)
{$tax = 0.24 * (160725 - ($altTaxable - $variable)) + 74266.5 + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 84200 && $altTaxable <= 160725)
{$tax = 970 + 3573 + 9839.5 + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 9839.5 + 18366 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 9839.5 + 18366 + 13880 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 39475 && $altTaxable > 510300)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 18366 + 13880 + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 970 + 3573 + 9839.5 + 18366 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 9839.5 + 18366 + 13880 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 510300)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 9839.5 + 18366 + 13880 + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 970 + 3573 + 9839.5 + 18366 + 13880 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 510300)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 9839.5 + 18366 + 13880 + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 510300)
{$tax = 970 + 3573 + 9839.5 + 18366 + 13880 + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
}
if ($filingStatus == 2 || $filingStatus == 5) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 19400) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 19400 && $altTaxable <= 78950) {$tax = 0.12 * $variable;}
elseif (($altTaxable - $variable) > 78950 && $altTaxable <= 168400) {$tax = 0.22 * $variable;}
elseif (($altTaxable - $variable) > 168400 && $altTaxable <= 321450) {$tax = 0.24 * $variable;}
elseif (($altTaxable - $variable) > 321450 && $altTaxable <= 408200) {$tax = 0.32 * $variable;}
elseif (($altTaxable - $variable) > 408200 && $altTaxable <= 612350) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 612350) {$tax = 0.37 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 19400)
{$tax = 0.10 * $altTaxable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 19400 && $altTaxable <= 78950)
{$tax = 0.10 * (19400 - ($altTaxable - $variable)) + 0.12 * ($altTaxable - 19400);}
elseif (($altTaxable - $variable) > 19400 && $altTaxable > 78950 && $altTaxable <= 168400)
{$tax = 0.12 * (78950 - ($altTaxable - $variable)) + 0.22 * ($altTaxable - 78950);}
elseif (($altTaxable - $variable) > 78950 && $altTaxable > 168400 && $altTaxable <= 321450)
{$tax = 0.22 * (168400 - ($altTaxable - $variable)) + 0.24 * ($altTaxable - 168400);}
elseif (($altTaxable - $variable) > 168400 && $altTaxable > 321450 && $altTaxable <= 408200)
{$tax = 0.24 * (321450 - ($altTaxable - $variable)) + 0.32 * ($altTaxable - 321450);}
elseif (($altTaxable - $variable) > 321450 && $altTaxable > 408200 && $altTaxable <= 612350)
{$tax = 0.32 * (408200 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 408200);}
elseif (($altTaxable - $variable) > 408200 && $altTaxable > 612350 )
{$tax = 0.35 * (612350 - ($altTaxable - $variable)) + 0.37 * ($altTaxable - 612350);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 19400 && $altTaxable <= 78950)
{$tax = 1940 + 0.12 * ($altTaxable - 19400);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 19400 && $altTaxable <= 168400)
{$tax = 0.10 * (19400 - ($altTaxable - $variable)) + 7146 + 0.22 * ($altTaxable - 78950);}
elseif (($altTaxable - $variable) > 19400 && $altTaxable > 168400 && $altTaxable <= 321450)
{$tax = 0.12 * (78950 - ($altTaxable - $variable)) + 19679 + 0.24 * ($altTaxable - 168400 );}
elseif (($altTaxable - $variable) > 78950 && $altTaxable > 321450 && $altTaxable <= 408200)
{$tax = 0.22 * (168400 - ($altTaxable - $variable)) + 36732 + 0.32 * ($altTaxable - 321450);}
elseif (($altTaxable - $variable) > 168400 && $altTaxable > 408200 && $altTaxable <= 612350)
{$tax = 0.24 * (321450 - ($altTaxable - $variable)) + 27760 + 0.35 * ($altTaxable - 408200);}
elseif (($altTaxable - $variable) > 321450 && $altTaxable > 612350)
{$tax = 0.32 * (408200 - ($altTaxable - $variable)) + 71452.5 + 0.37 * ($altTaxable - 612350 );}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 78950 && $altTaxable <= 168400)
{$tax = 1940 + 7146 + 0.22 * ($altTaxable - 78950);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 168400 && $altTaxable <= 321450)
{$tax = 0.10 * (19400 - ($altTaxable - $variable)) + 7146 + 19679 + 0.24 * ($altTaxable - 168400);}
elseif (($altTaxable - $variable) > 19400 && $altTaxable > 321450 && $altTaxable <= 408200)
{$tax = 0.12 * (78950 - ($altTaxable - $variable)) + 19679 + 36732 + 0.32 * ($altTaxable - 321450);}
elseif (($altTaxable - $variable) > 78950 && $altTaxable > 408200 && $altTaxable <= 612350)
{$tax = 0.22 * (168400 - ($altTaxable - $variable)) + 36732 + 27760 + 0.35 * ($altTaxable - 408200);}
elseif (($altTaxable - $variable) > 168400 && $altTaxable > 612350)
{$tax = 0.24 * (321450 - ($altTaxable - $variable)) + 27760 + 71452.5 + 0.37 * ($altTaxable - 612350);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 168400 && $altTaxable <= 321450)
{$tax = 1940 + 7146 + 19679 + 0.24 * ($altTaxable - 168400);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 321450 && $altTaxable <= 408200)
{$tax = 0.10 * (19400 - ($altTaxable - $variable)) + 7146 + 19679 + 36732 + 0.32 * ($altTaxable - 321450);}
elseif (($altTaxable - $variable) > 19400 && $altTaxable > 408200 && $altTaxable <= 612350)
{$tax = 0.12 * (78950 - ($altTaxable - $variable)) + 19679 + 36732 + 27760 + 0.35 * ($altTaxable - 408200);}
elseif (($altTaxable - $variable) > 78950 && $altTaxable > 612350)
{$tax = 0.22 * (168400 - ($altTaxable - $variable)) + 36732 + 27760 + 71452.5 + 0.37 * ($altTaxable - 612350 );}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 321450 && $altTaxable <= 408200)
{$tax = 1940 + 7146 + 19679 + 36732 + 0.32 * ($altTaxable - 321450);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 408200 && $altTaxable <= 612350)
{$tax = 0.10 * (19400 - ($altTaxable - $variable)) + 7146 + 19679 + 36732 + 27760 + 0.35 * ($altTaxable - 408200);}
elseif (($altTaxable - $variable) > 19400 && $altTaxable > 612350)
{$tax = 0.12 * (78950 - ($altTaxable - $variable)) + 19679 + 36732 + 27760 + 71452.5 + 0.37 * ($altTaxable - 612350);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 408200 && $altTaxable <= 612350)
{$tax = 1940 + 7146 + 19679 + 36732 + 27760 + 0.35 * ($altTaxable - 408200);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 612350)
{$tax = 0.10 * (19400 - ($altTaxable - $variable)) + 7146 + 19679 + 36732 + 27760 + 71452.5 + 0.37 * ($altTaxable - 612350);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 612350)
{$tax = 1940 + 7146 + 19679 + 36732 + 27760 + 71452.5 + 0.37 * ($altTaxable - 612350);}
return $tax;
}
}
if ($filingStatus == 3) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 9700) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 9700 && $altTaxable <= 39475) {$tax = 0.12 * $variable;}
elseif (($altTaxable - $variable) > 39475 && $altTaxable <= 84200 ) {$tax = 0.22 * $variable;}
elseif (($altTaxable - $variable) > 84200 && $altTaxable <= 160725) {$tax = 0.24 * $variable;}
elseif (($altTaxable - $variable) > 160725 && $altTaxable <= 204100) {$tax = 0.32 * $variable;}
elseif (($altTaxable - $variable) > 204100 && $altTaxable <= 306175) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 306175) {$tax = 0.37 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 9700)
{$tax = 0.10 * $altTaxable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9700 && $altTaxable <= 39475)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 0.12 * ($altTaxable - 9700);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 39475 && $altTaxable <= 84200)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 0.22 * ($altTaxable - 39475);}
elseif (($altTaxable - $variable) > 39475 && $altTaxable > 84200 && $altTaxable <= 160725)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 84200 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 0.24 * (160725 - ($altTaxable - $variable)) + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 160725 && $altTaxable > 204100 && $altTaxable <= 306175)
{$tax = 0.32 * (204100 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 306175 && $altTaxable > 306175)
{$tax = 0.35 * (306175 - ($altTaxable - $variable)) + 0.37 * ($altTaxable - 306175);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 9700 && $altTaxable <= 39475)
{$tax = 970 + 0.12 * ($altTaxable - 9700);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 9700 && $altTaxable <= 84200)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 0.22 * ($altTaxable - 39475);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 84200 && $altTaxable <= 160725)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 9839.5 + 0.24 * ($altTaxable - 84200 );}
elseif (($altTaxable - $variable) > 39475 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 18366 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 84200 && $altTaxable > 204100 && $altTaxable <= 306175)
{$tax = 0.24 * (160725 - ($altTaxable - $variable)) + 13880 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 160725 && $altTaxable > 306175)
{$tax = 0.32 * (204100 - ($altTaxable - $variable)) + 35726.25 + 0.37 * ($altTaxable - 306175);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 39475 && $altTaxable <= 84200)
{$tax = 970 + 3573 + 0.22 * ($altTaxable - 39475);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 84200 && $altTaxable <= 160725)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 9839.5 + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 9839.5 + 18366 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 39475 && $altTaxable > 204100 && $altTaxable <= 306175)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 18366 + 13880 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 84200 && $altTaxable > 306175)
{$tax = 0.24 * (160725 - ($altTaxable - $variable)) + 13880 + 35726.25 + 0.37 * ($altTaxable - 306175);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 84200 && $altTaxable <= 160725)
{$tax = 970 + 3573 + 9839.5 + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 9839.5 + 18366 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 204100 && $altTaxable <= 306175)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 9839.5 + 18366 + 13880 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 39475 && $altTaxable > 306175)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 18366 + 13880 + 35726.25 + 0.37 * ($altTaxable - 306175);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 160725 && $altTaxable <= 204100)
{$tax = 970 + 3573 + 9839.5 + 18366 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 204100 && $altTaxable <= 306175)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 9839.5 + 18366 + 13880 + 0.32 * ($altTaxable - 160725);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 306175)
{$tax = 0.12 * (39475 - ($altTaxable - $variable)) + 9839.5 + 18366 + 13880 + 35726.25 + 0.37 * ($altTaxable - 306175);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 204100 && $altTaxable <= 306175)
{$tax = 970 + 3573 + 9839.5 + 18366 + 13880 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 306175)
{$tax = 0.10 * (9700 - ($altTaxable - $variable)) + 3573 + 9839.5 + 18366 + 13880 + 35726.25 + 0.37 * ($altTaxable - 306175);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 306175)
{$tax = 970 + 3573 + 9839.5 + 18366 + 13880 + 35726.25 + 0.37 * ($altTaxable - 306175);}
return $tax;
}
}
if ($filingStatus == 4) {
if ($span == 0) {
if ($altTaxable <= 0) {$tax = 0;}
elseif (($altTaxable - $variable) > 0 && $altTaxable <= 13850) {$tax = 0.10 * $variable;}
elseif (($altTaxable - $variable) > 13850 && $altTaxable <= 52850) {$tax = 0.12 * $variable;}
elseif (($altTaxable - $variable) > 52850 && $altTaxable <= 84200) {$tax = 0.22 * $variable;}
elseif (($altTaxable - $variable) > 84200 && $altTaxable <= 160700) {$tax = 0.24 * $variable;}
elseif (($altTaxable - $variable) > 160700 && $altTaxable <= 204100) {$tax = 0.32 * $variable;}
elseif (($altTaxable - $variable) > 204100 && $altTaxable <= 510300) {$tax = 0.35 * $variable;}
elseif (($altTaxable - $variable) > 510300) {$tax = 0.37 * $variable;}
return $tax;
}
if ($span == 1) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 0 && $altTaxable <= 13850)
{$tax = 0.10 * $altTaxable;}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 13850 && $altTaxable <= 52850)
{$tax = 0.10 * (13850 - ($altTaxable - $variable)) + 0.12 * ($altTaxable - 13850);}
elseif (($altTaxable - $variable) > 13850 && $altTaxable > 52850 && $altTaxable <= 84200)
{$tax = 0.12 * (52850 - ($altTaxable - $variable)) + 0.22 * ($altTaxable - 52850);}
elseif (($altTaxable - $variable) > 52850 && $altTaxable > 84200 && $altTaxable <= 160700)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 84200 && $altTaxable > 160700 && $altTaxable <= 204100)
{$tax = 0.24 * (160700 - ($altTaxable - $variable)) + 0.32 * ($altTaxable - 160700);}
elseif (($altTaxable - $variable) > 160700 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.32 * (204100 - ($altTaxable - $variable)) + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 204100 && $altTaxable > 510300)
{$tax = 0.35 * (510300 - ($altTaxable - $variable)) + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 2) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 13888 && $altTaxable <= 52850)
{$tax = 1385 + 0.12 * ($altTaxable - 13888);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 52850 && $altTaxable <= 84200)
{$tax = 0.10 * (13850 - ($altTaxable - $variable)) + 4680 + 0.22 * ($altTaxable - 52850);}
elseif (($altTaxable - $variable) > 13888 && $altTaxable > 84200 && $altTaxable <= 160700)
{$tax = 0.12 * (52850 - ($altTaxable - $variable)) + 6897 + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 52850 && $altTaxable > 160700 && $altTaxable <= 204100)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 18360 + 0.32 * ($altTaxable - 160700);}
elseif (($altTaxable - $variable) > 84200 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.24 * (160700 - ($altTaxable - $variable)) + 13888 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 204100 && $altTaxable > 510300)
{$tax = 0.32 * (204100 - ($altTaxable - $variable)) + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 3) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 52850 && $altTaxable <= 84200)
{$tax = 1385 + 4680 + 0.22 * ($altTaxable - 52850);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 84200 && $altTaxable <= 160700)
{$tax = 0.10 * (13850 - ($altTaxable - $variable)) + 4680 + 6897 + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 9700 && $altTaxable > 160700 && $altTaxable <= 204100)
{$tax = 0.12 * (52850 - ($altTaxable - $variable)) + 6897 + 18360 + 0.32 * ($altTaxable - 160700);}
elseif (($altTaxable - $variable) > 52850 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 18360 + 13888 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 84200 && $altTaxable > 510300)
{$tax = 0.24 * (160700 - ($altTaxable - $variable)) + 13888 + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 4) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 84200 && $altTaxable <= 160700)
{$tax = 1385 + 4680 + 6897 + 0.24 * ($altTaxable - 84200);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 160700 && $altTaxable <= 204100)
{$tax = 0.10 * (13850 - ($altTaxable - $variable)) + 4680 + 6897 + 18360 + 0.32 * ($altTaxable - 160700);}
elseif (($altTaxable - $variable) > 13888 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.12 * (52850 - ($altTaxable - $variable)) + 6897 + 18360 + 13888 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 52850 && $altTaxable > 510300)
{$tax = 0.22 * (84200 - ($altTaxable - $variable)) + 18360 + 13888 + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 5) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 160700 && $altTaxable <= 204100)
{$tax = 1385 + 4680 + 6897 + 18360 + 0.32 * ($altTaxable - 160700);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 0.10 * (13850 - ($altTaxable - $variable)) + 4680 + 6897 + 18360 + 13888 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 13888 && $altTaxable > 510300)
{$tax = 0.12 * (52850 - ($altTaxable - $variable)) + 6897 + 18360 + 13888 + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 6) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 204100 && $altTaxable <= 510300)
{$tax = 1385 + 4680 + 6897 + 18360 + 13888 + 0.35 * ($altTaxable - 204100);}
elseif (($altTaxable - $variable) > 0 && $altTaxable > 510300)
{$tax = 0.10 * (13850 - ($altTaxable - $variable)) + 4680 + 6897 + 18360 + 13888 + 107170 + 0.37 * ($altTaxable - 510300);}
return $tax;
}
if ($span == 7) {
if (($altTaxable - $variable) <= 0 && $altTaxable > 510300)
{$tax = 1385 + 4680 + 6897 + 18360 + 13888 + 107170 + 0.37 * ($altTaxable - 510300);}
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 *
* *
* AGI[0] => the amount of Adjusted Gross Income. *
* *
* AGI[1] => the amount of Total Income. *
* *
* AGI[2] => the amount of Adjustments to Income. *
* *
* 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. *
* *
* TuitionAndFees[0] => the amount of allowable tuition and fees deduction. *
* *
* TuitionAndFees[1] => the amount of phase-out for the tuition and fees 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. *
* *
* *
* PSEDeduction[0] => the amount of deduction for income from Pass-Through Entities: *
* sole proprietorships, rental of real property, partnerships, *
* and S-corporation distributions. *
* *
* PSEDeduction[1] => the amount of phase-out for the Pass-Through Entity deduction. *
* *
******************************************************************************************
*/
if (isset($_POST['submitted'])) {
if (
is_numeric($winnings) && is_numeric($losses) && is_numeric($filingStatus) && 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($materialParticipation) && is_numeric($unemployment) && is_numeric($ssi) &&
is_numeric($exempt) && is_numeric($alimonyPaid) && is_numeric($traditionalIRA) && is_numeric($traditionalIRASpouse) && is_numeric($spousalIRA) &&
is_numeric($studentLoanInterest) && is_numeric($tuitionAndFees) && 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($miscellaneous) && is_numeric($spouseItemizing) &&
$winnings >= 0 && $losses >= 0 && $filingStatus > 0 && $filingStatus < 6 && $senior >= 0 && $spouseSenior >= 0 &&
$blind >= 0 && $spouseBlind >= 0 && $wages >= 0 && $investment >= 0 && $dividend >= 0 && $alimonyReceived >= 0 &&
$retire >= 0 && $materialParticipation >= 0 && $unemployment >= 0 && $ssi >= 0 && $exempt >= 0 && $alimonyPaid >= 0 &&
$traditionalIRA >= 0 && $spousalIRA >= 0 && $studentLoanInterest >= 0 && $tuitionAndFees >= 0 && $otherAdjustments >= 0 &&
$aged50Years >= 0 && $spouseAged50Years >= 0 && $coveredByEmployer >= 0 && $spouseCoveredByEmployer >= 0 && $together >= 0 &&
$medicalExpenses >= 0 && $stateTaxes >= 0 && $mortgageInterest >= 0 && $charity >= 0 && $miscellaneous >= 0 && $traditionalIRASpouse >= 0 &&
$spouseItemizing >= 0
){
$medicalExpensesThresholdRate = 0.10;
$cashCharitableDonationsLimitRate = 0.60;
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, $traditionalIRASpouse, $tuitionAndFees,
$studentLoanInterest, $alimonyPaid, $SelfEmployment[1], $winnings);
if ($ssi > 0) {
$IncludableSSI = includablessicalc($filingStatus, $AGI[1], $ssi, $exempt, $winnings);
$AGI[1] = $AGI[1] - $ssi + $IncludableSSI[0];
} else {
$IncludableSSI[0] = 0;
$IncludableSSI[1] = 0;
}
if ($traditionalIRA > 0 && ($filingStatus == 1 || $filingStatus == 4 || $filingStatus == 5) && $senior == 0) {
$TraditionalIRA = traditionaliracalc($filingStatus, $aged50Years, $coveredByEmployer, $traditionalIRA, $alimonyPaid, $otherAdjustments,
$wages, $profit, $alimonyReceived, $SelfEmployment[1], $AGI[1], $winnings);
$AGI[2] = $AGI[2] - $traditionalIRA + $TraditionalIRA[0];
} elseif ($traditionalIRA > 0 && $filingStatus == 3 && $together == 1 && $senior == 0) {
$TraditionalIRA = traditionaliramfscalc($filingStatus, $aged50Years, $coveredByEmployer, $traditionalIRA, $alimonyPaid, $otherAdjustments,
$wages, $profit, $alimonyReceived, $SelfEmployment[1], $AGI[1], $winnings);
$AGI[2] = $AGI[2] - $traditionalIRA + $TraditionalIRA[0];
} elseif ($traditionalIRA > 0 && $filingStatus == 3 && $together == 0 && $senior == 0) {
$TraditionalIRA = traditionaliracalc($filingStatus, $aged50Years, $coveredByEmployer, $traditionalIRA, $alimonyPaid, $otherAdjustments,
$wages, $profit, $alimonyReceived, $SelfEmployment[1], $AGI[1], $winnings);
$AGI[2] = $AGI[2] - $traditionalIRA + $TraditionalIRA[0];
} elseif ($traditionalIRA > 0 && $filingStatus == 2 && ($senior + $spouseSenior < 2)) {
$TraditionalIRA = traditionaliramfjcalc($filingStatus, $aged50Years, $spouseAged50Years, $senior, $spouseSenior, $coveredByEmployer,
$spouseCoveredByEmployer, $traditionalIRA, $traditionalIRASpouse, $alimonyPaid, $otherAdjustments,
$wages, $profit, $alimonyReceived, $SelfEmployment[1], $AGI[1], $winnings, $spousalIRA);
$AGI[2] = $AGI[2] - $traditionalIRA - $traditionalIRASpouse + $TraditionalIRA[0];
} else {
$TraditionalIRA[0] = 0;
$TraditionalIRA[1] = 0;
$AGI[2] = $AGI[2] - $traditionalIRA + $TraditionalIRA[0];
}
if ($studentLoanInterest > 0) {
$StudentLoanInterest = studentloaninterestcalc($filingStatus, $studentLoanInterest, $alimonyPaid, $otherAdjustments,
$TraditionalIRA[0], $SelfEmployment[1], $AGI[1], $winnings);
$AGI[2] = $AGI[2] - $studentLoanInterest + $StudentLoanInterest[0];
} else {
$StudentLoanInterest[0] = 0;
$StudentLoanInterest[1] = 0;
$AGI[2] = $AGI[2] - $studentLoanInterest + $StudentLoanInterest[0];
}
if ($tuitionAndFees > 0) {
$TuitionAndFees = tuitionandfeescalc($filingStatus, $tuitionAndFees, $StudentLoanInterest[0], $alimonyPaid, $otherAdjustments,
$TraditionalIRA[0], $SelfEmployment[1], $AGI[1], $winnings);
$AGI[2] = $AGI[2] - $tuitionAndFees + $TuitionAndFees[0];
} else {
$TuitionAndFees[0] = 0;
$TuitionAndFees[1] = 0;
$TuitionAndFees[2] = 0;
$AGI[2] = $AGI[2] - $tuitionAndFees + $TuitionAndFees[0];
}
$AGI[0] = $AGI[1] - $AGI[2];
$Itemized = itemizeddeductionscalc($filingStatus, $spouseItemizing, $AGI[0], $winnings, $losses, $senior, $blind, $spouseSenior,
$spouseBlind, $medicalExpenses, $medicalExpensesThresholdRate, $stateTaxes, $mortgageInterest,
$charity, $cashCharitableDonationsLimitRate, $miscellaneous, $StudentLoanInterest[1],
$IncludableSSI[1], $TraditionalIRA[1], $TuitionAndFees[1]);
$taxableIncomeA = $AGI[0] - $Itemized[0];
$taxableIncomeLessWinningsA = $AGI[0] - $Itemized[0] - $Itemized[1] - $Itemized[3] - $IncludableSSI[1] - $StudentLoanInterest[1] - $TuitionAndFees[1] - $TraditionalIRA[1];
$capital = $dividend + min(max($shortCapital + $longCapital, 0), max($longCapital, 0));
// The variable capital is computed in the LongGains function. It is computed above by itself due to a mutual computation issue between the capital gains
// and the Pass-Through Entity deduction. The amount of capital gains tax can only be computed after the computation of the PSE deduction, because the
// taxable income amount used in its computation is determined using the PSE deduction amount. The computation of the PSE deduction limit uses the value
// of taxable income excluding income from long-term capital gains and qualified dividends. The final PSE deduction amount requires the value of
// capital variable. Since the PSE function needs to be executed before the long-term capital gains function, we decided to compute the capital
// variable value by itself first for the PSE deduction function.
if (($profit > 0 || $rent > 0 || $kayone > 0) && ($profit + $rent + $kayone) > 0) {
$PSEDeduction = passthroughdeductionscalc($filingStatus, $profit, $SelfEmployment[1], $rent, $kayone, $taxableIncomeA,
$taxableIncomeLessWinningsA, $capital);
} else {
$PSEDeduction[0] = 0;
$PSEDeduction[1] = 0;
}
if ($shortCapital > 0 || $longCapital > 0 || $dividend > 0) {
$LongGains = longcapitalgainstaxcalc($filingStatus, $shortCapital, $longCapital, $dividend, $taxableIncomeA,
$Itemized[1], $Itemized[3], $StudentLoanInterest[1], $PSEDeduction[1], $TraditionalIRA[1], $IncludableSSI[1], $PSEDeduction[1]);
} else {
$LongGains[0] = 0;
$LongGains[1] = 0;
$LongGains[2] = 0;
}
if (($filingStatus == 1 || $filingStatus == 4 || $filingStatus == 5) && $AGI[0] > 200000) {
$MedicareTax = additionalmedicaretaxcalc($filingStatus, $wages, $SelfEmployment[2], $investment, $dividend, $shortCapital, $longCapital, $rent,
$kayone, $materialParticipation, $AGI[0]);
} elseif ($filingStatus == 2 && $AGI[0] > 250000) {
$MedicareTax = additionalmedicaretaxcalc($filingStatus, $wages, $SelfEmployment[2], $investment, $dividend, $shortCapital, $longCapital, $rent,
$kayone, $materialParticipation, $AGI[0]);
} elseif ($filingStatus == 3 && $AGI[0] > 125000) {
$MedicareTax = additionalmedicaretaxcalc($filingStatus, $wages, $SelfEmployment[2], $investment, $dividend, $shortCapital, $longCapital, $rent,
$kayone, $materialParticipation, $AGI[0]);
} else {
$MedicareTax[0] = 0;
$MedicareTax[1] = 0;
}
$taxableIncome = $AGI[0] - $Itemized[0] - $PSEDeduction[0] - $LongGains[1];
$taxableIncomeLessWinnings = $AGI[0] - $Itemized[0] - $Itemized[1] - $Itemized[3] - $IncludableSSI[1] - $StudentLoanInterest[1] - $TuitionAndFees[1] - $TraditionalIRA[1] - $PSEDeduction[0] - $LongGains[1];
$taxableIncomeC = $taxableIncome - $IncludableSSI[1];
// To reduce the taxable income by the amount of Social Security benefits phase-out.
// I am not sure why this adjustment works sometimes to reconcile the calculator with hand calculations for tax effect
// of the Social Security benefits phase-in, Pass-Through entity deduction phase-out, and itemized deductions phase-out.
// Comparing 2018 and 2019 to 2017, my suspicion is that my algorithm for the taxable income amount before gambling winnings needs
// some adjustments. The lack of any personal and dependent exemptions phase-out in 2018 and 2019 seemed to simplify that calculation.
// However, as with 2017, it is not clear to me how to predict when this adjustment is needed.
$span = spancalc($filingStatus, $taxableIncome, $Itemized[1]);
$tax = taxcalc($span, $filingStatus, $taxableIncome, $Itemized[1]);
if ($TraditionalIRA[1] > 0) {
$spanIRA = altspancalc($filingStatus, $taxableIncome, $Itemized[1], $TraditionalIRA[1]);
$taxIRA = alttaxcalc($spanIRA, $filingStatus, $taxableIncome, $Itemized[1], $TraditionalIRA[1]);
}
if ($TuitionAndFees[1] > 0) {
$spanTAF = altspancalc($filingStatus, $taxableIncome, $Itemized[1], $TuitionAndFees[1]);
$taxTAF = alttaxcalc($spanTAF, $filingStatus, $taxableIncome, $Itemized[1], $TuitionAndFees[1]);
}
if ($StudentLoanInterest[1] > 0) {
$spanSLI = altspancalc($filingStatus, $taxableIncome, $Itemized[1], $StudentLoanInterest[1]);
$taxSLI = alttaxcalc($spanSLI, $filingStatus, $taxableIncome, $Itemized[1], $StudentLoanInterest[1]);
}
if ($IncludableSSI[1] > 0) {
$spanSSI = altspancalc($filingStatus, $taxableIncomeC, $Itemized[1], $IncludableSSI[1]);
$taxSSI = alttaxcalc($spanSSI, $filingStatus, $taxableIncomeC, $Itemized[1], $IncludableSSI[1]);
}
if ($PSEDeduction[1] != 0) {
$spanPSE = altspancalc($filingStatus, $taxableIncomeC, $Itemized[1], $PSEDeduction[1]);
$taxPSE = alttaxcalc($spanPSE, $filingStatus, $taxableIncomeC, $Itemized[1], $PSEDeduction[1]);
}
if ($Itemized[3] > 0) {
$spanID = altspancalc($filingStatus, $taxableIncomeC, $Itemized[1], $Itemized[3]);
$taxID = alttaxcalc($spanID, $filingStatus, $taxableIncomeC, $Itemized[1], $Itemized[3]);
}
$taxTotal = $tax + $taxTAF + $taxSLI + $taxIRA + $LongGains[2] + $taxSSI + $taxID + $taxPSE + $MedicareTax[1] + $LongGains[3];
}
else
{ echo '
Please enter valid (non-negative and numeric) dollar values.
Except, 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 2019 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.