10 |
10 |
use SL::DB::PartsGroup;
|
11 |
11 |
use SL::DB::PaymentTerm;
|
12 |
12 |
use SL::DB::PriceFactor;
|
|
13 |
use SL::DB::Pricegroup;
|
|
14 |
use SL::DB::Price;
|
13 |
15 |
use SL::DB::Translation;
|
14 |
16 |
use SL::DB::Unit;
|
15 |
17 |
|
... | ... | |
19 |
21 |
(
|
20 |
22 |
scalar => [ qw(table) ],
|
21 |
23 |
'scalar --get_set_init' => [ qw(bg_by settings parts_by price_factors_by units_by packing_types_by partsgroups_by
|
22 |
|
translation_columns) ],
|
|
24 |
translation_columns all_pricegroups) ],
|
23 |
25 |
);
|
24 |
26 |
|
25 |
27 |
sub init_class {
|
... | ... | |
77 |
79 |
return $parts_by;
|
78 |
80 |
}
|
79 |
81 |
|
|
82 |
sub init_all_pricegroups {
|
|
83 |
my ($self) = @_;
|
|
84 |
|
|
85 |
return SL::DB::Manager::Pricegroup->get_all(sort => 'id');
|
|
86 |
}
|
|
87 |
|
80 |
88 |
sub init_settings {
|
81 |
89 |
my ($self) = @_;
|
82 |
90 |
|
... | ... | |
110 |
118 |
$self->check_payment($entry);
|
111 |
119 |
$self->check_packing_type($entry);
|
112 |
120 |
$self->check_partsgroup($entry);
|
|
121 |
$self->handle_pricegroups($entry);
|
113 |
122 |
$self->check_existing($entry) unless @{ $entry->{errors} };
|
114 |
123 |
$self->handle_prices($entry) if $self->settings->{sellprice_adjustment};
|
115 |
124 |
$self->handle_shoparticle($entry);
|
... | ... | |
123 |
132 |
$self->add_columns(map { "${_}_id" } grep { exists $self->controller->data->[0]->{raw_data}->{$_} } qw (price_factor payment packing_type partsgroup));
|
124 |
133 |
$self->add_columns(qw(shop)) if $self->settings->{shoparticle_if_missing};
|
125 |
134 |
$self->add_cvar_raw_data_columns;
|
|
135 |
map { $self->add_raw_data_columns("pricegroup_${_}") } (1..scalar(@{ $self->all_pricegroups }));
|
126 |
136 |
map { $self->add_raw_data_columns($_) if exists $self->controller->data->[0]->{raw_data}->{$_} } @{ $self->translation_columns };
|
127 |
137 |
}
|
128 |
138 |
|
... | ... | |
192 |
202 |
|
193 |
203 |
if ($self->settings->{article_number_policy} eq 'update_prices') {
|
194 |
204 |
if ($entry->{part}) {
|
195 |
|
map { $entry->{part}->$_( $object->$_ ) } qw(sellprice listprice lastcost min_sellprice);
|
|
205 |
map { $entry->{part}->$_( $object->$_ ) } qw(sellprice listprice lastcost min_sellprice prices);
|
196 |
206 |
push @{ $entry->{information} }, $::locale->text('Updating prices of existing entry in database');
|
197 |
207 |
$entry->{object_to_save} = $entry->{part};
|
|
208 |
|
|
209 |
$::lxdebug->dump(0, "P1", $entry->{object}->prices);
|
|
210 |
$::lxdebug->dump(0, "P1", $entry->{object_to_save}->prices);
|
198 |
211 |
}
|
199 |
212 |
|
200 |
213 |
} else {
|
... | ... | |
357 |
370 |
$entry->{object}->translations(\@translations);
|
358 |
371 |
}
|
359 |
372 |
|
|
373 |
sub handle_pricegroups {
|
|
374 |
my ($self, $entry) = @_;
|
|
375 |
|
|
376 |
my @prices;
|
|
377 |
my $idx = 0;
|
|
378 |
foreach my $pricegroup (@{ $self->all_pricegroups }) {
|
|
379 |
$idx++;
|
|
380 |
my $sellprice = $entry->{raw_data}->{"pricegroup_${idx}"};
|
|
381 |
next if $sellprice eq '';
|
|
382 |
|
|
383 |
push @prices, SL::DB::Price->new(pricegroup_id => $pricegroup->id,
|
|
384 |
price => $::form->parse_amount(\%::myconfig, $sellprice));
|
|
385 |
}
|
|
386 |
|
|
387 |
$entry->{object}->prices(\@prices);
|
|
388 |
}
|
|
389 |
|
360 |
390 |
sub set_various_fields {
|
361 |
391 |
my ($self, $entry) = @_;
|
362 |
392 |
|
... | ... | |
432 |
462 |
{ name => 'notes_' . $language->article_code,
|
433 |
463 |
description => $::locale->text('Notes (translation for #1)', $language->description) });
|
434 |
464 |
}
|
435 |
|
}
|
436 |
465 |
|
437 |
|
# TODO:
|
438 |
|
# Preisgruppen
|
439 |
|
# Preisaktualisierung
|
|
466 |
my $idx = 0;
|
|
467 |
foreach my $pricegroup (@{ $self->all_pricegroups }) {
|
|
468 |
$idx++;
|
|
469 |
$self->add_displayable_columns({ name => 'pricegroup_' . $idx,
|
|
470 |
description => $::locale->text("Sellprice for price group '#1'", $pricegroup->pricegroup) });
|
|
471 |
}
|
|
472 |
}
|
440 |
473 |
|
441 |
474 |
1;
|
Importieren von Preisgruppen