line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Number::Object::Plugin::Tax; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2252
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
81
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
5
|
2
|
|
|
2
|
|
10
|
use base 'Class::Component::Plugin'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
25829
|
use POSIX (); |
|
2
|
|
|
|
|
15934
|
|
|
2
|
|
|
|
|
190
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $RATE = '1.05'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub tax :Method { |
12
|
12
|
|
|
12
|
0
|
3572
|
my($self, $c, $args) = @_; |
13
|
12
|
|
|
|
|
46
|
$c->clone($self->calc($c)); |
14
|
2
|
|
|
2
|
|
1876
|
} |
|
2
|
|
|
|
|
3014
|
|
|
2
|
|
|
|
|
18
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub include_tax :Method { |
17
|
12
|
|
|
12
|
0
|
9240
|
my($self, $c, $args) = @_; |
18
|
12
|
|
|
|
|
54
|
$c->clone($self->calc($c) + $c->{value}); |
19
|
2
|
|
|
2
|
|
774
|
} |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub calc { |
22
|
24
|
|
|
24
|
0
|
45
|
my($self, $c, $rate) = @_; |
23
|
24
|
|
50
|
|
|
86
|
$rate ||= $self->config->{rate} || 1; |
|
|
|
66
|
|
|
|
|
24
|
24
|
|
|
|
|
133
|
my $price = $c->{value}; |
25
|
|
|
|
|
|
|
|
26
|
24
|
|
50
|
|
|
73
|
my $method = $self->config->{method} || 'floor'; |
27
|
24
|
50
|
|
|
|
233
|
$method = 'floor' unless $method eq 'ceil'; |
28
|
24
|
|
|
|
|
52
|
$method = "calc_$method"; |
29
|
|
|
|
|
|
|
|
30
|
24
|
|
|
|
|
134
|
$self->$method(($price * $rate) - $price); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub calc_floor { |
34
|
24
|
|
|
24
|
0
|
39
|
my($self, $price) = @_; |
35
|
24
|
|
|
|
|
213
|
POSIX::floor($price); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub calc_ceil { |
39
|
0
|
|
|
0
|
0
|
|
my($self, $price) = @_; |
40
|
0
|
|
|
|
|
|
POSIX::ceil($price); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |