X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/b9e6845d084e1510d1282cc8188e08804ffcfb5b..7caf72fffe2dfe58d11da0acd0e2892e6737330a:/SL/Controller/CsvImport.pm diff --git a/SL/Controller/CsvImport.pm b/SL/Controller/CsvImport.pm index e95b171e5..c2f2a6ce0 100644 --- a/SL/Controller/CsvImport.pm +++ b/SL/Controller/CsvImport.pm @@ -8,6 +8,7 @@ use SL::Helper::Flash; use SL::SessionFile; use SL::Controller::CsvImport::Contact; use SL::Controller::CsvImport::CustomerVendor; +use SL::Controller::CsvImport::Part; use SL::Controller::CsvImport::Shipto; use List::MoreUtils qw(none); @@ -17,7 +18,7 @@ use parent qw(SL::Controller::Base); use Rose::Object::MakeMethods::Generic ( scalar => [ qw(type profile file all_profiles all_charsets sep_char all_sep_chars quote_char all_quote_chars escape_char all_escape_chars all_buchungsgruppen - import_status errors headers data num_imported num_importable) ], + import_status errors headers raw_data_headers data num_imported num_importable worker displayable_columns) ], ); __PACKAGE__->run_before('check_auth'); @@ -123,6 +124,8 @@ sub render_inputs { $self->all_buchungsgruppen(SL::DB::Manager::Buchungsgruppe->get_all_sorted); + $self->setup_help; + $self->render('csv_import/form', title => $title); } @@ -143,11 +146,7 @@ sub test_and_import { return $self->action_new; } - my $worker = $self->{type} eq 'customers_vendors' ? SL::Controller::CsvImport::CustomerVendor->new(controller => $self, file => $file) - : $self->{type} eq 'contacts' ? SL::Controller::CsvImport::Contact->new( controller => $self, file => $file) - : $self->{type} eq 'addresses' ? SL::Controller::CsvImport::Shipto->new( controller => $self, file => $file) - : die "Program logic error"; - + my $worker = $self->create_worker($file); $worker->run; $worker->save_objects if !$params{test}; @@ -194,6 +193,10 @@ sub profile_from_form { push @settings, { key => "${type}_char", value => $char }; } + if ($self->type eq 'parts') { + $::form->{settings}->{sellprice_adjustment} = $::form->parse_amount(\%::myconfig, $::form->{settings}->{sellprice_adjustment}); + } + delete $::form->{profile}->{id}; $self->profile($existing_profile || SL::DB::CsvImportProfile->new); $self->profile->assign_attributes(%{ $::form->{profile} }); @@ -222,4 +225,21 @@ sub csv_file_name { return "csv-import-" . $self->type . ".csv"; } +sub create_worker { + my ($self, $file) = @_; + + return $self->{type} eq 'customers_vendors' ? SL::Controller::CsvImport::CustomerVendor->new(controller => $self, file => $file) + : $self->{type} eq 'contacts' ? SL::Controller::CsvImport::Contact->new( controller => $self, file => $file) + : $self->{type} eq 'addresses' ? SL::Controller::CsvImport::Shipto->new( controller => $self, file => $file) + : $self->{type} eq 'parts' ? SL::Controller::CsvImport::Part->new( controller => $self, file => $file) + : die "Program logic error"; +} + +sub setup_help { + my ($self) = @_; + + $self->create_worker->setup_displayable_columns; +} + + 1;