Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cd8b56f2

Von Kivitendo Admin vor mehr als 9 Jahren hinzugefügt

  • ID cd8b56f2ec945264132d443ad8f412699d1a8a1b
  • Vorgänger 37be5dfe
  • Nachfolger d180d84e

CSV Import Defaults in die Worker ausgelagert

Neben den Standard-Defaults, die für alle gelten (charset, numberformat,
...)

Unterschiede anzeigen:

SL/Controller/CsvImport.pm
385 385
  $profile ||= SL::DB::CsvImportProfile->new(type => $self->{type}, login => $::myconfig{login});
386 386

  
387 387
  $self->profile($profile);
388
  $self->worker->set_profile_defaults;
388 389
  $self->profile->set_defaults;
389 390
}
390 391

  
SL/Controller/CsvImport/BankTransaction.pm
15 15
 'scalar --get_set_init' => [ qw(bank_accounts_by) ],
16 16
);
17 17

  
18
sub set_profile_defaults {
19
  my ($self) = @_;
20

  
21
  $self->controller->profile->_set_defaults(
22
                       charset       => 'UTF8',  # override charset from defaults
23
                       update_policy => 'skip',
24
                      );
25
};
26

  
18 27
sub init_class {
19 28
  my ($self) = @_;
20 29
  $self->class('SL::DB::BankTransaction');
SL/Controller/CsvImport/Contact.pm
13 13
 scalar => [ qw(table) ],
14 14
);
15 15

  
16
sub set_profile_defaults {
17
};
18

  
16 19
sub init_class {
17 20
  my ($self) = @_;
18 21
  $self->class('SL::DB::Contact');
SL/Controller/CsvImport/CustomerVendor.pm
17 17
 'scalar --get_set_init' => [ qw(table languages_by businesses_by) ],
18 18
);
19 19

  
20
sub set_profile_defaults {
21
  my ($self) = @_;
22
  $self->controller->profile->_set_defaults(table => 'customer');
23
};
24

  
20 25
sub init_table {
21 26
  my ($self) = @_;
22 27
  $self->table($self->controller->profile->get('table') eq 'customer' ? 'customer' : 'vendor');
SL/Controller/CsvImport/Inventory.pm
28 28
  $self->class('SL::DB::Inventory');
29 29
}
30 30

  
31
sub set_profile_defaults {
32
};
33

  
31 34
sub init_profile {
32 35
  my ($self) = @_;
33 36

  
SL/Controller/CsvImport/Order.pm
34 34
  $self->class(['SL::DB::Order', 'SL::DB::OrderItem']);
35 35
}
36 36

  
37
sub set_profile_defaults {
38
  my ($self) = @_;
39

  
40
  $self->controller->profile->_set_defaults(
41
                       order_column    => $::locale->text('Order'),
42
                       item_column     => $::locale->text('OrderItem'),
43
                       max_amount_diff => 0.02,
44
                      );
45
};
46

  
37 47

  
38 48
sub init_settings {
39 49
  my ($self) = @_;
SL/Controller/CsvImport/Part.pm
27 27
                                 translation_columns all_pricegroups) ],
28 28
);
29 29

  
30
sub set_profile_defaults {
31
  my ($self) = @_;
32

  
33
  my $bugru = SL::DB::Manager::Buchungsgruppe->find_by(description => { like => 'Standard%19%' });
34

  
35
  $self->controller->profile->_set_defaults(
36
                       sellprice_places          => 2,
37
                       sellprice_adjustment      => 0,
38
                       sellprice_adjustment_type => 'percent',
39
                       article_number_policy     => 'update_prices',
40
                       shoparticle_if_missing    => '0',
41
                       parts_type                => 'part',
42
                       default_buchungsgruppe    => ($bugru ? $bugru->id : undef),
43
                       apply_buchungsgruppe      => 'all',
44
                      );
45
};
46

  
47

  
30 48
sub init_class {
31 49
  my ($self) = @_;
32 50
  $self->class('SL::DB::Part');
SL/Controller/CsvImport/Project.pm
18 18
  $self->class('SL::DB::Project');
19 19
}
20 20

  
21
sub set_profile_defaults {
22
};
23

  
21 24
sub init_all_cvar_configs {
22 25
  my ($self) = @_;
23 26

  
SL/Controller/CsvImport/Shipto.pm
11 11
 scalar => [ qw(table) ],
12 12
);
13 13

  
14
sub set_profile_defaults {
15
};
16

  
14 17
sub init_class {
15 18
  my ($self) = @_;
16 19
  $self->class('SL::DB::Shipto');
SL/DB/CsvImportProfile.pm
34 34
sub set_defaults {
35 35
  my ($self) = @_;
36 36

  
37

  
38
  if ($self->type eq 'parts') {
39
    my $bugru = SL::DB::Manager::Buchungsgruppe->find_by(description => { like => 'Standard%19%' });
40

  
41
    $self->_set_defaults(sellprice_places          => 2,
42
                         sellprice_adjustment      => 0,
43
                         sellprice_adjustment_type => 'percent',
44
                         article_number_policy     => 'update_prices',
45
                         shoparticle_if_missing    => '0',
46
                         parts_type                => 'part',
47
                         default_buchungsgruppe    => ($bugru ? $bugru->id : undef),
48
                         apply_buchungsgruppe      => 'all',
49
                        );
50
  } elsif ($self->type eq 'orders') {
51
    $self->_set_defaults(order_column    => $::locale->text('Order'),
52
                         item_column     => $::locale->text('OrderItem'),
53
                         max_amount_diff => 0.02,
54
                        );
55
  } elsif ($self->type eq 'mt940') {
56
    $self->_set_defaults(charset       => 'UTF8',
57
                         sep_char      => ';',
58
                         numberformat  => '1000.00',
59
                         update_policy => 'skip',
60
                        );
61
  } elsif ($self->type eq 'bank_transactions') {
62
    $self->_set_defaults(charset       => 'UTF8',
63
                         update_policy => 'skip',
64
                        );
65
  } else {
66
    $self->_set_defaults(table => 'customer');
67
  }
68

  
69
  # TODO: move the defaults into their own controller
70
  # defaults can only be set once, so use these values as default if they
71
  # haven't already been set above for one of the special import types
72
  # If the values have been set above they won't be overwritten here:
73

  
74 37
  $self->_set_defaults(sep_char     => ',',
75 38
                       quote_char   => '"',
76 39
                       escape_char  => '"',

Auch abrufbar als: Unified diff