diff --git a/extra/taxes/usa/federal/federal.factor b/extra/taxes/usa/federal/federal.factor index 5274535f81..b71b831ca6 100644 --- a/extra/taxes/usa/federal/federal.factor +++ b/extra/taxes/usa/federal/federal.factor @@ -45,3 +45,15 @@ M: federal withholding* ( salary w4 tax-table entity -- x ) [ federal-tax ] 3keep drop [ fica-tax ] 2keep medicare-tax + + ; + +: total-withholding ( salary w4 tax-table -- x ) + dup entity>> dup federal = [ + withholding* + ] [ + drop + [ drop federal withholding* ] + [ dup entity>> withholding* ] 3bi + + ] if ; + +: net ( salary w4 collector -- x ) + >r dupd r> total-withholding - ; diff --git a/extra/taxes/usa/fica/fica.factor b/extra/taxes/usa/fica/fica.factor index e71b2723a3..c1e85b75b4 100644 --- a/extra/taxes/usa/fica/fica.factor +++ b/extra/taxes/usa/fica/fica.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors math math.order money ; +USING: accessors assocs.lib math math.order money ; IN: taxes.usa.fica : fica-tax-rate ( -- x ) DECIMAL: .062 ; inline diff --git a/extra/taxes/usa/usa-tests.factor b/extra/taxes/usa/usa-tests.factor index 6aac4b928c..a529762c81 100644 --- a/extra/taxes/usa/usa-tests.factor +++ b/extra/taxes/usa/usa-tests.factor @@ -110,9 +110,9 @@ IN: taxes.usa.tests [ 138 69 ] [ - 24000 2008 2 f withholding biweekly dollars/cents + 24000 2008 2 f total-withholding biweekly dollars/cents ] unit-test [ 754 72 ] [ - 78250 2008 2 f withholding biweekly dollars/cents + 78250 2008 2 f total-withholding biweekly dollars/cents ] unit-test diff --git a/extra/taxes/usa/usa.factor b/extra/taxes/usa/usa.factor index 1d21524b45..27ff4aef98 100644 --- a/extra/taxes/usa/usa.factor +++ b/extra/taxes/usa/usa.factor @@ -1,8 +1,7 @@ ! 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.w4 -taxes.usa.federal ; +namespaces sequences money math.order taxes.usa.w4 ; IN: taxes.usa ! Withhold: FICA, Medicare, Federal (FICA is social security) @@ -17,12 +16,7 @@ GENERIC: withholding* ( salary w4 tax-table entity -- x ) dup entity>> adjust-allowances* ; : withholding ( salary w4 tax-table -- x ) - dup entity>> federal = [ - dup entity>> withholding* - ] [ - [ dup entity>> withholding* ] - [ drop federal withholding* ] 3bi + - ] if ; + dup entity>> withholding* ; : tax-bracket-range ( pair -- n ) first2 swap - ; @@ -36,6 +30,3 @@ GENERIC: withholding* ( salary w4 tax-table entity -- x ) : marriage-table ( w4 tax-table -- triples ) swap married?>> [ married>> ] [ single>> ] if ; - -: net ( salary w4 collector -- x ) - >r dupd r> withholding - ;