From: Moritz Bunkus Date: Tue, 20 Feb 2007 09:11:11 +0000 (+0000) Subject: Projektauswahl in Debitoren- und Kreditorenbuchungen per Drop-Down-Box. Bei der Buchu... X-Git-Tag: release-2.4.2~82 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f01741e36a022e2bb7503abb23fbc0f46f27cd62;p=kivitendo-erp.git Projektauswahl in Debitoren- und Kreditorenbuchungen per Drop-Down-Box. Bei der Buchung auf das Gegenkonto wird keine Projektnummer vermerkt. --- diff --git a/SL/AP.pm b/SL/AP.pm index f20d61a41..3522e6261 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -222,14 +222,8 @@ sub post_transaction { for $i (1 .. $form->{rowcount}) { if ($form->{"amount_$i"} != 0) { my $project_id; - if ("amount_$i" =~ /amount_/) { - if ($form->{"project_id_$i"} && $form->{"projectnumber_$i"}) { - $project_id = $form->{"project_id_$i"}; - } - } - if ("amount_$i" =~ /amount/) { - $taxkey = $form->{AP_amounts}{"amount_$i"}{taxkey}; - } + $project_id = conv_i($form->{"project_id_$i"}); + $taxkey = $form->{AP_amounts}{"amount_$i"}{taxkey}; # insert detail records in acc_trans $query = @@ -239,7 +233,7 @@ sub post_transaction { qq| ?, ?, ?, ?)|; @values = ($form->{id}, $form->{AP_amounts}{"amount_$i"}, $form->{"amount_$i"}, conv_date($form->{transdate}), - conv_i($project_id), $taxkey); + $project_id, $taxkey); do_query($form, $dbh, $query, @values); if ($form->{"tax_$i"} != 0) { @@ -251,7 +245,7 @@ sub post_transaction { qq| ?, ?, ?, ?)|; @values = ($form->{id}, $form->{AP_amounts}{"tax_$i"}, $form->{"tax_$i"}, conv_date($form->{transdate}), - conv_date($project_id), $taxkey); + $project_id, $taxkey); do_query($form, $dbh, $query, @values); } @@ -260,11 +254,10 @@ sub post_transaction { # add payables $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | . - qq| ?, ?, ?)|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate) | . + qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?)|; @values = ($form->{id}, $form->{AP_amounts}{payables}, $form->{payables}, - conv_date($form->{transdate}), conv_i($project_id)); + conv_date($form->{transdate})); do_query($form, $dbh, $query, @values); # if there is no amount but a payment record a payable diff --git a/SL/AR.pm b/SL/AR.pm index a38259a2a..22ed409c1 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -35,6 +35,7 @@ package AR; use Data::Dumper; +use SL::DBUtils; sub post_transaction { $main::lxdebug->enter_sub(); @@ -45,6 +46,8 @@ sub post_transaction { my $exchangerate = 0; my $i; + my @values; + my $dbh = $form->dbconnect_noauto($myconfig); if ($form->{currency} eq $form->{defaultcurrency}) { @@ -226,43 +229,38 @@ sub post_transaction { # add individual transactions for AR, amount and taxes for $i (1 .. $form->{rowcount}) { if ($form->{"amount_$i"} != 0) { - $project_id = 'NULL'; - if ("amount_$i" =~ /amount_/) { - if ($form->{"project_id_$i"} && $form->{"projectnumber_$i"}) { - $project_id = $form->{"project_id_$i"}; - } - } - if ("amount_$i" =~ /amount/) { - $taxkey = $form->{AR_amounts}{"amount_$i"}{taxkey}; - } + my $project_id = undef; + $project_id = conv_i($form->{"project_id_$i"}); + $taxkey = $form->{AR_amounts}{"amount_$i"}{taxkey}; + @values = ($project_id); # insert detail records in acc_trans $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) VALUES ($form->{id}, (SELECT c.id FROM chart c WHERE c.accno = '$form->{AR_amounts}{"amount_$i"}'), - $form->{"amount_$i"}, '$form->{transdate}', $project_id, '$taxkey')|; - $dbh->do($query) || $form->dberror($query); + $form->{"amount_$i"}, '$form->{transdate}', ?, '$taxkey')|; + do_query($form, $dbh, $query, @values); if ($form->{"tax_$i"} != 0) { + @values = ($project_id); # insert detail records in acc_trans $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) VALUES ($form->{id}, (SELECT c.id FROM chart c WHERE c.accno = '$form->{AR_amounts}{"tax_$i"}'), - $form->{"tax_$i"}, '$form->{transdate}', $project_id, '$taxkey')|; - $dbh->do($query) || $form->dberror($query); + $form->{"tax_$i"}, '$form->{transdate}', ?, '$taxkey')|; + do_query($form, $dbh, $query, @values); } } } # add recievables - $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, - project_id) + $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate) VALUES ($form->{id}, (SELECT c.id FROM chart c WHERE c.accno = '$form->{AR_amounts}{receivables}'), - $form->{receivables}, '$form->{transdate}', $project_id)|; + $form->{receivables}, '$form->{transdate}')|; $dbh->do($query) || $form->dberror($query); # add paid transactions diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 34b285de3..0d531cf82 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -397,6 +397,21 @@ sub form_header { ? qq|| : qq||; + my @old_project_ids = (); + map({ push(@old_project_ids, $form->{"project_id_$_"}) + if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + "all" => 0, + "old_id" => \@old_project_ids }); + + my %project_labels = (); + my @project_values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@project_values, $item->{"id"}); + $project_labels{$item->{"id"}} = $item->{"projectnumber"}; + } + # use JavaScript Calendar or not $form->{jsscript} = $jscalendar; $jsscript = ""; @@ -558,6 +573,12 @@ $jsscript my $korrektur = $form->{"korrektur_$i"} ? 'checked' : ''; + my $projectnumber = + NTI($cgi->popup_menu('-name' => "project_id_$i", + '-values' => \@project_values, + '-labels' => \%project_labels, + '-default' => $form->{"project_id_$i"} )); + print qq| @@ -565,9 +586,7 @@ $jsscript {"tax_$i"}> $tax - - {"project_id_$i"}> - + $projectnumber |; $amount = ""; @@ -843,7 +862,6 @@ sub update { &check_name(vendor); $form->{AP} = $save_AP; - &check_project; $form->{rowcount} = $count + 1; $form->{invtotal} = diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 291ad068d..9ca39fdd3 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -421,6 +421,21 @@ sub form_header { |; } + my @old_project_ids = (); + map({ push(@old_project_ids, $form->{"project_id_$_"}) + if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + "all" => 0, + "old_id" => \@old_project_ids }); + + my %project_labels = (); + my @project_values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@project_values, $item->{"id"}); + $project_labels{$item->{"id"}} = $item->{"projectnumber"}; + } + $form->{fokus} = "arledger.customer"; # use JavaScript Calendar or not @@ -582,6 +597,12 @@ $jsscript qq||; $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : ''); + my $projectnumber = + NTI($cgi->popup_menu('-name' => "project_id_$i", + '-values' => \@project_values, + '-labels' => \%project_labels, + '-default' => $form->{"project_id_$i"} )); + print qq| @@ -589,9 +610,7 @@ $jsscript {"tax_$i"}> $tax - - {"project_id_$i"}> - + $projectnumber |; $amount = ""; @@ -870,8 +889,6 @@ sub update { &check_name(customer); $form->{AR} = $save_AR; - &check_project; - $form->{invtotal} = ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;