factor/extra/taxes/usa/usa.factor

34 lines
1.0 KiB
Factor
Raw Normal View History

2008-09-30 13:47:46 -04:00
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs kernel math math.intervals
2009-02-09 20:18:18 -05:00
namespaces sequences money math.order taxes.usa.w4
2009-02-09 23:05:58 -05:00
taxes.usa.futa math.finance ;
2008-09-30 13:47:46 -04:00
IN: taxes.usa
! Withhold: FICA, Medicare, Federal (FICA is social security)
TUPLE: tax-table entity single married ;
C: <tax-table> tax-table
GENERIC: adjust-allowances* ( salary w4 tax-table entity -- newsalary )
GENERIC: withholding* ( salary w4 tax-table entity -- x )
: adjust-allowances ( salary w4 tax-table -- newsalary )
dup entity>> adjust-allowances* ;
: withholding ( salary w4 tax-table -- x )
2008-10-02 20:03:57 -04:00
dup entity>> withholding* ;
2008-09-30 13:47:46 -04:00
: tax-bracket-range ( pair -- n ) first2 swap - ;
: tax-bracket ( tax salary triples -- tax salary )
[ [ tax-bracket-range min ] keep third * + ] 2keep
tax-bracket-range [-] ;
: tax ( salary triples -- x )
0 -rot [ tax-bracket ] each drop ;
: marriage-table ( w4 tax-table -- triples )
swap married?>>
[ married>> ] [ single>> ] if ;