$self->controller->track_progress(phase => 'parsing csv', progress => 0);
my $profile = $self->profile;
- $self->csv(SL::Helper::Csv->new(file => $self->file->file_name,
+ $self->csv(SL::Helper::Csv->new(file => ('SCALAR' eq ref $self->file)? $self->file: $self->file->file_name,
encoding => $self->controller->profile->get('charset'),
profile => [{ profile => $profile, class => $self->class, mapping => $self->controller->mappings_for_profile }],
ignore_unknown_columns => 1,
vendors => { map { ( $_->vendornumber => $_ ) } @{ $self->all_vc->{vendors} } } );
my %by_name = ( customers => { map { ( $_->name => $_ ) } @{ $self->all_vc->{customers} } },
vendors => { map { ( $_->name => $_ ) } @{ $self->all_vc->{vendors} } } );
- my %by_gln = ( customers => { map { ( $_->gln => $_ ) } @{ $self->all_vc->{customers} } },
- vendors => { map { ( $_->gln => $_ ) } @{ $self->all_vc->{vendors} } } );
+ my %by_gln = ( customers => { map { ( $_->gln => $_ ) } grep $_->gln, @{ $self->all_vc->{customers} } },
+ vendors => { map { ( $_->gln => $_ ) } grep $_->gln, @{ $self->all_vc->{vendors} } } );
return { id => \%by_id,
number => \%by_number,
sub init_vc_counts_by {
my ($self) = @_;
- my $vc_counts_by;
+ my $vc_counts_by = {};
$vc_counts_by->{number}->{customers}->{$_->customernumber}++ for @{ $self->all_vc->{customers} };
$vc_counts_by->{number}->{vendors}-> {$_->vendornumber}++ for @{ $self->all_vc->{vendors} };
$vc_counts_by->{name}-> {customers}->{$_->name}++ for @{ $self->all_vc->{customers} };
$vc_counts_by->{name}-> {vendors}-> {$_->name}++ for @{ $self->all_vc->{vendors} };
- $vc_counts_by->{gln}-> {customers}->{$_->gln}++ for @{ $self->all_vc->{customers} };
- $vc_counts_by->{gln}-> {vendors}-> {$_->gln}++ for @{ $self->all_vc->{vendors} };
+ $vc_counts_by->{gln}-> {customers}->{$_->gln}++ for grep $_->gln, @{ $self->all_vc->{customers} };
+ $vc_counts_by->{gln}-> {vendors}-> {$_->gln}++ for grep $_->gln, @{ $self->all_vc->{vendors} };
return $vc_counts_by;
}
: $self->controller->{type} eq 'ar_transactions' ? 'invnumber_' . $object->invnumber
: '';
- my $what_done = $self->controller->{type} eq 'orders' ? 'sales_order'
- : '';
+ my $what_done = '';
+ if ($self->controller->{type} eq 'orders') {
+ $what_done = $object->customer_id ? 'sales_order' : 'purchase_order';
+ }
SL::DB::History->new(
trans_id => $object->id,