Finance::Bank::easybank - check your easybank accounts from Perl
# look for this script in the examples directory of the # tar ball (balance.pl). use Finance::Bank::easybank; use strict; use warnings; my $agent = Finance::Bank::easybank->new( user => 'xxx', pass => 'xxx', return_floats => 1, accounts => [ qw/ 200XXXXXXXX / ], entries => [ qw/ 200XXXXXXXX / ], ); my @accounts = $agent->check_balance; my $entries = $agent->get_entries; foreach my $account (@accounts) { printf("%11s: %25s\n", $_->[0], $account->{$_->[1]}) for(( [ qw/ Kontonummer account / ], [ qw/ BLZ bc / ], [ qw/ Bezeichnung name / ], [ qw/ Datum date / ], [ qw/ Waehrung currency / ] )); printf("%11s: %25.2f\n", $_->[0], $account->{$_->[1]}) for(( [ qw/ Saldo balance / ], [ qw/ Dispo final / ] )); print "\nBuchungzeilen:\n\n"; if(exists($entries->{$account->{account}})) { foreach my $row (@{$entries->{$account->{account}}}) { $row->{text} =~ s/(.{43}).*/$1.../; printf("%2d %6s %46s %6s %3s %9.2f\n", (map { $row->{$_} } qw/nr date text value currency/), $row->{amount} ); } } print "\n"; }
This module provides a basic interface to the online banking system of the easybank at http://www.easybank.at.
http://www.easybank.at
Please note, that you will need either Crypt::SSLeay or IO::Socket::SSL installed for working HTTPS support of LWP.
Crypt::SSLeay
IO::Socket::SSL
LWP
Queries all via attribute accounts defined accounts and extracts various informations about the account status.
accounts
If called in list context, returns an array of hashes containing all fetched information:
$VAR = [ { 'bc' => bank code 'account' => account number 'name' => name of the account 'date' => date shown on the summary page (format: DD.MM.YYYY/hh:mm) 'currency' => currency 'balance' => account balance 'final' => final account balance } ];
Otherwise, returns a hashref:
$VAR1 = { 'account' => { 'bc' => bank code 'account' => account number 'name' => name of the account 'date' => date shown on the summary page (format: DD.MM.YYYY/hh:mm) 'currency' => currency 'balance' => account balance 'final' => final account balance } };
Queries and parses the first page of the entry-history for all accounts defined via the entries attribute.
entries
Returns a hashref containing all fetched information:
$VAR1 = { 'account' => { 'date' => date of the transaction (format: DD.MM.) 'text' => posting text 'value' => value date (format: DD.MM.) 'currency' => currency 'amount' => transfer amount } };
All attributes are implemented by Class::MethodMaker, so please take a look at its man page for further information about the created accessor methods.
Class::MethodMaker
User to connect with (Verfuegernummer).
Password to connect with (Pin).
Optional list of accounts to query by check_balance. This list should contain only account numbers formated in exactly the same way as they are listed in the online banking system.
check_balance
Optional list of accounts to query by get_entries. This list should contain only account numbers formated in exactly the same way as they are listed in the online banking system.
get_entries
Boolean value defining wether the module returns the balance as signed float or just as it gets it from the online banking system (default: false).
In the examples directory of the distribution are two example scripts which show the usage of this module. Both scripts can be used out of the box and should represent a good starting point for a solution which fits your particular needs (I use a copy of balance-gpg.pl on a daily basis).
examples
balance-gpg.pl
The very same script as seen in the SYNOPSIS. Shows the basic usage, defines all authentication settings directly in the script.
SYNOPSIS
The main problem with this approach is of course the fact, that the sensible authentication data is stored in clear text in the script itself. Not a good thing at all if you're using it in an multiuser environment or on a mobile computer.
But do not fear - help in form of GPG is on the way (see balance-gpg.pl).
This script does the same thing as balance.pl but gets all the configuration settings from an GPG encrypted file which is decrypted on the fly at startup, GPG will interactive ask for your passphrase.
balance.pl
GPG
To use this example script you need to set up GPG and install GnuPG::Interface, IO::File, IO::Handle and YAML on your machine.
GnuPG::Interface
IO::File
IO::Handle
YAML
The encrypted file should have the following structure (in case of YAML):
user: XXX pass: XXX return_floats: 1 accounts: - 200XXXXXXX1 - 200XXXXXXX2 entries: - 200XXXXXXX1 - 200XXXXXXX2
The layout may differ, depending on the module you are using for serialization.
This is code for online banking, and that means your money, and that means BE CAREFUL. You are encouraged, nay, expected, to audit the source of this module yourself to reassure yourself that I am not doing anything untoward with your banking data. This software is useful to me, but is provided under NO GUARANTEE, explicit or implied.
I didn't had the chance of testing this module against an account mapped to only one bank account.
It would be very nice if someone with only one bank account could test this module and drop me note about the results.
Also take note that this module can break easily if easybank changes the layout of the online banking system.
Simon Cozens <simon@cpan.org> for Finance::Bank::LloydsTSB from which I've borrowed the warning message.
Finance::Bank::LloydsTSB
Chris Ball <chris@cpan.org> for his article about screen-scraping with WWW::Mechanize at http://www.perl.com/pub/a/2003/01/22/mechanize.html.
WWW::Mechanize
http://www.perl.com/pub/a/2003/01/22/mechanize.html
Florian Helmberger <fh@laudatio.com>
$Id: easybank.pod,v 1.2 2003/08/14 21:31:56 florian Exp $
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
Copyright (C) 2003 Florian Helmberger
WWW::Mechanize, HTML::TokeParser, Class::MethodMaker.
To install Finance::Bank::easybank, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Finance::Bank::easybank
CPAN shell
perl -MCPAN -e shell install Finance::Bank::easybank
For more information on module installation, please visit the detailed CPAN module installation guide.