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