line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::AMEX::Transaction 0.005; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
516271
|
use strict; |
|
9
|
|
|
|
|
74
|
|
|
9
|
|
|
|
|
250
|
|
4
|
9
|
|
|
9
|
|
54
|
use warnings; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
251
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Parse AMEX transaction files: EPRAW, EPPRC, EPTRN, CBNOT, GRRCN |
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
3272
|
use Finance::AMEX::Transaction::CBNOT; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
208
|
|
9
|
9
|
|
|
9
|
|
3253
|
use Finance::AMEX::Transaction::EPRAW; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
219
|
|
10
|
9
|
|
|
9
|
|
3257
|
use Finance::AMEX::Transaction::EPPRC; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
212
|
|
11
|
9
|
|
|
9
|
|
3463
|
use Finance::AMEX::Transaction::EPTRN; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
221
|
|
12
|
9
|
|
|
9
|
|
3301
|
use Finance::AMEX::Transaction::GRRCN; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
4075
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
14
|
|
|
14
|
1
|
2693
|
my ($class, %props) = @_; |
16
|
|
|
|
|
|
|
|
17
|
14
|
|
|
|
|
82
|
my $self = bless { |
18
|
|
|
|
|
|
|
_file_type => undef, |
19
|
|
|
|
|
|
|
_file_format => undef, |
20
|
|
|
|
|
|
|
_file_version => undef, |
21
|
|
|
|
|
|
|
_parser => undef, |
22
|
|
|
|
|
|
|
}, $class; |
23
|
|
|
|
|
|
|
|
24
|
14
|
|
|
|
|
65
|
my $type_map = { |
25
|
|
|
|
|
|
|
EPRAW => 'Finance::AMEX::Transaction::EPRAW', |
26
|
|
|
|
|
|
|
EPPRC => 'Finance::AMEX::Transaction::EPPRC', |
27
|
|
|
|
|
|
|
EPTRN => 'Finance::AMEX::Transaction::EPTRN', |
28
|
|
|
|
|
|
|
CBNOT => 'Finance::AMEX::Transaction::CBNOT', |
29
|
|
|
|
|
|
|
GRRCN => 'Finance::AMEX::Transaction::GRRCN', |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
14
|
|
|
|
|
65
|
$self->{_file_type} = $props{file_type}; |
33
|
14
|
|
100
|
|
|
74
|
$self->{_file_format} = $props{file_format} || 'UNKNOWN'; |
34
|
14
|
|
100
|
|
|
62
|
$self->{_file_version} = $props{file_version} || 'UNKNOWN'; |
35
|
|
|
|
|
|
|
|
36
|
14
|
50
|
33
|
|
|
43
|
if ($self->file_type and exists $type_map->{$self->file_type}) { |
37
|
14
|
|
|
|
|
43
|
$self->{_parser} = $type_map->{$self->file_type}->new( |
38
|
|
|
|
|
|
|
file_format => $self->file_format, |
39
|
|
|
|
|
|
|
file_version => $self->file_version, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
14
|
|
|
|
|
55
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub file_type { |
47
|
42
|
|
|
42
|
1
|
69
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
42
|
|
|
|
|
149
|
return $self->{_file_type}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub file_format { |
53
|
1344
|
|
|
1344
|
1
|
2412
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
1344
|
|
|
|
|
3698
|
return $self->{_file_format}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub file_version { |
59
|
1346
|
|
|
1346
|
1
|
2345
|
my ($self) = @_; |
60
|
|
|
|
|
|
|
|
61
|
1346
|
|
|
|
|
3551
|
return $self->{_file_version}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub parser { |
65
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
return $self->{_parser}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub getline { |
71
|
1300
|
|
|
1300
|
1
|
18675
|
my ($self, $fh) = @_; |
72
|
|
|
|
|
|
|
|
73
|
1300
|
|
|
|
|
6015
|
my $line = <$fh>; |
74
|
1300
|
|
|
|
|
3063
|
return $self->parse_line($line); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub parse_line { |
78
|
1300
|
|
|
1300
|
1
|
3005
|
my ($self, $line) = @_; |
79
|
|
|
|
|
|
|
|
80
|
1300
|
|
|
|
|
4531
|
my $ret = $self->{_parser}->parse_line($line); |
81
|
|
|
|
|
|
|
|
82
|
1300
|
|
|
|
|
3394
|
$self->_set_file_format; |
83
|
1300
|
|
|
|
|
3000
|
$self->_set_file_version; |
84
|
|
|
|
|
|
|
|
85
|
1300
|
|
|
|
|
2864
|
return $ret; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _set_file_format { |
89
|
1300
|
|
|
1300
|
|
1992
|
my ($self) = @_; |
90
|
|
|
|
|
|
|
|
91
|
1300
|
100
|
|
|
|
2478
|
return if not $self->file_format eq 'UNKNOWN'; |
92
|
13
|
50
|
|
|
|
48
|
return if $self->file_format eq $self->{_parser}->file_format; |
93
|
13
|
50
|
|
|
|
89
|
return if $self->{_parser}->file_format eq 'UNKNOWN'; |
94
|
|
|
|
|
|
|
|
95
|
13
|
|
|
|
|
31
|
$self->{_file_format} = $self->{_parser}->file_format; |
96
|
|
|
|
|
|
|
|
97
|
13
|
|
|
|
|
32
|
return $self->file_format; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _set_file_version { |
101
|
1300
|
|
|
1300
|
|
2035
|
my ($self) = @_; |
102
|
|
|
|
|
|
|
|
103
|
1300
|
100
|
|
|
|
2272
|
return if not $self->file_version eq 'UNKNOWN'; |
104
|
12
|
50
|
|
|
|
27
|
return if $self->file_version eq $self->{_parser}->file_version; |
105
|
12
|
50
|
|
|
|
66
|
return if $self->{_parser}->file_version eq 'UNKNOWN'; |
106
|
|
|
|
|
|
|
|
107
|
12
|
|
|
|
|
34
|
$self->{_file_version} = $self->{_parser}->file_version; |
108
|
|
|
|
|
|
|
|
109
|
12
|
|
|
|
|
30
|
return $self->file_version; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |