Skip to content

Instantly share code, notes, and snippets.

@thmcmahon
Last active May 23, 2018 23:17
Show Gist options
  • Save thmcmahon/0e48631a6d7836d881650a2b062a8697 to your computer and use it in GitHub Desktop.
Save thmcmahon/0e48631a6d7836d881650a2b062a8697 to your computer and use it in GitHub Desktop.
function lmito(income, initial_value = 200, increased_value = 530,
taper_one_start = 37000, taper_two_start = 90000, taper_in_rate = 0.03,
taper_out_rate = 0.015) {
if (income < taper_one_start) {
return initial_value * -1;
}
else if (income >= taper_one_start & income <= taper_two_start) {
let tapered_in_lmito = (initial_value + (income - taper_one_start) * taper_in_rate);
if (tapered_in_lmito < increased_value) {
return tapered_in_lmito * -1;
}
else {
return increased_value * -1;
}
}
else if (income >= taper_two_start) {
let tapered_out_lmito = (increased_value - (income - taper_two_start) *
taper_out_rate) * -1;
if (tapered_out_lmito < 0) {
return tapered_out_lmito;
}
else {
return 0;
}
}
else {
return 0;
}
}
function lmito_lab(income, initial_value = 350, increased_value = 927.5,
taper_one_start = 37000, taper_two_start = 90000, taper_in_rate = 0.0525,
taper_out_rate = 0.02625) {
if (income < taper_one_start) {
return initial_value * -1;
}
else if (income >= taper_one_start & income <= taper_two_start) {
let tapered_in_lmito = (initial_value + (income - taper_one_start) * taper_in_rate);
if (tapered_in_lmito < increased_value) {
return tapered_in_lmito * -1;
}
else {
return increased_value * -1;
}
}
else if (income >= taper_two_start) {
let tapered_out_lmito = (increased_value - (income - taper_two_start) * taper_out_rate) * -1;
if (tapered_out_lmito < 0) {
return tapered_out_lmito;
}
else {
return 0;
}
}
else {
return 0;
}
}
function lito(income, value = 445, taper_start = 37000, taper_rate = 0.015) {
if (income < taper_start) {
return value * -1;
} else {
let tapered_lito = (value - (income - taper_start) * taper_rate) * -1;
if (tapered_lito < 0) {
return tapered_lito;
} else {
return 0;
}
}
}
function value_of_bracket_cut(income) {
if (income < 87000) {
return 0;
} else if (income > 90000) {
return 135;
} else {
let base_tax = (income - 87000) * 0.37;
let change_tax = (income - 87000) * 0.325;
return base_tax - change_tax;
}
}
function income_tax(income) {
if (income <= 18200) {
return 0;
}
let income_tax_owed = (income - 18200) * 0.19;
return income_tax_owed;
}
function governments_plan(income) {
let initial_value = 200;
let income_tax_owed = income_tax(income) + lito(income);
if (income_tax_owed < initial_value) {
if (income_tax_owed >= 0) {
return Math.round(income_tax_owed);
} else {
return 0;
}
} else {
let total_benefit = lmito(income) * -1 + value_of_bracket_cut(income);
return Math.round(total_benefit);
}
}
function labors_plan(income) {
let initial_value = 350;
let income_tax_owed = income_tax(income) + lito(income);
if (income_tax_owed < initial_value) {
if (income_tax_owed >= 0) {
return Math.round(income_tax_owed);
} else {
return 0;
}
} else {
lmito_benefit = lmito_lab(income);
let total_benefit = lmito_benefit * -1 + value_of_bracket_cut(income);
return Math.round(total_benefit);
}
}
function difference_between(income) {
let output = {
'income': income,
'liberal': governments_plan(income),
'labor': labors_plan(income),
'difference': labors_plan(income) - governments_plan(income)
};
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment