IE/BankOfIreland.pm

filter: Statementstmt 70.9% 242 / 341 Branchbran 56.0% 112 / 200 Conditioncond 53.4% 55 / 103 MC/DCmcdc 32.7% 19 / 58 Subroutinesub 95.8% 23 / 24 Podpod 100% 4 / 4 totaltotal 62.3% 455 / 730 CC 141 SCAR 52.2
CC
141
Cov
64%
funds_transfer
812.0
list_beneficiaries
144.3
_scrub_page
58.9
CRAP 185.2
↑ Summary IE/PTSB.pm »
1 =head1 NAME
2  
3 Finance::Bank::IE::BankOfIreland - Interface to Bank of Ireland online banking
4  
5 =head1 SYNOPSIS
6  
7 use Finance::Bank::IE::BankOfIreland;
8  
9 # config
10 my $conf = { user => '', pin => '', contact => '', dob => '' };
11  
12 # get balance from all accounts
13 my @accounts = Finance::Bank::IE::BankOfIreland->check_balance( $conf );
14  
15 # get account transaction details
16 my @details = Finance::Bank::IE::BankOfIreland->account_details( $acct );
17  
18 # list beneficiaries for an account
19 my $bene = Finance::Bank::IE::BankOfIreland->list_beneficiaries( $acct );
20  
21 # transfer money to a beneficiary
22 my $tx = Finance::Bank::IE::BankOfIreland->funds_transfer( $from, $to, $amt );
23  
24 =head1 DESCRIPTION
25  
26 Module to interact with BoI's 365 Online service.
27  
28 =head1 FUNCTIONS
29  
30 Note that all functions are set up to act as methods (i.e. they all need to be invoked using F:B:I:B->method()). All functions also take an optional configuration hash as a final parameter.
31  
32 =over
33  
34 =cut
35 package Finance::Bank::IE::BankOfIreland;
36  
37  
38 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 3 our $VERSION = "0.30";
42  
43 3 ▶use base qw( Finance::Bank::IE );
Subroutine BEGIN: called CC=1 SCAR=0.0
44 3 ▶use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 # headers for account summary page
47 3 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
48 3 BALANCE => "Balance Information: Balance",
49 ACCTTYPE => "Account Type",
50 NICKNAME => "Nickname Information: Nickname",
51 CURRENCY => "Currency",
52 ACCTNUM => "Account Number",
53 3 };
54  
55 # headers for transaction list page
56 3 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
57 3 DATE => "Date",
58 DETAIL => "Details",
59 DEBIT => "Debit",
60 CREDIT => "Credit",
61 DETBAL => "Balance Information: Balance",
62 3 };
63  
64 # headers for payments page
65 3 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
66 3 BENNAME => 'Beneficiary Name Information: Beneficiary Name',
67 BENACCT => 'Account Number',
68 BENNSC =>
69 'National Sort Code (NSC) Information: National Sort Code (NSC)',
70 BENREF => 'Reference Number Information: Reference Number',
71 BENDESC =>
72 'Beneficiary Description Information: Beneficiary Description',
73 BENSTATUS => 'Status Information: Status',
74 3 };
75  
76 3 my $BASEURL = "https://www.365online.com/";
77  
78 3 my %pages = (
79 login => {
80 url => 'https://www.365online.com/online365/spring/authentication',
81 sentinel => 'Login.*Step 1 of 2',
82 },
83 login2 => {
84 url => 'https://www.365online.com/online365/spring/authentication',
85 sentinel => 'Login.*Step 2 of 2',
86 },
87 accessDenied => {
88 url => 'https://www.365online.com/online365/spring/accessDenied',
89 sentinel => '<h1>Access Denied',
90 },
91 badcreds => {
92 url => 'https://www.365online.com/online365/spring/authentication',
93 sentinel => 'Your login details are incorrect, please try again',
94 },
95 expired => {
96 url => 'https://www.365online.com/online365/spring/sessionExpired',
97 sentinel => 'The system has logged you out',
98 },
99 # generic interstitial
100 interstitial => {
101 url => 'not important',
102 sentinel => 'Continue to 365 Home',
103 },
104 termsandconds => {
105 url => 'not important',
106 sentinel => '<h1>Terms and Conditions</h1>',
107 },
108 accounts => {
109 url => 'https://www.365online.com/online365/spring/accountSummary?execution=e2s1',
110 sentinel => '>Your Accounts\b',
111 },
112 statements => {
113 url => 'https://www.365online.com/online365/spring/statements?execution=e1s1',
114 sentinel => 'Recent Transactions',
115 },
116 moneyTransfer => {
117 url => 'https://www.365online.com/online365/spring/moneyTransfer?execution=e7s1',
118 sentinel => 'Money Transfer</h1>',
119 },
120 manageaccounts => {
121 url => 'https://www.365online.com/online365/spring/manageAccounts?execution=e5s1',
122 sentinel => 'Manage Your Accounts</title>',
123 },
124 managepayees => {
125 url => 'https://www.365online.com/online365/spring/managePayees?execution=e6s1',
126 sentinel => 'Manage Payees</title>',
127 },
128 );
129  
130 3 ▶use HTML::TokeParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
131 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
132 3 ▶use Date::Parse;
Subroutine BEGIN: called CC=1 SCAR=0.0
133 3 ▶use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
134 3 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
135 3 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
136  
137 65 ▶sub _pages {
Subroutine _pages: called CC=1 SCAR=0.0
138 65 return \%pages;
139 }
140  
141 # =item * login_dance( $config );
142  
143 # Logs in or refreshes the current session. The config parameter is a hash reference which is cached the first time it is used, so can be omitted thereafter. The contents of the hash are the login details for your 365 Online account:
144  
145 # =over
146  
147 # =item * user: your six-digit BoI user ID
148  
149 # =item * pin: your six-digit PIN
150  
151 # =item * contact: the last four digits of your contact number
152  
153 # =item * dob: your date of birth in DD/MM/YYYY format
154  
155 # =back
156  
157 # No validation is currently done on the format of the config items. The function returns true or false. Note that this function should rarely need to be directly used as it's invoked by the other functions as a first step.
158  
159 # =cut
160 # sub login_dance {
161 # my $self = shift;
162 # my $confref = shift;
163  
164 # confess();
165  
166 # $confref ||= $self->cached_config();
167  
168 # for my $required ( "user", "pin", "contact", "dob" ) {
169 # if ( !defined( $confref->{$required} )) {
170 # $self->_dprintf( "$required not specified\n" );
171 # return;
172 # }
173 # }
174  
175 # $self->cached_config( $confref );
176  
177 # if ( !$self->_get( $pages{login}->{url}, $confref )) {
178 # croak( "Failed to get login page." );
179 # }
180  
181 # # TODO check sentinel & form name
182 # my $form = $self->_agent()->current_form();
183 # $self->_agent()->field( "form:userId", $confref->{user} );
184 # $self->_set_creds_fields( $confref );
185 # my $res = $self->_agent()->submit_form();
186 # $self->_identify_page();
187 # $self->_save_page();
188  
189 # if ( !$res->is_success ) {
190 # croak( "Failed to submit login form" );
191 # }
192  
193 # $self->_set_creds_fields( $confref );
194 # $res = $self->_agent()->submit_form();
195 # $self->_identify_page();
196 # $self->_save_page();
197  
198 # if ( !$res->is_success ) {
199 # croak( "Failed to submit login form" );
200 # }
201  
202 # if ( $res->content() =~ /$pages{badcreds}->{sentinel}/s ) {
203 # croak "Your login details are incorrect";
204 # } elsif ( $res->content() =~ /$pages{login}->{sentinel}/s ) {
205 # croak( "Looping, bailing out to avoid lockout\n" );
206 # }
207  
208 # # one other fail string: You did not enter the 3 requested digits of your PIN!
209  
210 # # GAH INTERSTITIALS
211 # if ( $self->_identify_page eq 'interstitial' ) {
212 # $self->_agent()->field( "form:continue", "form:continue" );
213 # $res = $self->_agent()->submit_form();
214 # $self->_identify_page();
215 # $self->_save_page();
216 # }
217  
218 # return 1;
219 # }
220  
221 6 ▶sub _submit_first_login_page {
Subroutine _submit_first_login_page: called CC=2 SCAR=7.1
222 6 my $self = shift;
223 6 ▶ my $confref = shift||$self->cached_config();
Condition33%1/3
shift() || $self->cached_config
l!l&&r!l&&!r
600
MC/DC0%0/2
shift() || $self->cached_config
shift() $self->cached_config
Truth table33%1/3
A || B
A= shift()B= $self->cached_config
ABresult
1X1
011
000
224  
225 6 my $form = $self->_agent()->current_form();
226 6 $self->_agent()->field( "form:userId", $confref->{user} );
227 6 $self->_set_creds_fields( $confref );
228 6 return $self->_agent()->submit_form();
229 }
230  
231 6 ▶sub _submit_second_login_page {
Subroutine _submit_second_login_page: called CC=2 SCAR=7.4
232 6 my $self = shift;
233 6 ▶ my $confref = shift||$self->cached_config();
Condition33%1/3
shift() || $self->cached_config
l!l&&r!l&&!r
600
MC/DC0%0/2
shift() || $self->cached_config
shift() $self->cached_config
Truth table33%1/3
A || B
A= shift()B= $self->cached_config
ABresult
1X1
011
000
234  
235 6 $self->_set_creds_fields( $confref );
236 6 return $self->_agent()->submit_form();
237 }
238  
239 =item * $self->check_balance()
240  
241 Fetch all account balances from the account summary page. Returns an array of Finance::Bank::IE::BankOfIreland::Account objects.
242  
243 =cut
244  
245 3 ▶sub check_balance {
Subroutine check_balance: called CC=9 SCAR=22.1
Pod documented
246 3 my $self = shift;
247 3 my $confref = shift;
248  
249 3 ▶ $confref ||= $self->cached_config();
Condition66%2/3
$confref ||= $self->cached_config
l!l&&r!l&&!r
210
MC/DC0%0/2
$confref ||= $self->cached_config
$confref $self->cached_config
Truth table66%2/3
A ||= B
A= $confrefB= $self->cached_config
ABresult
1X1
011
000
250 3 $self->_get( $self->_pages->{accounts}->{url}, $confref );
251  
252 3 ▶ if ( $self->_agent()->content() !~ /$pages{accounts}->{sentinel}/s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_agent->content =~ /$pages{"accounts"}{"sentinel"}/s) 1 2 3
253 1 croak( "Failed to get account summary page" );
254 }
255  
256 2 my $summary = $self->_agent()->content;
257 2 my $parser = new HTML::TokeParser( \$summary );
258  
259 2 my ( @accounts, %account, @headings );
260 2 my ( $getheadings, $col ) = ( 1, 0 );
261  
262 2 ▶ while ( my $tag = $parser->get_tag( "span" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = $parser->get_tag("span")) 28 2 30
263 28 ▶ if ( $self->_streq( $tag->[1]{class}, "acc_name" )) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_streq($tag->[1]{'class'}, 'acc_name')) { } 2 26 28
elsif ($self->_streq($tag->[1]{'class'}, 'acc_value')) { } 2 24 26
264 # ugh. <span foo />accountname
265 2 ▶ while ( my $token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $parser->get_token) 6 0 6
266 6 ▶ if ( $token->[0] eq 'T' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[0] eq "T") 2 4 6
267 2 ( $account{+NICKNAME} = $token->[1] ) =~ s/\s+$//;
268 2 last;
269 }
270 }
271 2 $account{+ACCTNUM} = $parser->get_trimmed_text( "/span");
272 } elsif ( $self->_streq( $tag->[1]{class}, "acc_value" )) {
273 2 $account{+CURRENCY} = $parser->get_trimmed_text( "/span" );
274 2 $parser->get_tag( "span" );
275 2 $account{+BALANCE} = $parser->get_trimmed_text;
276  
277 push @accounts,
278 bless {
279 type => delete $account{+ACCTTYPE},
280 nick => delete $account{+NICKNAME},
281 account_no => delete $account{+ACCTNUM},
282 currency => delete $account{+CURRENCY},
283 2 balance => delete $account{+BALANCE},
284 }, "Finance::Bank::IE::BankOfIreland::Account";
285 }
286 }
287  
288 2 ▶ if ( !@accounts ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@accounts) 0 2 2
289 0 $self->_dprintf( "No accounts found\n" );
290 }
291  
292 2 return @accounts;
293 }
294  
295 =item * $self->account_details( account [,config] )
296  
297 Return transaction details from the specified account
298  
299 =cut
300 2 ▶sub account_details {
Subroutine account_details: called CC=26 SCAR=37.5
Pod documented
301 2 my $self = shift;
302 2 my $account = shift;
303 2 my $confref = shift;
304 2 my ( @headings, @details );
305  
306 2 ▶ $confref ||= $self->cached_config();
Condition66%2/3
$confref ||= $self->cached_config
l!l&&r!l&&!r
110
MC/DC0%0/2
$confref ||= $self->cached_config
$confref $self->cached_config
Truth table66%2/3
A ||= B
A= $confrefB= $self->cached_config
ABresult
1X1
011
000
307  
308 2 my $content = $self->_get( $pages{statements}->{url}, $confref );
309  
310 2 ▶ if ( !$content) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($content) 0 2 2
311 0 croak( "Failed to get account summary page" );
312 }
313  
314 # account selector
315 2 my $error = 'account not found';
316 2 my $parser = new HTML::TokeParser( \$content );
317  
318 2 ▶ while ( my $tag = $parser->get_tag( "select" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = $parser->get_tag("select")) 2 0 2
319 2 ▶ if ( $self->_streq( "form:selectAccountDropDown", $tag->[1]{id})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_streq("form:selectAccountDropDown", $tag->[1]{"id"})) 2 0 2
320 2 ▶ while ( my $optiontag = $parser->get_tag("/select", "option")) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $optiontag = $parser->get_tag("/select", "option")) 4 0 4
321 4 ▶ last if $optiontag->[0] eq '/select';
Branch: 1 branch
BranchTrueFalseTotal
if $optiontag->[0] eq "/select" 0 4 4
322 4 my $accountname = $parser->get_trimmed_text( "/option" );
323 4 ▶ next if $accountname =~ /Select Account/;
Branch: 1 branch
BranchTrueFalseTotal
if $accountname =~ /Select Account/ 2 2 4
324 2 my ( $nick, $number ) = split( /\s*~\s*/, $accountname );
325 2 $self->_dprintf( "Found account '$nick' = '$number'\n" );
326 2 ▶ if ( $account eq $nick or $account eq $number or
Branch: 1 branch
BranchTrueFalseTotal
if ($account eq $nick or $account eq $number or $account eq '~' . $number) 2 0 2
Condition33%2/6
$account eq $nick or $account eq $number or $account eq '~' . $number
l!l&&r!l&&!r
200
$account eq $nick or $account eq $number
l!l&&r!l&&!r
200
MC/DC0%0/3
$account eq $nick or $account eq $number or $account eq '~' . $number
$account eq $nick $account eq $number $account eq '~' . $number
Truth table25%1/4
A or B or C
A= $account eq $nickB= $account eq $numberC= $account eq '~' . $number
ABCresult
1XX1
01X1
0011
0000
327 $account eq '~'.$number ) {
328 2 ▶ if ( $self->_streq( $optiontag->[1]{selected}, "selected" )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_streq($optiontag->[1]{'selected'}, 'selected')) { } 2 0 2
329 2 $error = 'ok';
330 } else {
331 0 $error = 'account not selected';
332 }
333 2 last;
334 }
335 }
336 2 last;
337 }
338 }
339  
340 2 ▶ if ( $error ne 'ok' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error ne "ok") 0 2 2
341 0 croak( "Account '$account': " . $error );
342 }
343  
344 # now pull out the stuff we were looking for
345 2 ▶ while ( my $tag = $parser->get_tag( "table" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = $parser->get_tag("table")) 2 0 2
346 2 ▶ if ( $self->_streq( "form:transactionDataTable" ), $tag->[1]{id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_streq("form:transactionDataTable"), $tag->[1]{"id"}) 2 0 2
347 2 ▶ while ( my $row = $parser->get_tag( "/table", "tr" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $parser->get_tag("/table", "tr")) 10 0 10
348 10 ▶ last if $row->[0] eq '/table';
Branch: 1 branch
BranchTrueFalseTotal
if $row->[0] eq "/table" 2 8 10
349 8 my @row;
350 8 ▶ while ( my $col = $parser->get_tag( "/tr", "th", "td" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $col = $parser->get_tag("/tr", "th", "td")) 48 0 48
351 48 ▶ last if $col->[0] eq '/tr';
Branch: 1 branch
BranchTrueFalseTotal
if $col->[0] eq "/tr" 8 40 48
352 40 push @row, $parser->get_trimmed_text( "/" . $col->[0] );
353 }
354 8 ▶ if ( !@headings ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @headings) { } 2 6 8
355 # Date, Details, Debit, Credit, Balance
356 2 @headings = @row;
357 } else {
358 # fixups of raw data:
359 6 my ( $date, $details, $dr, $cr, $balance ) = @row;
360 6 ▶ if ( !$date ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $date) { } 0 6 6
361 0 ▶ if ( @details ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@details) { } 0 0 0
362 0 $date = $details[-1]->[0];
363 } else {
364 0 $date = 0; # can't be helped
365 }
366 } else {
367 6 my ( $d, $m, $y ) = split( "/", $date );
368 # strftime ilk
369 6 $date = strftime( "%s", 0, 0, 0, $d, $m - 1, $y - 1900, );
370 }
371  
372 6 ▶ $dr ||= 0.0;
Condition50%1/2
$dr ||= 0
l!l
60
MC/DC0%0/1
$dr ||= 0
$dr
Truth table50%1/2
A
A= $dr
Aresult
11
00
373 6 ▶ $cr ||= 0.0;
Condition50%1/2
$cr ||= 0
l!l
06
MC/DC0%0/1
$cr ||= 0
$cr
Truth table50%1/2
A
A= $cr
Aresult
11
00
374  
375 6 ▶ $balance ||= ( @details ? $details[-1]->[-1] : 0 ) - $dr + $cr;
Branch: 1 branch
BranchTrueFalseTotal
@details ? : 2 0 2
Condition66%2/3
$balance ||= (@details ? $details[-1][-1] : 0) - $dr + $cr
l!l&&r!l&&!r
420
MC/DC0%0/2
$balance ||= (@details ? $details[-1][-1] : 0) - $dr + $cr
$balance (@details ? $details[-1][-1] : 0) - $dr + $cr
Truth table66%2/3
A ||= B
A= $balanceB= (@details ? $details[-1][-1] : 0) - $dr + $cr
ABresult
1X1
011
000
376 6 push @details, [ $date, $details, $dr, $cr, $balance ];
377 }
378 }
379 2 last;
380 }
381 }
382  
383 2 return \@headings, @details;
384 }
385  
386 =item * $self->list_beneficiaries( account )
387  
388 List beneficiaries of C<account>
389  
390 =cut
391 2 ▶sub list_beneficiaries {
Subroutine list_beneficiaries: called CC=22 SCAR=49.7
Pod documented
392 2 my $self = shift;
393 2 my $account_from = shift;
394 2 my $confref = shift;
395  
396 2 ▶ $self->_dprintf( "Fetching beneficiaries for %s\n", ref $account_from ? $account_from->{nick} : $account_from );
Branch: 1 branch
BranchTrueFalseTotal
ref $account_from ? : 2 0 2
397  
398 2 ▶ $confref ||= $self->cached_config();
Condition66%2/3
$confref ||= $self->cached_config
l!l&&r!l&&!r
110
MC/DC0%0/2
$confref ||= $self->cached_config
$confref $self->cached_config
Truth table66%2/3
A ||= B
A= $confrefB= $self->cached_config
ABresult
1X1
011
000
399  
400 # allow passing in of account objects
401 2 ▶ if ( ref $account_from eq "Finance::Bank::IE::BankOfIreland::Account" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $account_from eq "Finance::Bank::IE::BankOfIreland::Account") 2 0 2
402 2 $account_from = $account_from->{nick};
403 }
404  
405 my $res =
406 2 $self->_get( $pages{manageaccounts}->{url}, $confref );
407 2 $self->_save_page();
408 2 ▶ if ( !$res ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res) 0 2 2
409 0 croak( "Failed to get " . $pages{manageaccounts}->{url} );
410 }
411  
412 # now we have to pretend to be javascript again.
413 2 $self->_agent()->field( "form:managePayees", "form:managePayees" );
414 2 $res = $self->_agent()->submit_form();
415 2 $self->_identify_page();
416 2 $self->_save_page();
417  
418 2 ▶ if ( !$res->is_success ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->is_success) 0 2 2
419 0 croak( "Failed to submit manageAccounts form" );
420 }
421  
422 # it would be nice to have more payees to test this with
423 2 my $content = $self->_agent()->content;
424 2 my $parser = new HTML::TokeParser( \$content );
425 2 my @beneficiaries;
426 2 ▶ while ( my $tag = $parser->get_tag( "table" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = $parser->get_tag("table")) 2 2 4
427 2 ▶ next unless $tag->[1]{id};
Branch: 1 branch
BranchTrueFalseTotal
unless $tag->[1]{"id"} 0 2 2
428 2 ▶ next unless $tag->[1]{id} =~ /payee/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $tag->[1]{"id"} =~ /payee/i 2 0 2
429 0 my %beneficiary;
430 0 my @cols = qw( desc account_no nsc ref currency nick limit );
431 0 ▶ while ( $tag = $parser->get_tag( "td", "/tr", "/table" )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag = $parser->get_tag("td", "/tr", "/table")) 0 0 0
432 0 ▶ if ( $tag->[0] eq "/table" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag->[0] eq "/table") 0 0 0
433 0 last;
434 }
435 0 ▶ if ( $tag->[0] eq "/tr" and %beneficiary ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag->[0] eq '/tr' and %beneficiary) { } 0 0 0
Condition0%0/3
$tag->[0] eq "/tr" and %beneficiary
!ll&&!rl&&r
000
MC/DC0%0/2
$tag->[0] eq "/tr" and %beneficiary
$tag->[0] eq "/tr" %beneficiary
Truth table0%0/3
A and B
A= $tag->[0] eq "/tr"B= %beneficiary
ABresult
0X0
100
111
436 # I don't currently know what an inactive beneficiary
437 # looks like, so I'm flagging them all as Active.
438 0 push @beneficiaries, bless {
439 type => 'Beneficiary',
440 status => 'Active',
441 }, "Finance::Bank::IE::BankOfIreland::Account";
442 0 for my $k ( keys %beneficiary ) {
443 0 $beneficiaries[-1]->{$k} = $beneficiary{$k};
444 }
445  
446 0 %beneficiary = ();
447 } else {
448 0 ▶ while ( my $token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $parser->get_token) 0 0 0
449 0 ▶ if ( $token->[0] eq "E" and $token->[1] eq "td" ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->[0] eq 'E' and $token->[1] eq 'td') { } 0 0 0
elsif ($token->[0] eq 'S' and $token->[1] eq 'label') { } 0 0 0
elsif ($token->[0] eq 'T') { } 0 0 0
elsif ($token->[0] eq 'S' and $token->[1] eq 'input') { } 0 0 0
Condition0%0/3
$token->[0] eq "E" and $token->[1] eq "td"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->[0] eq "E" and $token->[1] eq "td"
$token->[0] eq "E" $token->[1] eq "td"
Truth table0%0/3
A and B
A= $token->[0] eq "E"B= $token->[1] eq "td"
ABresult
0X0
100
111
450 0 last;
451 ▶ } elsif ( $token->[0] eq "S" and $token->[1] eq "label" ) {
Condition0%0/3
$token->[0] eq "S" and $token->[1] eq "label"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->[0] eq "S" and $token->[1] eq "label"
$token->[0] eq "S" $token->[1] eq "label"
Truth table0%0/3
A and B
A= $token->[0] eq "S"B= $token->[1] eq "label"
ABresult
0X0
100
111
452 0 $beneficiary{$cols[0]} = $parser->get_trimmed_text( "/label" );
453 } elsif ( $token->[0] eq "T" ) {
454 0 my $idx = scalar( keys %beneficiary ) - 1;
455 0 $beneficiary{$cols[$idx]} = $token->[1];
456 ▶ } elsif ( $token->[0] eq "S" and $token->[1] eq 'input' ) {
Condition0%0/3
$token->[0] eq "S" and $token->[1] eq "input"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->[0] eq "S" and $token->[1] eq "input"
$token->[0] eq "S" $token->[1] eq "input"
Truth table0%0/3
A and B
A= $token->[0] eq "S"B= $token->[1] eq "input"
ABresult
0X0
100
111
457 0 $beneficiary{input} = [ @{$token} ];
458 }
459 }
460 }
461 }
462 }
463  
464 2 \@beneficiaries;
465 }
466  
467 =item * $self->funds_transfer( from, to, amount [,config] )
468  
469 Transfer C<amount> from C<from> to C<to>, optionally using C<config> as the config data.
470  
471 =cut
472  
473 0 ▶sub funds_transfer {
Subroutine funds_transfer: not called CC=28 SCAR=67.0
Pod documented
474 0 my $self = shift;
475 0 my $account_from = shift;
476 0 my $account_to = shift;
477 0 my $amount = shift;
478 0 my $confref = shift;
479  
480 $self->_dprintf( "Funds transfer of %s from %s to %s\n", $amount,
481 ref $account_from ? $account_from->{nick} : $account_from,
482 0 ▶ ref $account_to ? $account_to->{nick} : $account_to );
Branch: 2 branches
BranchTrueFalseTotal
ref $account_from ? : 0 0 0
ref $account_to ? : 0 0 0
483  
484 0 ▶ $confref ||= $self->cached_config();
Condition0%0/3
$confref ||= $self->cached_config
l!l&&r!l&&!r
000
MC/DC0%0/2
$confref ||= $self->cached_config
$confref $self->cached_config
Truth table0%0/3
A ||= B
A= $confrefB= $self->cached_config
ABresult
1X1
011
000
485  
486 # allow passing in of account objects
487 0 ▶ if ( ref $account_from eq "Finance::Bank::IE::BankOfIreland::Account" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $account_from eq "Finance::Bank::IE::BankOfIreland::Account") 0 0 0
488 0 $account_from = $account_from->{nick};
489 }
490  
491 0 ▶ if ( ref $account_to eq "Finance::Bank::IE::BankOfIreland::Account" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $account_to eq "Finance::Bank::IE::BankOfIreland::Account") 0 0 0
492 0 $account_to = $account_to->{nick};
493 }
494  
495 0 my $beneficiaries = $self->list_beneficiaries( $account_from, $confref );
496  
497 0 my $acct;
498 0 for my $bene ( @{$beneficiaries} ) {
499 0 ▶ if ((( $bene->{account_no} ||'' ) eq $account_to ) or
Branch: 1 branch
BranchTrueFalseTotal
if (($bene->{"account_no"} || "") eq $account_to or ($bene->{"nick"} || "") eq $account_to) 0 0 0
Condition0%0/7
($bene->{"account_no"} || "") eq $account_to or ($bene->{"nick"} || "") eq $account_to
l!l&&r!l&&!r
000
$bene->{'account_no'} || ''
l!l
00
$bene->{'nick'} || ''
l!l
00
MC/DC0%0/2
($bene->{"account_no"} || "") eq $account_to or ($bene->{"nick"} || "") eq $account_to
$bene->{'account_no'} $bene->{'nick'}
Truth table0%0/3
A or B
A= $bene->{'account_no'}B= $bene->{'nick'}
ABresult
1X1
011
000
500 (( $bene->{nick} ||'' ) eq $account_to )) {
501 0 ▶ croak "Ambiguous destination account $account_to"
Branch: 1 branch
BranchTrueFalseTotal
if $acct 0 0 0
502 if $acct;
503 0 $acct = $bene;
504 }
505 }
506  
507 0 ▶ if ( !defined( $acct )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $acct) 0 0 0
508 0 croak( "Unable to find $account_to in list of accounts" );
509 }
510  
511 0 ▶ if ( $acct->{status} eq "Inactive" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($acct->{"status"} eq "Inactive") 0 0 0
512 0 croak( "Inactive beneficiary" );
513 }
514  
515 # now get the funds transfer page
516 0 my $res = $self->_agent()->get( $pages{moneyTransfer}->{url} );
517 0 $self->_save_page();
518 0 ▶ if ( !$res->is_success ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->is_success) 0 0 0
519 0 croak( "Failed to get funds transfer page." );
520 }
521  
522 # fiddly bit. there are different types of transfer, and I don't
523 # have test accounts to support all of them.
524 # billPayment, ownAccountPayment, domesticPayment, internationalPayment
525 # So, testing the bit I can test.
526 0 $self->_agent()->field( "form:domesticPayment", "form:domesticPayment" );
527 0 $res = $self->_agent()->submit_form();
528 0 $self->_identify_page();
529 0 $self->_save_page();
530 0 ▶ croak( 'not on Origin page' ) unless $self->_agent()->content() =~ m@Domestic Transfer</h1>@;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_agent->content =~ m[Domestic Transfer</h1>] 0 0 0
531  
532 # select the origin account:
533 # select > option > id='form:dt_select_acc_from'
534 # defaults to the right account for me...
535  
536 # click on the continue button
537 0 $res = $self->_agent()->submit_form( button => 'form:formActions:continue' );
538 0 $self->_identify_page();
539 0 $self->_save_page();
540 0 ▶ croak( 'not on Details page' ) unless $self->_agent()->content() =~ m@Enter Details</h2>@;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_agent->content =~ m[Enter Details</h2>] 0 0 0
541  
542 # on this page, there's a single_line_div containing the account name/no
543 # then another one containing the available funds
544 # format is <div class="single_line_div"><span class="show_label long_label">label</span><span class="pad_txt"></span>data</span</div>
545 0 my $account_selector = '';
546 0 my $content = $self->_agent()->content();
547 0 my $parser = new HTML::TokeParser( \$content );
548 0 my @valid_accounts;
549 0 ▶ while ( my $selector = $parser->get_tag( "select" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $selector = $parser->get_tag("select")) 0 0 0
550 0 ▶ if ( $self->_streq( $selector->[1]{id}, 'form:selectPayeeDomestic')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_streq($selector->[1]{"id"}, "form:selectPayeeDomestic")) 0 0 0
551 0 ▶ while ( my $option = $parser->get_tag( "option", "/select" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $option = $parser->get_tag("option", "/select")) 0 0 0
552 0 ▶ last if $option->[0] eq '/select';
Branch: 1 branch
BranchTrueFalseTotal
if $option->[0] eq "/select" 0 0 0
553 0 my $accountname = $parser->get_trimmed_text( "/option" );
554 0 ▶ next if $accountname =~ /Select Payee/;
Branch: 1 branch
BranchTrueFalseTotal
if $accountname =~ /Select Payee/ 0 0 0
555 0 push @valid_accounts, $accountname;
556  
557 0 my ( $nick, $number ) = split( /\s*~\s*/, $accountname );
558 0 ▶ if ( $account_to eq $nick or $account_to eq $number or
Branch: 1 branch
BranchTrueFalseTotal
if ($account_to eq $nick or $account_to eq $number or substr($account_to, -4) eq $number) 0 0 0
Condition0%0/6
$account_to eq $nick or $account_to eq $number or substr($account_to, -4) eq $number
l!l&&r!l&&!r
000
$account_to eq $nick or $account_to eq $number
l!l&&r!l&&!r
000
MC/DC0%0/3
$account_to eq $nick or $account_to eq $number or substr($account_to, -4) eq $number
$account_to eq $nick $account_to eq $number substr($account_to, -4) eq $number
Truth table0%0/4
A or B or C
A= $account_to eq $nickB= $account_to eq $numberC= substr($account_to, -4) eq $number
ABCresult
1XX1
01X1
0011
0000
559 substr( $account_to, -4 ) eq $number ) {
560 0 $account_selector = $option->[1]{value};
561 0 last;
562 }
563 }
564 0 last;
565 }
566 }
567  
568 0 ▶ if ( $account_selector eq '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($account_selector eq "") 0 0 0
569 0 croak( sprintf( "Couldn't find payee '%s', valid accounts are '%s'", $account_to, join( "', '", @valid_accounts )));
570 }
571  
572 0 $res = $self->_agent()->submit_form(
573 fields => {
574 'form:selectPayeeDomestic' => $account_selector,
575 'form:amount' => $amount,
576 },
577 button => 'form:formActions:continue',
578 );
579 0 $self->_identify_page();
580 # also, the destination account number appears in full on this page.
581 0 $self->_save_page();
582 0 ▶ croak( 'not on PIN page' ) unless $self->_agent()->content() =~ m@Enter your PIN</h2>@;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_agent->content =~ m[Enter your PIN</h2>] 0 0 0
583  
584 0 $self->_set_creds_fields( $confref );
585  
586 0 $res = $self->_agent()->submit_form( button => 'form:formActions:continue' );
587 0 $self->_identify_page();
588 0 $self->_save_page();
589 0 ▶ croak( 'not on Confirmation page' ) unless $self->_agent()->content() =~ m@Confirmation</h2>@s;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_agent->content =~ m[Confirmation</h2>]s 0 0 0
590  
591 # return the 'receipt'
592 # extraction:
593 # <h2 class="section_title">Confirmation</h2>
594 # <p><span class="highlight"><strong>eur AMOUNT
595 # </strong></span>
596 # has been paid from <span class="highlight"><strong>SOURCE</strong></span> to
597 # <span class="highlight"><strong>DEST</strong></span>
598 # </p>
599 0 return $self->_agent()->content;
600 }
601  
602  
603 =item * $self->_set_creds_fields( $config )
604  
605 Parse the last received page for credentials entry fields, and populate them with the data from C<$config>. Also injects the missing 'form:continue' hidden field.
606  
607 =cut
608 12 ▶sub _set_creds_fields {
Subroutine _set_creds_fields: called CC=4 SCAR=13.9
609 12 my $self = shift;
610 12 my $confref = shift;
611  
612 12 my $form = $self->_agent()->current_form();
613 # avoid having to restructure old config
614 12 my @dob = split( '/', $confref->{dob} );
615 my %fieldmapping = (
616 'form:dateOfBirth_year' => $dob[2],
617 'form:dateOfBirth_month' => $dob[1],
618 'form:dateOfBirth_date' => $dob[0],
619 'form:phoneNumber' => $confref->{contact},
620 12 );
621 12 for my $i ( 1..6 ) {
622 72 $fieldmapping{"form:security_number_digit$i"} = substr( $confref->{pin}, $i - 1, 1 );
623 72 $fieldmapping{"form:pinFragment:security_number_digit$i"} = substr( $confref->{pin}, $i - 1, 1 );
624 }
625  
626 12 for my $id ( keys %fieldmapping ) {
627 192 my $field = $form->find_input( $id );
628 192 ▶ if ( $field ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($field) 36 156 192
629 36 $self->_agent()->field( $id, $fieldmapping{$id});
630 }
631 }
632  
633 # LOSERS.
634 12 my $input = new HTML::Form::Input( type => 'hidden',
635 name => 'form:continue',
636 value => 'form:continue',
637 );
638 12 $input->add_to_form( $form );
639 }
640  
641 =item * $scrubbed = $self->_scrub_page( $content )
642  
643 Scrub the supplied content for PII.
644  
645 =cut
646 16 ▶sub _scrub_page {
Subroutine _scrub_page: called CC=55 SCAR=40.8
647 16 my ( $self, $content ) = @_;
648  
649 16 my $output = "";
650  
651 16 my $parser = new HTML::TokeParser( \$content );
652 16 my $page = $self->_identify_page( $content );
653 16 my $payee_acct = 0;
654  
655 16 ▶ while ( my $token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $parser->get_token) 7909 16 7925
656 7909 ▶ my $token_string = $token->[0] eq 'T' ? $token->[1] : $token->[-1];
Branch: 1 branch
BranchTrueFalseTotal
$token->[0] eq 'T' ? : 2827 5082 7909
657  
658 7909 ▶ if ( $token->[0] eq 'T') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[0] eq "T") 2827 5082 7909
659 2827 $token_string =~ s@(Last Login.*?)\d+/\d+/\d+ \d+:\d+@${1}01/01/1970 00:00@;
660 2827 $token_string =~ s@(Last Payee Added.*?)\d+/\d+/\d+@${1}01/01/1970@;
661 }
662  
663 7909 ▶ if ( $token->[0] eq 'S' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[0] eq "S") 2879 5030 7909
664 2879 ▶ if ( $token->[1] eq 'h2' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] eq "h2") 104 2775 2879
665 104 my $tpage = "";
666 104 ▶ while ( my $h2_token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $h2_token = $parser->get_token) 433 0 433
667 433 ▶ my $h2_string = $h2_token->[0] eq 'T' ? $h2_token->[1] : $h2_token->[-1];
Branch: 1 branch
BranchTrueFalseTotal
$h2_token->[0] eq 'T' ? : 169 264 433
668 433 $token_string .= $h2_string;
669 433 ▶ if ( $h2_token->[0] eq 'E' and $h2_token->[1] eq 'h2' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h2_token->[0] eq "E" and $h2_token->[1] eq "h2") 104 329 433
Condition100%3/3
$h2_token->[0] eq "E" and $h2_token->[1] eq "h2"
!ll&&!rl&&r
24980104
MC/DC100%2/2
$h2_token->[0] eq "E" and $h2_token->[1] eq "h2"
$h2_token->[0] eq "E" $h2_token->[1] eq "h2"
Truth table100%3/3
A and B
A= $h2_token->[0] eq "E"B= $h2_token->[1] eq "h2"
ABresult
0X0
100
111
670 104 last;
671 }
672 329 $tpage .= $h2_string;
673 }
674 104 ▶ if ( $tpage ne $page ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tpage ne $page) 104 0 104
675 104 $page = $tpage;
676 }
677  
678 # XXX these should use sentinels from %pages
679 104 ▶ if ( $page eq 'Enter your PIN' or $page eq 'Confirmation' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($page eq 'Enter your PIN' or $page eq 'Confirmation') { } 2 102 104
elsif ($page eq 'Enter Details') { } 1 101 102
Condition100%3/3
$page eq "Enter your PIN" or $page eq "Confirmation"
l!l&&r!l&&!r
11102
MC/DC100%2/2
$page eq "Enter your PIN" or $page eq "Confirmation"
$page eq "Enter your PIN" $page eq "Confirmation"
Truth table100%3/3
A or B
A= $page eq "Enter your PIN"B= $page eq "Confirmation"
ABresult
1X1
011
000
680 # first para contains all the PII, so just nuke it outright
681 2 $parser->get_tag( "/p" );
682 } elsif ( $page eq 'Enter Details' ) {
683 # now process until we get past the PII
684 1 my @replacements = ( 'Nickname ~ 9999', 'eur 99.99' );
685 1 ▶ while ( @replacements and my $innertoken = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (@replacements and my $innertoken = $parser->get_token) 28 1 29
Condition66%2/3
@replacements and my $innertoken = $parser->get_token
!ll&&!rl&&r
1028
MC/DC50%1/2
@replacements and my $innertoken = $parser->get_token
@replacements my $innertoken = $parser->get_token
Truth table66%2/3
A and B
A= @replacementsB= my $innertoken = $parser->get_token
ABresult
0X0
100
111
686 28 ▶ my $itstring = $innertoken->[0] eq 'T' ? $innertoken->[1] : $innertoken->[-1];
Branch: 1 branch
BranchTrueFalseTotal
$innertoken->[0] eq 'T' ? : 13 15 28
687 28 ▶ if ( $innertoken->[0] eq 'S' and
Branch: 1 branch
BranchTrueFalseTotal
if ($innertoken->[0] eq "S" and $innertoken->[1] eq "span" and $self->_streq($innertoken->[2]{"class"}, "pad_txt")) 2 26 28
Condition100%6/6
$innertoken->[0] eq "S" and $innertoken->[1] eq "span" and $self->_streq($innertoken->[2]{"class"}, "pad_txt")
!ll&&!rl&&r
2422
$innertoken->[0] eq "S" and $innertoken->[1] eq "span"
!ll&&!rl&&r
1864
MC/DC100%3/3
$innertoken->[0] eq "S" and $innertoken->[1] eq "span" and $self->_streq($innertoken->[2]{"class"}, "pad_txt")
$innertoken->[0] eq "S" $innertoken->[1] eq "span" $self->_streq($innertoken->[2]{"class"}, "pad_txt")
Truth table100%4/4
A and B and C
A= $innertoken->[0] eq "S"B= $innertoken->[1] eq "span"C= $self->_streq($innertoken->[2]{"class"}, "pad_txt")
ABCresult
0XX0
10X0
1100
1111
688 $innertoken->[1] eq 'span' and
689 $self->_streq( $innertoken->[2]{class},
690 'pad_txt' )) {
691 2 my $tag = $parser->get_tag( '/span' );
692 2 $itstring .= $tag->[-1];
693 2 $parser->get_trimmed_text( '/div' );
694 2 $itstring .= shift @replacements;
695 2 $itstring .= "</div>";
696 }
697 28 $token_string .= $itstring;
698 }
699 }
700 }
701  
702 2879 ▶ if ( $token->[1] eq 'span' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->[1] eq 'span') { } 103 2776 2879
elsif ($self->_streq($token->[2]{'class'}, 'acc_value')) { } 0 2776 2776
703 103 ▶ if (( $token->[2]{id}||"") =~ /:detailsColumn$/ or
Branch: 1 branch
BranchTrueFalseTotal
if (($token->[2]{"id"} || "") =~ /:detailsColumn$/ or $self->_streq($token->[2]{"class"}, "acc_name")) 5 98 103
Condition100%5/5
($token->[2]{"id"} || "") =~ /:detailsColumn$/ or $self->_streq($token->[2]{"class"}, "acc_name")
l!l&&r!l&&!r
3298
$token->[2]{'id'} || ''
l!l
3271
MC/DC100%2/2
($token->[2]{"id"} || "") =~ /:detailsColumn$/ or $self->_streq($token->[2]{"class"}, "acc_name")
$token->[2]{'id'} $self->_streq($token->[2]{"class"}, "acc_name")
Truth table100%3/3
A or B
A= $token->[2]{'id'}B= $self->_streq($token->[2]{"class"}, "acc_name")
ABresult
1X1
011
000
704 ( $self->_streq( $token->[2]{class}, "acc_name" ))) {
705 5 ▶ while ( my $account_token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $account_token = $parser->get_token) 8 0 8
706 8 ▶ if ( $account_token->[0] eq 'T' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($account_token->[0] eq 'T') { } 5 3 8
707 5 $token_string .= "Nickname";
708 5 last;
709 } else {
710 3 $token_string .= $account_token->[-1];
711 }
712 }
713 5 $parser->get_trimmed_text( "/span");
714 5 ▶ while ( my $account_token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $account_token = $parser->get_token) 21 0 21
715 21 ▶ if ( $account_token->[0] eq 'T' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($account_token->[0] eq 'T') { } 5 16 21
716 5 ▶ if ( $account_token->[1] =~ /^(~ *)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($account_token->[1] =~ /^(~ *)/) 1 4 5
717 1 $token_string .= $1;
718 }
719 5 $token_string .= '9999';
720 5 last;
721 } else {
722 16 $token_string .= $account_token->[-1];
723 }
724 }
725 5 $parser->get_trimmed_text( "/span" );
726 }
727 } elsif ( $self->_streq( $token->[2]{class}, "acc_value" )) {
728 # a bit more destructive than I'd like...
729 0 $token_string .= "<span class=\"acc_value\"><span class=\"blue\">" . $parser->get_trimmed_text( "/span" ) . "</span>";
730 0 $token_string .= "<span id=\"form:retailAccountSummarySubView0:balance\">";
731 0 $parser->get_tag( "span" );
732 0 $token_string .= "99999.99";
733 0 $parser->get_trimmed_text;
734 0 $token_string .= "</span>";
735 }
736  
737 # manage payees
738 2879 ▶ if ( $token->[1] eq 'td' and
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] eq "td" and $token->[2]{"id"} and $token->[2]{"id"} =~ /payee/i) 28 2851 2879
Condition100%6/6
$token->[1] eq "td" and $token->[2]{"id"} and $token->[2]{"id"} =~ /payee/i
!ll&&!rl&&r
28391228
$token->[1] eq "td" and $token->[2]{"id"}
!ll&&!rl&&r
28053440
MC/DC100%3/3
$token->[1] eq "td" and $token->[2]{"id"} and $token->[2]{"id"} =~ /payee/i
$token->[1] eq "td" $token->[2]{"id"} $token->[2]{"id"} =~ /payee/i
Truth table100%4/4
A and B and C
A= $token->[1] eq "td"B= $token->[2]{"id"}C= $token->[2]{"id"} =~ /payee/i
ABCresult
0XX0
10X0
1100
1111
739 $token->[2]{id} and
740 $token->[2]{id} =~ /payee/i ) {
741 28 ▶ if ( $token->[2]{id} =~ /id109/ ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($token->[2]{'id'} =~ /id109/) { } 4 24 28
elsif ($token->[2]{'id'} =~ /id105/) { } 4 20 24
elsif ($token->[2]{'id'} =~ /id113/) { } 4 16 20
elsif ($token->[2]{'id'} =~ /id107/) { } 4 12 16
elsif ($token->[2]{'id'} =~ /id111/) { } 4 8 12
elsif ($token->[2]{'id'} =~ /radiobutton/i) { } 4 4 8
742 4 $token_string .= "reference $payee_acct";
743 } elsif ( $token->[2]{id} =~ /id105/ ) {
744 4 $token_string .= "account_no $payee_acct";
745 } elsif ( $token->[2]{id} =~ /id113/ ) {
746 4 $token_string .= "nick $payee_acct";
747 } elsif ( $token->[2]{id} =~ /id107/) {
748 4 $token_string .= "nsc $payee_acct";
749 } elsif ( $token->[2]{id} =~ /id111/) {
750 4 $token_string .= "currency $payee_acct";
751 } elsif ( $token->[2]{id} =~ /radiobutton/i ) {
752 4 $payee_acct++;
753 4 $token_string .= "<input name='input' value='$payee_acct'><label>&#160;LABEL</label>";
754 }
755 28 $parser->get_tag( "/td" );
756 28 $token_string .= "</td>";
757 }
758  
759 2879 ▶ if ( $token->[1] eq 'select' and
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] eq "select" and $self->_streq($token->[2]{"class"}, "acc_select") || $self->_streq($token->[2]{"id"}, "form:selectAccountDropDown")) 7 2872 2879
Condition100%6/6
$token->[1] eq "select" and $self->_streq($token->[2]{"class"}, "acc_select") || $self->_streq($token->[2]{"id"}, "form:selectAccountDropDown")
!ll&&!rl&&r
287027
$self->_streq($token->[2]{"class"}, "acc_select") or $self->_streq($token->[2]{"id"}, "form:selectAccountDropDown")
l!l&&r!l&&!r
612
MC/DC100%3/3
$token->[1] eq "select" and $self->_streq($token->[2]{"class"}, "acc_select") || $self->_streq($token->[2]{"id"}, "form:selectAccountDropDown")
$token->[1] eq "select" $self->_streq($token->[2]{"class"}, "acc_select") $self->_streq($token->[2]{"id"}, "form:selectAccountDropDown")
Truth table100%4/4
A and B or C
A= $token->[1] eq "select"B= $self->_streq($token->[2]{"class"}, "acc_select")C= $self->_streq($token->[2]{"id"}, "form:selectAccountDropDown")
ABCresult
0XX0
1000
11X1
1011
760 ( $self->_streq( $token->[2]{class}, "acc_select" ) or
761 ( $self->_streq( $token->[2]{id}, "form:selectAccountDropDown")))) {
762 7 my $added_nickname = 0;
763  
764 7 ▶ while ( my $account_token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $account_token = $parser->get_token) 44 0 44
765 44 ▶ my $string = $account_token->[0] eq 'T' ? $account_token->[1] : $account_token->[-1];
Branch: 1 branch
BranchTrueFalseTotal
$account_token->[0] eq 'T' ? : 22 22 44
766 44 ▶ if ( $account_token->[0] eq 'S' and $account_token->[1] eq 'option' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($account_token->[0] eq "S" and $account_token->[1] eq "option") 15 29 44
Condition66%2/3
$account_token->[0] eq "S" and $account_token->[1] eq "option"
!ll&&!rl&&r
29015
MC/DC50%1/2
$account_token->[0] eq "S" and $account_token->[1] eq "option"
$account_token->[0] eq "S" $account_token->[1] eq "option"
Truth table66%2/3
A and B
A= $account_token->[0] eq "S"B= $account_token->[1] eq "option"
ABresult
0X0
100
111
767 15 my $val = $account_token->[2]{value};
768 15 ▶ if ( $val ne 'From Account..' and
Branch: 1 branch
BranchTrueFalseTotal
if ($val ne "From Account.." and $val ne "defaultItem" and not $val =~ /^\d+$/) 0 15 15
Condition66%4/6
$val ne "From Account.." and $val ne "defaultItem" and not $val =~ /^\d+$/
!ll&&!rl&&r
780
$val ne "From Account.." and $val ne "defaultItem"
!ll&&!rl&&r
078
MC/DC0%0/3
$val ne "From Account.." and $val ne "defaultItem" and not $val =~ /^\d+$/
$val ne "From Account.." $val ne "defaultItem" not $val =~ /^\d+$/
Truth table50%2/4
A and B and not(C)
A= $val ne "From Account.."B= $val ne "defaultItem"C= not $val =~ /^\d+$/
ABCresult
0XX0
10X0
1100
1111
769 $val ne 'defaultItem' and
770 $val !~ /^\d+$/ ) {
771 0 $account_token->[2]{value} = "0";
772 0 $string = $self->_rebuild_tag( $account_token );
773 0 $val = '0';
774 }
775 15 ▶ if ( $val ne 'From Account..' and
Branch: 1 branch
BranchTrueFalseTotal
if ($val ne 'From Account..' and $val ne 'defaultItem') { } 8 7 15
Condition66%2/3
$val ne "From Account.." and $val ne "defaultItem"
!ll&&!rl&&r
078
MC/DC50%1/2
$val ne "From Account.." and $val ne "defaultItem"
$val ne "From Account.." $val ne "defaultItem"
Truth table66%2/3
A and B
A= $val ne "From Account.."B= $val ne "defaultItem"
ABresult
0X0
100
111
776 $val ne 'defaultItem' ) {
777 8 $added_nickname++;
778 8 ▶ if ( $added_nickname == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($added_nickname == 1) { } 5 3 8
779 5 $string .= "Nickname ~ 9999";
780 } else {
781 3 $string .= "nick $added_nickname ~ $val";
782 }
783 } else {
784 7 $string .= $parser->get_trimmed_text();
785 }
786 15 my $tag = $parser->get_tag( "/option" );
787 15 ▶ if ( $tag ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag) 15 0 15
788 15 $string .= $tag->[-1];
789 }
790 }
791 44 $token_string .= $string;
792 44 ▶ last if ( $account_token->[0] eq 'E' and $account_token->[1] eq 'select' );
Branch: 1 branch
BranchTrueFalseTotal
if $account_token->[0] eq "E" and $account_token->[1] eq "select" 7 37 44
Condition66%2/3
$account_token->[0] eq "E" and $account_token->[1] eq "select"
!ll&&!rl&&r
3707
MC/DC50%1/2
$account_token->[0] eq "E" and $account_token->[1] eq "select"
$account_token->[0] eq "E" $account_token->[1] eq "select"
Truth table66%2/3
A and B
A= $account_token->[0] eq "E"B= $account_token->[1] eq "select"
ABresult
0X0
100
111
793 }
794 }
795 }
796  
797 7909 $output .= $token_string;
798 }
799  
800 16 return $output;
801 }
802  
803 =back
804  
805 =cut
806  
807 package Finance::Bank::IE::BankOfIreland::Account;
808  
809 # magic (pulled directly from other code, which I now understand)
810 3 ▶no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
811 7 ▶sub AUTOLOAD { my $self=shift; $AUTOLOAD =~ s/.*:://; $self->{$AUTOLOAD} }
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
812  
813 3 1;
↑ Summary IE/PTSB.pm »