| 1 | package Finance::StockAccount::Import; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | 3 | our $VERSION = '0.01'; | |||||||||||||||||||||
| 4 | |||||||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 3 | ▶ | use Carp; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 3 | ▶ | use Finance::StockAccount; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | 3 | ▶ | use Finance::StockAccount::AccountTransaction; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 12 | |||||||||||||||||||||||
| 13 | 8 | ▶ | sub new { | ||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||
| 14 | 8 | my ($class, $file, $tzoffset) = @_; | |||||||||||||||||||||
| 15 | 8 | ▶ | $file or confess "Please pass a file to import.\n"; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 16 | 8 | ▶ | my $self = { | ||||||||||||||||||||
|
Condition100%2/2
$tzoffset || 0
MC/DC100%1/1
$tzoffset || 0
$tzoffset
Truth table100%2/2
A
A= $tzoffset
| |||||||||||||||||||||||
| 17 | file => $file, | ||||||||||||||||||||||
| 18 | fh => undef, | ||||||||||||||||||||||
| 19 | headers => undef, | ||||||||||||||||||||||
| 20 | tzoffset => $tzoffset || 0, | ||||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||||
| 22 | 8 | return bless($self, $class); | |||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||
| 24 | |||||||||||||||||||||||
| 25 | 0 | ▶ | sub renameMe { | ||||||||||||||||||||
|
Subroutine
renameMe: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||
| 26 | 0 | my ($self, $key, $value) = @_; | |||||||||||||||||||||
| 27 | 0 | ▶ | if ($key eq 'date') { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 28 | 0 | ▶ | $self->extractDate($value) or return 0; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||
| 30 | elsif ($key eq 'price') { | ||||||||||||||||||||||
| 31 | 0 | ▶ | $self->extractPrice($value) or return 0; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||
| 33 | elsif ($key eq 'commission') { | ||||||||||||||||||||||
| 34 | 0 | ▶ | $self->extractCommission($value) or return 0; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||
| 36 | elsif ($key eq 'symbol') { | ||||||||||||||||||||||
| 37 | 0 | ▶ | $self->extractSymbol($value) or return 0; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||
| 40 | |||||||||||||||||||||||
| 41 | 0 | ▶ | sub extractPrice { | ||||||||||||||||||||
|
Subroutine
extractPrice: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||
| 42 | 0 | my ($self, $priceString) = @_; | |||||||||||||||||||||
| 43 | 0 | my $pricePattern = ''; | |||||||||||||||||||||
| 44 | 0 | ▶ | if ($priceString =~ /$pricePattern/) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 45 | 0 | my $price = $1; | |||||||||||||||||||||
| 46 | 0 | $price =~ s/,//g; | |||||||||||||||||||||
| 47 | 0 | $self->{price} = $price; | |||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||
| 49 | else { | ||||||||||||||||||||||
| 50 | 0 | warn "Failed to recognize price pattern in string $priceString.\n"; | |||||||||||||||||||||
| 51 | 0 | return 0; | |||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||
| 54 | |||||||||||||||||||||||
| 55 | 0 | ▶ | sub extractCommission { | ||||||||||||||||||||
|
Subroutine
extractCommission: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||
| 56 | 0 | my ($self, $commissionString) = @_; | |||||||||||||||||||||
| 57 | 0 | my $pricePattern = ''; | |||||||||||||||||||||
| 58 | 0 | ▶ | if ($commissionString =~ /$pricePattern/) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 59 | 0 | my $commission = $1; | |||||||||||||||||||||
| 60 | 0 | $commission =~ s/,//g; | |||||||||||||||||||||
| 61 | 0 | $self->{commission} = $commission; | |||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||
| 63 | else { | ||||||||||||||||||||||
| 64 | 0 | warn "Failed to recognize commission pattern in string $commissionString.\n"; | |||||||||||||||||||||
| 65 | 0 | return 0; | |||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||
| 68 | |||||||||||||||||||||||
| 69 | 0 | ▶ | sub extractSymbol { | ||||||||||||||||||||
|
Subroutine
extractSymbol: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||
| 70 | 0 | my ($self, $symbolString) = @_; | |||||||||||||||||||||
| 71 | 0 | my $symbolPattern = ''; | |||||||||||||||||||||
| 72 | 0 | ▶ | if ($symbolString =~ /$symbolPattern/) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 73 | 0 | $self->{symbol} = $1; | |||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||
| 75 | else { | ||||||||||||||||||||||
| 76 | 0 | warn "Failed to recognize symbol pattern in string $symbolString.\n"; | |||||||||||||||||||||
| 77 | 0 | return 0; | |||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||
| 80 | |||||||||||||||||||||||
| 81 | 0 | ▶ | sub nextAt { | ||||||||||||||||||||
|
Subroutine
nextAt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||
| 82 | # method that returns the next AccountTransaction object, | ||||||||||||||||||||||
| 83 | # to be overridden by child classes | ||||||||||||||||||||||
| 84 | 0 | return 0; | |||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||
| 86 | |||||||||||||||||||||||
| 87 | 7 | ▶ | sub stockAccount { | ||||||||||||||||||||
|
Subroutine
stockAccount: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||
| 88 | 7 | my $self = shift; | |||||||||||||||||||||
| 89 | 7 | my $sa = Finance::StockAccount->new(); | |||||||||||||||||||||
| 90 | 7 | ▶ | while (my $at = $self->nextAt()) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 91 | 238 | $sa->addToSet($at); | |||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||
| 93 | 7 | return $sa; | |||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||
| 95 | |||||||||||||||||||||||
| 96 | |||||||||||||||||||||||
| 97 | |||||||||||||||||||||||
| 98 | |||||||||||||||||||||||
| 99 | |||||||||||||||||||||||
| 100 | |||||||||||||||||||||||
| 101 | |||||||||||||||||||||||
| 102 | |||||||||||||||||||||||
| 103 | |||||||||||||||||||||||
| 104 | |||||||||||||||||||||||
| 105 | |||||||||||||||||||||||
| 106 | 3 | 1; | |||||||||||||||||||||