From d0678fe5d5c229220e1b4e7e7cbd470b157c3261 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 23 May 2019 16:47:27 -0700 Subject: [PATCH] UI --- tax.html | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- tax_ui.js | 24 +++++++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 tax_ui.js 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)); +} -- 2.44.1