blib/lib/Finance/Bank/DE/DeutscheBank.pm

filter: Statementstmt 14.5% 39 / 269 Branchbran 0.0% 0 / 94 Conditioncond 0.0% 0 / 53 MC/DCmcdc 0.0% 0 / 27 Subroutinesub 41.9% 13 / 31 Podpod 29.4% 5 / 17 totaltotal 11.6% 57 / 491 CC 74 SCAR 49.7
CC
74
Cov
9%
account_statement
462.0
new_session
156.0
parse_account_overview
132.0
CRAP 143.6
↑ Summary
1 package Finance::Bank::DE::DeutscheBank;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base 'Class::Accessor';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use WWW::Mechanize;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use HTML::LinkExtractor;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use HTML::TreeBuilder;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Text::CSV_XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 1 ▶use vars qw[ $VERSION ];
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 $VERSION = '0.06';
16  
17 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 Finance::Bank::DE::DeutscheBank->mk_accessors(qw( agent ));
19 };
20  
21 1 ▶use constant BASEURL => 'https://meine.deutsche-bank.de';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use constant LOGIN => BASEURL . '/trxm/db/';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use constant FUNCTIONS => "(Übersicht)|(Ihr Konto)|(Ihr Depot)|(Service / Optionen)|(Umsatzanzeige)|(Inlands-Überweisung)|(Daueraufträge)|(Lastschrift)|(Kunden-Logout)|(Überweisungsvorlagen)|(Ihre Finanzübersicht als PDF-Datei speichern)|(Ihre Finanzübersicht als CSV-Datei speichern)|(Customer-Logout)|(Overview)|(Your account)|(Your sec. account)|(Service / Options)|(Transactions)|(Domestic transfer order)|(Standing orders)|(Direct debit)|(Transfer order templates)|(Customer-Logout)|(Save as PDF File)|(Save as CSV File)|(Save your financial overview as PDF file)|(Save your financial overview as CSV file)";
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25  
26 sub new
27 0 ▶{
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
28 0 my ($class,%args) = @_;
29  
30 croak "Filiale/Branch number must be specified"
31 0 ▶ unless $args{Branch};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"Branch"} 0 0 0
32  
33 croak "Konto/Account number must be specified"
34 0 ▶ unless $args{Account};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"Account"} 0 0 0
35  
36 croak "Unterkonto/SubAccount number must be specified"
37 0 ▶ unless $args{SubAccount};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"SubAccount"} 0 0 0
38  
39 croak "PIN/Password must be specified"
40 0 ▶ unless $args{PIN};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"PIN"} 0 0 0
41  
42 0 ▶ my $logger = $args{status} || sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$args{'status'} || sub { }
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'status'} || sub { }
$args{'status'} sub { }
Truth table0%0/3
A || B
A= $args{'status'}B= sub { }
ABresult
1X1
011
000
43  
44 my $self = {
45 agent => undef,
46 account => $args{Account},
47 password => $args{PIN},
48 branch => $args{Branch},
49 subaccount => $args{SubAccount},
50 0 logger => $logger,
51 navigation => undef,
52 };
53 0 bless $self, $class;
54  
55 0 $self->log("New $class created");
56 0 $self;
57 };
58  
59  
60 sub log
61 0 ▶{
Subroutine log: not called CC=1 SCAR=6.9
Pod undocumented
62 0 $_[0]->{logger}->(@_);
63 };
64  
65  
66 sub log_httpresult
67 0 ▶{
Subroutine log_httpresult: not called CC=1 SCAR=6.9
Pod undocumented
68 0 $_[0]->log("HTTP Code",$_[0]->agent->status,$_[0]->agent->res->as_string)
69 };
70  
71  
72 sub new_session
73 0 ▶{
Subroutine new_session: not called CC=12 SCAR=50.5
Pod undocumented
74 # Reset our user agent
75 0 my ($self) = @_;
76 0 my $url;
77  
78 0 ▶ $self->close_session()
Branch: 1 branch
BranchTrueFalseTotal
if $self->agent 0 0 0
79 if ($self->agent);
80  
81 0 my $result = $self->get_login_page(LOGIN);
82  
83 0 ▶ if ( $result != 200 )
Branch: 1 branch
BranchTrueFalseTotal
if ($result != 200) 0 0 0
84 {
85 0 $self->log("Status"," Banking is unavailable");
86 0 die "Banking is unavailable";
87 }
88  
89 0 ▶ if ( $result == 200 )
Branch: 1 branch
BranchTrueFalseTotal
if ($result == 200) 0 0 0
90 {
91 0 ▶ if ($self->maintenance)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->maintenance) 0 0 0
92 {
93 0 $self->log("Status","Banking is unavailable due to maintenance");
94 0 die "Banking unavailable due to maintenance";
95 };
96  
97 0 my $agent = $self->agent();
98 0 my $function = 'ACCOUNTBALANCE';
99 0 $self->log("Logging into function $function");
100  
101 # gvo=DisplayFinancialOverview&loginTab=iTAN&javascriptEnabled=true&branch=XXX&account=XXXXXX&subaccount=XX&pin=XXXXX&quickLink=DisplayFinancialOverview
102 0 $agent->current_form->value('gvo','DisplayFinancialOverview');
103 0 $agent->current_form->value('loginTab','iTAN');
104 0 $agent->current_form->value('javascriptEnabled','false');
105 0 $agent->current_form->value('quickLink','DisplayFinancialOverview');
106 0 $agent->current_form->value('account',$self->{account});
107 0 $agent->current_form->value('branch',$self->{branch});
108 0 $agent->current_form->value('subaccount',$self->{subaccount});
109 0 $agent->current_form->value('pin',$self->{password});
110 0 $agent->add_header('Accept-Charset' => 'utf-8');
111 0 $agent->add_header('Accept-Encoding' => '');
112  
113 0 local $^W=0;
114 0 $result = $agent->submit();
115  
116 0 ▶ if ( $self->access_denied )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->access_denied) 0 0 0
117 {
118 0 $self->log("Not possible to authenticate at bank server ( wrong account/pin combination ? )");
119 0 return 0;
120 }
121  
122 # extract links to account functions
123 0 my $LinkExtractor = new HTML::LinkExtractor();
124  
125 0 $LinkExtractor->strip( 1 );
126 0 $LinkExtractor->parse(\$agent->content());
127  
128 # needed here because of empty links ( href attribute )
129 0 local $^W=1;
130  
131 # now we have the links in the format
132 # {
133 # '_TEXT' => 'Overview',
134 # 'target' => '_top',
135 # 'href' => '/mod/WebObjects/dbpbc.woa/618/wo/HpRl1hqezkxfYRosJRjTg0/4.11.1.5.3.3.5.3',
136 # 'tag' => 'a',
137 # 'class' => 'NaviDirektLink'
138 # },
139 # { ...
140 # }
141 #
142  
143  
144 # but I would like to have them as
145 # {
146 # '_TEXT' => 'Overview',
147 # 'href' => '/mod/WebObjects/dbpbc.woa/618/wo/HpRl1hqezkxfYRosJRjTg0/4.11.1.5.3.3.5.3',
148 # },
149 # { ...
150 # }
151 # and only for functions ( not all links and images ... )
152  
153 0 my @tmp = ();
154 0 foreach my $elem ( @{$LinkExtractor->links} )
155 {
156 0 ▶ if (( defined( $elem->{ '_TEXT' } ) && ( $elem->{ '_TEXT' } ne '' ) && ( $elem->{ '_TEXT' } =~ "m/". FUNCTIONS ."/" )) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $elem->{"_TEXT"} and $elem->{"_TEXT"} ne "" and $elem->{"_TEXT"} =~ m[m/] . "(\303\234bersicht)|(Ihr Konto)|(Ihr Depot)|(Service / Optionen)|(Umsatzanzeige)|(Inlands-\303\234berweisung)|(Dauerauftr\303\244ge)|(Lastschrift)|(Kunden-Logout)|(\303\234berweisungsvorlagen)|(Ihre Finanz\303\274bersicht als PDF-Datei speichern)|(Ihre Finanz\303\274bersicht als CSV-Datei speichern)|(Customer-Logout)|(Overview)|(Your account)|(Your sec. account)|(Service / Options)|(Transactions)|(Domestic transfer order)|(Standing orders)|(Direct debit)|(Transfer order templates)|(Customer-Logout)|(Save as PDF File)|(Save as CSV File)|(Save your financial overview as PDF file)|(Save your financial overview as CSV file)" . "/") 0 0 0
Condition0%0/5
defined $elem->{"_TEXT"} and $elem->{"_TEXT"} ne "" and $elem->{"_TEXT"} =~ m[m/] . "(\303\234bersicht)|(Ihr Konto)|(Ihr Depot)|(Service / Optionen)|(Umsatzanzeige)|(Inlands-\303\234berweisung)|(Dauerauftr\303\244ge)|(Lastschrift)|(Kunden-Logout)|(\303\234berweisungsvorlagen)|(Ihre Finanz\303\274bersicht als PDF-Datei speichern)|(Ihre Finanz\303\274bersicht als CSV-Datei speichern)|(Customer-Logout)|(Overview)|(Your account)|(Your sec. account)|(Service / Options)|(Transactions)|(Domestic transfer order)|(Standing orders)|(Direct debit)|(Transfer order templates)|(Customer-Logout)|(Save as PDF File)|(Save as CSV File)|(Save your financial overview as PDF file)|(Save your financial overview as CSV file)" . "/"
!ll
00
defined $elem->{"_TEXT"} and $elem->{"_TEXT"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $elem->{"_TEXT"} and $elem->{"_TEXT"} ne "" and $elem->{"_TEXT"} =~ m[m/] . "(\303\234bersicht)|(Ihr Konto)|(Ihr Depot)|(Service / Optionen)|(Umsatzanzeige)|(Inlands-\303\234berweisung)|(Dauerauftr\303\244ge)|(Lastschrift)|(Kunden-Logout)|(\303\234berweisungsvorlagen)|(Ihre Finanz\303\274bersicht als PDF-Datei speichern)|(Ihre Finanz\303\274bersicht als CSV-Datei speichern)|(Customer-Logout)|(Overview)|(Your account)|(Your sec. account)|(Service / Options)|(Transactions)|(Domestic transfer order)|(Standing orders)|(Direct debit)|(Transfer order templates)|(Customer-Logout)|(Save as PDF File)|(Save as CSV File)|(Save your financial overview as PDF file)|(Save your financial overview as CSV file)" . "/"
defined $elem->{"_TEXT"} $elem->{"_TEXT"} ne ""
Truth table0%0/3
A and B
A= defined $elem->{"_TEXT"}B= $elem->{"_TEXT"} ne ""
ABresult
0X0
100
111
157 {
158 0 foreach $_ ( keys %$elem )
159 {
160 0 ▶ if ( $_ !~ m/(_TEXT)|(href)/ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ =~ /(_TEXT)|(href)/) 0 0 0
161 {
162 0 delete $elem->{ $_ };
163 }
164 }
165  
166 0 push @tmp, \%$elem;
167 }
168 }
169  
170 # save these links so that we can remember them
171 0 $self->{navigation} = \@tmp;
172 0 $self->log_httpresult();
173 0 $result = $agent->status;
174 };
175 0 $result;
176 };
177  
178  
179 sub get_login_page
180 0 ▶{
Subroutine get_login_page: not called CC=1 SCAR=6.9
Pod undocumented
181 0 my ($self,$url) = @_;
182 0 $self->log("Connecting to $url");
183 0 $self->agent(WWW::Mechanize->new(agent => "Mozilla/4.78 (Linux 2.4.19-4GB i686; U) Opera 6.03 [en]", cookie_jar => {} ));
184  
185 0 my $agent = $self->agent();
186 0 $agent->add_header('Accept-Language' => 'en-us,en;q=0.5');
187 0 $agent->get(LOGIN);
188 0 $self->log_httpresult();
189 0 $agent->status;
190 };
191  
192  
193 sub error_page
194 0 ▶{
Subroutine error_page: not called CC=3 SCAR=24.8
Pod undocumented
195 # Check if an error page is shown (a page with much red on it)
196 0 my ($self) = @_;
197 0 my $content = $self->agent->content;
198 0 $content =~ s!<div class="errorMsg"><label for="">Bitte beachten Sie, da\&szlig; die "Hochstell-Taste" \(Capslock\) aktiv ist.</label></div>!!;
199 0 $content =~ s!<div class="errorMsg"><label for="">Please note capslock-key is active.</label></div>!!;
200 0 ▶ $content =~ /<tr valign="top" bgcolor="#FF0033">/sm || $content =~ /<div class="errorMsg">/ || $content =~ /<div class="backendErrorMsg">/ ;
Branch: 1 branch
BranchTrueFalseTotal
$content =~ /<tr valign="top" bgcolor="#FF0033">/ms or $content =~ /<div class="errorMsg">/ or $content =~ /<div class="backendErrorMsg">/ 0 0 0
Condition0%0/3
$content =~ /<tr valign="top" bgcolor="#FF0033">/ms or $content =~ /<div class="errorMsg">/
l!l&&r!l&&!r
000
MC/DC0%0/2
$content =~ /<tr valign="top" bgcolor="#FF0033">/ms or $content =~ /<div class="errorMsg">/
$content =~ /<tr valign="top" bgcolor="#FF0033">/ms $content =~ /<div class="errorMsg">/
Truth table0%0/3
A or B
A= $content =~ /<tr valign="top" bgcolor="#FF0033">/msB= $content =~ /<div class="errorMsg">/
ABresult
1X1
011
000
201 };
202  
203  
204 sub maintenance
205 0 ▶{
Subroutine maintenance: not called CC=2 SCAR=17.9
Pod undocumented
206 0 my ($self) = @_;
207  
208 # would be nice if someone could mail me the actual english and german messages which are displayed in case of maintenance ...
209 0 ▶ $self->error_page or
Branch: 1 branch
BranchTrueFalseTotal
$self->error_page or $self->agent->content =~ /derzeit steht das Internet Banking aufgrund von Wartungsarbeiten leider nicht zur Verf&uuml;gung.\s*<br>\s*In K&uuml;rze wird das Internet Banking wieder wie gewohnt erreichbar sein./gms 0 0 0
210 $self->agent->content =~ /derzeit steht das Internet Banking aufgrund von Wartungsarbeiten leider nicht zur Verf&uuml;gung.\s*<br>\s*In K&uuml;rze wird das Internet Banking wieder wie gewohnt erreichbar sein./gsm;
211 };
212  
213  
214 sub access_denied
215 0 ▶{
Subroutine access_denied: not called CC=9 SCAR=45.0
Pod undocumented
216 0 my ($self) = @_;
217 0 my $content = $self->agent->content;
218  
219 0 ▶ $self->error_page or
Branch: 1 branch
BranchTrueFalseTotal
$self->error_page or ($content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms or $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms or $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms or $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/ or $content =~ /Unfortunately, you were not able to register successfully./ or $content =~ /Bitte \303\274berpr&uuml;fen Sie Ihre Anmeldedaten oder versuchen Sie es zu einem sp&auml;teren Zeitpunkt noch einmal./ or $content =~ /Please check your registration data or try again later./ or $content =~ /Bitte geben Sie ein g&uuml;ltiges Datum ein/) 0 0 0
Condition0%0/24
$self->error_page || ($content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms || $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms || $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms || $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/ || $content =~ /Unfortunately, you were not able to register successfully./ || $content =~ /Bitte \303\274berpr&uuml;fen Sie Ihre Anmeldedaten oder versuchen Sie es zu einem sp&auml;teren Zeitpunkt noch einmal./ || $content =~ /Please check your registration data or try again later./ || $content =~ /Bitte geben Sie ein g&uuml;ltiges Datum ein/)
l!l&&r!l&&!r
000
$content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms or $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms or $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms or $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/ or $content =~ /Unfortunately, you were not able to register successfully./ or $content =~ /Bitte \303\274berpr&uuml;fen Sie Ihre Anmeldedaten oder versuchen Sie es zu einem sp&auml;teren Zeitpunkt noch einmal./ or $content =~ /Please check your registration data or try again later./ or $content =~ /Bitte geben Sie ein g&uuml;ltiges Datum ein/
l!l&&r!l&&!r
000
$content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms or $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms or $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms or $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/ or $content =~ /Unfortunately, you were not able to register successfully./ or $content =~ /Bitte \303\274berpr&uuml;fen Sie Ihre Anmeldedaten oder versuchen Sie es zu einem sp&auml;teren Zeitpunkt noch einmal./ or $content =~ /Please check your registration data or try again later./
l!l&&r!l&&!r
000
$content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms or $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms or $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms or $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/ or $content =~ /Unfortunately, you were not able to register successfully./ or $content =~ /Bitte \303\274berpr&uuml;fen Sie Ihre Anmeldedaten oder versuchen Sie es zu einem sp&auml;teren Zeitpunkt noch einmal./
l!l&&r!l&&!r
000
$content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms or $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms or $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms or $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/ or $content =~ /Unfortunately, you were not able to register successfully./
l!l&&r!l&&!r
000
$content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms or $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms or $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms or $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/
l!l&&r!l&&!r
000
$content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms or $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms or $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms
l!l&&r!l&&!r
000
$content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms or $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms
l!l&&r!l&&!r
000
MC/DC0%0/9
$self->error_page || ($content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms || $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms || $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms || $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/ || $content =~ /Unfortunately, you were not able to register successfully./ || $content =~ /Bitte \303\274berpr&uuml;fen Sie Ihre Anmeldedaten oder versuchen Sie es zu einem sp&auml;teren Zeitpunkt noch einmal./ || $content =~ /Please check your registration data or try again later./ || $content =~ /Bitte geben Sie ein g&uuml;ltiges Datum ein/)
$self->error_page $content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gms $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gms $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gms $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/ $content =~ /Unfortunately, you were not able to register successfully./ $content =~ /Bitte \303\274berpr&uuml;fen Sie Ihre Anmeldedaten oder versuchen Sie es zu einem sp&auml;teren Zeitpunkt noch einmal./ $content =~ /Please check your registration data or try again later./ $content =~ /Bitte geben Sie ein g&uuml;ltiges Datum ein/
Truth table0%0/10
A || B or C or D or E or F or G or H or I
A= $self->error_pageB= $content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gmsC= $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gmsD= $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gmsE= $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/F= $content =~ /Unfortunately, you were not able to register successfully./G= $content =~ /Bitte \303\274berpr&uuml;fen Sie Ihre Anmeldedaten oder versuchen Sie es zu einem sp&auml;teren Zeitpunkt noch einmal./H= $content =~ /Please check your registration data or try again later./I= $content =~ /Bitte geben Sie ein g&uuml;ltiges Datum ein/
ABCDEFGHIresult
1XXXXXXXX1
01XXXXXXX1
001XXXXXX1
0001XXXXX1
00001XXXX1
000001XXX1
0000001XX1
00000001X1
0000000011
0000000000
220 ( $content =~ /Die eingegebene Kontonummer ist unvollst&auml;ndig oder falsch\..*\(2051\)/gsm
221 or $content =~ /Die eingegebene PIN ist falsch\. Bitte geben Sie die richtige PIN ein\.\s*\(10011\)/gsm
222 or $content =~ /Die von Ihnen eingegebene Kontonummer ist ung&uuml;ltig und entspricht keiner Deutsche Bank-Kontonummer.\s*\(3040\)/gsm
223 or $content =~ /Leider konnte Ihre Anmeldung nicht erfolgreich durchgef&uuml;hrt werden/
224 or $content =~ /Unfortunately, you were not able to register successfully./
225 or $content =~ /Bitte überpr&uuml;fen Sie Ihre Anmeldedaten oder versuchen Sie es zu einem sp&auml;teren Zeitpunkt noch einmal./
226 or $content =~ /Please check your registration data or try again later./
227 or $content =~ /Bitte geben Sie ein g&uuml;ltiges Datum ein/
228 );
229 };
230  
231  
232 sub session_timed_out
233 0 ▶{
Subroutine session_timed_out: not called CC=1 SCAR=6.9
Pod undocumented
234 0 my ($self) = @_;
235 0 $self->agent->content =~ /Die Sitzungsdaten sind ung&uuml;ltig, bitte f&uuml;hren Sie einen erneuten Login durch.\s+\(27000\)/;
236 };
237  
238  
239 sub functions
240 0 ▶{
Subroutine functions: not called CC=4 SCAR=30.0
Pod undocumented
241 0 my ($self,$function) = @_;
242 0 my $link = ();
243  
244 0 ▶ if ( $function =~ "m/". FUNCTIONS ."/" )
Branch: 1 branch
BranchTrueFalseTotal
if ($function =~ m[m/] . "(\303\234bersicht)|(Ihr Konto)|(Ihr Depot)|(Service / Optionen)|(Umsatzanzeige)|(Inlands-\303\234berweisung)|(Dauerauftr\303\244ge)|(Lastschrift)|(Kunden-Logout)|(\303\234berweisungsvorlagen)|(Ihre Finanz\303\274bersicht als PDF-Datei speichern)|(Ihre Finanz\303\274bersicht als CSV-Datei speichern)|(Customer-Logout)|(Overview)|(Your account)|(Your sec. account)|(Service / Options)|(Transactions)|(Domestic transfer order)|(Standing orders)|(Direct debit)|(Transfer order templates)|(Customer-Logout)|(Save as PDF File)|(Save as CSV File)|(Save your financial overview as PDF file)|(Save your financial overview as CSV file)" . '/') { } 0 0 0
245 {
246 0 foreach $_ ( @{$self->{ navigation }} )
247 {
248 0 ▶ if ( $_->{ '_TEXT' } eq $function )
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"_TEXT"} eq $function) 0 0 0
249 {
250 0 $link = $_->{ 'href' };
251 }
252 }
253 0 return $link;
254 }
255 else
256 {
257 0 return 0;
258 }
259 }
260  
261  
262 sub select_function
263 0 ▶{
Subroutine select_function: not called CC=4 SCAR=30.0
Pod documented
264 0 my ($self,$function) = @_;
265 0 ▶ carp "Unknown account function '$function'"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->functions($function) 0 0 0
266 unless $self->functions($function);
267  
268 0 ▶ $self->new_session unless $self->agent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->agent 0 0 0
269 0 $self->agent->get( $self->functions( "$function" ) );
270  
271 0 ▶ if ( $self->session_timed_out )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->session_timed_out) 0 0 0
272 {
273 0 $self->log("Session timed out");
274 0 $self->agent(undef);
275 0 $self->new_session();
276 0 $self->agent->get( $self->functions( $function ) );
277 };
278 0 $self->log_httpresult();
279 0 $self->agent->status;
280 };
281  
282  
283 sub close_session
284 0 ▶{
Subroutine close_session: not called CC=2 SCAR=17.9
Pod documented
285 0 my ($self) = @_;
286 0 my $result;
287 0 ▶ if (not $self->access_denied)
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->access_denied) { } 0 0 0
288 {
289 0 $self->log("Closing session");
290 0 local $^W=0;
291 0 $self->select_function('Customer-Logout');
292 0 local $^W=1;
293 0 $result = $self->agent->res->as_string =~ /https:\/\/meine.deutsche-bank.de\/trxm\/db\/.*;link=trxm_en_logout-pbcde-to-txm_login.*/;
294 }
295 else
296 {
297 0 $result = 'Never logged in';
298 };
299 0 $self->agent(undef);
300 0 $result;
301 };
302  
303  
304 sub login
305 0 ▶{
Subroutine login: not called CC=2 SCAR=17.9
Pod documented
306 0 my ($self) = @_;
307  
308 0 ▶ if ( $self->new_session() )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->new_session) { } 0 0 0
309 {
310 0 return 1;
311 }
312 else
313 {
314 0 return 0;
315 }
316  
317 };
318  
319  
320 sub parse_account_overview
321 0 ▶{
Subroutine parse_account_overview: not called CC=11 SCAR=48.8
Pod undocumented
322 0 my ($self) = @_;
323 0 my $agent = $self->agent();
324 0 my %saldo = ();
325  
326 0 my $tree = HTML::TreeBuilder->new();
327 0 $tree->parse( $agent->content() );
328  
329 0 foreach my $table ( $tree->look_down('_tag', 'table') )
330 {
331 0 foreach my $row ( $table->look_down('_tag', 'tr') )
332 {
333 0 foreach my $child ( $row->look_down('_tag', 'td') )
334 {
335 0 ▶ if (( defined $child->attr('class')) && ( $child->attr('class') eq 'balance'))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $child->attr("class") and $child->attr("class") eq "balance") 0 0 0
Condition0%0/3
defined $child->attr("class") and $child->attr("class") eq "balance"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $child->attr("class") and $child->attr("class") eq "balance"
defined $child->attr("class") $child->attr("class") eq "balance"
Truth table0%0/3
A and B
A= defined $child->attr("class")B= $child->attr("class") eq "balance"
ABresult
0X0
100
111
336 {
337 0 my $tmp = $child->as_trimmed_text;
338  
339 0 ▶ if ( $child->attr('class') eq 'balance')
Branch: 1 branch
BranchTrueFalseTotal
if ($child->attr("class") eq "balance") 0 0 0
340 {
341 0 ▶ if ( $tmp =~ m/\.[0-9][0-9]$/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($tmp =~ /\.[0-9][0-9]$/) 0 0 0
342 {
343 0 $tmp =~ s/\./#/;
344 0 $tmp =~ s/,/./g;
345 0 $tmp =~ s/#/,/;
346 }
347 0 $saldo{ 'Saldo' } = $tmp;
348 }
349 }
350  
351 0 foreach my $morechildren ( $child->look_down('_tag', 'acronym') )
352 {
353 0 ▶ if (( defined $morechildren->attr('title')) && ( $morechildren->attr('title') eq 'Euro'))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $morechildren->attr("title") and $morechildren->attr("title") eq "Euro") 0 0 0
Condition0%0/3
defined $morechildren->attr("title") and $morechildren->attr("title") eq "Euro"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $morechildren->attr("title") and $morechildren->attr("title") eq "Euro"
defined $morechildren->attr("title") $morechildren->attr("title") eq "Euro"
Truth table0%0/3
A and B
A= defined $morechildren->attr("title")B= $morechildren->attr("title") eq "Euro"
ABresult
0X0
100
111
354 {
355 0 $saldo{ 'Währung' } = $morechildren->as_trimmed_text;
356 }
357 }
358 }
359 }
360 }
361 0 return %saldo
362 }
363  
364  
365 sub saldo
366 0 ▶{
Subroutine saldo: not called CC=2 SCAR=17.9
Pod undocumented
367 0 my ($self) = @_;
368 0 my $agent = $self->agent;
369 0 ▶ if ($agent)
Branch: 1 branch
BranchTrueFalseTotal
if ($agent) { } 0 0 0
370 {
371 0 local $^W=0;
372 0 $self->select_function('Overview');
373 0 local $^W=1;
374 0 return $self->parse_account_overview();
375 }
376 else
377 {
378 0 return undef;
379 }
380 };
381  
382  
383 sub MapData
384 0 ▶{
Subroutine MapData: not called CC=8 SCAR=42.8
Pod undocumented
385 0 my ( @data ) = @_;
386 0 for my $row ( @data )
387 {
388 0 foreach $_ ( keys %$row )
389 {
390 0 ▶ if (( $_ eq 'Haben' )||( $_ eq 'Soll' ))
Branch: 3 branches
BranchTrueFalseTotal
if ($_ eq 'Haben' or $_ eq 'Soll') { } 0 0 0
elsif ($_ eq 'Buchungstag' or $_ eq 'Wert') { } 0 0 0
elsif ($_ eq 'Waehrung') { } 0 0 0
Condition0%0/3
$_ eq "Haben" or $_ eq "Soll"
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq "Haben" or $_ eq "Soll"
$_ eq "Haben" $_ eq "Soll"
Truth table0%0/3
A or B
A= $_ eq "Haben"B= $_ eq "Soll"
ABresult
1X1
011
000
391 {
392 0 $row->{ $_ } =~ s/\./#/;
393 0 $row->{ $_ } =~ s/,/./g;
394 0 $row->{ $_ } =~ s/#/,/;
395 }
396 ▶ elsif (( $_ eq 'Buchungstag' )||( $_ eq 'Wert' ))
Condition0%0/3
$_ eq "Buchungstag" or $_ eq "Wert"
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq "Buchungstag" or $_ eq "Wert"
$_ eq "Buchungstag" $_ eq "Wert"
Truth table0%0/3
A or B
A= $_ eq "Buchungstag"B= $_ eq "Wert"
ABresult
1X1
011
000
397 {
398 0 my @tmp = split( /\//, $row->{ $_ } );
399 0 $row->{ $_ } = join( '.', $tmp[1], $tmp[0], $tmp[2] );
400 }
401 elsif ( $_ eq 'Waehrung' )
402 {
403 0 my $tmp = $row->{ 'Waehrung' };
404 0 delete $row->{ 'Waehrung' };
405 0 $row->{ 'Währung' } = $tmp;
406 }
407 }
408 }
409 0 return @data;
410 }
411  
412  
413 sub account_statement
414 0 ▶{
Subroutine account_statement: not called CC=21 SCAR=61.4
Pod documented
415 0 my ($self, %parameter) = @_;
416  
417 0 my $count = 0;
418 0 my @header = ();
419 0 my @AccountStatement = ();
420 0 my $AccountRow = ();
421 0 my @date;
422 0 my $agent = $self->agent;
423 0 ▶ if ($agent)
Branch: 1 branch
BranchTrueFalseTotal
if ($agent) { } 0 0 0
424 {
425 0 local $^W=0;
426 0 $self->select_function('Overview');
427  
428 0 my %account = $self->parse_account_overview();
429 0 $agent->follow_link( 'text' => 'Transactions' );
430 0 local $^W=1;
431  
432 # should I get account statement for user defined period ?
433 0 ▶ if ( defined $parameter{ 'period' } )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $parameter{'period'}) { } 0 0 0
elsif (defined $parameter{'last'}) { } 0 0 0
434 {
435 0 my ( $day, $month, $year ) = split( '\.', $parameter{ 'StartDate' } );
436  
437 0 $day = sprintf("%02d", $day );
438 0 $month = sprintf("%02d", $month );
439 0 $year = sprintf("%04d", $year );
440  
441 0 ▶ croak "Year must have 4 digits in StartDate"
Branch: 1 branch
BranchTrueFalseTotal
unless length $year == 4 0 0 0
442 unless ( length $year == 4 );
443  
444 0 $agent->current_form->value( 'period','dynamicRange');
445 0 $agent->current_form->value( 'periodStartDay', $day );
446 0 $agent->current_form->value( 'periodStartMonth', $month );
447 0 $agent->current_form->value( 'periodStartYear', $year );
448  
449 0 ( $day, $month, $year ) = split( '\.', $parameter{ 'EndDate' } );
450 0 $day = sprintf("%02d", $day );
451 0 $month = sprintf("%02d", $month );
452 0 $year = sprintf("%04d", $year );
453  
454 0 ▶ croak "Year must have 4 digits in EndDate"
Branch: 1 branch
BranchTrueFalseTotal
unless length $year == 4 and $year > 1900 0 0 0
Condition0%0/3
length $year == 4 and $year > 1900
!ll&&!rl&&r
000
MC/DC0%0/2
length $year == 4 and $year > 1900
length $year == 4 $year > 1900
Truth table0%0/3
A and B
A= length $year == 4B= $year > 1900
ABresult
0X0
100
111
455 unless (( length $year == 4 )&&( $year > 1900 ));
456  
457 0 $agent->current_form->value( 'period','dynamicRange');
458 0 $agent->current_form->value( 'periodEndDay', $day );
459 0 $agent->current_form->value( 'periodEndMonth', $month );
460 0 $agent->current_form->value( 'periodEndYear', $year );
461 }
462 elsif ( defined $parameter{ 'last' } )
463 {
464 0 my $last = ();
465 0 $agent->current_form->value('period','fixedRange');
466 0 ▶ if ( $parameter{ 'last' } <= 10 )
Branch: 6 branches
BranchTrueFalseTotal
if ($parameter{'last'} <= 10) { } 0 0 0
elsif ($parameter{'last'} <= 20) { } 0 0 0
elsif ($parameter{'last'} <= 30) { } 0 0 0
elsif ($parameter{'last'} <= 60) { } 0 0 0
elsif ($parameter{'last'} <= 90) { } 0 0 0
elsif ($parameter{'last'} <= 120) { } 0 0 0
467 {
468 0 $last = 10;
469 }
470 elsif ( $parameter{ 'last' } <= 20 )
471 {
472 0 $last = 20;
473 }
474 elsif ( $parameter{ 'last' } <= 30 )
475 {
476 0 $last = 30;
477 }
478 elsif ( $parameter{ 'last' } <= 60 )
479 {
480 0 $last = 60;
481 }
482 elsif ( $parameter{ 'last' } <= 90 )
483 {
484 0 $last = 90;
485 }
486 elsif ( $parameter{ 'last' } <= 120 )
487 {
488 0 $last = 120;
489 }
490 else # > 120
491 {
492 0 $last = 180;
493 }
494 0 $agent->select('periodDays', $last);
495 }
496 else #expect that per default last login date is set ...
497 {
498 ;
499 }
500  
501 0 local $^W=0;
502 # 'refresh view' is used to trigger update of account balance
503 0 my $result = $agent->submit();
504  
505 # download CSV formated data of account balances
506 0 $result = $agent->follow_link( text_regex => qr/Save your account turnover as.*CSV.*file/ );
507 0 local $^W=1;
508  
509 #successfully downloaded account balance data in csv format
510 0 ▶ if ( $result->is_success )
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success) { } 0 0 0
511 {
512 0 my @balance = split( '\n', $result->content );
513 0 my $csv = Text::CSV_XS->new( { 'sep_char' => ';' });
514  
515 0 my $StartLineDetected = 0;
516 0 ▶ for ( my $loop = 0; $loop < scalar @balance; $loop++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($loop < scalar @balance) 0 0 0
517 {
518 0 my $line = $balance[ $loop ];
519 0 chomp( $line );
520  
521 0 $line =~ s/^Booking date;/Buchungstag;/;
522 0 $line =~ s/;Value date;/;Wert;/;
523 0 $line =~ s/;Transactions Payment details;/;Verwendungszweck;/;
524 0 $line =~ s/;Debit;/;Soll;/;
525 0 $line =~ s/;Credit;/;Haben;/;
526 0 $line =~ s/;Currency/;Waehrung/;
527 0 $line =~ s/^Account balance;/Kontostand;/;
528  
529 0 ▶ if ( $StartLineDetected == 1 )
Branch: 3 branches
BranchTrueFalseTotal
if ($StartLineDetected == 1) { } 0 0 0
elsif ($StartLineDetected == 2) { } 0 0 0
elsif ($line =~ /Vorgemerkte und noch nicht gebuchte Ums\303\244tze sind nicht Bestandteil dieser Aufstellung/ or $line =~ /Transactions pending are not included in this report/) { } 0 0 0
530 {
531 0 my $status = $csv->parse( $line );
532 0 @header = $csv->fields();
533 0 $AccountRow = 0;
534 0 @AccountStatement = ();
535 0 $StartLineDetected = 2;
536 }
537 elsif ( $StartLineDetected == 2 )
538 {
539 0 ▶ if ( $line !~ /^Kontostand;/ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^Kontostand;/) 0 0 0
540 {
541 0 my $status = $csv->parse( $line );
542 0 my @columns = $csv->fields();
543  
544 0 ▶ for (my $loop = 0; $loop < scalar @columns; $loop++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($loop < scalar @columns) 0 0 0
545 {
546 0 $AccountStatement[ $AccountRow ]{ $header[ $loop ] } = $columns[ $loop ];
547 }
548 0 $AccountRow++;
549 }
550 }
551 ▶ elsif ( ( $line =~ /Vorgemerkte und noch nicht gebuchte Umsätze sind nicht Bestandteil dieser Aufstellung/ )||
Condition0%0/3
$line =~ /Vorgemerkte und noch nicht gebuchte Ums\303\244tze sind nicht Bestandteil dieser Aufstellung/ or $line =~ /Transactions pending are not included in this report/
l!l&&r!l&&!r
000
MC/DC0%0/2
$line =~ /Vorgemerkte und noch nicht gebuchte Ums\303\244tze sind nicht Bestandteil dieser Aufstellung/ or $line =~ /Transactions pending are not included in this report/
$line =~ /Vorgemerkte und noch nicht gebuchte Ums\303\244tze sind nicht Bestandteil dieser Aufstellung/ $line =~ /Transactions pending are not included in this report/
Truth table0%0/3
A or B
A= $line =~ /Vorgemerkte und noch nicht gebuchte Ums\303\244tze sind nicht Bestandteil dieser Aufstellung/B= $line =~ /Transactions pending are not included in this report/
ABresult
1X1
011
000
552 ( $line =~ /Transactions pending are not included in this report/ ) )
553 {
554 0 $StartLineDetected = 1;
555 }
556 }
557 0 return MapData( @AccountStatement );
558 }
559 else
560 {
561 0 return undef;
562 }
563 }
564 else
565 {
566 0 return undef;
567 }
568 }
569  
570  
571 1 1;
572 __END__
↑ Summary