Finance::Wesabe::Transaction - Class to represent a transaction


Finance-Wesabe documentation Contained in the Finance-Wesabe distribution.

Index


Code Index:

NAME

Top

Finance::Wesabe::Transaction - Class to represent a transaction

SYNOPSIS

Top

    my $txn = Finance::Wesabe::Transaction->new(
        content => $c, parent => $p
    );

DESCRIPTION

Top

This class represents a single transaction for a given account.

ACCESSORS

Top

* content - Hashref of data from the response
* parent - Parent object with acces to the user agent

TRANSACTION INFORMATION

Top

* raw_name
* guid
* memo
* note
* raw_txntype
* amount
* date - A DateTime object
* original_date - A DateTime object

METHODS

Top

pretty_amount( )

Returns the transaction amount in a nicely formatted string based on your preferenes.

tags( )

Returns a list of tag names associated with this transaction.

is_transfer( )

Returns a boolean indicating if this transaction is a transfer.

AUTHOR

Top

Brian Cassidy <bricas@cpan.org>

COPYRIGHT AND LICENSE

Top


Finance-Wesabe documentation Contained in the Finance-Wesabe distribution.
package Finance::Wesabe::Transaction;

use Moose;
use Finance::Wesabe::Utils;

has content => ( is => 'ro', isa => 'HashRef' );

has parent => ( is => 'ro', isa => 'Object' );

__PACKAGE__->mk_simple_field( qw( memo raw-name guid raw-txntype note ) );
__PACKAGE__->mk_deep_field( qw( amount ) );
__PACKAGE__->mk_simple_date_field( qw( date original-date ) );

sub pretty_amount {
    my $self = shift;
    return $self->parent->_format_number( $self->amount );
}

sub tags {
    my $self = shift;

    my $tags = $self->content->{ tags }->{ tag };
    return $tags->{ name } unless ref $tags eq 'ARRAY';
    return map { $_->{ name } } @$tags;
}

sub is_transfer {
    return exists shift->content->{ transfer };
}

no Moose;

__PACKAGE__->meta->make_immutable;

1;