1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel math money taxes.usa taxes.usa.fica
4 taxes.usa.medicare taxes.usa.w4 ;
7 ! http://www.irs.gov/pub/irs-pdf/p15.pdf
8 ! Table 7 ANNUAL Payroll Period
10 : federal-single ( -- triples )
13 { 2650 10300 DECIMAL: .10 }
14 { 10300 33960 DECIMAL: .15 }
15 { 33960 79725 DECIMAL: .25 }
16 { 79725 166500 DECIMAL: .28 }
17 { 166500 359650 DECIMAL: .33 }
18 { 359650 1/0. DECIMAL: .35 }
21 : federal-married ( -- triples )
24 { 8000 23550 DECIMAL: .10 }
25 { 23550 72150 DECIMAL: .15 }
26 { 72150 137850 DECIMAL: .25 }
27 { 137850 207700 DECIMAL: .28 }
28 { 207700 365100 DECIMAL: .33 }
29 { 365100 1/0. DECIMAL: .35 }
33 : <federal> ( -- obj )
34 federal federal-single federal-married <tax-table> ;
36 : federal-tax ( salary w4 tax-table -- n )
37 [ adjust-allowances ] 2keep marriage-table tax ;
39 M: federal adjust-allowances* ( salary w4 collector entity -- newsalary )
40 2drop calculate-w4-allowances - ;
42 M: federal withholding* ( salary w4 tax-table entity -- x )
44 [ federal-tax ] 2keepd
48 : total-withholding ( salary w4 tax-table -- x )
49 dup entity>> dup federal = [
53 [ drop <federal> federal withholding* ]
54 [ dup entity>> withholding* ] 3bi +
57 : net ( salary w4 collector -- x )
58 [ dupd ] dip total-withholding - ;