| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Finance::AMEX::Transaction::GRRCN; |
|
2
|
|
|
|
|
|
|
$Finance::AMEX::Transaction::GRRCN::VERSION = '0.003'; |
|
3
|
7
|
|
|
7
|
|
46
|
use strict; |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
190
|
|
|
4
|
7
|
|
|
7
|
|
34
|
use warnings; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
161
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
4842
|
use Text::CSV; |
|
|
7
|
|
|
|
|
134177
|
|
|
|
7
|
|
|
|
|
358
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
3137
|
use Finance::AMEX::Transaction::GRRCN::Header; |
|
|
7
|
|
|
|
|
22
|
|
|
|
7
|
|
|
|
|
206
|
|
|
9
|
7
|
|
|
7
|
|
3281
|
use Finance::AMEX::Transaction::GRRCN::Summary; |
|
|
7
|
|
|
|
|
20
|
|
|
|
7
|
|
|
|
|
177
|
|
|
10
|
7
|
|
|
7
|
|
3023
|
use Finance::AMEX::Transaction::GRRCN::TaxRecord; |
|
|
7
|
|
|
|
|
23
|
|
|
|
7
|
|
|
|
|
190
|
|
|
11
|
7
|
|
|
7
|
|
3293
|
use Finance::AMEX::Transaction::GRRCN::Submission; |
|
|
7
|
|
|
|
|
24
|
|
|
|
7
|
|
|
|
|
174
|
|
|
12
|
7
|
|
|
7
|
|
3474
|
use Finance::AMEX::Transaction::GRRCN::Transaction; |
|
|
7
|
|
|
|
|
20
|
|
|
|
7
|
|
|
|
|
202
|
|
|
13
|
7
|
|
|
7
|
|
3233
|
use Finance::AMEX::Transaction::GRRCN::TxnPricing; |
|
|
7
|
|
|
|
|
20
|
|
|
|
7
|
|
|
|
|
174
|
|
|
14
|
7
|
|
|
7
|
|
3120
|
use Finance::AMEX::Transaction::GRRCN::Chargeback; |
|
|
7
|
|
|
|
|
20
|
|
|
|
7
|
|
|
|
|
191
|
|
|
15
|
7
|
|
|
7
|
|
3275
|
use Finance::AMEX::Transaction::GRRCN::Adjustment; |
|
|
7
|
|
|
|
|
22
|
|
|
|
7
|
|
|
|
|
184
|
|
|
16
|
7
|
|
|
7
|
|
3113
|
use Finance::AMEX::Transaction::GRRCN::FeeRevenue; |
|
|
7
|
|
|
|
|
20
|
|
|
|
7
|
|
|
|
|
204
|
|
|
17
|
7
|
|
|
7
|
|
2885
|
use Finance::AMEX::Transaction::GRRCN::Trailer; |
|
|
7
|
|
|
|
|
20
|
|
|
|
7
|
|
|
|
|
182
|
|
|
18
|
7
|
|
|
7
|
|
2868
|
use Finance::AMEX::Transaction::GRRCN::Unknown; |
|
|
7
|
|
|
|
|
22
|
|
|
|
7
|
|
|
|
|
3915
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# ABSTRACT: Parse AMEX Global Reconciliation (GRRCN) |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
|
23
|
1
|
|
|
1
|
1
|
3
|
my ($class, %props) = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
7
|
my $type_map = { |
|
26
|
|
|
|
|
|
|
HEADER => 'Finance::AMEX::Transaction::GRRCN::Header', |
|
27
|
|
|
|
|
|
|
SUMMARY => 'Finance::AMEX::Transaction::GRRCN::Summary', |
|
28
|
|
|
|
|
|
|
TAXRECORD => 'Finance::AMEX::Transaction::GRRCN::TaxRecord', |
|
29
|
|
|
|
|
|
|
SUBMISSION => 'Finance::AMEX::Transaction::GRRCN::Submission', |
|
30
|
|
|
|
|
|
|
TRANSACTN => 'Finance::AMEX::Transaction::GRRCN::Transaction', |
|
31
|
|
|
|
|
|
|
TXNPRICING => 'Finance::AMEX::Transaction::GRRCN::TxnPricing', |
|
32
|
|
|
|
|
|
|
CHARGEBACK => 'Finance::AMEX::Transaction::GRRCN::Chargeback', |
|
33
|
|
|
|
|
|
|
ADJUSTMENT => 'Finance::AMEX::Transaction::GRRCN::Adjustment', |
|
34
|
|
|
|
|
|
|
FEEREVENUE => 'Finance::AMEX::Transaction::GRRCN::FeeRevenue', |
|
35
|
|
|
|
|
|
|
TRAILER => 'Finance::AMEX::Transaction::GRRCN::Trailer', |
|
36
|
|
|
|
|
|
|
}; |
|
37
|
|
|
|
|
|
|
|
|
38
|
1
|
|
50
|
|
|
5
|
my $file_format = $props{format} || 'UNKNOWN'; |
|
39
|
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
3
|
my $self = bless { |
|
41
|
|
|
|
|
|
|
_type_map => $type_map, |
|
42
|
|
|
|
|
|
|
_file_format => $file_format, |
|
43
|
|
|
|
|
|
|
}, $class; |
|
44
|
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
3
|
return $self; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub file_format { |
|
49
|
392
|
|
|
392
|
0
|
603
|
my ($self) = @_; |
|
50
|
392
|
|
|
|
|
1222
|
return $self->{_file_format}; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub detect_file_format { |
|
54
|
1
|
|
|
1
|
0
|
3
|
my ($self, $line) = @_; |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
50
|
|
|
|
4
|
if (substr($line, 0, 1) eq '"') { |
|
57
|
1
|
50
|
|
|
|
5
|
if ($line =~ m{","}) { |
|
|
|
0
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
3
|
$self->{_file_format} = 'CSV'; |
|
59
|
|
|
|
|
|
|
} elsif ($line =~ m{\"\t\"}) { |
|
60
|
0
|
|
|
|
|
0
|
$self->{_file_format} = 'TSV'; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
2
|
return $self->{_file_format}; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
0
|
|
|
|
|
0
|
$self->{_file_format} = 'FIXED'; |
|
66
|
0
|
|
|
|
|
0
|
return $self->{_file_format}; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub parse_line { |
|
70
|
99
|
|
|
99
|
1
|
224
|
my ($self, $line) = @_; |
|
71
|
|
|
|
|
|
|
|
|
72
|
99
|
100
|
|
|
|
249
|
return if not defined $line; |
|
73
|
|
|
|
|
|
|
|
|
74
|
98
|
100
|
|
|
|
231
|
if ($self->file_format eq 'UNKNOWN') { |
|
75
|
1
|
|
|
|
|
3
|
$self->detect_file_format($line); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
98
|
|
|
|
|
232
|
my $type = $self->detect_line_type($line); |
|
79
|
|
|
|
|
|
|
|
|
80
|
98
|
50
|
|
|
|
1638
|
if (exists $self->{_type_map}->{$type}) { |
|
81
|
98
|
|
|
|
|
229
|
return $self->{_type_map}->{$type}->new(line => $line, file_format => $self->file_format); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
0
|
return Finance::AMEX::Transaction::GRRCN::Unknown->new(line => $line); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub detect_line_type { |
|
88
|
98
|
|
|
98
|
0
|
205
|
my ($self, $line) = @_; |
|
89
|
|
|
|
|
|
|
|
|
90
|
98
|
50
|
|
|
|
165
|
if ($self->file_format eq 'FIXED') { |
|
91
|
0
|
|
|
|
|
0
|
return substr($line, 0, 10); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
98
|
50
|
|
|
|
457
|
my $csv = Text::CSV->new ({ |
|
95
|
|
|
|
|
|
|
binary => 1, |
|
96
|
|
|
|
|
|
|
quote_char => '"', |
|
97
|
|
|
|
|
|
|
escape_char => "\\", |
|
98
|
|
|
|
|
|
|
}) or die "Cannot use CSV: ".Text::CSV->error_diag (); |
|
99
|
98
|
|
|
|
|
12057
|
$line =~ s{\s+\z}{}; # csv parser does not like trailing whitespace |
|
100
|
|
|
|
|
|
|
|
|
101
|
98
|
50
|
|
|
|
259
|
if ($self->file_format eq 'CSV') { |
|
|
|
0
|
|
|
|
|
|
|
102
|
98
|
|
|
|
|
280
|
$csv->sep_char(','); |
|
103
|
|
|
|
|
|
|
} elsif ($self->file_format eq 'TSV') { |
|
104
|
0
|
|
|
|
|
0
|
$csv->sep_char("\t"); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
98
|
50
|
|
|
|
4285
|
if (my $status = $csv->parse($line)) { |
|
108
|
98
|
|
|
|
|
3162
|
return ($csv->fields)[0]; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |