X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FCsvImport%2FBaseMulti.pm;h=ad84039943ae7e3a8dcd271d26679107b4bbfde4;hb=f5df17caa4a22bcb8abe4910b837ec86a84ba9f0;hp=7650938e0b3596213c31a1d9c6d1af1480c56b4b;hpb=2f6a11fb5314d652152e0514bf5e5bf2735dc8fe;p=kivitendo-erp.git diff --git a/SL/Controller/CsvImport/BaseMulti.pm b/SL/Controller/CsvImport/BaseMulti.pm index 7650938e0..ad8403994 100644 --- a/SL/Controller/CsvImport/BaseMulti.pm +++ b/SL/Controller/CsvImport/BaseMulti.pm @@ -70,7 +70,7 @@ sub run { $self->controller->raw_data_headers($raw_data_headers); $self->controller->info_headers($info_headers); - my @objects = $self->csv->get_objects; + my $objects = $self->csv->get_objects; $self->controller->track_progress(progress => 70); @@ -78,7 +78,7 @@ sub run { $self->controller->track_progress(progress => 80); - $self->controller->data([ pairwise { { object => $a, raw_data => $b, errors => [], information => [], info_data => {} } } @objects, @raw_data ]); + $self->controller->data([ pairwise { { object => $a, raw_data => $b, errors => [], information => [], info_data => {} } } @$objects, @raw_data ]); $self->controller->track_progress(progress => 90); @@ -187,6 +187,18 @@ sub init_profile { eval "require " . $class; my %unwanted = map { ( $_ => 1 ) } (qw(itime mtime), map { $_->name } @{ $class->meta->primary_key_columns }); + + # TODO: exceptions for AccTransaction and Invoice wh + if ( $class =~ m/^SL::DB::AccTransaction/ ) { + my %unwanted_acc_trans = map { ( $_ => 1 ) } (qw(acc_trans_id trans_id cleared fx_transaction ob_transaction cb_transaction itime mtime chart_link tax_id description gldate memo source transdate), map { $_->name } @{ $class->meta->primary_key_columns }); + @unwanted{keys %unwanted_acc_trans} = values %unwanted_acc_trans; + }; + if ( $class =~ m/^SL::DB::Invoice/ ) { + # remove fields that aren't needed / shouldn't be set for ar transaction + my %unwanted_ar = map { ( $_ => 1 ) } (qw(closed currency currency_id datepaid dunning_config_id gldate invnumber_for_credit_note invoice marge_percent marge_total amount netamount paid shippingpoint shipto_id shipvia storno storno_id type cp_id), map { $_->name } @{ $class->meta->primary_key_columns }); + @unwanted{keys %unwanted_ar} = values %unwanted_ar; + }; + my %prof; $prof{datatype} = ''; for my $col ($class->meta->columns) { @@ -268,7 +280,7 @@ sub fix_field_lengths { my %field_lengths_by_ri = $self->field_lengths; foreach my $entry (@{ $self->controller->data }) { - next unless @{ $entry->{errors} }; + next unless defined $entry->{errors} && @{ $entry->{errors} }; my %field_lengths = %{ $field_lengths_by_ri{ $entry->{raw_data}->{datatype} } }; map { $entry->{object}->$_(substr($entry->{object}->$_, 0, $field_lengths{$_})) if $entry->{object}->$_ } keys %field_lengths; }