line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Loan; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
32557
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
783
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
) ] ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw( |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Technique for new class borrowed from Effective Perl Programming by Hall / Schwartz pp 211 |
23
|
|
|
|
|
|
|
sub new{ |
24
|
1
|
|
|
1
|
1
|
13
|
my $pkg = shift; |
25
|
|
|
|
|
|
|
# bless package variables |
26
|
1
|
|
|
|
|
10
|
bless{ |
27
|
|
|
|
|
|
|
principle => 0.00, |
28
|
|
|
|
|
|
|
interest_rate => 0.00, |
29
|
|
|
|
|
|
|
number_of_months => 0, |
30
|
|
|
|
|
|
|
@_}, $pkg; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Forecasting With Your Microcomputer pp 198 |
34
|
|
|
|
|
|
|
sub getMonthlyPayment{ |
35
|
2
|
|
|
2
|
1
|
8
|
my $self = shift; |
36
|
2
|
|
100
|
|
|
11
|
my $flag = shift || 1; |
37
|
|
|
|
|
|
|
# P = Principle |
38
|
|
|
|
|
|
|
# r = interest Rate Per Month (eg. 14%/12) |
39
|
|
|
|
|
|
|
# S = Monthly Payemnt |
40
|
|
|
|
|
|
|
# n = Number of Months |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
10
|
my $P = $self->{principle}; |
43
|
2
|
|
|
|
|
4
|
my $r = $self->{interest_rate}/12; |
44
|
2
|
|
|
|
|
5
|
my $n = $self->{number_of_months}; |
45
|
2
|
100
|
|
|
|
6
|
if ($flag==1) |
46
|
|
|
|
|
|
|
{ |
47
|
1
|
|
|
|
|
34
|
my $almost_val = ($P*$r*((1+$r)**$n))/(((1+$r)**$n)-1.0); |
48
|
1
|
|
|
|
|
22
|
my $retval = sprintf("%0.2f",$almost_val); |
49
|
1
|
|
|
|
|
4
|
return($retval); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else |
52
|
|
|
|
|
|
|
{ |
53
|
1
|
|
|
|
|
17
|
return($P*$r*((1+$r)**$n))/(((1+$r)**$n)-1.0); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Forecasting With Your Microcomputer pp198 |
58
|
|
|
|
|
|
|
sub getInterestPaid{ |
59
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
60
|
|
|
|
|
|
|
# (n*s)-P |
61
|
1
|
|
|
|
|
2
|
my $n = $self->{number_of_months}; |
62
|
1
|
|
|
|
|
5
|
my $S = getMonthlyPayment($self,2); |
63
|
1
|
|
|
|
|
3
|
my $P = $self->{principle}; |
64
|
1
|
|
|
|
|
2
|
my $almost_val = ($n*$S)-$P; |
65
|
1
|
|
|
|
|
7
|
my $retval = sprintf("%0.2f",$almost_val); |
66
|
1
|
|
|
|
|
3
|
return($retval); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub getDailyInterest{ |
70
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
71
|
1
|
|
|
|
|
3
|
my $P = $self->{principle}; |
72
|
1
|
|
|
|
|
3
|
my $i = $self->{interest_rate}; |
73
|
1
|
|
|
|
|
3
|
my $val = $P * $i / 365; |
74
|
1
|
|
|
|
|
4
|
my $retval = sprintf("%0.2f",$val); |
75
|
1
|
|
|
|
|
4
|
return($retval); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
__END__ |