X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9a9025f648db87efdf2ae8bcd14641f419932248..101b9705bda052abb1237c92d3920f6ddbf12d04:/bin/mozilla/ap.pl diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 98f6df750..23d1b0a5c 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -114,7 +114,7 @@ sub load_record_template { $::form->{AP_chart_id} = $template->ar_ap_chart_id; $::form->{transdate} = $today->to_kivitendo; $::form->{duedate} = $today->to_kivitendo; - $::form->{rowcount} = @{ $template->items } + 1; + $::form->{rowcount} = @{ $template->items }; $::form->{paidaccounts} = 1; $::form->{$_} = $template->$_ for qw(department_id ordnumber taxincluded notes); @@ -152,7 +152,10 @@ sub load_record_template { flash('info', $::locale->text("The record template '#1' has been loaded.", $template->template_name)); - update(); + update( + keep_rows_without_amount => 1, + dont_add_new_row => 1, + ); } sub save_record_template { @@ -165,7 +168,7 @@ sub save_record_template { $js->dialog->close('#record_template_dialog'); my @items = grep { - $_->{chart_id} && (($_->{tax_id} // '') ne '') && ($_->{amount1} != 0) + $_->{chart_id} && (($_->{tax_id} // '') ne '') } map { +{ chart_id => $::form->{"AP_amount_chart_id_${_}"}, amount1 => $::form->parse_amount(\%::myconfig, $::form->{"amount_${_}"}), @@ -584,6 +587,8 @@ sub show_draft { } sub update { + my %params = @_; + $main::lxdebug->enter_sub(); my $form = $main::form; @@ -605,7 +610,7 @@ sub update { my (@a, $j, $totaltax); for my $i (1 .. $form->{rowcount}) { $form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"}); - if ($form->{"amount_$i"}) { + if ($form->{"amount_$i"} || $params{keep_rows_without_amount}) { push @a, {}; $j = $#a; my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); @@ -632,7 +637,7 @@ sub update { IR->get_vendor(\%::myconfig, $form); } - $form->{rowcount} = $count + 1; + $form->{rowcount} = $count + ($params{dont_add_new_row} ? 0 : 1); $form->{invtotal} = ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax; @@ -658,7 +663,7 @@ sub update { $form->{oldinvtotal} = $form->{invtotal}; $form->{oldtotalpaid} = $totalpaid; - &display_form; + display_form(); $main::lxdebug->leave_sub(); }