From: G. Richardson Date: Wed, 6 May 2015 15:53:48 +0000 (+0200) Subject: CSV Import Defaults in die Worker ausgelagert X-Git-Tag: release-3.3.0beta~100^2~2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=cd8b56f2ec945264132d443ad8f412699d1a8a1b;p=kivitendo-erp.git CSV Import Defaults in die Worker ausgelagert Neben den Standard-Defaults, die für alle gelten (charset, numberformat, ...) --- diff --git a/SL/Controller/CsvImport.pm b/SL/Controller/CsvImport.pm index 2bc295598..e58d025e9 100644 --- a/SL/Controller/CsvImport.pm +++ b/SL/Controller/CsvImport.pm @@ -385,6 +385,7 @@ sub load_default_profile { $profile ||= SL::DB::CsvImportProfile->new(type => $self->{type}, login => $::myconfig{login}); $self->profile($profile); + $self->worker->set_profile_defaults; $self->profile->set_defaults; } diff --git a/SL/Controller/CsvImport/BankTransaction.pm b/SL/Controller/CsvImport/BankTransaction.pm index 76e9020af..4bd9b96f9 100644 --- a/SL/Controller/CsvImport/BankTransaction.pm +++ b/SL/Controller/CsvImport/BankTransaction.pm @@ -15,6 +15,15 @@ use Rose::Object::MakeMethods::Generic 'scalar --get_set_init' => [ qw(bank_accounts_by) ], ); +sub set_profile_defaults { + my ($self) = @_; + + $self->controller->profile->_set_defaults( + charset => 'UTF8', # override charset from defaults + update_policy => 'skip', + ); +}; + sub init_class { my ($self) = @_; $self->class('SL::DB::BankTransaction'); diff --git a/SL/Controller/CsvImport/Contact.pm b/SL/Controller/CsvImport/Contact.pm index e653d7cb0..adaa85ce6 100644 --- a/SL/Controller/CsvImport/Contact.pm +++ b/SL/Controller/CsvImport/Contact.pm @@ -13,6 +13,9 @@ use Rose::Object::MakeMethods::Generic scalar => [ qw(table) ], ); +sub set_profile_defaults { +}; + sub init_class { my ($self) = @_; $self->class('SL::DB::Contact'); diff --git a/SL/Controller/CsvImport/CustomerVendor.pm b/SL/Controller/CsvImport/CustomerVendor.pm index 0a5c121b6..b70c0a7b3 100644 --- a/SL/Controller/CsvImport/CustomerVendor.pm +++ b/SL/Controller/CsvImport/CustomerVendor.pm @@ -17,6 +17,11 @@ use Rose::Object::MakeMethods::Generic 'scalar --get_set_init' => [ qw(table languages_by businesses_by) ], ); +sub set_profile_defaults { + my ($self) = @_; + $self->controller->profile->_set_defaults(table => 'customer'); +}; + sub init_table { my ($self) = @_; $self->table($self->controller->profile->get('table') eq 'customer' ? 'customer' : 'vendor'); diff --git a/SL/Controller/CsvImport/Inventory.pm b/SL/Controller/CsvImport/Inventory.pm index c0dcfb519..c1406d059 100644 --- a/SL/Controller/CsvImport/Inventory.pm +++ b/SL/Controller/CsvImport/Inventory.pm @@ -28,6 +28,9 @@ sub init_class { $self->class('SL::DB::Inventory'); } +sub set_profile_defaults { +}; + sub init_profile { my ($self) = @_; diff --git a/SL/Controller/CsvImport/Order.pm b/SL/Controller/CsvImport/Order.pm index 246438c75..f8dbbb1cb 100644 --- a/SL/Controller/CsvImport/Order.pm +++ b/SL/Controller/CsvImport/Order.pm @@ -34,6 +34,16 @@ sub init_class { $self->class(['SL::DB::Order', 'SL::DB::OrderItem']); } +sub set_profile_defaults { + my ($self) = @_; + + $self->controller->profile->_set_defaults( + order_column => $::locale->text('Order'), + item_column => $::locale->text('OrderItem'), + max_amount_diff => 0.02, + ); +}; + sub init_settings { my ($self) = @_; diff --git a/SL/Controller/CsvImport/Part.pm b/SL/Controller/CsvImport/Part.pm index 33301d140..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'); diff --git a/SL/Controller/CsvImport/Project.pm b/SL/Controller/CsvImport/Project.pm index d03de46bf..4b846dc27 100644 --- a/SL/Controller/CsvImport/Project.pm +++ b/SL/Controller/CsvImport/Project.pm @@ -18,6 +18,9 @@ sub init_class { $self->class('SL::DB::Project'); } +sub set_profile_defaults { +}; + sub init_all_cvar_configs { my ($self) = @_; diff --git a/SL/Controller/CsvImport/Shipto.pm b/SL/Controller/CsvImport/Shipto.pm index 1d2fdd7f6..e32da468b 100644 --- a/SL/Controller/CsvImport/Shipto.pm +++ b/SL/Controller/CsvImport/Shipto.pm @@ -11,6 +11,9 @@ use Rose::Object::MakeMethods::Generic scalar => [ qw(table) ], ); +sub set_profile_defaults { +}; + sub init_class { my ($self) = @_; $self->class('SL::DB::Shipto'); diff --git a/SL/DB/CsvImportProfile.pm b/SL/DB/CsvImportProfile.pm index 9980ad528..8797a7a49 100644 --- a/SL/DB/CsvImportProfile.pm +++ b/SL/DB/CsvImportProfile.pm @@ -34,43 +34,6 @@ sub new_with_default { sub set_defaults { my ($self) = @_; - - if ($self->type eq 'parts') { - my $bugru = SL::DB::Manager::Buchungsgruppe->find_by(description => { like => 'Standard%19%' }); - - $self->_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', - ); - } elsif ($self->type eq 'orders') { - $self->_set_defaults(order_column => $::locale->text('Order'), - item_column => $::locale->text('OrderItem'), - max_amount_diff => 0.02, - ); - } elsif ($self->type eq 'mt940') { - $self->_set_defaults(charset => 'UTF8', - sep_char => ';', - numberformat => '1000.00', - update_policy => 'skip', - ); - } elsif ($self->type eq 'bank_transactions') { - $self->_set_defaults(charset => 'UTF8', - update_policy => 'skip', - ); - } else { - $self->_set_defaults(table => 'customer'); - } - - # TODO: move the defaults into their own controller - # defaults can only be set once, so use these values as default if they - # haven't already been set above for one of the special import types - # If the values have been set above they won't be overwritten here: - $self->_set_defaults(sep_char => ',', quote_char => '"', escape_char => '"',