X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/185d7c5bea8e3b9098d81bf98a3da5c23db8fd84..0437033e3e747a77b8999ae13a599e3c614be817:/SL/GL.pm diff --git a/SL/GL.pm b/SL/GL.pm index 4dbd703c7..8aef1b108 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -39,6 +39,7 @@ package GL; use Data::Dumper; +use SL::DBUtils; sub delete_transaction { my ($self, $myconfig, $form) = @_; @@ -179,10 +180,10 @@ sub post_transaction { $posted = 0; } + $project_id = conv_i($form->{"project_id_$i"}); + # if there is an amount, add the record if ($amount != 0) { - $project_id = - ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL'; $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) VALUES @@ -192,30 +193,24 @@ sub post_transaction { $amount, '$form->{transdate}', | . $dbh->quote($form->{"source_$i"}) . qq|, | . $dbh->quote($form->{"memo_$i"}) . qq|, - $project_id, $taxkey)|; + ?, $taxkey)|; - $dbh->do($query) || $form->dberror($query); + do_query($form, $dbh, $query, $project_id); } if ($tax != 0) { - # add taxentry - $amount = $tax; - - $project_id = - ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL'; $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, - source, memo, project_id, taxkey) + source, memo, taxkey) VALUES ($form->{id}, (SELECT t.chart_id FROM tax t WHERE t.id = $form->{"tax_id_$i"}), - $amount, '$form->{transdate}', | + $tax, '$form->{transdate}', | . $dbh->quote($form->{"source_$i"}) . qq|, | - . $dbh->quote($form->{"memo_$i"}) . qq|, - $project_id, $taxkey)|; + . $dbh->quote($form->{"memo_$i"}) . qq|, ?, $taxkey)|; - $dbh->do($query) || $form->dberror($query); + do_query($form, $dbh, $query, $project_id); } }