From 1beca8de27492157b3534d1b0fd432ce0286828a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 30 Apr 2013 14:18:19 +0200 Subject: [PATCH] =?utf8?q?Umwandlung=20Angebot/Auftrag=20->=20Lieferschein?= =?utf8?q?/Rechnung:=20Seriennummern=20bei=20Mengenberechnung=20ber=C3=BCc?= =?utf8?q?ksichtigen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bin/mozilla/io.pl | 12 ++++++++++-- bin/mozilla/oe.pl | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index c1bc77032..56a0354ef 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1920,6 +1920,13 @@ sub _remove_billed_or_delivered_rows { my @fields = map { s/_1$//; $_ } grep { m/_1$/ } keys %{ $::form }; my @new_rows; + my $make_key = sub { + my ($row) = @_; + return $::form->{"id_${row}"} unless $::form->{"serialnumber_${row}"}; + my $key = $::form->{"id_${row}"} . ':' . $::form->{"serialnumber_${row}"}; + return exists $params{quantities}->{$key} ? $key : $::form->{"id_${row}"}; + }; + my $removed_rows = 0; my $row = 0; while ($row < $::form->{rowcount}) { @@ -1929,8 +1936,9 @@ sub _remove_billed_or_delivered_rows { my $parts_id = $::form->{"id_$row"}; my $base_qty = $::form->parse_amount(\%::myconfig, $::form->{"qty_$row"}) * SL::DB::Manager::Unit->find_by(name => $::form->{"unit_$row"})->base_factor; - my $sub_qty = min($base_qty, $params{quantities}->{$parts_id}); - $params{quantities}->{$parts_id} -= $sub_qty; + my $key = $make_key->($row); + my $sub_qty = min($base_qty, $params{quantities}->{$key}); + $params{quantities}->{$key} -= $sub_qty; if (!$sub_qty || ($sub_qty != $base_qty)) { $::form->{"qty_${row}"} = $::form->format_amount(\%::myconfig, ($base_qty - $sub_qty) / SL::DB::Manager::Unit->find_by(name => $::form->{"unit_$row"})->base_factor); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 883507aa9..6001c87bc 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -2068,7 +2068,9 @@ sub _oe_remove_delivered_or_billed_rows { next if $ord_quot->is_sales != $record->is_sales; foreach my $item (@{ $record->items }) { - $handled_base_qtys{ $item->parts_id } += $item->qty * $item->unit_obj->base_factor; + my $key = $item->parts_id; + $key .= ':' . $item->serialnumber if $item->serialnumber; + $handled_base_qtys{$key} += $item->qty * $item->unit_obj->base_factor; } } -- 2.20.1