From: Scott Worley Date: Thu, 23 May 2019 23:47:27 +0000 (-0700) Subject: UI X-Git-Tag: v1.0~9 X-Git-Url: http://git.scottworley.com/inverse-tax/commitdiff_plain/d0678fe5d5c229220e1b4e7e7cbd470b157c3261?hp=a3217513164a82c3c60cb199333541d331eeff98 UI --- diff --git a/tax.html b/tax.html index 3b0ab91..51c323e 100644 --- a/tax.html +++ b/tax.html @@ -2,8 +2,66 @@ - + + - + +

Inverse income tax tool

+

What gross salary is needed to provide a specified after-tax salary?

+ +
+ + + + + + + + + + + +
+Federal deductible
+
+State deductible
+
+Federal tax table
+ +
+State tax table
+ +
(Initial table is California's) +
+Desired after-tax salary
+ +
+
+ +

before tax + - federal tax + - state tax + = after tax.

+ +

Privacy policy: All calculations are client-side; no figures are sent to any server.

diff --git a/tax_ui.js b/tax_ui.js new file mode 100644 index 0000000..4f2b625 --- /dev/null +++ b/tax_ui.js @@ -0,0 +1,24 @@ +function load_tax_table(table_id, deductible_id) { + return apply_deductible(parse_tax_table(document.getElementById(table_id).value), + parseFloat(document.getElementById(deductible_id).value)); +} + +function format_number(n) { + return n.toLocaleString('en', {useGrouping:true, style: 'currency', currency: 'USD'}); +} + +function calculate() { + const table1 = load_tax_table('tax_table_1', 'deductible_1'); + const table2 = load_tax_table('tax_table_2', 'deductible_2'); + const after_tax = parseFloat(document.getElementById('after_tax').value); + + const before_tax = invert(merge_tax_tables(table1, table2))(after_tax); + + const tax1 = tax(table1, before_tax); + const tax2 = tax(table2, before_tax); + + document.getElementById('before_tax').textContent = format_number(before_tax); + document.getElementById('tax_1').textContent = format_number(tax1); + document.getElementById('tax_2').textContent = format_number(tax2); + document.getElementById('after_tax_verification').textContent = format_number(before_tax - (tax1 + tax2)); +}