# The Awesome Factor

## Monday, February 11, 2008

### Factor Tax Library

I've been doing my own taxes for a few years, so I decided to start writing some Factor words to help with the calculations. This library does FICA tax, Medicare tax, and federal income tax, along with Minnesota state tax.

To get paid by an employer you fill out a Form W-4 which they keep on file. The three relevant pieces of information are the tax year (2008), the number of allowances, and whether or not you are married.

In Factor this looks like:
`TUPLE: w4 year allowances married? ;C: <w4> w4`

To calculate your withholding, or the amount your employer should withhold from your salary every pay period, the library starts with your yearly salary, a Form W-4, and a tax collector entity, such as <federal> or <minnesota> and calls the withholding word.

For the average single male programmer making \$70k per year, the calculation looks like this:
`( scratchpad ) 70000   2008 3 f <w4> <federal> withholding dup money.\$16,054.00( scratchpad ) biweekly money.\$617.46`

The government's cut of your paycheck isn't too hard to calculate. The employer withholds 6.2% of your paycheck for FICA (social security) and contributes a matching 6.2% that is over and above your salary, for a total of 12.4%. The FICA tax has what's known as a base rate, which is a ceiling on the amount of your salary that this tax is applied to. For 2008, the base rate is \$102,000, which means that the FICA tax is not applied above this amount. Additionally, you and your employer pay Medicare tax, which is 1.45% each for a total of 3.9%, and this is applied to all income (no base rate).

Now for the Federal income tax. Take your salary and subtract \$3500 times the number of allowances you claimed on your Form W-4. For instance, three allowances (working only one job, claiming self as a dependent, and head of household) will give you a \$10,500 allowance, which will leave \$59,500 taxable income. (Note: FICA and Medicare tax apply to the entire salary, while Federal income tax applies only to the salary - allowances) There are several equivalent charts for looking up the federal income tax withholding, so this library uses the annual one because it was easiest to encode.

So for the example salary of \$70,000 with three allowances, the calculation looks like:
`( scratchpad ) 70000 2008 3 f <w4> <federal> federal-tax money.\$10,699.00( scratchpad ) 70000  2008 3 f <w4> fica-tax money.\$4,340.00( scratchpad ) 70000  2008 3 f <w4> <federal> medicare-tax money.\$1,015.00( scratchpad ) { 10699 4340 1015 } sum money.\$16,054.00( scratchpad ) 70000  2008 3 f <w4> <federal> withholding money.\$16,054.00`

Salaries are taxed at different rates as they increase. For example, the first \$2,650 dollars you make are taxed at 0% federal income tax rate. This does not mean you pay no tax at all; FICA and Medicare still apply. From \$2,650 to \$10,300 the tax rate is 10%. So, if somehow you were making \$8,650 per year after deducting allowances, you would be in the second tax bracket and your taxable income would be \$6000, taxed at 10%, for a total of \$600. Your employer would withhold this amount from your paychecks and pay it to the government quarterly. (Note: the numbers above are for single people, married people have a more advantageous table)

Minnesota has one of the highest state taxes. To calculate this tax, take the same allowances from your Form W-4 and calculate the allowance per the federal income tax, \$3,500 per allowance. Again, there are two tables -- single and married. The tax amounts are 5.35%, 7.05%, and 7.85% in the highest bracket.
`( scratchpad ) 70000  2008 3 f <w4> <minnesota> withholding money.\$3,686.68`

So, altogether, the employer withholds your federal and state taxes from the paycheck. You can calculate this:
`( scratchpad ) 70000  2008 3 f <w4>  employer-withhold dup money. biweekly money.\$19,740.68\$759.26( scratchpad ) 70000  2008 3 f <w4> <minnesota> net money. biweekly money.\$50,259.33`

So if you make \$70k in Minnesota, your employer should withhold \$759.26 per paycheck, to be split between the federal and state government and paid quarterly (or monthly). You would get to keep \$50,259.33 and the employer would give you a Form W-2 with the relevant details. You could the file income tax returns on April 15th, where you could possibly get some of that back from various deductions and refunds.

All values are calculated in rational numbers, so they are exact until the end, where the cents are rounded to the nearest cent. Percentages are in the source as decimal numbers, and are parsed using the `DECIMAL:` word.

`( scratchpad ) DECIMAL: .1 .1/10`

Please feel free to submit patches for other states and to help me correct any bugs.

#### 1 comment:

Blogger said...

QUANTUM BINARY SIGNALS