Created
October 11, 2020 04:08
-
-
Save bencooper222/8495dc79d462a7eb3d04d9c02281b8c0 to your computer and use it in GitHub Desktop.
Calculate tax burden of IL joint filers in JS under the Fair Tax Amendment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gonna refer to this as bracket0, bracket1 etc | |
//| Income | Marginal Tax Rate | | |
//|------------------------|-------------------| | |
//| $0 – $10,000 | 4.75% | | |
//| $10,001 – $100,000 | 4.90% | | |
//| $100,001 – $250,000 | 4.95% | | |
//| $250,001 – $500,000 | 7.75% | | |
//| $500,001 – $1,000,000 | 7.85% | | |
//| $1,000,001 and above | 7.95% on net | | |
const brackets = [ | |
{ min: 0, max: 10000, rate: 0.0475 }, | |
{ min: 10001, max: 100000, rate: 0.049 }, | |
{ min: 100001, max: 250000, rate: 0.0495 }, | |
{ min: 250001, max: 500000, rate: 0.0775 }, | |
{ min: 500001, max: 1000000, rate: 0.0785 }, | |
]; | |
// assume income is Number | |
function calculateNetTaxForILJointFiler(income) { | |
const truncatedIncome = Math.floor(income); // taxes are always calculated with income truncated | |
let rtn = 0; | |
if (truncatedIncome >= 1000001) rtn = truncatedIncome * 0.0795; // sighs non marginal | |
// this is not performant in any way but that's OK | |
for (const bracket of brackets) { | |
const func = getBracketFunction(bracket.min, bracket.max, bracket.rate); | |
const bracketRtn = func(truncatedIncome); | |
rtn += bracketRtn.amount; | |
if (bracketRtn.done) break; | |
} | |
return Math.floor(rtn); | |
} | |
const getBracketFunction = (min, max, rate) => { | |
return (income) => { | |
if (income < min) return { amount: 0, done: true }; | |
if (income > max) return { amount: rate * (max - min), done: false }; | |
// in between | |
return { amount: rate * (income - min), done: true }; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment