! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs kernel math math.intervals
-namespaces sequences money math.order taxes.usa.fica
-taxes.usa.medicare taxes.usa taxes.usa.w4 ;
+USING: accessors kernel math money taxes.usa taxes.usa.fica
+taxes.usa.medicare taxes.usa.w4 ;
IN: taxes.usa.federal
! http://www.irs.gov/pub/irs-pdf/p15.pdf
-! Table 7 ANNUAL Payroll Period
+! Table 7 ANNUAL Payroll Period
: federal-single ( -- triples )
{
M: federal withholding* ( salary w4 tax-table entity -- x )
drop
- [ federal-tax ] 3keep drop
+ [ federal-tax ] 2keepd
[ fica-tax ] 2keep
medicare-tax + + ;
: total-withholding ( salary w4 tax-table -- x )
dup entity>> dup federal = [
- withholding*
+ withholding*
] [
drop
[ drop <federal> federal withholding* ]
] if ;
: net ( salary w4 collector -- x )
- >r dupd r> total-withholding - ;
+ [ dupd ] dip total-withholding - ;