Revision a2820962
Von Moritz Bunkus vor fast 12 Jahren hinzugefügt
bin/mozilla/io.pl | ||
---|---|---|
1898 | 1898 |
|
1899 | 1899 |
$main::lxdebug->leave_sub(2); |
1900 | 1900 |
} |
1901 |
|
|
1902 |
sub _remove_billed_or_delivered_rows { |
|
1903 |
my (%params) = @_; |
|
1904 |
|
|
1905 |
croak "Missing parameter 'quantities'" if !$params{quantities}; |
|
1906 |
|
|
1907 |
my @fields = map { s/_1$//; $_ } grep { m/_1$/ } keys %{ $::form }; |
|
1908 |
my @new_rows; |
|
1909 |
|
|
1910 |
my $removed_rows = 0; |
|
1911 |
my $row = 0; |
|
1912 |
while ($row < $::form->{rowcount}) { |
|
1913 |
$row++; |
|
1914 |
next unless $::form->{"id_$row"}; |
|
1915 |
|
|
1916 |
my $parts_id = $::form->{"id_$row"}; |
|
1917 |
my $base_qty = $::form->parse_amount(\%::myconfig, $::form->{"qty_$row"}) * SL::DB::Manager::Unit->find_by(name => $::form->{"unit_$row"})->base_factor; |
|
1918 |
|
|
1919 |
my $sub_qty = min($base_qty, $params{quantities}->{$parts_id}); |
|
1920 |
$params{quantities}->{$parts_id} -= $sub_qty; |
|
1921 |
|
|
1922 |
if (!$sub_qty || ($sub_qty != $base_qty)) { |
|
1923 |
$::form->{"qty_${row}"} = $::form->format_amount(\%::myconfig, ($base_qty - $sub_qty) / SL::DB::Manager::Unit->find_by(name => $::form->{"unit_$row"})->base_factor); |
|
1924 |
push @new_rows, { map { $_ => $::form->{"${_}_${row}"} } @fields }; |
|
1925 |
|
|
1926 |
} else { |
|
1927 |
$removed_rows++; |
|
1928 |
} |
|
1929 |
} |
|
1930 |
|
|
1931 |
$::form->redo_rows(\@fields, \@new_rows, scalar(@new_rows), $::form->{rowcount}); |
|
1932 |
$::form->{rowcount} -= $removed_rows; |
|
1933 |
} |
Auch abrufbar als: Unified diff
Umwandlung Angebot/Auftrag -> Lieferschein/Rechnung: nur nicht gelieferte/berechnete Mengen vorgeben