- if ($form->{"${i}_splited"}) {
-
- # if there is an amount, add the record
- for $j (2 .. $form->{"${i}rowcount"}) {
- ($accno) = split(/--/, $form->{"${i}chartselected_$j"});
-
- $amount = $form->{"${i}_$j"};
-
- ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$j"});
-
- if ($i eq "debit") {
- $amount *= -1;
- }
- 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, project_id, taxkey)
- VALUES
- ($form->{id}, (SELECT c.id
- FROM chart c
- WHERE c.accno = '$accno'),
- $amount, '$form->{transdate}', '$form->{reference}',
- $project_id, $taxkey)|;
-
- $dbh->do($query) || $form->dberror($query);
- }
-
- $tax = $form->{"tax_$j"};
- print(STDERR $tax, " Steuer bei Durchlauf $j\n\n");
- if ($tax != 0) {
-
- # add taxentry
- if ($i eq "debit") {
- $tax = $tax * (-1);
- }
- $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, project_id, taxkey)
- VALUES
- ($form->{id}, (SELECT t.chart_id
- FROM tax t
- WHERE t.taxkey = $taxkey),
- $amount, '$form->{transdate}', '$form->{reference}',
- $project_id, $taxkey)|;
-
- $dbh->do($query) || $form->dberror($query);
- }
- }
- } else {
-
- # if there is an amount, add the record
- ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected"});
- $taxkey *= 1;
- debug("$amount auf $accno buchen");
- 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, project_id, taxkey)
- VALUES
- ($form->{id}, (SELECT c.id
- FROM chart c
- WHERE c.accno = '$accno'),
- $amount, '$form->{transdate}', '$form->{reference}',
- $project_id, $taxkey)|;
-
- $dbh->do($query) || $form->dberror($query);
- }
+ $project_id = conv_i($form->{"project_id_$i"});
+
+ # if there is an amount, add the record
+ if ($amount != 0) {
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
+ source, memo, project_id, taxkey)
+ VALUES
+ ($form->{id}, (SELECT c.id
+ FROM chart c
+ WHERE c.accno = '$accno'),
+ $amount, '$form->{transdate}', |
+ . $dbh->quote($form->{"source_$i"}) . qq|, |
+ . $dbh->quote($form->{"memo_$i"}) . qq|,
+ ?, $taxkey)|;
+
+ do_query($form, $dbh, $query, $project_id);