]> gitweb.factorcode.org Git - factor.git/commitdiff
fix taxes
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 3 Oct 2008 00:03:57 +0000 (19:03 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 3 Oct 2008 00:03:57 +0000 (19:03 -0500)
extra/taxes/usa/federal/federal.factor
extra/taxes/usa/fica/fica.factor
extra/taxes/usa/usa-tests.factor
extra/taxes/usa/usa.factor

index 5274535f81c19b1d04dfe0de57e255545ad738b2..b71b831ca6068ba922cf25670c883f2020cf422e 100644 (file)
@@ -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> federal withholding* ]
+        [ dup entity>> withholding* ] 3bi +
+    ] if ;
+
+: net ( salary w4 collector -- x )
+    >r dupd r> total-withholding - ;
index e71b2723a32717e692ac88e2cc76af09b756fc1e..c1e85b75b4e1ee1f963d02608135bb8b86cc49db 100644 (file)
@@ -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
index 6aac4b928c0e7847c7e2a979715b814a5ef2f6eb..a529762c81500a2d75cbab65007d207f40c6945f 100644 (file)
@@ -110,9 +110,9 @@ IN: taxes.usa.tests
 
 
 [ 138 69 ] [
-    24000 2008 2 f <w4> <federal> withholding biweekly dollars/cents
+    24000 2008 2 f <w4> <federal> total-withholding biweekly dollars/cents
 ] unit-test
 
 [ 754 72 ] [
-    78250 2008 2 f <w4> <federal> withholding biweekly dollars/cents
+    78250 2008 2 f <w4> <federal> total-withholding biweekly dollars/cents
 ] unit-test
index 1d21524b4561bb577ce04bafacada97c575e3ec4..27ff4aef989f40efd89280150e97380a2b401af4 100644 (file)
@@ -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> 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 - ;