| 1 | package Finance::Bank::Wachovia::Account; | ||||||||||
| 2 | 3 | ▶ | use Finance::Bank::Wachovia::ErrorHandler; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 3 | my @attrs; | |||||||||
| 7 | 3 | our @ISA = qw/Finance::Bank::Wachovia::ErrorHandler/; | |||||||||
| 8 | |||||||||||
| 9 | 3 | ▶ | BEGIN{ | ||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||
| 10 | 3 | @attrs = qw( | |||||||||
| 11 | name | ||||||||||
| 12 | number | ||||||||||
| 13 | type | ||||||||||
| 14 | available_balance | ||||||||||
| 15 | posted_balance | ||||||||||
| 16 | transactions | ||||||||||
| 17 | data_obtainer | ||||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | 3 | my $x = @__SUPER__::ATTRIBUTES; | |||||||||
| 21 | 3 | for( @attrs ){ | |||||||||
| 22 | 0 | ▶ | eval "sub _$_ { $x }"; | ||||||||
|
Subroutine
_available_balance: called CC=1 SCAR=0.0
Subroutine
_data_obtainer: called CC=1 SCAR=0.0
Subroutine
_name: called CC=1 SCAR=0.0
Subroutine
_number: called CC=1 SCAR=0.0
Subroutine
_posted_balance: not called CC=1 SCAR=0.0
Subroutine
_transactions: called CC=1 SCAR=0.0
Subroutine
_type: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 21 | $x++; | |||||||||
| 24 | } | ||||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 4 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 28 | 4 | my($class, %attrs) = @_; | |||||||||
| 29 | 4 | my $self = []; | |||||||||
| 30 | 4 | bless $self, $class; | |||||||||
| 31 | 4 | foreach my $att ( keys %attrs ){ | |||||||||
| 32 | 8 | $self->$att( $attrs{$att} ); | |||||||||
| 33 | } | ||||||||||
| 34 | 4 | ▶ | return Finance::Bank::Wachovia::Account->Error("no account number set in Finance::Bank::Wachovia::Account->new") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | unless $self->number; | ||||||||||
| 36 | 4 | return $self; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 25 | ▶ | sub AUTOLOAD { | ||||||||
|
Subroutine
AUTOLOAD: called CC=3 SCAR=11.0
| |||||||||||
| 40 | 3 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | 25 | our $AUTOLOAD; | |||||||||
| 42 | 25 | my $self = shift; | |||||||||
| 43 | 25 | my $attr = lc $AUTOLOAD; | |||||||||
| 44 | 25 | $attr =~ s/.*:://; | |||||||||
| 45 | 25 | ▶ | return $self->Error( "$attr not a valid attribute" ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | unless grep /$attr/, @attrs; | ||||||||||
| 47 | # get if no args passed | ||||||||||
| 48 | 25 | ▶ | return $self->[ &{"_$attr"} ] unless @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | # set if args passed | ||||||||||
| 50 | 8 | $self->[ &{"_$attr"} ] = shift; | |||||||||
| 51 | 8 | return $self; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 147 | ▶ | sub add_transaction { | ||||||||
|
Subroutine
add_transaction: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 55 | 147 | my($self) = shift; | |||||||||
| 56 | 147 | foreach my $t ( @_ ){ | |||||||||
| 57 | 147 | ▶ | return $self->Error( "Must pass valid Transaction object" ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | unless $t->isa('Finance::Bank::Wachovia::Transaction'); | ||||||||||
| 59 | 147 | push @{ $self->[ _transactions ] }, $t; | |||||||||
| 60 | } | ||||||||||
| 61 | 147 | return $self; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 2 | ▶ | sub set_transactions { | ||||||||
|
Subroutine
set_transactions: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 65 | 2 | my($self, $transactions) = @_; | |||||||||
| 66 | 2 | ▶ | unless ( ref $transactions eq 'ARRAY' ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 1 | $self->[ _transactions ] = []; | |||||||||
| 68 | 1 | return $self; | |||||||||
| 69 | } | ||||||||||
| 70 | 1 | foreach my $t ( @$transactions ){ | |||||||||
| 71 | 3 | ▶ | return $self->Error( "Must pass valid Transaction objects" ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | unless $t->isa('Finance::Bank::Wachovia::Transaction'); | ||||||||||
| 73 | } | ||||||||||
| 74 | 1 | $self->[ _transactions ] = $transactions; | |||||||||
| 75 | 1 | return $self; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 1 | ▶ | sub balance { available_balance(@_) } | ||||||||
|
Subroutine
balance: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 79 | 1 | ▶ | sub transactions { get_transactions(@_) } | ||||||||
|
Subroutine
transactions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | # these values are loaded on-demand | ||||||||||
| 83 | 0 | ▶ | sub posted_balance { | ||||||||
|
Subroutine
posted_balance: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 84 | 0 | my $self = shift; | |||||||||
| 85 | 0 | ▶ | if(@_){ $self->[ _posted_balance ] = shift; return $self; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 86 | 0 | ▶ | return $self->[ _posted_balance ] if $self->[ _posted_balance ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | 0 | my $do = $self->data_obtainer(); | |||||||||
| 88 | 0 | my $posted_bal = $do->get_account_posted_balance( $self->number() ); | |||||||||
| 89 | 0 | $self->[ _posted_balance ] = $posted_bal; | |||||||||
| 90 | 0 | return $posted_bal; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 6 | ▶ | sub get_transactions { | ||||||||
|
Subroutine
get_transactions: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 94 | 6 | my $self = shift; | |||||||||
| 95 | 6 | ▶ | return $self->[ _transactions ] if $self->[ _transactions ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 96 | |||||||||||
| 97 | 2 | my $do = $self->data_obtainer(); | |||||||||
| 98 | 2 | my $transactions = $do->get_account_transactions( $self->number() ); | |||||||||
| 99 | 2 | foreach ( @$transactions ){ | |||||||||
| 100 | 146 | ▶ | my $t = Finance::Bank::Wachovia::Transaction->new( %$_ ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 101 | or return $self->Error( "Couldn't make transaction object" ); | ||||||||||
| 102 | 146 | $self->add_transaction( $t ); | |||||||||
| 103 | } | ||||||||||
| 104 | 2 | return $self->[ _transactions ]; | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | 2 | ▶ | sub name { | ||||||||
|
Subroutine
name: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||
| 108 | 2 | my $self = shift; | |||||||||
| 109 | 0 | ▶ | if(@_){ $self->[ _name ] = shift; return $self; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 110 | 2 | ▶ | return $self->[ _name ] if $self->[ _name ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 111 | 2 | $self->[ _name ] = $self->data_obtainer->get_account_name( $self->number ); | |||||||||
| 112 | 2 | return $self->[ _name ]; | |||||||||
| 113 | } | ||||||||||
| 114 | |||||||||||
| 115 | 3 | ▶ | sub type { | ||||||||
|
Subroutine
type: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 116 | 3 | my $self = shift; | |||||||||
| 117 | 3 | ▶ | if(@_){ $self->[ _type ] = shift; return $self; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 118 | 2 | ▶ | return $self->[ _type ] if $self->[ _type ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 119 | 1 | $self->[ _type ] = $self->data_obtainer->get_account_type( $self->number ); | |||||||||
| 120 | 1 | return $self->[ _type ]; | |||||||||
| 121 | } | ||||||||||
| 122 | |||||||||||
| 123 | 1 | ▶ | sub available_balance { | ||||||||
|
Subroutine
available_balance: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||
| 124 | 1 | my $self = shift; | |||||||||
| 125 | 0 | ▶ | if(@_){ $self->[ _available_balance ] = shift; return $self; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 126 | 1 | ▶ | return $self->[ _available_balance ] if $self->[ _available_balance ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 127 | 1 | $self->[ _available_balance ] = $self->data_obtainer->get_account_available_balance( $self->number ); | |||||||||
| 128 | 1 | return $self->[ _available_balance ]; | |||||||||
| 129 | } | ||||||||||
| 130 | |||||||||||
| 131 | 0 | ▶ | sub DESTROY {} | ||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||
| 132 | |||||||||||
| 133 | __END__ | ||||||||||