From: Moritz Bunkus Date: Wed, 3 Mar 2010 15:00:38 +0000 (+0100) Subject: Beim Speichern/Buchen geleerte Zeilen entfernen X-Git-Tag: release-2.6.1beta1~42^2~2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0a5317e7d69e81f6052d4659b4379c6c8e398ea0;p=kivitendo-erp.git Beim Speichern/Buchen geleerte Zeilen entfernen Vor dem Speichern/Buchen von Verkaufs- und Einkaufsbelegen evtl. geleerte Zeilen entfernen (also Zeilen, in denen die Artikelnummer entfernt wurde), damit kein explizites "Erneuern" durch den Benutzer notwendig ist. Fix für Bug 1197. --- diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index cf7bc4207..45adf186f 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -609,6 +609,7 @@ sub save { # $locale->text('Customer missing!'); # $locale->text('Vendor missing!'); + remove_emptied_rows(); validate_items(); # if the name changed get new values diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 07db7eac6..90fdcc2db 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -765,44 +765,9 @@ sub check_form { map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(listprice sellprice lastcost); } else { - my @flds = qw(id partnumber description qty ship sellprice unit - discount inventory_accno income_accno expense_accno listprice - taxaccounts bin assembly weight projectnumber project_id - oldprojectnumber runningnumber serialnumber partsgroup payment_id - not_discountable shop ve gv buchungsgruppen_id language_values - sellprice_pg pricegroup_old price_old price_new unit_old ordnumber - transdate longdescription basefactor marge_total marge_percent - marge_price_factor lastcost price_factor_id partnotes - stock_out stock_in has_sernumber); - - my $ic_cvar_configs = CVar->get_configs(module => 'IC'); - push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; - - # this section applies to invoices and orders - # remove any empty numbers - if ($form->{rowcount}) { - for my $i (1 .. $form->{rowcount} - 1) { - if ($form->{"partnumber_$i"}) { - push @a, {}; - my $j = $#a; - - map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds; - $count++; - if ($main::lizenzen) { - if ($form->{"licensenumber_$i"} == -1) { - &new_license($i); - exit; - } - } - } - } - - $form->redo_rows(\@flds, \@a, $count, $form->{rowcount}); - $form->{rowcount} = $count; - - $form->{creditremaining} -= &invoicetotal; + remove_emptied_rows(1); - } + $form->{creditremaining} -= &invoicetotal; } #sk @@ -825,6 +790,37 @@ sub check_form { $main::lxdebug->leave_sub(); } +sub remove_emptied_rows { + my $dont_add_empty = shift; + my $form = $::form; + + return unless $form->{rowcount}; + + my @flds = qw(id partnumber description qty ship sellprice unit + discount inventory_accno income_accno expense_accno listprice + taxaccounts bin assembly weight projectnumber project_id + oldprojectnumber runningnumber serialnumber partsgroup payment_id + not_discountable shop ve gv buchungsgruppen_id language_values + sellprice_pg pricegroup_old price_old price_new unit_old ordnumber + transdate longdescription basefactor marge_total marge_percent + marge_price_factor lastcost price_factor_id partnotes + stock_out stock_in has_sernumber); + + my $ic_cvar_configs = CVar->get_configs(module => 'IC'); + push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; + + my @new_rows; + for my $i (1 .. $form->{rowcount} - 1) { + next unless $form->{"partnumber_$i"}; + + push @new_rows, { map { $_ => $form->{"${_}_$i" } } @flds }; + } + + my $new_rowcount = scalar @new_rows; + $form->redo_rows(\@flds, \@new_rows, $new_rowcount, $form->{rowcount}); + $form->{rowcount} = $new_rowcount + ($dont_add_empty ? 0 : 1); +} + sub invoicetotal { $main::lxdebug->enter_sub(); diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index c44ef42f3..09ef5249c 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -667,6 +667,7 @@ sub post { exit; } + remove_emptied_rows(); &validate_items; my $closedto = $form->datetonum($form->{closedto}, \%myconfig); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 6446cc787..f44c5809c 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -656,6 +656,7 @@ sub post { $form->{print_and_post} = 0; } + remove_emptied_rows(); &validate_items; my $closedto = $form->datetonum($form->{closedto}, \%myconfig); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index cd7c1eeab..8883096b6 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1101,6 +1101,7 @@ sub save { $form->isblank("exchangerate", $locale->text('Exchangerate missing!')) if ($form->{currency} ne $form->{defaultcurrency}); + remove_emptied_rows(); &validate_items; my $payment_id;