X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FCsvImport%2FPart.pm;h=be989eee1bd3dbf651169c9afb64cb0e623dfdca;hb=4b04c42212bb045a98535fcc16eef4ad81b2dbb6;hp=75adc9778e91d9aa5049734fc0f67a7d998464b8;hpb=0c537bffbf60f078202ca72977b3e35f2e0f0fd7;p=kivitendo-erp.git diff --git a/SL/Controller/CsvImport/Part.pm b/SL/Controller/CsvImport/Part.pm index 75adc9778..be989eee1 100644 --- a/SL/Controller/CsvImport/Part.pm +++ b/SL/Controller/CsvImport/Part.pm @@ -27,6 +27,24 @@ use Rose::Object::MakeMethods::Generic translation_columns all_pricegroups) ], ); +sub set_profile_defaults { + my ($self) = @_; + + my $bugru = SL::DB::Manager::Buchungsgruppe->find_by(description => { like => 'Standard%19%' }); + + $self->controller->profile->_set_defaults( + sellprice_places => 2, + sellprice_adjustment => 0, + sellprice_adjustment_type => 'percent', + article_number_policy => 'update_prices', + shoparticle_if_missing => '0', + parts_type => 'part', + default_buchungsgruppe => ($bugru ? $bugru->id : undef), + apply_buchungsgruppe => 'all', + ); +}; + + sub init_class { my ($self) = @_; $self->class('SL::DB::Part'); @@ -427,10 +445,11 @@ sub handle_makemodel { return; } - my %old_makemodels_by_make = map { $_->make => $_ } $entry->{part}->makemodels; + my %old_makemodels_by_mm = map { $_->make . $; . $_->model => $_ } $entry->{part}->makemodels; + my @new_makemodels; foreach my $makemodel ($object->makemodels()) { - my $makemodel_orig = $old_makemodels_by_make{$makemodel->make}; + my $makemodel_orig = $old_makemodels_by_mm{$makemodel->make,$makemodel->model}; $found_any = 1; if ($makemodel_orig) { @@ -438,16 +457,16 @@ sub handle_makemodel { $makemodel_orig->lastcost($makemodel->lastcost); } else { - $entry->{part}->add_makemodels($makemodel); + push @new_makemodels, $makemodel; } } + $entry->{part}->makemodels([ $entry->{part}->makemodels, @new_makemodels ]) if @new_makemodels; + # reindex makemodels my $i = 0; $_->sortorder(++$i) for @{ $entry->{part}->makemodels }; - $entry->{part}->makemodel($object->makemodel); - $self->save_with_cascade(1) if $found_any; }