IE/PTSB.pm

filter: Statementstmt 80.7% 243 / 301 Branchbran 78.9% 139 / 176 Conditioncond 79.3% 50 / 63 MC/DCmcdc 58.9% 23 / 39 Subroutinesub 94.7% 18 / 19 Podpod 100% 5 / 5 totaltotal 79.2% 478 / 603 CC 116 SCAR 36.5
CC
116
Cov
80%
funds_transfer
132.0
_scrub_page
57.3
check_balance
16.0
CRAP 38.6
« IE/BankOfIreland.pm ↑ Summary IE/AvantCard.pm »
1 =head1 NAME
2  
3 Finance::Bank::IE::PTSB - Finance::Bank interface for Permanent TSB (Ireland)
4  
5 =head1 DESCRIPTION
6  
7 This module implements the Finance::Bank 'API' for Permanent TSB
8 (Ireland)'s Open24 online banking service.
9  
10 =over
11  
12 =cut
13 package Finance::Bank::IE::PTSB;
14  
15 3 ▶use base qw( Finance::Bank::IE );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 3 our $VERSION = "0.30";
18  
19 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 3 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 3 ▶use constant BASEURL => 'https://www.open24.ie/online/';
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 3 my %pages = (
28 login => {
29 url => 'https://www.open24.ie/online/login.aspx',
30 sentinel => 'LOGIN STEP 1 OF 2',
31 },
32 login2 => {
33 url => 'https://www.open24.ie/online/Login2.aspx',
34 sentinel => 'LOGIN STEP 2 OF 2',
35 },
36 accounts => {
37 url => 'https://www.open24.ie/online/Account.aspx',
38 sentinel => 'CLICK ACCOUNT NAME FOR A MINI STATEMENT',
39 },
40 accountdetails => {
41 url => 'https://www.open24.ie/online/StateMini.aspx?ref=0',
42 sentinel => 'MINI STATEMENT',
43 },
44 payandtransfer => {
45 url => "https://www.open24.ie/online/PayAndTransfer.aspx",
46 sentinel => "Payments & Transfers",
47 },
48 );
49  
50 125 ▶sub _pages {
Subroutine _pages: called CC=1 SCAR=0.0
51 125 return \%pages;
52 }
53  
54 17 ▶sub _submit_first_login_page {
Subroutine _submit_first_login_page: called CC=2 SCAR=7.4
55 17 my $self = shift;
56 17 ▶ my $confref = shift||$self->cached_config();
Condition33%1/3
shift() || $self->cached_config
l!l&&r!l&&!r
1700
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
57  
58 17 $self->_add_event_fields();
59  
60 return
61 $self->_agent()->submit_form( fields => {
62 txtLogin => $confref->{user},
63 txtPassword => $confref->{password},
64 17 '__EVENTTARGET' => 'lbtnContinue',
65 '__EVENTARGUMENT' => '',
66 }
67 );
68 }
69  
70 16 ▶sub _submit_second_login_page {
Subroutine _submit_second_login_page: called CC=2 SCAR=6.9
71 16 my $self = shift;
72 16 my $confref = shift;
73  
74 16 my @pins = grep /(Digit No. \d+)/, split( /[\r\n]+/, $self->_agent()->content );
75 16 my %submit;
76 16 my @secrets = split( //, $confref->{pin} );
77 16 for my $pin ( @pins ) {
78 48 my ( $digit, $field ) = $pin =~
79 m{Digit No. (\d+).*input name="(.*?)"};
80 48 my $secret = $secrets[$digit - 1];
81 48 $submit{$field} = $secret;
82 }
83 16 $submit{'__EVENTTARGET'} = 'btnContinue';
84 16 $submit{'__EVENTARGUMENT'} = '';
85 16 $self->_add_event_fields();
86 16 return $self->_agent()->submit_form( fields => \%submit );
87 }
88  
89 =item * check_balance( [config] )
90  
91 Check the balances on all accounts. Optional config hashref.
92  
93 =cut
94  
95 4 ▶sub check_balance {
Subroutine check_balance: called CC=16 SCAR=27.7
Pod documented
96 4 my $self = shift;
97 4 my $confref = shift;
98  
99 4 ▶ $confref ||= $self->cached_config();
Condition66%2/3
$confref ||= $self->cached_config
l!l&&r!l&&!r
310
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
100 4 my $res = $self->_get( $pages{accounts}->{url}, $confref );
101  
102 4 ▶ return unless $res;
Branch: 1 branch
BranchTrueFalseTotal
unless $res 2 2 4
103  
104 # find table class="statement"
105 # first is headers (account name, number-ending-with, balance, available
106 # each subsequent one is an account
107 2 my @headers;
108 my @accounts;
109 2 my $parser = new HTML::TokeParser( \$res );
110 2 ▶ while( my $tag = $parser->get_tag( "table" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = $parser->get_tag("table")) 12 2 14
111 12 ▶ next unless $self->_streq( $tag->[1]{class}, "statement" );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_streq($tag->[1]{"class"}, "statement") 8 4 12
112  
113 4 my @account;
114 4 ▶ while( $tag = $parser->get_tag( "th", "td", "/tr", "/table" )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag = $parser->get_tag("th", "td", "/tr", "/table")) 28 0 28
115 28 ▶ last if $tag->[0] eq "/table";
Branch: 1 branch
BranchTrueFalseTotal
if $tag->[0] eq "/table" 4 24 28
116 24 ▶ if ( $tag->[0] =~ /^t[hd]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag->[0] =~ /^t[hd]$/) { } 18 6 24
117 18 my $closer = "/" . $tag->[0];
118 18 my $text = $parser->get_trimmed_text( $closer );
119 18 ▶ if ( $tag->[0] eq "th" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag->[0] eq 'th') { } 8 10 18
120 8 push @headers, $text;
121 } else {
122 10 push @account, $text;
123 }
124 } else { # ( $tag->[0] eq "/tr" ) {
125 6 ▶ if ( @account ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@account) 4 2 6
126 4 push @accounts, [ @account ];
127 4 @account = ();
128 }
129 }
130 }
131 }
132  
133 # match headers to data
134 2 my @return;
135 2 for my $account ( @accounts ) {
136 4 my %account;
137  
138 4 for my $header ( @headers ) {
139 16 my $data = shift @{$account};
140  
141 16 ▶ if ( $header =~ /Account Name/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($header =~ /Account Name/) { } 4 12 16
elsif ($header =~ /Account No\./) { } 4 8 12
elsif ($header =~ /Account Balance \((\w+)\)/) { } 4 4 8
142 4 $account{type} = $data;
143 4 $account{nick} = $data;
144 } elsif ( $header =~ /Account No\./ ) {
145 4 $account{account_no} = $data;
146 } elsif ( $header =~ /Account Balance \((\w+)\)/ ) {
147 4 $account{currency} = $1;
148 4 $account{balance} = $data;
149 }
150 }
151 # prune stuff we can't identify
152 4 ▶ next if !defined( $account{balance} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $account{"balance"} 2 2 4
153 2 push @return, bless \%account, "Finance::Bank::IE::PTSB::Account";
154 }
155  
156 2 return @return;
157 }
158  
159 =item * account_details( $account [, config] )
160  
161 Return transaction details from the specified account
162  
163 =cut
164  
165 7 ▶sub account_details {
Subroutine account_details: called CC=12 SCAR=24.9
Pod documented
166 7 my $self = shift;
167 7 my $wanted = shift;
168 7 my $confref = shift;
169  
170 7 my @details;
171  
172 7 ▶ $confref ||= $self->cached_config();
Condition66%2/3
$confref ||= $self->cached_config
l!l&&r!l&&!r
610
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
173  
174 7 my $res = $self->_get( $pages{accounts}->{url}, $confref );
175  
176 7 ▶ return unless $res;
Branch: 1 branch
BranchTrueFalseTotal
unless $res 1 6 7
177 6 ▶ return unless $wanted;
Branch: 1 branch
BranchTrueFalseTotal
unless $wanted 1 5 6
178  
179 # this is pretty brutal
180 5 my @likely = grep {m{(StateMini.aspx\?ref=\d+).*?$wanted}} split( /[\r\n]/, $res );
181 5 ▶ if ( scalar( @likely ) == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @likely == 1) { } 4 1 5
182 4 my ( $url ) = $likely[0] =~ m/^.*(StateMini[^"]+)".*$/;
183 # convert to an absolute URL so that the _get pagelookup works
184 4 my $uri = new_abs URI( $url, $self->_agent()->response()->request->uri());
185 4 $res = $self->_get( $uri->as_string(), $confref );
186  
187 # parse!
188 # there's a header table which is untagged
189 # and then there's this (tblTransactions):
190 # <tr>
191 # <td class="Content" align="left" valign="middle" colspan="1" width="18%">DD/MM/YYYY</td><td class="Content" align="left" valign="middle" colspan="1" width="46%">DESC</td><td class="Content" align="right" valign="middle" colspan="1" width="18%">- AMT (withdrawal) or + AMT (deposit)</td><td class="Content" align="right" valign="middle" colspan="1" width="18%">BALANCE +/-</td>
192 # </tr>
193  
194 4 my $parser = new HTML::TokeParser( \$res );
195 4 ▶ while( my $tag = $parser->get_tag( "table" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = $parser->get_tag("table")) 16 0 16
196 16 ▶ if ( $self->_streq( $tag->[1]{id}, "tblTransactions" )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_streq($tag->[1]{"id"}, "tblTransactions")) 4 12 16
197 4 $self->_dprintf( "Found transaction table\n" );
198 4 my @fields;
199 4 ▶ while( my $tag = $parser->get_tag( "td", "/tr", "/table" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = $parser->get_tag("td", "/tr", "/table")) 484 0 484
200 484 ▶ if ( $tag->[0] eq "td" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tag->[0] eq 'td') { } 320 164 484
elsif ($tag->[0] eq '/tr') { } 160 4 164
201 320 push @fields, $parser->get_trimmed_text( "/td" );
202 } elsif ( $tag->[0] eq "/tr" ) {
203 160 ▶ if ( @fields ) { # there are spurious blank lines
Branch: 1 branch
BranchTrueFalseTotal
if (@fields) 80 80 160
204 80 my ( $dr, $cr ) = ( 0, 0 );
205 80 ▶ if ( $fields[2] =~ /^-/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fields[2] =~ /^-/) { } 68 12 80
206 68 ( $dr = $fields[2] ) =~ s/^- //;
207 } else {
208 12 ( $cr = $fields[2] ) =~ s/^\+ //;
209 }
210  
211 80 my ( $bal, $sign ) = $fields[3] =~ /^(.*) (.)$/;
212  
213 80 push @details,
214 [
215 $fields[0],
216 $fields[1],
217 $dr,
218 $cr,
219 $sign.$bal,
220 ]
221 ;
222 80 @fields = ();
223 }
224 } else {
225 4 last;
226 }
227 }
228 4 last;
229 }
230 }
231  
232 } else {
233 1 $self->_dprintf( "Found " . scalar(@likely) . " matches\n" );
234 1 return;
235 }
236  
237 4 unshift @details, [ 'Date', 'Desc', 'DR', 'CR', 'Balance' ];
238  
239 4 return @details;
240 }
241  
242 =item * $self->_get_payments_page( account [, config ] )
243  
244 Get the third-party payments page for account
245  
246 =cut
247  
248 11 ▶sub _get_payments_page {
Subroutine _get_payments_page: called CC=7 SCAR=19.7
249 11 my $self = shift;
250 11 my $account_from = shift;
251 11 my $confref = shift;
252  
253 11 ▶ return unless $account_from;
Branch: 1 branch
BranchTrueFalseTotal
unless $account_from 1 10 11
254  
255 # allow passing in of account objects
256 10 ▶ if ( ref $account_from eq "Finance::Bank::IE::PTSB::Account" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $account_from eq "Finance::Bank::IE::PTSB::Account") 9 1 10
257 9 $account_from = $account_from->{nick};
258 }
259  
260 10 ▶ $confref ||= $self->cached_config();
Condition66%2/3
$confref ||= $self->cached_config
l!l&&r!l&&!r
820
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
261 10 my $res = $self->_get( $pages{accounts}->{url}, $confref );
262  
263 10 ▶ return unless $res;
Branch: 1 branch
BranchTrueFalseTotal
unless $res 2 8 10
264  
265 $self->_get( $pages{payandtransfer}->{url} )
266 8 ▶ or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_get($pages{"payandtransfer"}{"url"}) or return 0 7 1 8
267 7 $self->_save_page();
268  
269 7 ▶ if ( $self->_agent()->content() !~ /Payments &amp; Transfers/is ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_agent->content =~ /Payments &amp; Transfers/is) 0 7 7
270 0 $self->_dprintf( "PayAndTransfer.aspx doesn't contain sentinel\n" );
271 0 return 0;
272 }
273  
274 7 return 1;
275 }
276  
277 =item * $self->list_beneficiaries( account )
278  
279 List beneficiaries of C<account>
280  
281 =cut
282 7 ▶sub list_beneficiaries {
Subroutine list_beneficiaries: called CC=14 SCAR=26.4
Pod documented
283 7 my $self = shift;
284 7 my $account_from = shift;
285 7 my $confref = shift;
286  
287 7 ▶ return unless $self->_get_payments_page( $account_from, $confref );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_get_payments_page($account_from, $confref) 3 4 7
288  
289 # follow link to 'manage accounts'
290 4 $self->_add_event_fields();
291 4 my $res = $self->_agent()->submit_form(
292 fields => {
293 '__EVENTTARGET' => 'ctl00$cphBody$lbManageMyPayeeAccounts',
294 '__EVENTARGUMENT' => '',
295 }
296 );
297  
298 4 $self->_save_page();
299 4 ▶ return unless $res->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_success 0 4 4
300  
301 4 my @beneficiaries;
302  
303 4 for my $ddlPaymentType ( 0..3 ) {
304 16 ▶ if ( $ddlPaymentType > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ddlPaymentType > 0) 12 4 16
305 12 $self->_add_event_fields();
306 12 $res = $self->_agent()->submit_form(
307 fields => {
308 '__EVENTTARGET' => 'ctl00$cphBody$ddlPaymentType',
309 '__EVENTARGUMENT' => '',
310 'ctl00$cphBody$ddlPaymentType' => $ddlPaymentType,
311 }
312 );
313 12 $self->_save_page( "ddlPaymentType=$ddlPaymentType" );
314 12 ▶ return unless $res->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_success 0 12 12
315 }
316  
317 16 my $page = $self->_agent()->content;
318 16 my $parser = new HTML::TokeParser( \$page );
319  
320 16 my @beneficiary;
321 16 my $found = 0;
322 16 ▶ while ( my $tag = $parser->get_tag( "table" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = $parser->get_tag("table")) 24 8 32
323 24 ▶ if ( $self->_streq( $tag->[1]{class}, 'transfereeList' )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_streq($tag->[1]{"class"}, "transfereeList")) 8 16 24
324 8 $found = 1;
325 8 last;
326 }
327 }
328  
329 # no transferees of this type
330 16 ▶ if ( !$found ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($found) 8 8 16
331 8 $self->_dprintf( "No category $ddlPaymentType beneficiaries found\n" );
332 8 next;
333 }
334  
335 8 ▶ while ( my $tag = $parser->get_tag( "td", "/tr", "/table" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = $parser->get_tag("td", "/tr", "/table")) 396 0 396
336 396 ▶ last if ( $tag->[0] eq "/table" );
Branch: 1 branch
BranchTrueFalseTotal
if $tag->[0] eq "/table" 8 388 396
337 388 ▶ if ( $tag->[0] eq "/tr" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag->[0] eq '/tr') { } 68 320 388
338 68 ▶ if ( @beneficiary ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@beneficiary) 60 8 68
339 60 push @beneficiaries,
340 bless {
341 type => 'Beneficiary',
342 nick => $beneficiary[0],
343 lastused => $beneficiary[1],
344 ref => $beneficiary[2],
345 source => $beneficiary[3],
346 input => $beneficiary[4],
347 type => $ddlPaymentType,
348 account_no => 'hidden',
349 status => 'Active',
350 }, "Finance::Bank::IE::PTSB::Account";
351 60 @beneficiary = ();
352 60 $self->_dprintf( "Found beneficiary " . $beneficiaries[-1]->{nick} . "\n" );
353 }
354 } else {
355 320 ▶ if ( $self->_streq( $tag->[1]{class}, 'transfereeListAction' )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_streq($tag->[1]{'class'}, 'transfereeListAction')) { } 20 300 320
356 20 $tag = $parser->get_tag( "input" );
357 20 push @beneficiary, $tag->[1]{id};
358 } else {
359 300 push @beneficiary, $parser->get_trimmed_text( "/td" );
360 }
361 }
362 }
363 }
364  
365 4 \@beneficiaries;
366 }
367  
368 =item * $self->add_beneficiary( $from_account, $to_account_details, $config )
369  
370 Add a beneficiary to $from_account.
371  
372 =cut
373  
374 5 ▶sub add_beneficiary {
Subroutine add_beneficiary: called CC=6 SCAR=24.6
Pod documented
375 5 my ( $self, $account_from, $to_account_no, $to_nsc, $to_ref, $to_nick,
376 $confref ) =
377 @_;
378  
379 5 ▶ return unless $to_nick;
Branch: 1 branch
BranchTrueFalseTotal
unless $to_nick 1 4 5
380 4 ▶ return unless $self->_get_payments_page( $account_from, $confref );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_get_payments_page($account_from, $confref) 1 3 4
381  
382 # Create a new Third Party Transfer
383 3 $self->_agent()->follow_link( text => 'Create a new Third Party Transfer' );
384 3 $self->_save_page();
385  
386 3 ▶ return unless $self->_agent()->content() =~
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_agent->content =~ /CREATE A NEW THIRD PARTY TRANSFER/is 3 0 3
387 /CREATE A NEW THIRD PARTY TRANSFER/is;
388  
389 0 $self->_add_event_fields();
390 0 $self->_agent()->submit_form(
391 fields => {
392 txtSortCode => $to_nsc,
393 txtAccountCode => $to_account_no,
394 txtBillRef => $to_ref,
395 txtBillName => $to_nick,
396 # if you have multiple accounts, ddlAccounts probably needs setting. Option value = NSC+Account_no!
397 '__EVENTTARGET' => 'lbtnContinue',
398 '__EVENTARGUMENT' => '',
399 },
400 );
401 0 $self->_save_page();
402  
403 0 ▶ return unless $self->_agent()->content() =~
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_agent->content =~ /CREATE A NEW THIRD PARTY TRANSFER.*STEP 2/is 0 0 0
404 /CREATE A NEW THIRD PARTY TRANSFER.*STEP 2/si;
405  
406 0 $self->_add_event_fields();
407 0 $self->_agent()->submit_form(
408 fields => {
409 'txtSMSCode' => '11111',
410 '__EVENTTARGET' => 'lbtnContinue',
411 '__EVENTARGUMENT' => '',
412 },
413 );
414  
415 0 ▶ return unless $self->_agent()->content() =~
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_agent->content =~ /CREATE A NEW THIRD PARTY TRANSFER.*STEP 3/is 0 0 0
416 /CREATE A NEW THIRD PARTY TRANSFER.*STEP 3/si;
417  
418 0 return 1;
419 }
420  
421 =item * $receipt = $self->funds_transfer( $from, $to, $amt )
422  
423 Transfer C<$amt> from C<$from> to C<$to>. C<$from> has to match one
424 of your account nicknames; C<$to> has to match a configured
425 beneficiary.
426  
427 =cut
428  
429 0 ▶sub funds_transfer {
Subroutine funds_transfer: not called CC=11 SCAR=48.8
Pod documented
430 0 my $self = shift;
431 0 my $account_from = shift;
432 0 my $account_to = shift;
433 0 my $amount = shift;
434 0 my $confref = shift;
435  
436 # allow passing account object as destination. source is handled
437 # by list_beneficiaries.
438 0 ▶ if ( ref $account_to eq __PACKAGE__ . "::Account" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $account_to eq "Finance::Bank::IE::PTSB::Account") 0 0 0
439 0 $account_to = $account_to->{nick};
440 }
441  
442 0 $self->_dprintf( " funds_transfer: listing beneficiaries\n" );
443 0 my $beneficiaries = $self->list_beneficiaries( $account_from, $confref );
444  
445 0 my $found;
446 0 for my $beneficiary ( @{$beneficiaries}) {
447 0 ▶ if ( $beneficiary->{ref} eq $account_to or
Branch: 1 branch
BranchTrueFalseTotal
if ($beneficiary->{"ref"} eq $account_to or $beneficiary->{"nick"} eq $account_to) 0 0 0
Condition0%0/3
$beneficiary->{"ref"} eq $account_to or $beneficiary->{"nick"} eq $account_to
l!l&&r!l&&!r
000
MC/DC0%0/2
$beneficiary->{"ref"} eq $account_to or $beneficiary->{"nick"} eq $account_to
$beneficiary->{"ref"} eq $account_to $beneficiary->{"nick"} eq $account_to
Truth table0%0/3
A or B
A= $beneficiary->{"ref"} eq $account_toB= $beneficiary->{"nick"} eq $account_to
ABresult
1X1
011
000
448 $beneficiary->{nick} eq $account_to ) {
449 0 ▶ if ( $found ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found) 0 0 0
450 0 $found = "ambiguous";
451 0 last;
452 }
453 0 $found = $beneficiary;
454 }
455 }
456  
457 0 my $receipt;
458 0 ▶ if ( !$found ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $found) { } 0 0 0
elsif (ref $found ne 'Finance::Bank::IE::PTSB::Account') { } 0 0 0
459 0 $self->_dprintf( "no beneficiaries found for specified account" );
460 } elsif ( ref $found ne "Finance::Bank::IE::PTSB::Account" ) {
461 0 $self->_dprintf( "multiple matching beneficiaries found" );
462 } else {
463 0 ▶ if ( $found->{status} ne "Active" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found->{'status'} ne 'Active') { } 0 0 0
464 0 $self->_dprintf( "found an account but it's not active" );
465 } else {
466 $self->_agent()->submit_form( fields => {
467 grpTransOther => $found->{input},
468 0 txtAmount => $amount,
469 '__EVENTTARGET' => 'lbtnPay',
470 '__EVENTARGUMENT' => '',
471 },
472 );
473 0 $self->_save_page();
474  
475 0 $receipt = $self->_agent()->content();
476  
477 0 ▶ if ( $receipt =~ /lbtnConfirm/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($receipt =~ /lbtnConfirm/s) { } 0 0 0
478 0 $self->_agent()->submit_form( fields => {
479 '__EVENTTARGET' => 'lbtnConfirm',
480 '__EVENTARGUMENT' => '',
481 });
482 0 $self->_save_page();
483 0 $receipt = $self->_agent()->content();
484 0 ▶ if ( $receipt !~ /successfully processed/si ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($receipt =~ /successfully processed/is) 0 0 0
485 0 $self->_dprintf( "did not get transaction confirmation" );
486 0 $receipt = undef;
487 }
488 } else {
489 0 $self->_dprintf( "did not get confirmation request page" );
490 0 $receipt = undef;
491 }
492 }
493 }
494  
495 0 return $receipt;
496 }
497  
498 =item * $scrubbed = $self->_scrub_page( $content )
499  
500 Scrub the supplied content for PII.
501  
502 =cut
503 13 ▶sub _scrub_page {
Subroutine _scrub_page: called CC=52 SCAR=40.5
504 13 my ( $self, $content ) = @_;
505  
506 # This would be nicer with XPath. Alas, I tried XML::Xpath and the
507 # world ended - it wanted to fetch a DTD from the web, which
508 # didn't exist, and it took an awfully long time to figure that
509 # out.
510 13 my $output = "";
511 13 my $parser = new HTML::TokeParser( \$content );
512 13 ▶ while( my $token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $parser->get_token) 5884 13 5897
513 5884 my $token_string = $token->[-1];
514 5884 ▶ if ( $token->[0] eq 'T' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[0] eq "T") 2560 3324 5884
515 2560 $token_string = $token->[1];
516 2560 ▶ if ( $token_string =~ /Your last successful logon/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_string =~ /Your last successful logon/) 11 2549 2560
517 11 $token_string = "Your last successful logon was on 01 January 1970 at 00:00";
518 }
519 }
520  
521 5884 ▶ if ( $token->[0] eq 'S' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[0] eq "S") 1781 4103 5884
522 # ASP state
523 1781 ▶ if ( $token->[1] eq 'input' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] eq "input") 55 1726 1781
524 55 ▶ if ( $self->_streq( $token->[2]{name}, "__VIEWSTATE" ) or
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_streq($token->[2]{"name"}, "__VIEWSTATE") or $self->_streq($token->[2]{"name"}, "__EVENTVALIDATION") or $self->_streq($token->[2]{"name"}, "PtsbCifNumber") or $self->_streq($token->[2]{"name"}, "PtsbBranchNumber")) 28 27 55
Condition88%8/9
$self->_streq($token->[2]{"name"}, "__VIEWSTATE") or $self->_streq($token->[2]{"name"}, "__EVENTVALIDATION") or $self->_streq($token->[2]{"name"}, "PtsbCifNumber") or $self->_streq($token->[2]{"name"}, "PtsbBranchNumber")
l!l&&r!l&&!r
28027
$self->_streq($token->[2]{"name"}, "__VIEWSTATE") or $self->_streq($token->[2]{"name"}, "__EVENTVALIDATION") or $self->_streq($token->[2]{"name"}, "PtsbCifNumber")
l!l&&r!l&&!r
27127
$self->_streq($token->[2]{"name"}, "__VIEWSTATE") or $self->_streq($token->[2]{"name"}, "__EVENTVALIDATION")
l!l&&r!l&&!r
151228
MC/DC75%3/4
$self->_streq($token->[2]{"name"}, "__VIEWSTATE") or $self->_streq($token->[2]{"name"}, "__EVENTVALIDATION") or $self->_streq($token->[2]{"name"}, "PtsbCifNumber") or $self->_streq($token->[2]{"name"}, "PtsbBranchNumber")
$self->_streq($token->[2]{"name"}, "__VIEWSTATE") $self->_streq($token->[2]{"name"}, "__EVENTVALIDATION") $self->_streq($token->[2]{"name"}, "PtsbCifNumber") $self->_streq($token->[2]{"name"}, "PtsbBranchNumber")
Truth table80%4/5
A or B or C or D
A= $self->_streq($token->[2]{"name"}, "__VIEWSTATE")B= $self->_streq($token->[2]{"name"}, "__EVENTVALIDATION")C= $self->_streq($token->[2]{"name"}, "PtsbCifNumber")D= $self->_streq($token->[2]{"name"}, "PtsbBranchNumber")
ABCDresult
1XXX1
01XX1
001X1
00011
00000
525 $self->_streq( $token->[2]{name}, "__EVENTVALIDATION" ) or
526 $self->_streq( $token->[2]{name}, "PtsbCifNumber" ) or
527 $self->_streq( $token->[2]{name}, "PtsbBranchNumber" )
528 ) {
529 28 $token->[2]{value} = "";
530 28 $token_string = $self->_rebuild_tag( $token );
531 }
532 }
533  
534 1781 ▶ if ( $token->[1] eq 'select' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] eq "select") 7 1774 1781
535 7 ▶ if ( $self->_streq( $token->[2]{name}, 'ctl00$cphBody$ddlDestinationAccount' ) or
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlDestinationAccount") or $self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlSourceAccount")) 2 5 7
Condition100%3/3
$self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlDestinationAccount") or $self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlSourceAccount")
l!l&&r!l&&!r
115
MC/DC100%2/2
$self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlDestinationAccount") or $self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlSourceAccount")
$self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlDestinationAccount") $self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlSourceAccount")
Truth table100%3/3
A or B
A= $self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlDestinationAccount")B= $self->_streq($token->[2]{"name"}, "ctl00\$cphBody\$ddlSourceAccount")
ABresult
1X1
011
000
536 ( $self->_streq( $token->[2]{name}, 'ctl00$cphBody$ddlSourceAccount' ))) {
537 2 ▶ while ( my $account_token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $account_token = $parser->get_token) 12 0 12
538 12 ▶ my $string = $account_token->[0] eq 'T' ? $account_token->[1] : $account_token->[-1];
Branch: 1 branch
BranchTrueFalseTotal
$account_token->[0] eq 'T' ? : 6 6 12
539 12 ▶ 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") 4 8 12
Condition66%2/3
$account_token->[0] eq "S" and $account_token->[1] eq "option"
!ll&&!rl&&r
804
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
540 4 my $val = $account_token->[2]{value};
541 4 ▶ if ( $val ne 'Please select' and $val !~ /^\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val ne "Please select" and not $val =~ /^\d+$/) 0 4 4
Condition66%2/3
$val ne "Please select" and not $val =~ /^\d+$/
!ll&&!rl&&r
220
MC/DC0%0/2
$val ne "Please select" and not $val =~ /^\d+$/
$val ne "Please select" not $val =~ /^\d+$/
Truth table66%2/3
A and not(B)
A= $val ne "Please select"B= not $val =~ /^\d+$/
ABresult
0X0
100
111
542 0 $account_token->[2]{value} = "0";
543 0 $string = $self->_rebuild_tag( $account_token );
544 0 $val = '0';
545 }
546 4 ▶ if ( $val ne 'Please select' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val ne 'Please select') { } 2 2 4
547 2 $string .= "Account Type $val - 9999";
548 } else {
549 2 $string .= $parser->get_trimmed_text();
550 }
551 4 my $tag = $parser->get_tag( "/option" );
552 4 $string .= $tag->[-1];
553  
554 }
555 12 $token_string .= $string;
556 12 ▶ 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" 2 10 12
Condition66%2/3
$account_token->[0] eq "E" and $account_token->[1] eq "select"
!ll&&!rl&&r
1002
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
557 }
558 }
559 }
560  
561 1781 ▶ if ( $token->[1] eq 'table' and $self->_streq( $token->[2]{class}, "transfereeList" )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] eq "table" and $self->_streq($token->[2]{"class"}, "transfereeList")) 2 1779 1781
Condition100%3/3
$token->[1] eq "table" and $self->_streq($token->[2]{"class"}, "transfereeList")
!ll&&!rl&&r
1728512
MC/DC100%2/2
$token->[1] eq "table" and $self->_streq($token->[2]{"class"}, "transfereeList")
$token->[1] eq "table" $self->_streq($token->[2]{"class"}, "transfereeList")
Truth table100%3/3
A and B
A= $token->[1] eq "table"B= $self->_streq($token->[2]{"class"}, "transfereeList")
ABresult
0X0
100
111
562 2 my $col = 0;
563 2 ▶ while ( my $account_token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $account_token = $parser->get_token) 377 0 377
564 377 ▶ my $string = $account_token->[0] eq 'T' ? $account_token->[1] : $account_token->[-1];
Branch: 1 branch
BranchTrueFalseTotal
$account_token->[0] eq 'T' ? : 104 273 377
565 377 ▶ if ( $account_token->[1] eq 'td' and $account_token->[0] eq 'S' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($account_token->[1] eq "td" and $account_token->[0] eq "S") 80 297 377
Condition100%3/3
$account_token->[1] eq "td" and $account_token->[0] eq "S"
!ll&&!rl&&r
2178080
MC/DC100%2/2
$account_token->[1] eq "td" and $account_token->[0] eq "S"
$account_token->[1] eq "td" $account_token->[0] eq "S"
Truth table100%3/3
A and B
A= $account_token->[1] eq "td"B= $account_token->[0] eq "S"
ABresult
0X0
100
111
566 80 my $replacement = "";
567 80 ▶ if ( $col == 0 ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($col == 0) { } 15 65 80
elsif ($col == 1) { } 15 50 65
elsif ($col == 2) { } 15 35 50
elsif ($col == 3) { } 15 20 35
568 15 $replacement = "Recipient";
569 } elsif ( $col == 1 ) {
570 15 $replacement = "01/01/1970";
571 } elsif ( $col == 2 ) {
572 15 $replacement = "Reference";
573 } elsif ( $col == 3 ) {
574 15 $replacement = "Source A/C";
575 }
576 80 $string .= $replacement;
577 80 $parser->get_text();
578 80 $col++;
579 }
580 377 ▶ if ( $account_token->[0] eq 'E' and $account_token->[1] eq 'tr' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($account_token->[0] eq "E" and $account_token->[1] eq "tr") 17 360 377
Condition100%3/3
$account_token->[0] eq "E" and $account_token->[1] eq "tr"
!ll&&!rl&&r
24211817
MC/DC100%2/2
$account_token->[0] eq "E" and $account_token->[1] eq "tr"
$account_token->[0] eq "E" $account_token->[1] eq "tr"
Truth table100%3/3
A and B
A= $account_token->[0] eq "E"B= $account_token->[1] eq "tr"
ABresult
0X0
100
111
581 17 $col = 0;
582 }
583 377 $token_string .= $string;
584 377 ▶ last if ( $account_token->[0] eq 'E' and $account_token->[1] eq 'table' );
Branch: 1 branch
BranchTrueFalseTotal
if $account_token->[0] eq "E" and $account_token->[1] eq "table" 2 375 377
Condition100%3/3
$account_token->[0] eq "E" and $account_token->[1] eq "table"
!ll&&!rl&&r
2421332
MC/DC100%2/2
$account_token->[0] eq "E" and $account_token->[1] eq "table"
$account_token->[0] eq "E" $account_token->[1] eq "table"
Truth table100%3/3
A and B
A= $account_token->[0] eq "E"B= $account_token->[1] eq "table"
ABresult
0X0
100
111
585 }
586 }
587  
588 1781 ▶ if ( $token->[1] eq 'span' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] eq "span") 70 1711 1781
589 70 ▶ if ( $self->_streq( $token->[2]{id}, "lblTransferTo" )) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->_streq($token->[2]{'id'}, 'lblTransferTo')) { } 0 70 70
elsif ($self->_streq($token->[2]{'id'}, 'lblTranRef')) { } 0 70 70
elsif ($self->_streq($token->[2]{'id'}, 'lblFrAcc')) { } 0 70 70
elsif ($self->_streq($token->[2]{'id'}, 'lblAmount')) { } 0 70 70
590 0 $token_string .= "Recipient";
591 0 $parser->get_text();
592 } elsif ( $self->_streq( $token->[2]{id}, "lblTranRef" )) {
593 0 $token_string .= "Reference";
594 0 $parser->get_text();
595 } elsif ( $self->_streq( $token->[2]{id}, "lblFrAcc" )) {
596 0 $token_string .= "Source A/C";
597 0 $parser->get_text();
598 } elsif ( $self->_streq( $token->[2]{id}, "lblAmount" )) {
599 0 $token_string .= "9999";
600 0 $parser->get_text();
601 }
602 }
603  
604 # should possibly do this within table class="statement"
605 1781 ▶ if ( $token->[1] eq 'a' and
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] eq "a" and defined $token->[2]{"href"} and $token->[2]{"href"} =~ /^StateMini.aspx/) 3 1778 1781
Condition83%5/6
$token->[1] eq "a" and defined $token->[2]{"href"} and $token->[2]{"href"} =~ /^StateMini.aspx/
!ll&&!rl&&r
16701083
$token->[1] eq "a" and defined $token->[2]{"href"}
!ll&&!rl&&r
16700111
MC/DC66%2/3
$token->[1] eq "a" and defined $token->[2]{"href"} and $token->[2]{"href"} =~ /^StateMini.aspx/
$token->[1] eq "a" defined $token->[2]{"href"} $token->[2]{"href"} =~ /^StateMini.aspx/
Truth table75%3/4
A and B and C
A= $token->[1] eq "a"B= defined $token->[2]{"href"}C= $token->[2]{"href"} =~ /^StateMini.aspx/
ABCresult
0XX0
10X0
1100
1111
606 defined( $token->[2]{href}) and
607 $token->[2]{href} =~ /^StateMini.aspx/ ) {
608  
609 # winging it a little here.
610 3 my @replacements = ( "Account Type",
611 9999, # account number
612 99999.99, # balance
613 99999.99, # balance
614 );
615  
616 3 ▶ while ( my $account_token = $parser->get_token()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $account_token = $parser->get_token) 40 0 40
617 40 ▶ my $string = $account_token->[0] eq 'T' ? $account_token->[1] : $account_token->[-1];
Branch: 1 branch
BranchTrueFalseTotal
$account_token->[0] eq 'T' ? : 14 26 40
618 40 ▶ if ( $account_token->[0] eq 'E' and $account_token->[1] eq 'tr' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($account_token->[0] eq "E" and $account_token->[1] eq "tr") 3 37 40
Condition100%3/3
$account_token->[0] eq "E" and $account_token->[1] eq "tr"
!ll&&!rl&&r
23143
MC/DC100%2/2
$account_token->[0] eq "E" and $account_token->[1] eq "tr"
$account_token->[0] eq "E" $account_token->[1] eq "tr"
Truth table100%3/3
A and B
A= $account_token->[0] eq "E"B= $account_token->[1] eq "tr"
ABresult
0X0
100
111
619 3 $token_string .= $string;
620 3 last;
621 }
622 37 ▶ if ( $account_token->[0] eq 'T' and $string !~ /^\s+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($account_token->[0] eq "T" and not $string =~ /^\s+$/) 11 26 37
Condition100%3/3
$account_token->[0] eq "T" and not $string =~ /^\s+$/
!ll&&!rl&&r
23311
MC/DC100%2/2
$account_token->[0] eq "T" and not $string =~ /^\s+$/
$account_token->[0] eq "T" not $string =~ /^\s+$/
Truth table100%3/3
A and not(B)
A= $account_token->[0] eq "T"B= not $string =~ /^\s+$/
ABresult
0X0
100
111
623 11 $string = shift @replacements;
624 }
625 37 ▶ if ( $account_token->[0] eq 'S' and
Branch: 1 branch
BranchTrueFalseTotal
if ($account_token->[0] eq "S" and defined $account_token->[2]{"title"}) 3 34 37
Condition100%3/3
$account_token->[0] eq "S" and defined $account_token->[2]{"title"}
!ll&&!rl&&r
2863
MC/DC100%2/2
$account_token->[0] eq "S" and defined $account_token->[2]{"title"}
$account_token->[0] eq "S" defined $account_token->[2]{"title"}
Truth table100%3/3
A and B
A= $account_token->[0] eq "S"B= defined $account_token->[2]{"title"}
ABresult
0X0
100
111
626 defined( $account_token->[2]{title} )) {
627 3 $account_token->[2]{title} = "";
628 3 $string = $self->_rebuild_tag( $account_token );
629 }
630 37 $token_string .= $string;
631 }
632 }
633 }
634  
635 5884 $output .= $token_string;
636 }
637  
638 13 return $output;
639 }
640  
641 49 ▶sub _add_event_fields {
Subroutine _add_event_fields: called CC=3 SCAR=11.3
642 49 my $self = shift;
643  
644 # these get added by javascript on the page
645 49 my $form = $self->_agent()->current_form();
646 49 for my $name (qw( __EVENTTARGET __EVENTARGUMENT )) {
647 98 ▶ if ( my $input = $form->find_input( $name )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $input = $form->find_input($name)) { } 0 98 98
648 0 $input->readonly( 0 );
649 } else {
650 98 $input = new HTML::Form::Input( type => 'text',
651 name => $name );
652 98 $input->add_to_form( $form );
653 }
654 }
655 }
656  
657 =back
658  
659 =cut
660  
661 package Finance::Bank::IE::PTSB::Account;
662  
663 3 ▶no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
664 128 ▶sub AUTOLOAD { my $self=shift; $AUTOLOAD =~ s/.*:://; $self->{$AUTOLOAD} }
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
665  
666 3 1;
« IE/BankOfIreland.pm ↑ Summary IE/AvantCard.pm »