PCX Payroll System

FICA.pm
FICA->calculate(
gross, # gross pay
date, # date of payment
YTD # total FICA payments made year to date
)
{
iterate over sorted keys descending in data hash.
Compare $date to keys.
Stop when $date >= key.
set $foundDate = $key.
If date < all keys, that is an error.
my $cap = data{$foundDate}->{cap}
my $rate = data{$foundDate}->{rate}
if (YTD >= $cap)
return 0
else
{
fica = rate * gross
if (fica + YTD <= cap)
return fica
else
return (cap - YTD) * rate
}
}

data{$foundDate}-> | {rate}
ex. data{20010101}-> | {cap}

sub new()
{
#create tables for lookup
data{
'19990101' => {rate => 0.0565, cap => 68000},
'20010101' => {rate => 0.0565, cap => 72000}
}
}