]> wagnertech.de Git - mfinanz.git/commitdiff
CSV Import Defaults in die Worker ausgelagert
authorG. Richardson <information@kivitendo-premium.de>
Wed, 6 May 2015 15:53:48 +0000 (17:53 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Thu, 7 May 2015 07:37:47 +0000 (09:37 +0200)
Neben den Standard-Defaults, die für alle gelten (charset, numberformat,
...)

SL/Controller/CsvImport.pm
SL/Controller/CsvImport/BankTransaction.pm
SL/Controller/CsvImport/Contact.pm
SL/Controller/CsvImport/CustomerVendor.pm
SL/Controller/CsvImport/Inventory.pm
SL/Controller/CsvImport/Order.pm
SL/Controller/CsvImport/Part.pm
SL/Controller/CsvImport/Project.pm
SL/Controller/CsvImport/Shipto.pm
SL/DB/CsvImportProfile.pm

index 2bc295598788ac5b91e5829e51d6dce4da780b63..e58d025e91157dd3418fdf867abaeb12954997f2 100644 (file)
@@ -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;
 }
 
index 76e9020afb59a5e3722690a98988e6c4695c2679..4bd9b96f9b663adea178ee59b7d7a4ed95aa0186 100644 (file)
@@ -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');
index e653d7cb0eca915bcce61ec1fa28e4277850dde4..adaa85ce6f8161e14a5b1d81948e246a68b4a494 100644 (file)
@@ -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');
index 0a5c121b6bd6e4759554ac2c8985f62076304b3e..b70c0a7b38134095f8feb54894fc8b4f0474063d 100644 (file)
@@ -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');
index c0dcfb5193e2069eeb50329fb5d2f1b3c760fbaf..c1406d05963c1ab4331ff7e6adb9734449756315 100644 (file)
@@ -28,6 +28,9 @@ sub init_class {
   $self->class('SL::DB::Inventory');
 }
 
+sub set_profile_defaults {
+};
+
 sub init_profile {
   my ($self) = @_;
 
index 246438c75f798fa9997a6ce61fb8733f508eaeb8..f8dbbb1cb141e52c6f54866602b24d18206c6a51 100644 (file)
@@ -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) = @_;
index 33301d140c4991dfb4969398f8c9fe337a87ecec..be989eee1bd3dbf651169c9afb64cb0e623dfdca 100644 (file)
@@ -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');
index d03de46bf975b39c6f18f81c3c1399f65e27d3dd..4b846dc27cef68418244ab1ef134de8643f48f1e 100644 (file)
@@ -18,6 +18,9 @@ sub init_class {
   $self->class('SL::DB::Project');
 }
 
+sub set_profile_defaults {
+};
+
 sub init_all_cvar_configs {
   my ($self) = @_;
 
index 1d2fdd7f6e707ebfdb8bb5c4121b4cf51d10c5ff..e32da468b52483c40aa687bafe397c7db62095c7 100644 (file)
@@ -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');
index 9980ad52865b64e6262c5549888c7d08c1fda4e0..8797a7a4925d3d09da74503d19f63c0b0be7658b 100644 (file)
@@ -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  => '"',