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 |
|
CsvImport Aufträge: bei nicht eindeutigen Artikeln Fehler melden.