Bankwest/Parser/TransactionExport.pm

filter: Statementstmt 100% 64 / 64 Branchbran 100% 16 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod n/a totaltotal 100% 94 / 94 CC 11 SCAR 12.5
CC
11
Cov
100%
__ANON__
6.0
handle
6.0
BEGIN
1.0
CRAP 3.5
« Bankwest/SessionFromLogin.pm ↑ Summary Bankwest/Session.pm »
1 package Finance::Bank::Bankwest::Parser::TransactionExport;
2 # ABSTRACT: transaction CSV export parser
3 9 $Finance::Bank::Bankwest::Parser::TransactionExport::VERSION = '1.2.8';
4  
5 ## no critic (RequireUseStrict, RequireUseWarnings, RequireEndWithOne)
6 10 ▶use MooseX::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use HTTP::Response::Switch::Handler 1.000000;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 class Finance::Bank::Bankwest::Parser::TransactionExport
9 with HTTP::Response::Switch::Handler
10 10 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
11 10 ▶ use Finance::Bank::Bankwest::Transaction ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶ use IO::String ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 10 ▶ use Text::CSV_XS 0.66 (); # for "empty_is_undef" attribute
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 10 ▶ method handle {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=6 SCAR=17.9
Subroutine handle: called CC=6 SCAR=17.9
16 2 ▶ $self->decline
Branch: 2 branches
BranchTrueFalseTotal
if $self->response->headers->content_type ne "text/csv" 1 1 2
if $self->response->headers->content_type ne "text/csv" 1 1 2
17 if $self->response->headers->content_type ne 'text/csv';
18  
19 1 my $io = IO::String->new( $self->response->content_ref );
20 1 my $csv = Text::CSV_XS->new({
21 auto_diag => 2,
22 empty_is_undef => 1,
23 });
24 1 $csv->column_names( $csv->getline($io) );
25  
26 1 my @txns;
27 1 ▶ while (my $row = $csv->getline_hr($io)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $row = $csv->getline_hr($io)) 8 1 9
if (my $row = $csv->getline_hr($io)) 8 1 9
28 8 my $amount;
29 8 for (qw{ Credit Debit }) {
30 16 ▶ next if not defined $row->{$_};
Branch: 2 branches
BranchTrueFalseTotal
unless defined $row->{$_} 8 8 16
unless defined $row->{$_} 8 8 16
31 8 $amount = $row->{$_};
32 8 ▶ undef $amount if $amount == 0;
Branch: 2 branches
BranchTrueFalseTotal
if $amount == 0 1 7 8
if $amount == 0 1 7 8
33 }
34 push @txns, Finance::Bank::Bankwest::Transaction->new(
35 date => $row->{'Transaction Date'},
36 narrative => $row->{'Narration'},
37 cheque_num => $row->{'Cheque Number'},
38 amount => $amount,
39 8 type => $row->{'Transaction Type'},
40 );
41 }
42 1 return @txns;
43 10 }
44 10 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 __END__
« Bankwest/SessionFromLogin.pm ↑ Summary Bankwest/Session.pm »