StateIncome.pm

StateIncome->calculate(
    gross,            # - gross pay
    date,             #- date of payment format YYYYMMDD
    method,         #- specifies mthod to use. currently only 1
    allowances    #, - state allowances claimed, integer
    period,             #- annual, semiannual, quarterly, monthly, semimonthly, biweekly, weekly, daily
    marital,             #- single, married, spouseWorks, head
    federal,             #- amount of federal tax withheld here
    fYTD,             #- total federal tax withheld yeart to date
    round,             #yes, no - defaults to yes
)
{
    #Step 1.1
    if period ne "annual"
      aGross = annualize(gross, period)
    #Step 1.2
    aGross -= dataTables{$foundDate}->{standardDeduction}->{marital}
    #Step 1.3
    if allowances >= 1
        aGross -= dataTables{$foundDate}->{allowance1}->{marital}
    if allowances >= 2
        aGross -= dataTables{$foundDate}->{allowance2}->{marital}
    if allowances >= 3
        aGross -= dataTables{$foundDate}->{allowance3}->{marital}
    if allowances >= 4
        aGross -= dataTables{$foundDate}->{allowance4}->{marital}
    if allowances >= 5
        aGross -= (dataTables{$foundDate}->{allowance5}->{marital} * (allowances -4))
    #Step 1.4
    aFed = annualize(federal, period) - dataTables{$foundDate}->{federalLimit}->{marital}
    #Step 1.5 done along the way and finished here
    aGross -= aFed

    #Step 2.1   lookup tables for percentages
#need to place table in reverse oder so that we can know the top is
   mGross = aGross
    for (in reverse)
       if mGross >= bottom[x]
          if bottom[x] == 0
            tax+= (mGross) * percent[x]
            mGross = 0
          else
            tax += (mGross - bottom[x] + .01) * percent[x]  #bottom is inclusive
            mGross = bottom[x] - .01
 
    #Step 2.2
    tax = reverseAnnualize(tax, period)
    
    if round eq "no"
        return tax
    else
        return round(tax) #to whole number
}

#############!!!!!!!!!!!!!!!make the  ='s   into   =>'s
new()
{
    $dataTables->{tables}
    dataTables{'20020101' =>
            { standardDeduction => {single = '4700', married = '7850' , spouseworks = '3925', head ='6900' },
               allowance1 => { single = '1200', married = '1200' , spouseworks = '1200', head = '3500'},
               allowance2 => { single = '1200', married = '1200' , spouseworks = '1200', head = '0'},
               allowance3 => { single = '1200', married = '1200' , spouseworks = '1200', head = '0'},
               allowance4 => { single = '1200', married = '1200' , spouseworks = '1200', head = '0'},
               allowance5 => { single = '1200', married = '1200' , spouseworks = '1200', head = '1200'},
                federalLimit = '5000', married = '10000' , spouseworks = '5000', head = '10000'} ,
                percentTable =>
                    {top = '1000.00', percent = '1.5' },
                    {top = '2000.00', percent = '2.0' },
                    {top = '3000.00', percent = '2.5' },
                    {top = '4000.00', percent = '3.0' },
                    {top = '5000.00', percent = '3.5' },
                    {top = '6000.00', percent = '4.0' },
                    {top = '7000.00', percent = '4.5' },
                    {top = '8000.00', percent = '5.0' },
                    {top = '9000.00', percent = '5.5' },
                    {top = '-1', percent = '6.0' }
            }
        }
    dataTables{$foundDate}->{allowance1}->{marital}

The periodDays hash holds the number of days in a period
periodDays->
{annual}
= 1

{semiannual}
= 2

{quarterly}
= 4

{monthly}
= 12

{semimonthly}
= 24

{biweekly}
= 26

{weekly}
= 52

{daily}
= 260

}