Medicare.pm
Medicare->calculate(
gross, # gross pay
date, # date of payment
)
{
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.
return data{$foundDate}->{rate} * gross
}
data{$foundDate}->
|
{rate}
|
ex. data{20010101}->
|
|
sub new()
{
#create tables for lookup
#when did they set it at 1.45%?
data{
'19990101' => {rate => 0.0145},
'20000101' => {rate => 0.0145}
}
}