]> pd.if.org Git - amortization/blob - examples/htmlamtable
initial commit from pause
[amortization] / examples / htmlamtable
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use lib '../blib/lib';
7
8 use Finance::Amortization;
9 use HTML::Table;
10
11 # this program generates a 30 year amortization table on a $200,000
12 # loan at 7%
13
14 my $am = Finance::Amortization->new(principal => 200000, rate => .07,
15          periods => 30*12, compounding => 12, precision => 2);
16
17
18 #balance, interest, payment
19
20 my @cols = qw(Period Payment Interest Principal Balance);
21
22 my $table = HTML::Table->new(0, 5);
23
24 $table->addRow(@cols);
25 $table->setRowHead(1);
26
27 my $pmt = $am->payment;
28
29 for(1 .. 30*12) {
30         my ($int, $bal) = ($am->interest($_),$am->balance($_));
31         $table->addRow($_, $pmt, $int, $pmt-$int, $bal);
32 }
33
34 $table->print;