Finance::Bank::Cahoot::DirectDebit - Cahoot direct debit record


Finance-Bank-Cahoot documentation Contained in the Finance-Bank-Cahoot distribution.

Index


Code Index:

NAME

Top

Finance::Bank::Cahoot::DirectDebit - Cahoot direct debit record

DESCRIPTION

Top

This module describes describes the object that holds the information contained in a single statement transaction.

SYNOPSIS

Top

  my $cahoot = Finance::Bank::Cahoot->new(credentials => 'ReadLine');
  my @accounts = $cahoot->accounts;
  $cahoot->set_account($accounts->[0]->{account});
  my $debits = $cahoot->debits;
  foreach my $debit (@$debits) {
    print $debit->payee, q{,},
          $debit->reference || 0, qq{\n};
  }

METHODS

Top

new

Create a new instance of a a Cahoot direct debit entry. It is unlikely that the new method should need to be called by anything other than Finance::Bank::Cahoot.

payee

Returns the name of the recipients of the direct debit.

reference

Returns the direct debit reference supplied to the payee.

WARNING

Top

This warning is from Simon Cozens' Finance::Bank::LloydsTSB, and seems just as apt here.

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.

NOTES

Top

This has only been tested on my own accounts. I imagine it should work on any account types, but I can't guarantee this.

AUTHOR

Top

Jon Connell <jon@figsandfudge.com>

LICENSE AND COPYRIGHT

Top


Finance-Bank-Cahoot documentation Contained in the Finance-Bank-Cahoot distribution.

# Copyright (c) 2008 Jon Connell.
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.

package Finance::Bank::Cahoot::DirectDebit;
use base qw(Class::Accessor);
__PACKAGE__->mk_ro_accessors(qw(payee reference)); ## no critic

use strict;
use warnings 'all';
use vars qw($VERSION);

$VERSION = '1.07';

use Carp qw(croak);

sub new
{
  my ($class, $row) = @_;

  croak 'No row data passed to '.__PACKAGE__.' constructor'
    if not defined $row;
  croak 'row data is not an array ref'
    if ref $row ne 'ARRAY';

  my $self = { payee     => _trim($row->[0]),
               reference => _trim($row->[1]) };
  bless $self, $class;

  return $self;
}

sub _trim
{
  my ($str) = @_;
  return if not defined $str;
  $str =~ s/[\x80-\xff]//gs;
  $str =~ s/\r//gs;
  $str =~ s/\s+/ /gs;
  $str =~ s/^\s+//gs;
  $str =~ s/\s+$//gs;
  return $str;
}

1;
__END__