Revision 4e8e85fc
Von Moritz Bunkus vor mehr als 8 Jahren hinzugefügt
SL/IC.pm | ||
---|---|---|
262 | 262 |
} |
263 | 263 |
|
264 | 264 |
# get old price |
265 |
$query = qq|SELECT sellprice, weight FROM parts WHERE id = ?|; |
|
266 |
my ($sellprice, $weight) = selectrow_query($form, $dbh, $query, conv_i($form->{id})); |
|
267 |
|
|
268 |
# if item is part of an assembly adjust all assemblies |
|
269 |
$query = qq|SELECT id, qty FROM assembly WHERE parts_id = ?|; |
|
270 |
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); |
|
271 |
while (my ($id, $qty) = $sth->fetchrow_array) { |
|
272 |
&update_assembly($dbh, $form, $id, $qty, $sellprice * 1, $weight * 1); |
|
273 |
} |
|
274 |
$sth->finish; |
|
265 |
$query = qq|SELECT sellprice FROM parts WHERE id = ?|; |
|
266 |
my ($sellprice) = selectrow_query($form, $dbh, $query, conv_i($form->{id})); |
|
275 | 267 |
|
276 | 268 |
# delete makemodel records |
277 | 269 |
do_query($form, $dbh, qq|DELETE FROM makemodel WHERE parts_id = ?|, conv_i($form->{id})); |
... | ... | |
553 | 545 |
return $rc; |
554 | 546 |
} |
555 | 547 |
|
556 |
sub update_assembly { |
|
557 |
$main::lxdebug->enter_sub(); |
|
558 |
|
|
559 |
my ($dbh, $form, $id, $qty, $sellprice, $weight) = @_; |
|
560 |
|
|
561 |
my $query = qq|SELECT id, qty FROM assembly WHERE parts_id = ?|; |
|
562 |
my $sth = prepare_execute_query($form, $dbh, $query, conv_i($id)); |
|
563 |
|
|
564 |
while (my ($pid, $aqty) = $sth->fetchrow_array) { |
|
565 |
&update_assembly($dbh, $form, $pid, $aqty * $qty, $sellprice, $weight); |
|
566 |
} |
|
567 |
$sth->finish; |
|
568 |
|
|
569 |
$query = |
|
570 |
qq|UPDATE parts SET sellprice = sellprice + ?, weight = weight + ? |
|
571 |
WHERE id = ?|; |
|
572 |
my @values = ($qty * ($form->{sellprice} - $sellprice), |
|
573 |
$qty * ($form->{weight} - $weight), conv_i($id)); |
|
574 |
do_query($form, $dbh, $query, @values); |
|
575 |
|
|
576 |
$form->new_lastmtime('parts') if $id == $form->{id}; |
|
577 |
|
|
578 |
$main::lxdebug->leave_sub(); |
|
579 |
} |
|
580 |
|
|
581 | 548 |
sub retrieve_assemblies { |
582 | 549 |
$main::lxdebug->enter_sub(); |
583 | 550 |
|
Auch abrufbar als: Unified diff
Artikelstammdaten: Verkaufspreisänderungen nicht mehr an Erzeugnisse propagieren