X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/52518527bc507767386d21e1870cc2888269ba70..7bbdbf2bd966e6317cff568ac6f60936b51d8df7:/SL/Controller/CsvImport/Part.pm diff --git a/SL/Controller/CsvImport/Part.pm b/SL/Controller/CsvImport/Part.pm index 6c94ef53b..4a0074812 100644 --- a/SL/Controller/CsvImport/Part.pm +++ b/SL/Controller/CsvImport/Part.pm @@ -97,12 +97,12 @@ sub init_warehouses_by { sub init_parts_by { my ($self) = @_; -# my $parts_by = { id => { map { ( $_->id => $_ ) } grep { !$_->assembly } @{ $self->existing_objects } }, +# my $parts_by = { id => { map { ( $_->id => $_ ) } grep { !$_->part_type = 'assembly' } @{ $self->existing_objects } }, # partnumber => { part => { }, # service => { } } }; # # foreach my $part (@{ $self->existing_objects }) { -# next if $part->assembly; +# next if $part->part_type eq 'assembly'; # $parts_by->{partnumber}->{ $part->type }->{ $part->partnumber } = $part; # } @@ -118,7 +118,7 @@ sub init_parts_by { sub init_all_pricegroups { my ($self) = @_; - return SL::DB::Manager::Pricegroup->get_all(sort => 'id'); + return SL::DB::Manager::Pricegroup->get_all_sorted; } sub init_settings { @@ -150,7 +150,7 @@ sub check_objects { $self->makemodel_columns({}); - my $i; + my $i = 0; my $num_data = scalar @{ $self->controller->data }; foreach my $entry (@{ $self->controller->data }) { $self->controller->track_progress(progress => $i/$num_data * 100) if $i % 100 == 0; @@ -223,7 +223,7 @@ sub check_buchungsgruppe { $object->buchungsgruppen_id(undef) if $object->buchungsgruppen_id && !$self->bg_by->{id}->{ $object->buchungsgruppen_id }; # 3. Look up name if supplied. - if (!$object->buchungsgruppen_id) { + if (!$object->buchungsgruppen_id && $entry->{raw_data}->{buchungsgruppe}) { my $bg = $self->bg_by->{description}->{ $entry->{raw_data}->{buchungsgruppe} }; $object->buchungsgruppen_id($bg->id) if $bg; } @@ -261,13 +261,13 @@ sub check_existing { my $raw = $entry->{raw_data}; if ($object->partnumber && $self->parts_by->{partnumber}{$object->partnumber}) { - $entry->{part} = SL::DB::Manager::Part->get_all( query => [ partnumber => $object->partnumber ], limit => 1, - with_objects => [ 'translations', 'custom_variables' ] - ) -> [0]; + $entry->{part} = SL::DB::Manager::Part->get_first( query => [ partnumber => $object->partnumber ], limit => 1, + with_objects => [ 'translations', 'custom_variables' ], multi_many_ok => 1 + ); if ( !$entry->{part} ) { - $entry->{part} = SL::DB::Manager::Part->get_all( query => [ partnumber => $object->partnumber ], limit => 1, - with_objects => [ 'translations' ] - ) -> [0]; + $entry->{part} = SL::DB::Manager::Part->get_first( query => [ partnumber => $object->partnumber ], limit => 1, + with_objects => [ 'translations' ], multi_many_ok => 1 + ); } } @@ -276,7 +276,7 @@ sub check_existing { push(@{$entry->{errors}}, $::locale->text('Skipping due to existing entry in database with different type')); return; } - if ( $entry->{part}->unit != $object->unit || $entry->{part}->inventory_accno_id != $object->inventory_accno_id ) { + if ( $entry->{part}->unit ne $object->unit || $entry->{part}->inventory_accno_id != $object->inventory_accno_id ) { if ( $entry->{part}->onhand != 0 || $self->_part_is_used($entry->{part})) { push(@{$entry->{errors}}, $::locale->text('Skipping due to existing entry with different unit or inventory_accno_id')); return; @@ -675,7 +675,7 @@ sub init_profile { my ($self) = @_; my $profile = $self->SUPER::init_profile; - delete @{$profile}{qw(alternate assembly bom expense_accno_id income_accno_id inventory_accno_id makemodel priceupdate stockable type)}; + delete @{$profile}{qw(bom expense_accno_id income_accno_id inventory_accno_id makemodel priceupdate stockable type)}; $profile->{"pricegroup_$_"} = '' for 1 .. scalar @{ $_[0]->all_pricegroups };