line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Spreadsheet::Engine::Function::NPV; |
2
|
|
|
|
|
|
|
|
3
|
28
|
|
|
28
|
|
156
|
use strict; |
|
28
|
|
|
|
|
60
|
|
|
28
|
|
|
|
|
936
|
|
4
|
28
|
|
|
28
|
|
139
|
use warnings; |
|
28
|
|
|
|
|
60
|
|
|
28
|
|
|
|
|
797
|
|
5
|
|
|
|
|
|
|
|
6
|
28
|
|
|
28
|
|
146
|
use base 'Spreadsheet::Engine::Fn::base'; |
|
28
|
|
|
|
|
65
|
|
|
28
|
|
|
|
|
10388
|
|
7
|
|
|
|
|
|
|
|
8
|
51
|
|
|
51
|
1
|
138
|
sub argument_count { -2 } |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub result { |
11
|
51
|
|
|
51
|
1
|
89
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
51
|
|
|
|
|
144
|
my $rate = $self->next_operand_as_number; |
14
|
51
|
50
|
|
|
|
1248
|
die $rate if $rate->is_error; |
15
|
|
|
|
|
|
|
|
16
|
51
|
|
|
|
|
1470
|
my $type = Spreadsheet::Engine::Value->new(type => 'n', value => '0'); |
17
|
51
|
|
|
|
|
948
|
my $sum = 0; |
18
|
51
|
|
|
|
|
78
|
my $factor = 1; |
19
|
|
|
|
|
|
|
|
20
|
51
|
|
|
|
|
84
|
while (@{ $self->foperand }) { |
|
188
|
|
|
|
|
3416
|
|
21
|
137
|
|
|
|
|
381
|
my $op = $self->next_operand; |
22
|
137
|
50
|
33
|
|
|
2987
|
die Spreadsheet::Engine::Error->new(type => $op->type, value => $sum) |
23
|
|
|
|
|
|
|
if $op->is_error && !$type->is_error; |
24
|
|
|
|
|
|
|
|
25
|
137
|
50
|
|
|
|
1330
|
if ($op->is_num) { |
26
|
137
|
50
|
|
|
|
3687
|
$factor *= (1 + $rate->value) or die Spreadsheet::Engine::Error->div0; |
27
|
137
|
|
|
|
|
3527
|
$sum += $op->value / $factor; |
28
|
137
|
|
|
|
|
1119
|
$type = $self->optype(plus => $op, $type); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
51
|
50
|
|
|
|
177
|
return Spreadsheet::Engine::Value->new( |
33
|
|
|
|
|
|
|
type => $type->is_num ? 'n$' : $type->type, |
34
|
|
|
|
|
|
|
value => $sum |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |