NAME

Finance::Bank::Postbank_de::Account - Postbank bank account class

SYNOPSIS

  use strict;
  require Crypt::SSLeay; # It's a prerequisite
  use Finance::Bank::Postbank_de::Account;
  my $statement = Finance::Bank::Postbank_de::Account->parse_statement(
                number => '9999999999',
                password => '11111',
              );
  # Retrieve account data :
  print "Balance : ",$statement->balance->[1]," EUR\n";

  # Output CSV for the transactions
  for my $row ($statement->transactions) {
    print join( ";", map { $row->{$_} } (qw( tradedate valuedate type comment receiver sender amount ))),"\n";
  };

DESCRIPTION

This module provides a rudimentary interface to the Postbank online banking system at https://banking.postbank.de/. You will need either Crypt::SSLeay or IO::Socket::SSL installed for HTTPS support to work with LWP.

The interface was cooked up by me without taking a look at the other Finance::Bank modules. If you have any proposals for a change, they are welcome !

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.

WARNUNG

Dieser Code beschaeftigt sich mit Online Banking, das heisst, hier geht es um Dein Geld und das bedeutet SEI VORSICHTIG ! Ich gehe davon aus, dass Du den Quellcode persoenlich anschaust, um Dich zu vergewissern, dass ich nichts unrechtes mit Deinen Bankdaten anfange. Diese Software finde ich persoenlich nuetzlich, aber ich stelle sie OHNE JEDE GARANTIE zur Verfuegung, weder eine ausdrueckliche noch eine implizierte Garantie.

METHODS

new

Creates a new object. It takes three named parameters :

number => '9999999999'

This is the number of the account. If you don't know it (for example, you are reading in an account statement from disk), leave it undef.

$account->parse_statement %ARGS

Parses an account statement and returns it as a hash reference. The account statement can be passed in via two named parameters. If no parameter is given, the current statement is fetched via the website through a call to get_account_statement (is this so?).

Parameters :

file => $filename

Parses the file $filename instead of downloading data from the web.

content => $string

Parses the content of $string instead of downloading data from the web.

$account->iban

Returns the IBAN for the account as a string. Later, a move to Business::IBAN is planned. The IBAN is a unique identifier for every account, that identifies the country, bank and account with that bank.

$account->transactions %ARGS

Delivers you all transactions within a statement. The transactions may be filtered by date by specifying the parameters 'since', 'upto' or 'on'. The values are, as always, 8-digit strings denoting YYYYMMDD dates.

Parameters :

since => $date

Removes all transactions that happened on or before $date. $date must be in the format YYYYMMDD. If the line is missing, since => '00000000' is assumed.

upto => $date

Removes all transactions that happened after $date. $date must be in the format YYYYMMDD. If the line is missing, upto => '99999999' is assumed.

on => $date

Removes all transactions that happened on a date that is not eq to $date. $date must be in the format YYYYMMDD. $date may also be the special string 'today', which will be converted to a YYYYMMDD string corresponding to todays date.

$account->value_dates

value_dates is a convenience method that returns all value dates on the account statement.

$account->trade_dates

trade_dates is a convenience method that returns all trade dates on the account statement.

Converting a daily download to a sequence

  #!/usr/bin/perl -w
  use strict;

  use Finance::Bank::Postbank_de::Account;
  use Tie::File;
  use List::Sliding::Changes qw(find_new_elements);
  use FindBin;
  use MIME::Lite;

  my $filename = "$FindBin::Bin/statement.txt";
  tie my @statement, 'Tie::File', $filename
    or die "Couldn't tie to '$filename' : $!";

  my @transactions;

  # See what has happened since we last polled
  my $retrieved_statement = Finance::Bank::Postbank_de::Account->parse_statement(
                         number => '9999999999',
                         password => '11111',
                );

  # Output CSV for the transactions
  for my $row (reverse @{$retrieved_statement->transactions()}) {
    push @transactions, join( ";", map { $row->{$_} } (qw( tradedate valuedate type comment receiver sender amount )));
  };

  # Find out what we did not already communicate
  my (@new) = find_new_elements(\@statement,\@transactions);
  if (@new) {
    my ($body) = "<html><body><table>";
    my ($date,$balance) = @{$retrieved_statement->balance};
    $body .= "<b>Balance ($date) :</b> $balance<br>";
    $body .= "<tr><th>";
    $body .= join( "</th><th>", qw( tradedate valuedate type comment receiver sender amount )). "</th></tr>";
    for my $line (@{[@new]}) {
      $line =~ s!;!</td><td>!g;
      $body .= "<tr><td>$line</td></tr>\n";
    };
    $body .= "</body></html>";
    MIME::Lite->new(
                    From     =>'update.pl',
                    To       =>'you',
                    Subject  =>"Account update $date",
                    Type     =>'text/html',
                    Encoding =>'base64',
                    Data     => $body,
                    )->send;
  };

  # And update our log with what we have seen
  push @statement, @new;

AUTHOR

Max Maischein, <corion@cpan.org>

SEE ALSO

perl, Finance::Bank::Postbank_de.