Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9ca0da81

Von Bernd Bleßmann vor fast 8 Jahren hinzugefügt

  • ID 9ca0da81731536fd78983f92f4f491c34bebb7e6
  • Vorgänger f87214b2
  • Nachfolger fd840a7b

CsvImport Aufträge: bei nicht eindeutigen Artikeln Fehler melden.

Unterschiede anzeigen:

SL/Controller/CsvImport/Order.pm
26 26

  
27 27
use Rose::Object::MakeMethods::Generic
28 28
(
29
 'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by ct_shiptos_by price_factors_by pricegroups_by units_by) ],
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) ],
30 30
);
31 31

  
32 32

  
......
194 194
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $self->all_languages } } ) } qw(id description article_code) };
195 195
}
196 196

  
197
sub init_all_parts {
198
  my ($self) = @_;
199

  
200
  return SL::DB::Manager::Part->get_all;
201
}
202

  
197 203
sub init_parts_by {
198 204
  my ($self) = @_;
199 205

  
200
  my $all_parts = SL::DB::Manager::Part->get_all;
201
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_parts } } ) } qw(id partnumber ean description) };
206
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $self->all_parts } } ) } qw(id partnumber ean description) };
207
}
208

  
209
sub init_part_counts_by {
210
  my ($self) = @_;
211

  
212
  my $part_counts_by;
213

  
214
  $part_counts_by->{ean}->        {$_->ean}++         for @{ $self->all_parts };
215
  $part_counts_by->{description}->{$_->description}++ for @{ $self->all_parts };
216

  
217
  return $part_counts_by;
202 218
}
203 219

  
204 220
sub init_contacts_by {
......
436 452
  my ($self, $entry) = @_;
437 453

  
438 454
  my $object = $entry->{object};
455
  my $is_ambiguous;
439 456

  
440 457
  # Check whether or not part ID is valid.
441 458
  if ($object->parts_id && !$self->parts_by->{id}->{ $object->parts_id }) {
......
462 479
      return 0;
463 480
    }
464 481

  
465
    $object->parts_id($part->id);
482
    if ($self->part_counts_by->{description}->{ $entry->{raw_data}->{description} } > 1) {
483
      $is_ambiguous = 1;
484
    } else {
485
      $object->parts_id($part->id);
486
    }
466 487
  }
467 488

  
468 489
  # Map ean to ID if given.
......
473 494
      return 0;
474 495
    }
475 496

  
476
    $object->parts_id($part->id);
497
    if ($self->part_counts_by->{ean}->{ $entry->{raw_data}->{ean} } > 1) {
498
      $is_ambiguous = 1;
499
    } else {
500
      $object->parts_id($part->id);
501
    }
477 502
  }
478 503

  
479 504
  if ($object->parts_id) {
480 505
    $entry->{info_data}->{partnumber} = $self->parts_by->{id}->{ $object->parts_id }->partnumber;
481 506
  } else {
482
    push @{ $entry->{errors} }, $::locale->text('Error: Part not found');
507
    if ($is_ambiguous) {
508
      push @{ $entry->{errors} }, $::locale->text('Error: Part is ambiguous');
509
    } else {
510
      push @{ $entry->{errors} }, $::locale->text('Error: Part not found');
511
    }
483 512
    return 0;
484 513
  }
485 514

  
locale/de/all
1227 1227
  'Error: Invalid warehouse id' => 'Ungültige Lager-ID',
1228 1228
  'Error: Invalid warehouse name #1' => 'Ungültiger Lagername \'#1\'',
1229 1229
  'Error: Name missing'         => 'Fehler: Name fehlt',
1230
  'Error: Part is ambiguous'    => 'Artikel ist mehrdeutig',
1230 1231
  'Error: Part is obsolete'     => 'Fehler: Artikel ist ungültig',
1231 1232
  'Error: Part not found'       => 'Fehler: Artikel nicht gefunden',
1232 1233
  'Error: Quantity to transfer is zero.' => 'Fehler: Zu bewegende Menge ist Null.',
locale/en/all
1214 1214
  'Error: Invalid warehouse id' => '',
1215 1215
  'Error: Invalid warehouse name #1' => '',
1216 1216
  'Error: Name missing'         => '',
1217
  'Error: Part is ambiguous'    => '',
1217 1218
  'Error: Part is obsolete'     => '',
1218 1219
  'Error: Part not found'       => '',
1219 1220
  'Error: Quantity to transfer is zero.' => '',

Auch abrufbar als: Unified diff