One of the more difficult parts in developing an application is the planning process and deciding how your app should work. The first important computer program I ever wrote was in 1978. It was an accounting program. I had just written a grant to obtain funding from the Regional Occupations Program. I had just started to teach Accounting at Dos Pueblos High School in Goleta, CA. The grant entailed using personal computers to process accounting functions, like general ledger, financial reports, payroll, inventory, account receivable and accounts payable.
I had planned to use Radio Shack personal computers that had a few accounting computer programs available. In its infinite wisdom, my employer decided on Apple, which had no software for accounting.
The grant I wrote was accepted and funded.
I got three Apple computers, one disk drive, one tape recorder, three TV sets to use for monitors and a dot matrix printer.
After the decsion to purchase Apple computers, I made a deal with math teacher who knew something about computer programming. I was to supply the accounting information and he was to show me how to write some computer programs for my Computer Accounting class. The arrangement never worked out. I went to our school library and checked all the books I could find on computer programming and went to work. One day I was working in our business teachers' office, when a young man approached me and asked if he could look at what I was doing. His name is Randy Evered. He was student at Dos Publos High School. After observing him use the computer, I knew that he could be instrumental in my trying to develop software for my upcoming class.
I put him on an independent study course with me and we worked after school for months. Eventually we came out with a general ledger program.
After that first program, I developed programs for classes that I taught : Computer Business Applications, Math Basics, Visual Basic Progrmming, Applied Biology and Chemistry, Networking, Medical Office Management, Digital Arts and Computer Animation. I also developed this web page for the California Virtual Enterprise program.
After a few years we purchased IBM Pc's and I got to start programming all over again.
Here are a few things to consider when planning an application.
What tools do you need for this project? Notepad++, HTML 5, Javascript, cascading style sheets, Visual Basic, Python etc.
Do you want the application to mobile friendly?
Where will you find information?
What knowledge do you have about the application you are trying to create?
Do you need an expert in the field that your application covers?
To make this lesson work, we will be developing a payroll application. Anyone that has ever had a part-time job knows a little about payroll and paychecks. There is a gross amount determined by multiplying hours worked times rate of pay. Then some deductions for the government are subtracted, which leads to a smaller amount for the money you get.
I picked payroll, since I have a good working knowledge. I prepared my first payroll when I was a junior, Business Administration major at San Diego State University. My father owned a clothing store and that summer I got to work as a bookkeeper. After getting my teaching credential, I taught high school Accounting, Computer Accounting and Accounting at Santa Barbara Community College. Later My father and I had an accounting business and we prepared payroll and financial statements for our clients.
The first step is to define elements of the program. What do you want the software to do?
To make this lesson work, we will develop an payroll application using HTML5 and javaScript.
We need a module that allows you to set up employee information: name hourly rate, marital status, etc.
Initialize all variables for the application for each employee for 4 weeks
Decide on weekly, semi-monthly or monthly pay period.
A second module that allow you to enter hours worked.
A section in module 2 that calculates overtime, gross pay, Federal Income tax, FICA, Medicare, State income tax, state disability insurance, total deduction and net pay.
You could look at a pay stub to see these deductions and calculate the percentages.
A function in module 2, a payroll register, showing all employees, hours worked, gross pay, deduction for federal Income tax, FICA, Medicare, state income tax, state disability insurance, total deductions and net pay.
A function in module 2 to calculate the employers' share of Federal Insurance Contributions Act (social security), Medicare FUTA and SUTA.
A third module to keep track of employee earnings' records for 4 weeks.
Day 1: Module 1 Employee Information
Initialize Variables
Employee information might include, name, contact information, social security number hourly rate, exemptions claimed, marital status, job title, etc.
First we need to see how to organize this information. In the HTML section we could create a table, to hold this information.
Let's use Employee Name, Job Title, Marital Status, Exemptions and Pay Rate.
First we need to create the table. We set cellspacing, cellpadding and border to 2 pixels.
Next we create the table headings. The next step is to create the table data rows and table data cells.
Instead of entering data into the table, I want to load the data from a file stored in HTML5 local storage.
Javascript has a file format called JSON, Javascript Object Notation.
JSON is an open standard file format, and data interchange format, that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and array data types. It is a very common data format, with a diverse range of applications, such as serving as a replacement for XML in AJAX systems.
We will use this format to store our employee information for our payroll project and then using the retrieve() function and load it into our table using the getElementById innerHTML method.
Next we will decide on variables for the project. There are lots of them. We have 4 employees, each has a deduction each week for 4 weeks for hours worked, grosss pay, Federal Income Tax, FICA, Medicare, state income tax, state disability insurance, state training tax, total deductions and net pay.
You need to have a system when assigning this many variables: Here is what I did. Jerry, is employee 0, Janet is employee 1, Julie is number 2 and Shelley is number 3.
For example. Janet's gross pay is grossPay1, Julie's net pay is netPay2. Each week needs to also be indentified. I used nothing for the first week, w2 for week 2, w3 for week 3 and w4 for week 4.
For example, Janet's federal income tax for week 3 is fedIncTax1w3.
After the variables names have been determined, I write these variable to the local storage of HTML5 and set them all equal to zero.
Remember when using local storage and session storage, each browser acts separately. If you store the variables using Chrome using the first module, use the same browser for the other modules.
When you click on the Save button using any browser, the array with employee information is stored and the
the variables names for the payroll are written and a zero assigned for their value.
Copy the code in the textarea box above to get started
Paste this code into Notepad++ and save it as an html document. This is the first of three modules. You may want to call it setup.html
Now let's look at the JSON file.
Copy the code in the textarea box above.
Paste this code into your setup.html project between the script tags.
Now let's look at the JSON file.
This JSON file format is a multi-dimensional array.
It works with lots of computer languages.
I have used it in Python projects for artificial intelligence applications.
The name of the array is employees.
There is a separate line for each employee.
That line is enclosed in square brackets followed by a comma at the end. (except for the last employee.)
Name, marital status, job title are enclosed in either single or double quotation marks.
Just make sure that if you start using a single quote , that you end with one. If you start with double quotation marks, then end with double quotes.
Exemptions and pay rates are numbers are not enclosed in quotation marks.
Next, the array is saved into local storage using setItem.
The JSON.stringify () method converts JavaScript objects into strings. The javascript object is the array with our employees. When sending data to a web server the data has to be a string.
JSON.parse() method takes JSON string and transforms it into a JavaScript object.
The alert tag let's us know that the file is saved.
The retrieve() function is next called.
The file is next converted back to an javaScript object so we can work with it.
name0, job0, marital0, exem0, and pay0 all refer to the first employee: Jerry
Each employee has in index in the array, starting with 0. Jerry is 0, Janet is 1, Julie is 2 and Shelley is 3
Each employee has another number that refers to the specific information relating to them, like store manager, married, 25.55, etc.
If you want to see Jerry's name you refer to obj[0][0]
If you want to see Janets' job title, you would use obj[1][1]
The code takes the information and inserts it into the table in the correct place based on the paragraph id.
Next all variables are initialized and saved in local storage.
Let's look at the file. Launch the app using the browser of your choice. Press Save File button.
Print the page out by pressing the ... dots in the upper-right-hand corner of the page, select print.
Press the F12 key to activate the javaScript debugger. Here is what you should see using Firefox after clicking the storage tab and then local storage and then the file listed below it..
The Firefox debugger puts the variables in alphabetical order. All variables should be set to zero, except the JSON array.
You can also clear any data in storage from the javascript debugger. You can clear all data or individual amounts.
Here is what the debugger looks like using Chrome. Click to expand the selection. Click on Application, local storage and then the file listed below it. It has a filter box, which you can use to search for variables.
All variables should be set to zero except the JSON array.
Finished page that creates and saves the employees array
Day 2: Calculating hours worked HTML5 form
In this second module, we need to decide the pay period: weekly, semi-monthly or monthly. I chose weekly for this lesson. The pay period is important for determining the hours and payroll deductions.
First we have to retrieve our file containing employees' names, job titles, marital status, exemptions and pay rates.
Next we want to load that data into a table.
Now we have to determine how the user enters the hours worked.
I chose the HTML5 input number field. You can specify a minimum and maximum number of hours to be input.
In our company, employees usually work on average 40 hours per week.
Some work 35 hours and some may put in 5 hours of overtime, hours greater than 40 for a maximum of 45 hours.
We can also set a value of 35 and the user can then scroll up or down to increase or decrease that number.
We first retrieve the file with employee names. This is the same file as on the previous page.
The body onload tag calls the retrieve file function.
Next we want to give the user the opportunity to enter the hours.
Listed below is the html5 code for this.
Copy the code in the textarea box above and save it with an html extension. You might want to call this second module register.html
Adding the javascript function to retrieve the file from local storage.
Here is the code.
var myObj, myJSON, text, obj;
function retrieve(){
text = localStorage.getItem("MyJSON", myJSON);
obj = JSON.parse(text);
//employee Jerry
document.getElementById("name0").innerHTML=obj[0][0];
document.getElementById("job0").innerHTML=obj[0][1];
document.getElementById("marital0").innerHTML=obj[0][2];
document.getElementById("exem0").innerHTML=obj[0][3];
document.getElementById("pay0").innerHTML=obj[0][4];
document.getElementById("employee0").innerHTML = obj[0][0] + " hours worked";
// employee Janet
document.getElementById("name1").innerHTML=obj[1][0];
document.getElementById("job1").innerHTML=obj[1][1];
document.getElementById("marital1").innerHTML=obj[1][2];
document.getElementById("exem1").innerHTML=obj[1][3];
document.getElementById("pay1").innerHTML=obj[1][4];
document.getElementById("employee1").innerHTML = obj[1][0] + " hours worked";
//Employee Julie
document.getElementById("name2").innerHTML=obj[2][0];
document.getElementById("job2").innerHTML=obj[2][1];
document.getElementById("marital2").innerHTML=obj[2][2];
document.getElementById("exem2").innerHTML=obj[2][3];
document.getElementById("pay2").innerHTML=obj[2][4];
document.getElementById("employee2").innerHTML = obj[2][0] + " hours worked";
//Employee Shelley
document.getElementById("name3").innerHTML=obj[3][0];
document.getElementById("job3").innerHTML=obj[3][1];
document.getElementById("marital3").innerHTML=obj[3][2];
document.getElementById("exem3").innerHTML=obj[3][3];
document.getElementById("pay3").innerHTML=obj[3][4];
document.getElementById("employee3").innerHTML = obj[3][0] + " hours worked";
}
Open up your register.html page. Copy the code in the textarea box, paste it between the script tags above and save it.
Day 3: Payroll Register
The payroll register is an accounting form that show us our company's payroll costs. Below is a sample of what one might look like.
It is just a table with rows and columns and headings. We will fill it with our employees information soon.
We have already added the html code for the payroll register and the employers' payroll taxes.
The Calculate() function.
function calculate()
{
if(validateRadio(Payroll)==false)
{
alert("Click on the week for the payroll");
return;
}
var grossPay0=0;
var grossPay1=0;
var grossPay2=0;
var grossPay3=0;
var overtimeHours0=0;
var overtimeHours1=0;
var overtimeHours2=0;
var overtimeHours3=0;
var overtimePayRate0=0;
var overtimePayRate1=0;
var overtimePayRate2=0;
var overtimePayRate3=0;
var overtimePay0=0;
var overtimePay1=0;
var overtimePay2=0;
var overtimePay3=0;
var overtime0=0;
var overtime1=0;
var overtime2=0;
var overtime3=0;
var hoursWorked0=document.forms.Payroll.hoursWorked0.value;
//alert("hoursWorked0=document.forms.Payroll.hoursWorked0.value " + hoursWorked0);
var hoursWorked1=document.forms.Payroll.hoursWorked1.value;
var hoursWorked2=document.forms.Payroll.hoursWorked2.value;
var hoursWorked3=document.forms.Payroll.hoursWorked3.value;
var regHoursWorked0=0;
var regHoursWorked1=0;
var regHoursWorked2=0;
var regHoursWorked3=0;
var regPay0=0;
var regPay1=0;
var regPay2=0;
var regPay3=0;
var overtimeHours0=0;
var overtimeHours1=0;
var overtimeHours2=0;
var overtimeHours3=0;
var overtimePayRate0=0;
var overtimePayRate1=0;
var overtimePayRate2=0;
var overtimePayRate3=0;
var overtime0=0;
var overtime1=0;
var overtime2=0;
var overtime3=0;
var fedIncTax0=0;
var fedIncTax1=0;
var fedIncTax2=0;
var fedIncTax3=0;
// put names into payroll register
document.getElementById("employee00").innerHTML = obj[0][0];
document.getElementById("employee10").innerHTML = obj[1][0];
document.getElementById("employee20").innerHTML = obj[2][0];
document.getElementById("employee30").innerHTML = obj[3][0];
//Put hours worked in payroll register
document.getElementById("hoursWorked0").innerHTML = hoursWorked0;
document.getElementById("hoursWorked1").innerHTML = hoursWorked1;
document.getElementById("hoursWorked2").innerHTML = hoursWorked2;
document.getElementById("hoursWorked3").innerHTML = hoursWorked3;
//Calculate overtime for hours worked over 40 for employee Jerry
if (hoursWorked0 > 40)
{
regHoursWorked0=40;
regPay0 = obj[0][4] * regHoursWorked0
// alert("Regular Pay for employee 0 = " + regPay0);
overtimeHours0 = hoursWorked0 - 40;
// alert("overtime0 hours = " + overtimeHours0);
//calculate overtime pay rate
overtimePayRate0 = obj [0][4] * 1.5
// alert("overtimePayrate0 = " + overtimePayRate0);
//calculate overtime pay for employee Jerry
overtime0 = overtimePayRate0 * overtimeHours0
// calculate gross pay for employee Jerry
grossPay0 = regPay0 + overtime0;
// round off grosspay to two decimals
var n = grossPay0.toFixed(2)
document.getElementById("grossPay0").innerHTML = n;
}
else if(hoursWorked0 <= 40)
{
grossPay0 = obj[0][4] * hoursWorked0
var n = grossPay0.toFixed(2)
document.getElementById("grossPay0").innerHTML = n;
}
// calculate pay for employee Janet
if (hoursWorked1 > 40)
{
regHoursWorked1=40;
regPay1 = obj[1][4] * regHoursWorked1
// alert("Regular Pay for employee 1 = " + regPay1);
overtimeHours1 = hoursWorked1 - 40;
// alert("overtime1 hours = " + overtimeHours1);
//calculate overtime pay rate
overtimePayRate1 = obj [1][4] * 1.5
// alert("overtimePayrate1 = " + overtimePayRate1);
//calculate overtime pay for employee Janet
overtime1 = overtimePayRate1 * overtimeHours1
//Math.round(overtimePay1 * 100)/100
//overtimePay1.toFixed(2);
// alert("Overtime for employee 1 is " + overtime1);
// calculate gross pay for employee Janet
grossPay1 = regPay1 + overtime1;
var n = grossPay1.toFixed(2)
document.getElementById("grossPay1").innerHTML = n;
}
else if (hoursWorked1 <=40)
{
grossPay1 = obj[1][4] * hoursWorked1
var n = grossPay1.toFixed(2)
document.getElementById("grossPay1").innerHTML = n;
}
// employee 2
//Calculate overtime for hours worked over 40 for employee Julie
if (hoursWorked2 > 40)
{
regHoursWorked2=40;
regPay2 = obj[2][4] * regHoursWorked2
// alert("Regular Pay for employee 2 = " + regPay2);
overtimeHours2 = hoursWorked2 - 40;
// alert("overtime2 hours = " + overtimeHours2);
//calculate overtime pay rate
overtimePayRate2 = obj [2][4] * 1.5
// alert("overtimePayrate2 = " + overtimePayRate2);
//calculate overtime pay for employee Julie
overtime2 = overtimePayRate2 * overtimeHours2
// calculate gross pay for employee Julie
grossPay2 = regPay2 + overtime2;
// round off grosspay to two decimals
var n = grossPay2.toFixed(2)
document.getElementById("grossPay2").innerHTML = n;
}
else if(hoursWorked2 <= 40)
{
grossPay2 = obj[2][4] * hoursWorked2
var n = grossPay2.toFixed(2)
document.getElementById("grossPay2").innerHTML = n;
}
// calculate pay for employee Shelley
//Calculate overtime for hours worked over 40 for employee Shelley
if (hoursWorked3 > 40)
{
regHoursWorked3=40;
regPay3 = obj[3][4] * regHoursWorked3
// alert("Regular Pay for employee 3 = " + regPay3);
overtimeHours3 = hoursWorked3 - 40;
// alert("overtime3 hours = " + overtimeHours3);
//calculate overtime pay rate
overtimePayRate3 = obj [3][4] * 1.5
// alert("overtimePayrate3 = " + overtimePayRate3);
//calculate overtime pay for employee Shelley
overtime3 = overtimePayRate3 * overtimeHours3
// calculate gross pay for employee Shelley
grossPay3 = regPay3 + overtime3;
// round off grosspay to two decimals
var n = grossPay3.toFixed(2)
document.getElementById("grossPay3").innerHTML = n;
}
else if(hoursWorked3 <= 40)
{
grossPay3 = obj[3][4] * hoursWorked3
var n = grossPay3.toFixed(2)
document.getElementById("grossPay3").innerHTML = n;
}
Paste it just below the retrieve function. Save your register.html file.
The calculate() function function is quite extensive.
First we check to see that the user clicked on one of the week radio buttons.
If they did not pick a week, we do not let them enter hours worked.
next we initialize the variables for each employee.
grossPay, overtimeHours,overtimePayRate and overtime amount.
Next we get the hours worked from the user.
Users will use the up and down arrow keys to enter number of hours over 35.
Now we put those hours into the payroll register table.
Now we calculate overtime for each employee if there is any.
If there is no overtime, we get gross pay by multiplying hourly rate time hours worked.
Now we need to deal with federal income tax that needs to deducted from each employee's paychecks
There are two methods for calculating federal income tax: Wage Bracket and Percentage Method.
I got the information on line. Use the most current tax tables.
I used the wage bracket method. It is a little simplier to code. Both IRS tables are shown below.
Jerry is married and files jointly and his wife does not work outside of the household.
Janet is married and files separately
Julie is single
Shelley is married and files separately
Let's look at Jerry federal Income first. Wage and Bracket table, first column standard withholding
He is paid $25.55 per hour. If he works 35 hours he would be paid $894.25. His tax is $43.00
If he works 45 hours he would make 40 hours times $25.55 or $1,022.00 + 25.55 times 1.5 which is $38.33 per hour times 5 hours or $191.63.
Now add $1,022.00 + 191.63 to get $1,213.63 gross pay for the week.
Now if we look up $1,213.63 on the table we see the tax is $81.00
The code for this is for the wage and bracket method is as follows:
else if (grossPay0 >=1210 && grossPay0<1220 )
{
fedIncTax0 = 81;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
Percentage method. Look up 1,213.63 in table.
Tax for this amount ,standard withholding, married filing jointly is $38.00 plus 12% of any amount over $857
$1,213.63- $857.00 = $356.63 times 12% equals $42.79 + $38.00 = $80.79 federal tax.
As you can see both tables produce essentially the same results.
if you were to code this using javaScript, it would look like this.
else if (grossPay0 >=1210 && grossPay0<1220 )
{
fedIncTax0 = 38.00 + (grossPay0-857) * .12;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
Day 4: javaScript code for federal income tax wage and bracket
// calculate federal income tax from Jerry - married joint filing status
if (grossPay0 >=890 && grossPay0<900)
{
fedIncTax0 = 43;
//alert("federal income tax withheld = " + fedIncTax0);
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=900 && grossPay0<910 )
{
fedIncTax0 = 44;
//document.getElementById("result6").innerHTML = "Federal Income Withheld " + fedIncTax.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=910 && grossPay0<920 )
{
fedIncTax0 = 45;
//document.getElementById("result6").innerHTML = "Federal Income Withheld " + fedIncTax.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=920 && grossPay0<930 )
{
fedIncTax0 = 46;
//document.getElementById("result6").innerHTML = "Federal Income Withheld " + fedIncTax.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=930 && grossPay0<940 )
{
fedIncTax0 = 47;
//document.getElementById("result6").innerHTML = "Federal Income Withheld " + fedIncTax.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=940 && grossPay0<950 )
{
fedIncTax0 = 49;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=950 && grossPay0<960 )
{
fedIncTax0 = 50;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=960 && grossPay0<970 )
{
fedIncTax0 = 51;
}
else if (grossPay0 >=970 && grossPay0<980 )
{
fedIncTax0 = 52;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=980 && grossPay0<990 )
{
fedIncTax0 = 53;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=990 && grossPay0<1000 )
{
fedIncTax0 = 55;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1000 && grossPay0<1010 )
{
fedIncTax0 = 56;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1010 && grossPay0<1020 )
{
fedIncTax0 = 57;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1020 && grossPay0<1030 )
{
fedIncTax0 = 58;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1030 && grossPay0<1040 )
{
fedIncTax0 = 59;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1040 && grossPay0<1050 )
{
fedIncTax0 = 61;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1050 && grossPay0<1060 )
{
fedIncTax0 = 62;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1060 && grossPay0<1070 )
{
fedIncTax0 = 63;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1070 && grossPay0<1080 )
{
fedIncTax0 = 64;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1080 && grossPay0<1090 )
{
fedIncTax0 = 65;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1090 && grossPay0<1100 )
{
fedIncTax0 = 66;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1100 && grossPay0<1110 )
{
fedIncTax0 = 68;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1110 && grossPay0<1120 )
{
fedIncTax0 = 69;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1120 && grossPay0<1130 )
{
fedIncTax0 = 70;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1130 && grossPay0<1140 )
{
fedIncTax0 = 71;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1140 && grossPay0<1150 )
{
fedIncTax0 = 73;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1150 && grossPay0<1160 )
{
fedIncTax0 = 74;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1160 && grossPay0<1170 )
{
fedIncTax0 = 75;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1170 && grossPay0<1180 )
{
fedIncTax0 = 76;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1180 && grossPay0<1190 )
{
fedIncTax0 = 77;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1190 && grossPay0<1200 )
{
fedIncTax0 = 79;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1200 && grossPay0<1210 )
{
fedIncTax0 = 80;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay0 >=1210 && grossPay0<1220 )
{
fedIncTax0 = 81;
document.getElementById("fedIncTax0").innerHTML = fedIncTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else
{
fedIncTax0 = 0;
alert("Federal tax table does not cover wages for this amount: Minimum amount is $890 and the maximum amount is $1220");
//document.getElementById("result6").innerHTML = "Federal Income Withheld " + fedIncTax.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
// Calculate federal income tax for Janet McIntyre Married filing separately table
// minimum amount made is 803.25
//Maximum amount earned is 1090.13
if (grossPay1 >=800 && grossPay1<810 )
{
fedIncTax1 = 64;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=810 && grossPay1<820 )
{
fedIncTax1 = 65;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=820 && grossPay1<830 )
{
fedIncTax1 = 67;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=830 && grossPay1<840 )
{
fedIncTax1 = 68;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=840 && grossPay1<850 )
{
fedIncTax1 = 69;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=850 && grossPay1<860 )
{
fedIncTax1 = 70;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=860 && grossPay1<870 )
{
fedIncTax1 = 71;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=870 && grossPay1<880 )
{
fedIncTax1 = 73;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=880 && grossPay1<890 )
{
fedIncTax1 = 74;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=890 && grossPay1<900 )
{
fedIncTax1 = 75;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=900 && grossPay1<910 )
{
fedIncTax1 = 75;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=910 && grossPay1<920 )
{
fedIncTax1 = 77;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=920 && grossPay1<930 )
{
fedIncTax1 = 79;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=930 && grossPay1<940 )
{
fedIncTax1 = 80;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=940 && grossPay1<950 )
{
fedIncTax1 = 81;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=950 && grossPay1<960 )
{
fedIncTax1 = 82;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=960 && grossPay1<970 )
{
fedIncTax1 = 83;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=970 && grossPay1<980 )
{
fedIncTax1 = 84;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=980 && grossPay1<990 )
{
fedIncTax1 = 85;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=990 && grossPay1<1000 )
{
fedIncTax1 = 86;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1000 && grossPay1<1010 )
{
fedIncTax1 = 87;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1010 && grossPay1<1020 )
{
fedIncTax1 = 88;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1020 && grossPay1<1030 )
{
fedIncTax1 = 90;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1030 && grossPay1<1040 )
{
fedIncTax1 = 92;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1040 && grossPay1<1050 )
{
fedIncTax1 = 94;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1050 && grossPay1<1060 )
{
fedIncTax1 = 99;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1060 && grossPay1<1070 )
{
fedIncTax1 = 100;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1070 && grossPay1<1080 )
{
fedIncTax1 = 103;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1080 && grossPay1<1090 )
{
fedIncTax1 = 105;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay1 >=1090 && grossPay1<1100 )
{
fedIncTax1 = 107;
document.getElementById("fedIncTax1").innerHTML = fedIncTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else
{
fedIncTax1 = 0;
alert("Federal tax table does not cover wages for this amount: Minimum amount is $803.25 and the maximum amount is $1090.13");
//document.getElementById("result6").innerHTML = "Federal Income Withheld " + fedIncTax.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
// Julie's pay low end 768.25 high end 1042.63 wage and bracket single standard deduction
if (grossPay2 >=760 && grossPay2<770 )
{
fedIncTax2 = 59;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=770 && grossPay2<780 )
{
fedIncTax2 = 61;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=780 && grossPay2<790 )
{
fedIncTax2 = 62;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=790 && grossPay2<800 )
{
fedIncTax2 = 63;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if(grossPay2 >=800 && grossPay2<810 )
{
fedIncTax2 = 64;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=810 && grossPay2<820 )
{
fedIncTax2 = 65;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=820 && grossPay2<830 )
{
fedIncTax2 = 67;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=830 && grossPay2<840 )
{
fedIncTax2 = 68;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=840 && grossPay2<850 )
{
fedIncTax2 = 69;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=850 && grossPay2<860 )
{
fedIncTax2 = 70;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=860 && grossPay2<870 )
{
fedIncTax2 = 71;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=870 && grossPay2<880 )
{
fedIncTax2 = 73;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=880 && grossPay2<890 )
{
fedIncTax2 = 74;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=890 && grossPay2<900 )
{
fedIncTax2 = 75;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=900 && grossPay2<910 )
{
fedIncTax2 = 75;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=910 && grossPay2<920 )
{
fedIncTax2 = 77;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=920 && grossPay2<930 )
{
fedIncTax2 = 79;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=930 && grossPay2<940 )
{
fedIncTax2 = 80;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=940 && grossPay2<950 )
{
fedIncTax2 = 81;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=950 && grossPay2<960 )
{
fedIncTax2 = 82;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=960 && grossPay2<970 )
{
fedIncTax2 = 83;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=970 && grossPay2<980 )
{
fedIncTax2 = 84;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=980 && grossPay2<990 )
{
fedIncTax2 = 85;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=990 && grossPay2<1000 )
{
fedIncTax2 = 86;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=1000 && grossPay2<1010 )
{
fedIncTax2 = 87;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=1010 && grossPay2<1020 )
{
fedIncTax2 = 88;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=1020 && grossPay2<1030 )
{
fedIncTax2 = 90;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=1030 && grossPay2<1040 )
{
fedIncTax2 = 92;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay2 >=1040 && grossPay2<1050 )
{
fedIncTax2 = 94;
document.getElementById("fedIncTax2").innerHTML = fedIncTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else
{
fedIncTax2 = 0;
alert("Federal tax table does not cover wages for this amount: Minimum amount is $768.25 and the maximum amount is $1042.63");
}
// Shelley's federal income tax min amount is 698.25 maximum amount is 947.65 standard withholding
if (grossPay3 >=690 && grossPay3<700 )
{
fedIncTax3 = 51;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=700 && grossPay3<710 )
{
fedIncTax3 = 52;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=710 && grossPay3<720 )
{
fedIncTax3 = 53;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=720 && grossPay3<730 )
{
fedIncTax3 = 55;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=730 && grossPay3<740 )
{
fedIncTax3 = 56;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=740 && grossPay3<750 )
{
fedIncTax3 = 57;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=750 && grossPay3<760 )
{
fedIncTax3 = 58;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=760 && grossPay3<770 )
{
fedIncTax3 = 59;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=770 && grossPay3<780 )
{
fedIncTax3 = 61;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=780 && grossPay3<790 )
{
fedIncTax3 = 62;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=790 && grossPay3<800 )
{
fedIncTax3 = 63;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if(grossPay3 >=800 && grossPay3<810 )
{
fedIncTax3 = 64;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=810 && grossPay3<820 )
{
fedIncTax3 = 65;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=820 && grossPay3<830 )
{
fedIncTax3 = 67;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=830 && grossPay3<840 )
{
fedIncTax3 = 68;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=840 && grossPay3<850 )
{
fedIncTax3 = 69;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=850 && grossPay3<860 )
{
fedIncTax3 = 70;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=860 && grossPay3<870 )
{
fedIncTax3 = 71;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=870 && grossPay3<880 )
{
fedIncTax3 = 73;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3>=880 && grossPay3<890 )
{
fedIncTax3 = 74;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=890 && grossPay3<900 )
{
fedIncTax3 = 75;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=900 && grossPay3<910 )
{
fedIncTax3 = 75;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=910 && grossPay3<920 )
{
fedIncTax3 = 77;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=920 && grossPay3<930 )
{
fedIncTax3 = 79;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=930 && grossPay3<940 )
{
fedIncTax3 = 80;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=940 && grossPay3<950 )
{
fedIncTax3 = 81;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=950 && grossPay3<960 )
{
fedIncTax3 = 82;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=960 && grossPay3<970 )
{
fedIncTax3 = 83;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=970 && grossPay3<980 )
{
fedIncTax3 = 84;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=980 && grossPay3<990 )
{
fedIncTax3 = 85;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=990 && grossPay3<1000 )
{
fedIncTax3 = 86;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=1000 && grossPay3<1010 )
{
fedIncTax3 = 87;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=1010 && grossPay3<1020 )
{
fedIncTax3 = 88;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=1020 && grossPay3<1030 )
{
fedIncTax3 = 90;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=1030 && grossPay3<1040 )
{
fedIncTax3 = 92;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else if (grossPay3 >=1040 && grossPay3<1050 )
{
fedIncTax3 = 94;
document.getElementById("fedIncTax3").innerHTML = fedIncTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
else
{
fedIncTax3 = 0;
alert("Federal tax table does not cover wages for this amount: Minimum amount is $698.25 and the maximum amount is $947.65");
}
Copy the code in the textarea box above.
Paste this code into your project just below the javaScript code for calculating hours worked.
Day 6: Determining FICA, Medicare, State Disability Insurance and State Training Tax
FICA stands for Federal Insurance Contributions Act, Social Security. It is a 6% deduction from employee paychecks. The employer must also match this amount of tax.
A wage base limit applies to employees who pay Social Security taxes. This means that gross income above a certain threshold is exempt from this tax. The wage limit changes almost every year based on inflation. For 2019, it was $132,900. For 2020, it’s $137,700. Wages paid exceeding $137,700 are not subject to the tax. As you can see from our payroll numbers, no employee will exceed this limit, so all of their earnings will be subject to the tax.
We are going to store the percentages for these taxes in local HTML5 storage. Next we will determine the fica deduction for each employee.
Then we will take the fica and medicare deductions and load them into the payroll register.
Next we store sdi at .005 and state traing at .001, store these numbers, calculate these taxes and load them into the payroll register.
// store in local storage fica, medicare, sdi, state training tax
var fica=.06;
localStorage.setItem("fica",fica);
//alert("Your file has been saved");
//retrieve();
localStorage.getItem("fica",fica);
//alert("fica is set to " + fica);
// medicare
var medicare=.0145;
localStorage.setItem("medicare", medicare);
//alert("Your file has been saved");
//retrieve();
localStorage.getItem("medicare",medicare);
//alert("medicare is set to " + medicare);
// state disability insurance
var sdi=.005;
localStorage.setItem("sdi", sdi);
//alert("Your file has been saved");
//retrieve();
localStorage.getItem("sdi",sdi);
//alert("sdi is set to " + sdi);
// state training tax
var stateTraining=.001;
localStorage.setItem("stateTraining", stateTraining);
//alert("Your file has been saved");
//retrieve();
localStorage.getItem("stateTraining",stateTraining);
//alert("stateTraining is set to " + stateTraining);
// multiply each by each employees' gross pay to determine amounts
var fica0 = grossPay0 * fica
var fica1 = grossPay1 * fica
var fica2 = grossPay2 * fica
var fica3 = grossPay3 * fica
//alert("fica0 for employee 0 is " + fica0);
document.getElementById("fica0").innerHTML = fica0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("fica1").innerHTML = fica1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("fica2").innerHTML = fica2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("fica3").innerHTML = fica3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
// calculate medicare for each employee
var medicare0 = grossPay0 * medicare
var medicare1 = grossPay1 * medicare
var medicare2 = grossPay2 * medicare
var medicare3 = grossPay3 * medicare
document.getElementById("medicare0").innerHTML = medicare0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("medicare1").innerHTML = medicare1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("medicare2").innerHTML = medicare2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("medicare3").innerHTML = medicare3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
Copy the code in the textarea box above.
Paste this code into your project just below the javaScript code for calculating gross pay.
Day 7: Determining State Income Tax
California provides two methods for determining the amount of wages and salaries to be withheld for state personal income tax:
• METHOD A - WAGE BRACKET TABLE METHOD (Limited to wages/salaries less than $1 million)
• METHOD B - EXACT CALCULATION METHOD
METHOD A provides a quick and easy way to select the appropriate withholding amount, based on the payroll period,
filing status, and number of withholding allowances (regular and additional) if claimed. The STANDARD DEDUCTION
and EXEMPTION ALLOWANCE CREDIT are already included in the wage bracket tables. Even though this method
involves fewer computations than Method B, it cannot be used with your computer in determining amounts to be withheld.
METHOD B may be used to calculate withholding amounts either manually or by computer. This method will give an exact
amount of tax to withhold. To use this method, you must enter the payroll period, filing status, number of withholding
allowances, standard deduction, and exemption allowance credit amounts. These amounts are included in TABLES 1
through 5 of the EXACT CALCULATION section.
California Tax table 5
California Tax Tables 3 and 4
We are going to use the Exact Calculation Method for our project.
Any time you write code, you need to make sure that you are getting the same results as if you calculated it manually. Let's do this for Jerry's pay check.
Jerry worked 35 hours
His pay rate is 25.55 per hour
His gross pay, therefore, would be $894.25 (25.55 times 35)
Next we look at table 3: standard deduction table.
The standard deduction for weekly pay periods dual income married people is $87.00
Next we subtract $87.00 from $894.25 and get $807.25
We subtract the standard deduction so we can still use grossPay as our determining variable.
We will add it back when we are finished calculating state income tax.
There are four lines subtracting the standard deduction from gross pay for each employee.
Next step is to look up $807.25 in table 5: Tax Rate Table for Method B - Exact Calculation Method
According to our payroll information, Jerry is married claims 4 exemptions and his wife works fulltime.
We look at weekly payroll, single persons, dual income married or married with multiple employers.
Jerry's adjusted gross pay, after deducting the standard deduction falls in the over $634 but not over $880 category.
Now we subtract $634 from $807.25 : result is $173.25
Now we multiply this amount by .066: result is $11.43
Next, we add $11.43 to $17.20: result is $28.63
Finally we look up Jerry's exemption from table 4 for weekly pay period
That amount is $10.32 for 4 exemptions.
The next step is to subtract 10.32 from 28.63. result is 18.31. That is Jerry's state income tax deduction for the week.
Next we add the standard deduction of $87.00 back into the gross pay
Manually try different hours for different employees and then compare your result with the code below.
Now its time to write the javascript code to accomplish this with the same results. We could code our project with the entire range of salaries or look at our particular situation.
For example Janet can make as little as 803.25 ( 35 hours times 22.95) and as much as 1090.13 (22.95 times 40 = 918.00) plus (22.95 times 1.5 times 5 hours 172.13)
Looking at the code, that is how I wrote it using lowest amount of gross pay to highest for each employee. Of course, crcumstances could change and the code would have to be modified. A raise in salary for an employee could affect the lines of code needed to process our payroll.
if (grossPay0>634 && grossPay0<880)
{
caTax0 =.066 * (grossPay0 -634) + 17.20
// get total deductions weekly 4 exemptions = 10.32
caTax0= caTax0-10.32
//alert("Jerry's ca tax is " + caTax0);
}
// calculate state income tax
//Jerry married max salary per week 1213
//Janet married max salary per week 1090
//Shelley married max salary per week 1042
//Julie max salary per week 947
var caTax0=0;//jerry
var caTax1=0;//janet
var caTax2 = 0;//julie
var caTax3 = 0;//shelley
// deduct standard deduction table 3
var grossPay0 = grossPay0-87.00
alert("gross pay for Jerry after standard deduction " + grossPay0);
var grossPay1 = grossPay1-87.00
var grossPay2 = grossPay2-87.00
var grossPay3 = grossPay3-87.00
if (grossPay0>634 && grossPay0<880)
{
caTax0 =.066 * (grossPay0 -634) + 17.20
// get total deductions weekly 4 exemptions = 10.32
caTax0= caTax0-10.32
}
else if (grossPay0>880 && grossPay0 <1112)
{
caTax0 = .088 * (grossPay0 -880) + 33.44
// get total deductions weekly 4 exemptions = 10.32
caTax0= caTax0-10.32
alert("Jerry's ca tax is " + caTax0);
}
else if (grossPay0>1112 && grossPay0< 5680)
{
caTax0= .1023 * (grossPay0-1112) + 53.86
// get total deductions weekly 4 exemptions = 10.32
caTax0= caTax0-10.32
//alert("Jerry's ca tax is " + caTax0);
}
else
{
alert("California State Income Tax can not be computed");
}
if (grossPay1>634 && grossPay1<880)
{
caTax1 =.066 * (grossPay1 -634) + 17.20
// get total deductions weekly 3 exemptions = 7.74
caTax1= caTax1-7.74
//alert("Janet's ca tax is " + caTax1);
}
else if (grossPay1>880 && grossPay1 <1112)
{
caTax1 = .088 * (grossPay1 -880) + 33.44
// get total deductions weekly 3 exemptions = 7.74
caTax1= caTax1-7.74
//alert("Janet's ca tax is " + caTax1);
}
else if (grossPay1>1112 && grossPay1< 5680)
{
caTax1= .1023 * (grossPay1-1112) + 53.86
// get total deductions weekly 3 exemptions = 7.74
caTax1= caTax1-7.74
//alert("Janet's ca tax is " + caTax1);
}
else
{
alert("Janet's California Income Tax can not be computed");
}
//Jule single 1 exemption
if (grossPay2>634 && grossPay2<880)
{
caTax2 =.066 * (grossPay2 -634) + 17.20
// get total deductions weekly 1 exemptions = 2.58
caTax2= caTax2-2.58
//alert("Julie's ca tax is " + caTax2);
}
else if (grossPay2>880 && grossPay2 <1112)
{
caTax2 = .088 * (grossPay2 -880) + 33.44
// get total deductions weekly 1 exemptions = 2.58
caTax2= caTax2-2.58
//alert("Julie's ca tax is " + caTax2);
}
else if (grossPay2>1112 && grossPay2< 5680)
{
caTax2= .1023 * (grossPay2-1112) + 53.86
// get total deductions weekly 1 exemptions = 2.58
caTax2= caTax2-2.58
// alert("Julie's ca tax is " + caTax2);
}
else
{
alert("Tax can not be computed");
}
// Shelley married 3 exemptions
if (grossPay3>402 && grossPay3<634)
{
caTax3 =.044 * (grossPay3 -402) + 6.99
// get total deductions weekly married 3 exemptions = 7.74
caTax3= caTax3-7.74
//alert("Shelley's ca tax is " + caTax3);
}
else if (grossPay3>634 && grossPay3<880)
{
caTax3 =.066 * (grossPay3 -634) + 17.20
// get total deductions weekly married 3 exemptions = 7.74
caTax3= caTax3-7.74
//alert("Shelley's ca tax is " + caTax3);
}
else if (grossPay3>880 && grossPay3 <1112)
{
caTax3 = .088 * (grossPay3 -880) + 33.44
// get total deductions weekly married 3 exemptions = 7.74
caTax3= caTax3-7.74
//alert("Shelley's ca tax is " + caTax3);
}
else if (grossPay3>1112 && grossPay3< 5680)
{
caTax3= .1023 * (grossPay3-1112) + 53.86
// get total deductions weekly married 3 exemptions = 7.74
caTax3= caTax3-7.74
//alert("Shelley's's ca tax is " + caTax3);
}
else
{
alert("Tax can not be computed");
}
document.getElementById("caTax0").innerHTML = caTax0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("caTax1").innerHTML = caTax1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("caTax2").innerHTML = caTax2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("caTax3").innerHTML = caTax3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
// add 87 back into gross pay to adjust for state income tax deduction
var grossPay0 = grossPay0 + 87;
var grossPay1 = grossPay1 + 87;
var grossPay2 = grossPay2 + 87;
var grossPay3 = grossPay3 + 87;
Copy the code in the textarea box above.
Paste this code into your project just below the javaScript code for calculating FICA, and Medicare.
Day 8: Calculating State Disability, State Training tax, total deductions and net pay
Now its time to calculate state disability insurance .009, state training tax,.001, total all deductions and calculate net pay. Here is the code.
/ California state Disability insurance .009
var sdi0=grossPay0 * .009;
var sdi1=grossPay1 * .009;
var sdi2=grossPay2 * .009;
var sdi3=grossPay3 * .009;
document.getElementById("sdi0").innerHTML = sdi0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("sdi1").innerHTML = sdi1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("sdi2").innerHTML = sdi2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("sdi3").innerHTML = sdi3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
// state training tax .001
var stt0=grossPay0 * .001;
var stt1=grossPay1 * .001;
var stt2=grossPay2 * .001;
var stt3=grossPay3 * .001;
document.getElementById("stt0").innerHTML = stt0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("stt1").innerHTML = stt1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("stt2").innerHTML = stt2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("stt3").innerHTML = stt3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
// total deductions
var td0=fedIncTax0 + fica0 + medicare0 + sdi0 + caTax0 + stt0
var td1=fedIncTax1 + fica1 + medicare1 + sdi1 + caTax1 + stt1
var td2=fedIncTax2 + fica2 + medicare2 + sdi2 + caTax2 + stt2
var td3=fedIncTax3 + fica3 + medicare3 + sdi3 + caTax3 + stt3
document.getElementById("td0").innerHTML = td0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("td1").innerHTML = td1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("td2").innerHTML = td2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("td3").innerHTML = td3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
// calculate net pay for each employee. subtract total deductions from gross pay
var np0=grossPay0-td0;
var np1=grossPay1-td1;
var np2=grossPay2-td2;
var np3=grossPay3-td3;
document.getElementById("np0").innerHTML = np0.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("np1").innerHTML = np1.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("np2").innerHTML = np2.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("np3").innerHTML = np3.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
Copy the code in the textarea box above.
Paste this code into your project just below the javaScript code for calculating State Income tax.
Day 9: Totaling Payroll register
Now its time to total up the payroll register.
// calculate totals for payroll register
var totalHoursWorked = hoursWorked0 + hoursWorked1 + hoursWorked2 + hoursWorked3;
var grossPay = grossPay0 + grossPay1+ grossPay2 + grossPay3;
var fedIncTax= fedIncTax0 + fedIncTax1 + fedIncTax2 + fedIncTax3;
var fica = fica0 + fica1 + fica2 + fica3
var medicare = medicare0 + medicare1 + medicare2 + medicare3;
var sdi = sdi0 + sdi1 + sdi2 + sdi3;
var caTax = caTax0 + caTax1 + caTax2 + caTax3;
var stt = stt0 + stt1 + stt2 + stt3;
var td = td0 + td1 + td2 + td3;
var np = np0 + np1 + np2 + np3
document.getElementById("grossPay").innerHTML = grossPay.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("fedIncTax").innerHTML = fedIncTax.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("fica").innerHTML = fica.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("medicare").innerHTML = medicare.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("sdi").innerHTML = sdi.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("caTax").innerHTML = caTax.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("stt").innerHTML = stt.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("td").innerHTML = td.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("np").innerHTML = np.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
Copy the code in the textarea box above.
Paste this code into your project just below the javaScript code for totaling total deductions and net pay.
Save your register.html project and launch it using your favorite browser. Enter different hours for each employee. Remember F12 to activate your javaScript debugger. The concole view shows you any errors and the lines where they occured.
Day 10: Employer's share of the payroll taxes
The employer must match FICA and Medicare deductions taken out of employees' paychecks. In addition they must pay federal unemployment tax (FUTA)
The Federal Unemployment Tax Act (or FUTA, I.R.C. ch. 23) is a United States federal law that imposes a federal employer tax used to help fund state workforce agencies. Employers report this tax by filing an annual Form 940 with the Internal Revenue Service. In some cases, the employer is required to pay the tax in installments during the tax year.
Wikipedia definition: FUTA covers a federal share of the costs of administering the unemployment insurance (UI) and job service programs in every state. In addition, FUTA pays one-half of the cost of extended unemployment benefits (during periods of high unemployment) and provides for a fund from which states may borrow, if necessary, to pay benefits.
Currently that rate is .6% or .006¹. It is paid on the first $7,000 of each employees' gross pay.
To check for the $7,000 for each employee, you would need to get the totals from the employees' earning records. I created a calculator to sum up gross pay for our employees.
FUTA Calculator
The acronym SUTA is for "State Unemployment Tax."
In all 50 states, each employer is given a variable "experience" or "unemployment insurance" rate, depending on various factors, including worker retention. Some businesses retain the same employees for years and have a low rate, but other industries, such as construction, tend to have high turnover and a corresponding higher rate. New businesses are given a new employer rate, which varies per state (California's, for example, is 3.4%); they stay on that rate for a few years, when they are considered "experience rated."
Employers pay state unemployment insurance for each employee based on their gross pay.¹
Here is the code to calculate employers' payroll taxes:
var ficaEmployer =fica;
var medicareEmployer= medicare;
var futaEmployer= (grossPay0 * .006) + (grossPay1 * .006) + (grossPay2 * .006) + (grossPay3 * .006);
var sutaEmployer = (grossPay0 * .034) + (grossPay1 * .034) + (grossPay2 * .034) + (grossPay3 * .034);
document.getElementById("ficaEmployer").innerHTML = "FICA = " + fica.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("medicareEmployer").innerHTML = "Medicare = " + medicareEmployer.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("futaEmployer").innerHTML = "FUTA = " + futaEmployer.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
document.getElementById("sutaEmployer").innerHTML = "SUTA= " +sutaEmployer.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
Copy and paste this code segment just after where printed out the payroll register totals.
Information needed for employee earning records
// store information needed for employee's earning records
var week=document.forms.Payroll.week.value;
alert("week = " + week);
localStorage.setItem("week", week);
//store hours worked for Jerry
if (week == "january1"){
localStorage.setItem("hoursWorked0", hoursWorked0);
//localStorage.getItem("hoursWorked0", hoursWorked0);
// store hours worked for Janet
localStorage.setItem("hoursWorked1", hoursWorked1);
// store hours worked for Julie
localStorage.setItem("hoursWorked2", hoursWorked2);
//store hours for Shelley
localStorage.setItem("hoursWorked3", hoursWorked3);
//store gross pay for Jerry
localStorage.setItem("grossPay0", grossPay0);
// store gross pay for Janet
localStorage.setItem("grossPay1", grossPay1);
// store gross pay for Julie
localStorage.setItem("grossPay2", grossPay2);
// store grosspay for Shelley
localStorage.setItem("grossPay3", grossPay3);
// store fedIncTax for all employees
localStorage.setItem("fedIncTax0", fedIncTax0);
localStorage.setItem("fedIncTax1", fedIncTax1);
localStorage.setItem("fedIncTax2", fedIncTax2);
localStorage.setItem("fedIncTax3", fedIncTax3);
// store fica for all employees
localStorage.setItem("fica0", fica0);
localStorage.setItem("fica1", fica1);
localStorage.setItem("fica2", fica2);
localStorage.setItem("fica3", fica3);
// store values for medicare for all employees
localStorage.setItem("medicare0", medicare0);
localStorage.setItem("medicare1", medicare1);
localStorage.setItem("medicare2", medicare2);
localStorage.setItem("medicare3", medicare3);
// store caTAx for each employee
localStorage.setItem("caTax0", caTax0);
localStorage.setItem("caTax1", caTax1);
localStorage.setItem("caTax2", caTax2);
localStorage.setItem("caTax3", caTax3);
// store sdi for each employee
localStorage.setItem("sdi0", sdi0);
localStorage.setItem("sdi1", sdi1);
localStorage.setItem("sdi2", sdi2);
localStorage.setItem("sdi3", sdi3);
// store state training tax for all employees
localStorage.setItem("stt0", stt0);
localStorage.setItem("stt1", stt1);
localStorage.setItem("stt2", stt2);
localStorage.setItem("stt3", stt3);
// store total deductions for each employee
localStorage.setItem("td0", td0);
localStorage.setItem("td1", td1);
localStorage.setItem("td2", td2);
localStorage.setItem("td3", td3);
// store net pay for all employees
localStorage.setItem("np0", np0);
localStorage.setItem("np1", np1);
localStorage.setItem("np2", np2);
localStorage.setItem("np3", np3);
}
if (week == "january2"){
var hoursWorked0w2 =localStorage.setItem("hoursWorked0w2", hoursWorked0);
//localStorage.getItem("hoursWorked0", hoursWorked0);
// store hours worked for Janet
var hoursWorked1w2 = localStorage.setItem("hoursWorked1w2", hoursWorked1);
// store hours worked for Julie
var hoursWorked2w2 = localStorage.setItem("hoursWorked2w2", hoursWorked2);
//store hours for Shelley
var hoursWorked3w2 = localStorage.setItem("hoursWorked3w2", hoursWorked3);
//store gross pay for Jerry
var grossPay0w2 = localStorage.setItem("grossPay0w2", grossPay0);
// store gross pay for Janet
var grossPay1w2 = localStorage.setItem("grossPay1w2", grossPay1);
// store gross pay for Julie
var grossPay2w2 = localStorage.setItem("grossPay2w2", grossPay2);
// store grosspay for Shelley
var grossPay3w2 = localStorage.setItem("grossPay3w2", grossPay3);
// store fedIncTax for all employees
var fedIncTax0w2 = localStorage.setItem("fedIncTax0w2", fedIncTax0);
var fedIncTax1w2 = localStorage.setItem("fedIncTax1w2", fedIncTax1);
var fedIncTax2w2 = localStorage.setItem("fedIncTax2w2", fedIncTax2);
var fedIncTax3w2 = localStorage.setItem("fedIncTax3w2", fedIncTax3);
// store fica for all employees
var fica0w2 = localStorage.setItem("fica0w2", fica0);
var fica1w2 = localStorage.setItem("fica1w2", fica1);
var fica2w2 = localStorage.setItem("fica2w2", fica2);
var fica3w2 = localStorage.setItem("fica3w2", fica3);
// store values for medicare for all employees
var medicare0w2 = localStorage.setItem("medicare0w2", medicare0);
var medicare1w2 = localStorage.setItem("medicare1w2", medicare1);
var medicare2w2 = localStorage.setItem("medicare2w2", medicare2);
var medicare3w2 = localStorage.setItem("medicare3w2", medicare3);
// store caTAx for each employee
var caTax0w2 = localStorage.setItem("caTax0w2", caTax0);
var caTax1w2= localStorage.setItem("caTax1w2", caTax1);
var caTax2w2 = localStorage.setItem("caTax2w2", caTax2);
var caTax3w2 = localStorage.setItem("caTax3w2", caTax3);
// store sdi for each employee
var sdi0w2 = localStorage.setItem("sdi0w2", sdi0);
var sdi1w2 = localStorage.setItem("sdi1w2", sdi1);
var sdi2w2 = localStorage.setItem("sdi2w2", sdi2);
var sdi3w2 = localStorage.setItem("sdi3w2", sdi3);
// store state training tax for all employees
var stt0w2 = localStorage.setItem("stt0w2", stt0);
var stt1w2 = localStorage.setItem("stt1w2", stt1);
var stt2w2 = localStorage.setItem("stt2w2", stt2);
var stt3w2 = localStorage.setItem("stt3w2", stt3);
// store total deductions for each employee
var td0w2 = localStorage.setItem("td0w2", td0);
var td1w2 = localStorage.setItem("td1w2", td1);
var td2w2 = localStorage.setItem("td2w2", td2);
var td3w2 = localStorage.setItem("td3w2", td3);
// store net pay for all employees
var np0w2 = localStorage.setItem("np0w2", np0);
var np1w2 = localStorage.setItem("np1w2", np1);
var np2w2 = localStorage.setItem("np2w2", np2);
var np3w2 = localStorage.setItem("np3w2", np3);
}
if (week == "january3"){
var hoursWorked0w3 =localStorage.setItem("hoursWorked0w3", hoursWorked0);
//localStorage.getItem("hoursWorked0", hoursWorked0);
// store hours worked for Janet
var hoursWorked1w3 = localStorage.setItem("hoursWorked1w3", hoursWorked1);
// store hours worked for Julie
var hoursWorked2w3 = localStorage.setItem("hoursWorked2w3", hoursWorked2);
//store hours for Shelley
var hoursWorked3w3 = localStorage.setItem("hoursWorked3w3", hoursWorked3);
//store gross pay for Jerry
var grossPay0w3 = localStorage.setItem("grossPay0w3", grossPay0);
// store gross pay for Janet
var grossPay1w3 = localStorage.setItem("grossPay1w3", grossPay1);
// store gross pay for Julie
var grossPay2w3 = localStorage.setItem("grossPay2w3", grossPay2);
// store grosspay for Shelley
var grossPay3w3 = localStorage.setItem("grossPay3w3", grossPay3);
// store fedIncTax for all employees
var fedIncTax0w3 = localStorage.setItem("fedIncTax0w3", fedIncTax0);
var fedIncTax1w3 = localStorage.setItem("fedIncTax1w3", fedIncTax1);
var fedIncTax2w3 = localStorage.setItem("fedIncTax2w3", fedIncTax2);
var fedIncTax3w3 = localStorage.setItem("fedIncTax3w3", fedIncTax3);
// store fica for all employees
var fica0w3 = localStorage.setItem("fica0w3", fica0);
var fica1w3 = localStorage.setItem("fica1w3", fica1);
var fica2w3 = localStorage.setItem("fica2w3", fica2);
var fica3w3 = localStorage.setItem("fica3w3", fica3);
// store values for medicare for all employees
var medicare0w3 = localStorage.setItem("medicare0w3", medicare0);
var medicare1w3 = localStorage.setItem("medicare1w3", medicare1);
var medicare2w3 = localStorage.setItem("medicare2w3", medicare2);
var medicare3w3 = localStorage.setItem("medicare3w3", medicare3);
// store caTAx for each employee
var caTax0w3 = localStorage.setItem("caTax0w3", caTax0);
var caTax1w3= localStorage.setItem("caTax1w3", caTax1);
var caTax2w3 = localStorage.setItem("caTax2w3", caTax2);
var caTax3w3 = localStorage.setItem("caTax3w3", caTax3);
// store sdi for each employee
var sdi0w3 = localStorage.setItem("sdi0w3", sdi0);
var sdi1w3 = localStorage.setItem("sdi1w3", sdi1);
var sdi2w3 = localStorage.setItem("sdi2w3", sdi2);
var sdi3w3 = localStorage.setItem("sdi3w3", sdi3);
// store state training tax for all employees
var stt0w3 = localStorage.setItem("stt0w3", stt0);
var stt1w3 = localStorage.setItem("stt1w3", stt1);
var stt2w3 = localStorage.setItem("stt2w3", stt2);
var stt3w3 = localStorage.setItem("stt3w3", stt3);
// store total deductions for each employee
var td0w3 = localStorage.setItem("td0w3", td0);
var td1w3 = localStorage.setItem("td1w3", td1);
var td2w3 = localStorage.setItem("td2w3", td2);
var td3w3 = localStorage.setItem("td3w3", td3);
// store net pay for all employees
var np0w3 = localStorage.setItem("np0w3", np0);
var np1w3 = localStorage.setItem("np1w3", np1);
var np2w3 = localStorage.setItem("np2w3", np2);
var np3w3 = localStorage.setItem("np3w3", np3);
}
if (week == "january4"){
var hoursWorked0w4 =localStorage.setItem("hoursWorked0w4", hoursWorked0);
//localStorage.getItem("hoursWorked0", hoursWorked0);
// store hours worked for Janet
var hoursWorked1w4 = localStorage.setItem("hoursWorked1w4", hoursWorked1);
// store hours worked for Julie
var hoursWorked2w4 = localStorage.setItem("hoursWorked2w4", hoursWorked2);
//store hours for Shelley
var hoursWorked3w4 = localStorage.setItem("hoursWorked3w4", hoursWorked3);
//store gross pay for Jerry
var grossPay0w4 = localStorage.setItem("grossPay0w4", grossPay0);
// store gross pay for Janet
var grossPay1w4 = localStorage.setItem("grossPay1w4", grossPay1);
// store gross pay for Julie
var grossPay2w4 = localStorage.setItem("grossPay2w4", grossPay2);
// store grosspay for Shelley
var grossPay3w4 = localStorage.setItem("grossPay3w4", grossPay3);
// store fedIncTax for all employees
var fedIncTax0w4 = localStorage.setItem("fedIncTax0w4", fedIncTax0);
var fedIncTax1w4 = localStorage.setItem("fedIncTax1w4", fedIncTax1);
var fedIncTax2w4 = localStorage.setItem("fedIncTax2w4", fedIncTax2);
var fedIncTax3w4 = localStorage.setItem("fedIncTax3w4", fedIncTax3);
// store fica for all employees
var fica0w4 = localStorage.setItem("fica0w4", fica0);
var fica1w4 = localStorage.setItem("fica1w4", fica1);
var fica2w4 = localStorage.setItem("fica2w4", fica2);
var fica3w4 = localStorage.setItem("fica3w4", fica3);
// store values for medicare for all employees
var medicare0w4 = localStorage.setItem("medicare0w4", medicare0);
var medicare1w4 = localStorage.setItem("medicare1w4", medicare1);
var medicare2w4 = localStorage.setItem("medicare2w4", medicare2);
var medicare3w4 = localStorage.setItem("medicare3w4", medicare3);
// store caTAx for each employee
var caTax0w4 = localStorage.setItem("caTax0w4", caTax0);
var caTax1w4= localStorage.setItem("caTax1w4", caTax1);
var caTax2w4 = localStorage.setItem("caTax2w4", caTax2);
var caTax3w4 = localStorage.setItem("caTax3w4", caTax3);
// store sdi for each employee
var sdi0w4 = localStorage.setItem("sdi0w4", sdi0);
var sdi1w4 = localStorage.setItem("sdi1w4", sdi1);
var sdi2w4 = localStorage.setItem("sdi2w4", sdi2);
var sdi3w4 = localStorage.setItem("sdi3w4", sdi3);
// store state training tax for all employees
var stt0w4 = localStorage.setItem("stt0w4", stt0);
var stt1w4 = localStorage.setItem("stt1w4", stt1);
var stt2w4 = localStorage.setItem("stt2w4", stt2);
var stt3w4 = localStorage.setItem("stt3w4", stt3);
// store total deductions for each employee
var td0w4 = localStorage.setItem("td0w4", td0);
var td1w4 = localStorage.setItem("td1w4", td1);
var td2w4 = localStorage.setItem("td2w4", td2);
var td3w4 = localStorage.setItem("td3w4", td3);
// store net pay for all employees
var np0w4 = localStorage.setItem("np0w4", np0);
var np1w4 = localStorage.setItem("np1w4", np1);
var np2w4 = localStorage.setItem("np2w4", np2);
var np3w4 = localStorage.setItem("np3w4", np3);
}
}
function validateRadio(Payroll)
{
if(Payroll.week[0].checked == true)
{
return true;
}
if(Payroll.week[1].checked == true)
{
return true;
}
if(Payroll.week[2].checked == true)
{
return true;
}
if(Payroll.week[3].checked == true)
{
return true;
}
return false;
}
Copy and paste this code segment just after employer payroll taxes section.
In this lesson, our employee earning records can accomodate just 4 weeks. We need to provide the amounts each week. You will notice that on the register.HTML page there are four radio buttons, week one, week 2, week 3 and week 4.
We can use the same interface each week for entering hours and have the variables saved by person, deductions and week.
Let's look at the validateRadio(Payroll) function first. It is the last function in the textarea box above.
First we check to see which button has been clicked. Then if has been clicked we return true otherwise we return false.
This code is to prevent a user from not selecting a week for the payroll. This code is at the beginning of the calclate() function.
function calculate()
{
if(validateRadio(Payroll)==false)
{
alert("Click on the week for the payroll");
return;
}
There are four variables, one for each week, for each employee. These variables are declared and then stored in local storage. The earnings record page will read and intrepret these variables.
Run the program. Enter hours for each employee for each week. Check to see if was stored, by pressing F12 and checking the presence of the variables.
Remember if you switch browsers, the data will not be there. It is stored by the web page and the browser used.
Completed register page
Day 11: Employee Earning Records: module 3
Payroll accounting involves keeping track of each employees' hours worked, gross pay, federal income tax withheld, FICA and Medicare deductions, State income tax withheld, SDI, State Training, total deductions and net pay.
At the end of each year, every employer engaged in a trade or business who pays remuneration, including noncash payments of $600 or more for the year (all amounts if any income, social security, or Medicare tax was withheld) for services performed by an employee must file a Form W-2 for each employee (even if the employee is related to the employer) from whom:
Income, Social Security, or Medicare tax was withheld.
Income tax would have been withheld if the employee had claimed no more than one withholding allowance or had not claimed exemption from withholding on Form W-4, Employee's Withholding Allowance Certificate.
Here is all of the code for the earnings.html page.
Employee Earning Records
Employee Name Job title Marital Status Exem. Pay Rate
Pay Period Hours Gross Pay Fed Inc Tax FICA Medicare State Inc Tax SDI State Train Total Deductions Net Pay
Week 1
Week 2
Week 3
Week 4
Employee Name Job title Marital Status Exem. Pay Rate
Pay Period Hours Gross Pay Fed Inc Tax FICA Medicare State Inc Tax SDI State Train Total Deductions Net Pay
Week 1
Week 2
Week 3
Week 4
Employee Name Job title Marital Status Exem. Pay Rate
Pay Period Hours Gross Pay Fed Inc Tax FICA Medicare State Inc Tax SDI State Train Total Deductions Net Pay
Week 1
Week 2
Week 3
Week 4
Employee Name Job title Marital Status Exem. Pay Rate
Pay Period Hours Gross Pay Fed Inc Tax FICA Medicare State Inc Tax SDI State Train Total Deductions Net Pay
Week 1
Week 2
Week 3
Week 4
Copy and paste this code into Notepad++ and save the HTML file as earnings.html.
Now let's look at what the code on this page does.
Define the array with employee information: name, marital status, exemptions, pay rate.
Load the array into the first table for each employee.
Retrieve from local storage, hours worked for all.
Get gross pay, federal income tax, FICA, Medicare, etc for Jerry
Get same information for the other employees and put them into the second table for each employee.
Run your earnings.html page and compare it to Employee Earnings Page
Day 12: Modifications to payroll app.
Seldom do things remain static. Changes happen. Think about what you would need to do in order to modify the program if the following events occured.
Shelley got a $3.00 per hour raise.
What modules are affected?
Write out the code both html and javascript code to accomodate this change.
Make the changes to your modules and test.
What modules are affected
The company hired a part time sales person at $15.00 per hour 20 hours per week. Hal Beecher, single one exemption.
Julie got married and her new last name is now Winslow.
Her husband works full time.
They file a joint return.
What modules are affected?
Write out the code both html and javascript to handle this event.
Actually change the code to make these changes.