NAME

Finance::Bank::PSK - check your P.S.K. accounts from Perl

SYNOPSIS

  # look for this script in the examples directory of the
  # tar ball.
  use Finance::Bank::PSK;
  
  use strict;
  use warnings;
  
  my $agent = Finance::Bank::PSK->new(
	  account       => 'xxx',
          user          => 'xxx',
          pass          => 'xxx',
          return_floats => 1,
	  newline       => '; ',
  );
  
  my $result  = $agent->check_balance;
  my @entries = $agent->get_entries;
  
  foreach my $account (@{$result->{accounts}}) {
          printf("%11s: %25s\n", $_->[0], $account->{$_->[1]})
                  for(( [ qw/ Kontonummer account / ],
                        [ qw/ Bezeichnung name / ],
                        [ qw/ Waehrung currency / ]
                  ));
          printf("%11s: %25.2f\n", $_->[0], $account->{$_->[1]})
                  for(( [ qw/ Saldo balance / ],
                        [ qw/ Dispo final / ]
                  ));
          print "\n";
  }
  
  foreach my $fund (@{$result->{funds}}) {
          printf("%11s: %25s\n", $_->[0], $fund->{$_->[1]})
                  for(( [ qw/ Depotnummer fund / ],
                        [ qw/ Bezeichnung name / ],
                        [ qw/ Waehrung currency / ]
                  ));
          printf("%11s: %25.2f\n", 'Saldo', $fund->{balance});
          print "\n";
  }

  if(scalar @entries) {
          printf("Buchungszeilen:\n\n");
          foreach my $row (@entries) {
                  $row->{text} =~ s/(.{50}).*/$1.../;

                  printf("%7s %5s %53s %9.2f\n",
                          @{$row}{qw/nr value text ammount/}
                  );
          }
  }

DESCRIPTION

This module provides a basic interface to the online banking system of the P.S.K. at https://wwwtb.psk.at.

Please note, that you will need either Crypt::SSLeay or IO::Socket::SSL installed for working HTTPS support of LWP.

METHODS

check_balance

Queries the via user and pass defined accounts and mutual funds and returns a reference to a list of hashes containing all fetched information:

$VAR1 = {
          'accounts' => [
                          {
                            'name'     => name of the account
                            'account'  => account number
                            'currency' => currency
                            'balance'  => account balance
                            'final'    => final account balance
                          }
                        ],
          'funds' => [
                        {
                          'name'     => name of the mutual fund
                          'fund'     => mutual fund number
                          'currency' => currency
                          'balance'  => mutual fund balance
                        }
                      ],
        };
get_entries

Queries and parses the Umsatzarchiv page for the defined account.

Returns an array of hashes containing all fetched information:

$VAR = [
         {
           'nr'     => nr of the bank statement
           'text'   => posting text
           'value'  => value date (format: DD.MM)
           'amount' => transfer amount
         },
];

ATTRIBUTES

All attributes are implemented by Class::MethodMaker, so please take a look at its man page for further information about the created accessor methods.

account

Account to connect with (Teilnehmernummer).

user

User to connect with (Verfueger).

pass

Password to connect with (PIN).

return_floats

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).

newline

Scalar which should be used instead of the HTML breaklines (default '; ').

EXAMPLES

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).

balance.pl

The very same script as seen in the SYNOPSIS. Shows the basic usage, defines all authentication settings directly in the script.

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).

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.

To use this example script you need to set up GPG and install GnuPG::Interface, IO::File, IO::Handle and YAML on your machine.

The encrypted file should have the following structure (in case of YAML):

account:       XXX
user:          XXX
pass:          XXX
return_floats: 1
newline:       '; '

The layout may differ, depending on the module you are using for serialization.

WARNING

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.

THANKS

Simon Cozens <simon@cpan.org> for Finance::Bank::LloydsTSB from which I've borrowed the warning message.

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.

AUTHOR

Florian Helmberger <fh@laudatio.com>

VERSION

$Id: PSK.pod,v 1.5 2004/05/02 11:59:58 florian Exp $

COPYRIGHT AND LICENCE

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, 2004 Florian Helmberger

SEE ALSO

WWW::Mechanize, HTML::TokeParser, Class::MethodMaker.