4 |
4 |
|
5 |
5 |
use SL::Helper::Csv;
|
6 |
6 |
|
|
7 |
use SL::DBUtils;
|
7 |
8 |
use SL::DB::Buchungsgruppe;
|
8 |
9 |
use SL::DB::CustomVariable;
|
9 |
10 |
use SL::DB::CustomVariableConfig;
|
... | ... | |
60 |
61 |
sub init_parts_by {
|
61 |
62 |
my ($self) = @_;
|
62 |
63 |
|
63 |
|
my $parts_by = { id => { map { ( $_->id => $_ ) } grep { !$_->assembly } @{ $self->existing_objects } },
|
64 |
|
partnumber => { part => { },
|
65 |
|
service => { } } };
|
66 |
|
|
67 |
|
foreach my $part (@{ $self->existing_objects }) {
|
68 |
|
next if $part->assembly;
|
69 |
|
$parts_by->{partnumber}->{ $part->type }->{ $part->partnumber } = $part;
|
|
64 |
# my $parts_by = { id => { map { ( $_->id => $_ ) } grep { !$_->assembly } @{ $self->existing_objects } },
|
|
65 |
# partnumber => { part => { },
|
|
66 |
# service => { } } };
|
|
67 |
#
|
|
68 |
# foreach my $part (@{ $self->existing_objects }) {
|
|
69 |
# next if $part->assembly;
|
|
70 |
# $parts_by->{partnumber}->{ $part->type }->{ $part->partnumber } = $part;
|
|
71 |
# }
|
|
72 |
|
|
73 |
my $parts_by = {};
|
|
74 |
my $sth = prepare_execute_query($::form, $::form->get_standard_dbh, 'SELECT partnumber FROM parts');
|
|
75 |
while (my ($partnumber) = $sth->fetchrow_array()) {
|
|
76 |
$parts_by->{partnumber}{$partnumber} = 1;
|
70 |
77 |
}
|
71 |
78 |
|
72 |
79 |
return $parts_by;
|
... | ... | |
196 |
203 |
|
197 |
204 |
my $object = $entry->{object};
|
198 |
205 |
|
199 |
|
$entry->{part} = SL::DB::Manager::Part->find_by(
|
200 |
|
SL::DB::Manager::Part->type_filter($object->type),
|
201 |
|
( partnumber => $object->partnumber ) x!! $object->partnumber,
|
202 |
|
);
|
|
206 |
if (!$self->test_run && $object->partnumber && $self->parts_by->{partnumber}{$object->partnumber}) {
|
|
207 |
$entry->{part} = SL::DB::Manager::Part->find_by(
|
|
208 |
SL::DB::Manager::Part->type_filter($object->type),
|
|
209 |
( partnumber => $object->partnumber ) x!! $object->partnumber,
|
|
210 |
);
|
|
211 |
}
|
203 |
212 |
|
204 |
213 |
if ($self->settings->{article_number_policy} eq 'update_prices') {
|
|
214 |
if ($object->partnumber && $self->parts_by->{partnumber}{$object->partnumber}) {
|
|
215 |
push @{ $entry->{information} }, $::locale->text('Updating prices of existing entry in database');
|
|
216 |
}
|
205 |
217 |
if ($entry->{part}) {
|
206 |
218 |
map { $entry->{part}->$_( $object->$_ ) if defined $object->$_ } qw(sellprice listprice lastcost);
|
207 |
219 |
|
PartImport: check_existing etwas optimiert, spart bei Testimports gut 40% Zeit.