package Finance::Bank::PC; use strict; use version; our $VERSION = qv('0.01'); use base 'Finance::Bank::Generic'; use Regexp::Common qw/whitespace/; sub _config { return { LOGIN_FORM_URL => 'https://www.txn.banking.pcfinancial.ca/a/authentication/preSignOn.ams?referid=loginBox_banking_go', ACCOUNTS_URL => 'https://www.txn.banking.pcfinancial.ca/a/banking/accounts/accountSummary.ams?refId=sidenav', FIELD_CARD_NUMBER => 'cardNumber', FIELD_PASSWORD => 'password', TABLE_HEADERS => { "summary" => [ "accounts & products", "Bank card designation", "Funds available", "Balance" ], "details" => [ "Date", "Transaction details", "Funds out", "Funds in", "Balance" ], }, DETAIL_FORM_ACCOUNT_FIELD => 'fromAccount', }; }; sub bank_name { return 'pc'; } sub _parse_summary_row { my ($self, $row) = @_; # first column is name and number and account id, remove anything that's not alphanum my ($name, $number) = $row->[0] =~ m/(.+?)<\/span>.+?\[(.+?)\]/; my ($account_id) = $row->[0] =~ m/goTxnHistory\('(.+?)'\)/; $name =~ s/TM<\/sup>//; $name =~ s/[^\w\s]//g; # second column is designation (Chequing or Savings), remove anything that's not alphanum my $designation = $row->[1]; $designation =~ s/[^\w]//g; # third column is Available Balance, remove anything that's not a dollar amount my $available = $row->[2]; $available =~ s/[^\$\-\.\d]//g; # fourth column is Posted Balance, remove anything that's not a dollar amount my $posted = $row->[3]; $posted =~ s/[^\$\-\.\d]//g; unless ( defined $name && defined $number && defined $available && defined $posted ) { return undef; } return { bank_name => $self->bank_name(), bank_id => $self->{bank_id}, account_id => $account_id, name => $name, number => $number, designation => $designation, available => $available, posted => $posted, }; } sub _parse_details_row { my ($self, $row) = @_; my $date = $row->[0]; $date =~ s/[^\w\s,]//g; $date =~ s/$RE{ws}{crop}//g; my $info = $row->[1]; $info =~ s/$RE{ws}{crop}//g; my $debit = $row->[2]; $debit =~ s/[^\$\.\d]//g; my $credit = $row->[3]; $credit =~ s/[^\$\.\d]//g; my $balance = $row->[4]; $balance =~ s/[^\$\.\d]//g; unless ( defined $date && defined $info && defined $balance ) { return undef; } return { date => $date, info => $info, debit => $debit, credit => $credit, balance => $balance, }; } 1; __END__ =head1 NAME Finance::Bank::PC =head1 AUTHOR Ilia Lobsanov