| 1 | package Finance::AMEX::Transaction; | ||||||||||||||||||||||||||||
| 2 | 7 | $Finance::AMEX::Transaction::VERSION = '0.003'; | |||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Parse AMEX transaction files: EPRAW, EPPRC, EPTRN, CBNOT, GRRCN | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Finance::AMEX::Transaction::CBNOT; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use Finance::AMEX::Transaction::EPRAW; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Finance::AMEX::Transaction::EPPRC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use Finance::AMEX::Transaction::EPTRN; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use Finance::AMEX::Transaction::GRRCN; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | sub new { | ||||||||||||||||||||||||||||
| 15 | 7 | ▶ | my ($class, %props) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 7 | my $self = bless { | |||||||||||||||||||||||||||
| 18 | _file_type => undef, | ||||||||||||||||||||||||||||
| 19 | _file_format => undef, | ||||||||||||||||||||||||||||
| 20 | _parser => undef, | ||||||||||||||||||||||||||||
| 21 | }, $class; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 7 | my $type_map = { | |||||||||||||||||||||||||||
| 24 | EPRAW => 'Finance::AMEX::Transaction::EPRAW', | ||||||||||||||||||||||||||||
| 25 | EPPRC => 'Finance::AMEX::Transaction::EPPRC', | ||||||||||||||||||||||||||||
| 26 | EPTRN => 'Finance::AMEX::Transaction::EPTRN', | ||||||||||||||||||||||||||||
| 27 | CBNOT => 'Finance::AMEX::Transaction::CBNOT', | ||||||||||||||||||||||||||||
| 28 | GRRCN => 'Finance::AMEX::Transaction::GRRCN', | ||||||||||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 7 | $self->{_file_type} = $props{file_type}; | |||||||||||||||||||||||||||
| 32 | 7 | $self->{_file_format} = $props{file_format}; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 7 | ▶ | if ($self->file_type and exists $type_map->{$self->file_type}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->file_type and exists $$type_map{$self->file_type}
MC/DC0%0/2
$self->file_type and exists $$type_map{$self->file_type}
$self->file_type
exists $$type_map{$self->file_type}
Truth table33%1/3
A and B
A= $self->file_typeB= exists $$type_map{$self->file_type}
| |||||||||||||||||||||||||||||
| 35 | 7 | $self->{_parser} = $type_map->{$self->file_type}->new(file_format => $self->file_format); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 7 | return $self; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub file_type { | ||||||||||||||||||||||||||||
| 42 | 21 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
file_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 21 | return $self->{_file_type}; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | sub file_format { | ||||||||||||||||||||||||||||
| 48 | 7 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
file_format: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 7 | return $self->{_file_format}; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub parser { | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parser: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | return $self->{_parser}; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub getline { | ||||||||||||||||||||||||||||
| 60 | 1287 | ▶ | my ($self, $fh) = @_; | ||||||||||||||||||||||||||
|
Subroutine
getline: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 1287 | my $line = <$fh>; | |||||||||||||||||||||||||||
| 63 | 1287 | return $self->parse_line($line); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | sub parse_line { | ||||||||||||||||||||||||||||
| 67 | 1287 | ▶ | my ($self, $line) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parse_line: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 1287 | my $ret = $self->{_parser}->parse_line($line); | |||||||||||||||||||||||||||
| 70 | 1287 | return $ret; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 7 | 1; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||