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