X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FCsvImport%2FBase.pm;h=9e8956f22fb3fee5147492d2152dc74001a5bf9f;hb=72b10cee5d0beac5c6169f5d18c074fbdc791395;hp=1e92cb14d00a586984d5a9fe2e579625da6286d2;hpb=8ebd75685952192deb585e5f5e1cb3c0d65df76e;p=kivitendo-erp.git diff --git a/SL/Controller/CsvImport/Base.pm b/SL/Controller/CsvImport/Base.pm index 1e92cb14d..9e8956f22 100644 --- a/SL/Controller/CsvImport/Base.pm +++ b/SL/Controller/CsvImport/Base.pm @@ -34,7 +34,7 @@ sub run { $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, @@ -188,8 +188,8 @@ sub init_vc_by { 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, @@ -200,14 +200,14 @@ sub init_vc_by { 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; } @@ -603,8 +603,10 @@ sub _save_history { : $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,