Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2e8c9ffd

Von Bernd Bleßmann vor mehr als 1 Jahr hinzugefügt

  • ID 2e8c9ffdfafd92059007f0affe6a66c844d0148b
  • Vorgänger 0ec64c00
  • Nachfolger aaa70744

Csv-Import: Behandlung Preisgruppen ausgelagert

Unterschiede anzeigen:

SL/Controller/CsvImport/DeliveryOrder.pm
16 16
use SL::DB::PaymentTerm;
17 17
use SL::DB::Contact;
18 18
use SL::DB::PriceFactor;
19
use SL::DB::Pricegroup;
20 19
use SL::DB::Shipto;
21 20
use SL::DB::Unit;
22 21
use SL::DB::Inventory;
......
34 33
(
35 34
 'scalar --get_set_init' => [ qw(settings languages_by all_parts parts_by part_counts_by
36 35
                                 contacts_by ct_shiptos_by
37
                                 price_factors_by pricegroups_by units_by
36
                                 price_factors_by units_by
38 37
                                 warehouses_by bins_by transfer_types_by) ],
39 38
);
40 39

  
......
347 346
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_price_factors } } ) } qw(id description) };
348 347
}
349 348

  
350
sub init_pricegroups_by {
351
  my ($self) = @_;
352

  
353
  my $all_pricegroups = SL::DB::Manager::Pricegroup->get_all;
354
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_pricegroups } } ) } qw(id pricegroup) };
355
}
356

  
357 349
sub init_units_by {
358 350
  my ($self) = @_;
359 351

  
......
1047 1039
  return 1;
1048 1040
}
1049 1041

  
1050
sub check_pricegroup {
1051
  my ($self, $entry) = @_;
1052

  
1053
  my $object = $entry->{object};
1054

  
1055
  # Check whether or not pricegroup ID is valid.
1056
  if ($object->pricegroup_id && !$self->pricegroups_by->{id}->{ $object->pricegroup_id }) {
1057
    push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
1058
    return 0;
1059
  }
1060

  
1061
  # Map pricegroup to ID if given.
1062
  if (!$object->pricegroup_id && $entry->{raw_data}->{pricegroup}) {
1063
    my $pricegroup = $self->pricegroups_by->{pricegroup}->{ $entry->{raw_data}->{pricegroup} };
1064
    if (!$pricegroup) {
1065
      push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
1066
      return 0;
1067
    }
1068

  
1069
    $object->pricegroup_id($pricegroup->id);
1070
  }
1071

  
1072
  return 1;
1073
}
1074

  
1075 1042
sub check_warehouse {
1076 1043
  my ($self, $entry) = @_;
1077 1044

  
SL/Controller/CsvImport/Helper/Consistency.pm
6 6
use SL::DB::Default;
7 7
use SL::DB::Currency;
8 8
use SL::DB::TaxZone;
9
use SL::DB::Pricegroup;
9 10
use SL::DB::Project;
10 11
use SL::DB::Department;
11 12

  
12 13
use SL::Helper::Csv::Error;
13 14

  
14 15
use parent qw(Exporter);
15
our @EXPORT = qw(check_currency check_taxzone check_project check_department check_customer_vendor handle_salesman handle_employee);
16
our @EXPORT = qw(check_currency check_taxzone check_pricegroup check_project check_department check_customer_vendor handle_salesman handle_employee);
16 17

  
17 18
#
18 19
# public functions
......
113 114
  return 1;
114 115
}
115 116

  
117
sub check_pricegroup {
118
  my ($self, $entry) = @_;
119

  
120
  my $object = $entry->{object};
121

  
122
  # Check whether or not pricegroup ID is valid.
123
  if ($object->pricegroup_id && !_pricegroups_by($self)->{id}->{ $object->pricegroup_id }) {
124
    push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
125
    return 0;
126
  }
127

  
128
  # Map pricegroup to ID if given.
129
  if (!$object->pricegroup_id && $entry->{raw_data}->{pricegroup}) {
130
    my $pricegroup = _pricegroups_by($self)->{pricegroup}->{ $entry->{raw_data}->{pricegroup} };
131
    if (!$pricegroup) {
132
      push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
133
      return 0;
134
    }
135

  
136
    $object->pricegroup_id($pricegroup->id);
137
  }
138

  
139
  return 1;
140
}
141

  
116 142
sub check_project {
117 143
  my ($self, $entry, %params) = @_;
118 144

  
......
266 292
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_departments } } ) } qw(id description) };
267 293
}
268 294

  
295
sub _pricegroups_by {
296
  my ($self) = @_;
297

  
298
  my $all_pricegroups = SL::DB::Manager::Pricegroup->get_all;
299
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_pricegroups } } ) } qw(id pricegroup) };
300
}
301

  
269 302
sub _projects_by {
270 303
  my ($self) = @_;
271 304

  
SL/Controller/CsvImport/Order.pm
14 14
use SL::DB::Contact;
15 15
use SL::DB::Department;
16 16
use SL::DB::PriceFactor;
17
use SL::DB::Pricegroup;
18 17
use SL::DB::Project;
19 18
use SL::DB::Shipto;
20 19
use SL::DB::TaxZone;
......
26 25

  
27 26
use Rose::Object::MakeMethods::Generic
28 27
(
29
 'scalar --get_set_init' => [ qw(settings languages_by all_parts parts_by part_counts_by contacts_by ct_shiptos_by price_factors_by pricegroups_by units_by) ],
28
 'scalar --get_set_init' => [ qw(settings languages_by all_parts parts_by part_counts_by contacts_by ct_shiptos_by price_factors_by units_by) ],
30 29
);
31 30

  
32 31

  
......
250 249
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_price_factors } } ) } qw(id description) };
251 250
}
252 251

  
253
sub init_pricegroups_by {
254
  my ($self) = @_;
255

  
256
  my $all_pricegroups = SL::DB::Manager::Pricegroup->get_all;
257
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_pricegroups } } ) } qw(id pricegroup) };
258
}
259

  
260 252
sub init_units_by {
261 253
  my ($self) = @_;
262 254

  
......
648 640
  return 1;
649 641
}
650 642

  
651
sub check_pricegroup {
652
  my ($self, $entry) = @_;
653

  
654
  my $object = $entry->{object};
655

  
656
  # Check whether or not pricegroup ID is valid.
657
  if ($object->pricegroup_id && !$self->pricegroups_by->{id}->{ $object->pricegroup_id }) {
658
    push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
659
    return 0;
660
  }
661

  
662
  # Map pricegroup to ID if given.
663
  if (!$object->pricegroup_id && $entry->{raw_data}->{pricegroup}) {
664
    my $pricegroup = $self->pricegroups_by->{pricegroup}->{ $entry->{raw_data}->{pricegroup} };
665
    if (!$pricegroup) {
666
      push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
667
      return 0;
668
    }
669

  
670
    $object->pricegroup_id($pricegroup->id);
671
  }
672

  
673
  return 1;
674
}
675

  
676 643
sub add_items_to_order {
677 644
  my ($self) = @_;
678 645

  

Auch abrufbar als: Unified diff