Revision 1beca8de
Von Moritz Bunkus vor fast 11 Jahren hinzugefügt
bin/mozilla/io.pl | ||
---|---|---|
1920 | 1920 |
my @fields = map { s/_1$//; $_ } grep { m/_1$/ } keys %{ $::form }; |
1921 | 1921 |
my @new_rows; |
1922 | 1922 |
|
1923 |
my $make_key = sub { |
|
1924 |
my ($row) = @_; |
|
1925 |
return $::form->{"id_${row}"} unless $::form->{"serialnumber_${row}"}; |
|
1926 |
my $key = $::form->{"id_${row}"} . ':' . $::form->{"serialnumber_${row}"}; |
|
1927 |
return exists $params{quantities}->{$key} ? $key : $::form->{"id_${row}"}; |
|
1928 |
}; |
|
1929 |
|
|
1923 | 1930 |
my $removed_rows = 0; |
1924 | 1931 |
my $row = 0; |
1925 | 1932 |
while ($row < $::form->{rowcount}) { |
... | ... | |
1929 | 1936 |
my $parts_id = $::form->{"id_$row"}; |
1930 | 1937 |
my $base_qty = $::form->parse_amount(\%::myconfig, $::form->{"qty_$row"}) * SL::DB::Manager::Unit->find_by(name => $::form->{"unit_$row"})->base_factor; |
1931 | 1938 |
|
1932 |
my $sub_qty = min($base_qty, $params{quantities}->{$parts_id}); |
|
1933 |
$params{quantities}->{$parts_id} -= $sub_qty; |
|
1939 |
my $key = $make_key->($row); |
|
1940 |
my $sub_qty = min($base_qty, $params{quantities}->{$key}); |
|
1941 |
$params{quantities}->{$key} -= $sub_qty; |
|
1934 | 1942 |
|
1935 | 1943 |
if (!$sub_qty || ($sub_qty != $base_qty)) { |
1936 | 1944 |
$::form->{"qty_${row}"} = $::form->format_amount(\%::myconfig, ($base_qty - $sub_qty) / SL::DB::Manager::Unit->find_by(name => $::form->{"unit_$row"})->base_factor); |
Auch abrufbar als: Unified diff
Umwandlung Angebot/Auftrag -> Lieferschein/Rechnung: Seriennummern bei Mengenberechnung berücksichtigen