Business-US_Amort
view release on metacpan or search on metacpan
lib/Business/US_Amort.pm view on Meta::CPAN
=back
=cut
###########################################################################
%Proto = # public attributes and their values
(
principal => 0,
interest_rate => 8, # annual, percent
term => 30, # years (target term)
error => '',
cent_rounding => 1,
start_date => undef,
initial_monthly_payment => undef,
total_paid_interest => undef,
total_month_count => undef,
am_snapshot => 0, # flag for objects that are snapshots
lib/Business/US_Amort.pm view on Meta::CPAN
return 0;
}
$this->{'term'} = abs($this->{'term'} + 0);
unless($this->{'term'}) {
$this->{'error'} = 'term must be positive and nonzero';
return 0;
}
# The only real voodoo is here:
my $j = # monthly interest rate in decimal -- in percent, not like .0875
$this->{'interest_rate'} / 1200;
my $n = # number of months the loan is amortized over
int($this->{'term'} * 12);
#print "j: $j\n";
if($j) {
#print "Nonzero interest\n";
$this->{'initial_monthly_payment'} =
$this->maybe_round(
$this->{'_remainder'} * $j / ( 1 - (1 + $j) ** (-$n) )
( run in 0.300 second using v1.01-cache-2.11-cpan-709fd43a63f )