From a851fde7ef0995a2848c0edb732fe1d50a58d82b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 19 Mar 2007 15:55:26 +0000 Subject: [PATCH] =?utf8?q?Debitoren-=20und=20Kreditorenrechnungen:=20Beim?= =?utf8?q?=20Erstellen=20der=20Eintr=C3=A4ge=20in=20acc=5Ftrans=20keine=20?= =?utf8?q?leeren=20Felder=20f=C3=BCr=20taxkey=20erzeugen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/AP.pm | 60 ++++++++++++++++++++++++++++++--------------------- SL/AR.pm | 66 +++++++++++++++++++++++++++++++++----------------------- 2 files changed, 75 insertions(+), 51 deletions(-) diff --git a/SL/AP.pm b/SL/AP.pm index 8699920ef..b63abab88 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -254,10 +254,11 @@ sub post_transaction { # add payables $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?)|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = ($form->{id}, $form->{AP_amounts}{payables}, $form->{payables}, - conv_date($form->{transdate})); + conv_date($form->{transdate}), $form->{AP_amounts}{payables}); do_query($form, $dbh, $query, @values); # if there is no amount but a payment record a payable @@ -301,21 +302,24 @@ sub post_transaction { 2); if ($form->{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|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = ($form->{id}, $form->{AP}{payables}, $amount, - conv_date($form->{"datepaid_$i"}), $project_id); + conv_date($form->{"datepaid_$i"}), $project_id, + $form->{AP}{payables}); do_query($form, $dbh, $query, @values); } $form->{payables} = $amount; # add payment $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = ($form->{id}, $form->{AP}{"paid_$i"}, $form->{"paid_$i"}, conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, - $form->{"memo_$i"}, $project_id); + $form->{"memo_$i"}, $project_id, $form->{AP}{"paid_$i"}); do_query($form, $dbh, $query, @values); # add exchange rate difference @@ -324,10 +328,12 @@ sub post_transaction { ($form->{"exchangerate_$i"} - 1), 2); if ($amount != 0) { $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 't', 'f', ?)|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = ($form->{id}, $form->{AP}{"paid_$i"}, $amount, - conv_date($form->{"datepaid_$i"}), $project_id); + conv_date($form->{"datepaid_$i"}), $project_id, + $form->{AP}{"paid_$i"}); do_query($form, $dbh, $query, @values); } @@ -339,11 +345,14 @@ sub post_transaction { if ($amount != 0) { $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 't', 'f', ?)|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = ($form->{id}, ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}, - $amount, conv_date($form->{"datepaid_$i"}), $project_id); + $amount, conv_date($form->{"datepaid_$i"}), $project_id, + ($amount > 0) ? + $form->{fxgain_accno} : $form->{fxloss_accno}); do_query($form, $dbh, $query, @values); } @@ -572,11 +581,12 @@ sub post_payment { do_query($form, $dbh, $query, @values); $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|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = ($form->{id}, $accno_ap, $amount, conv_date($form->{"datepaid_$i"}), - conv_i($form->{"paid_project_id_$i"})); + conv_i($form->{"paid_project_id_$i"}), $accno_ap); do_query($form, $dbh, $query, @values); $query = @@ -590,12 +600,13 @@ sub post_payment { do_query($form, $dbh, $query, @values); $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = ($form->{id}, $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"}, $form->{"source_$i"}, $form->{"memo_$i"}, - conv_i($form->{"paid_project_id_$i"})); + conv_i($form->{"paid_project_id_$i"}), $accno); do_query($form, $dbh, $query, @values); # gain/loss @@ -639,10 +650,11 @@ sub post_payment { do_query($form, $dbh, $query, @values); $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 'f', 't')|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey) | . + qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 'f', 't', | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = ($form->{id}, $accno, $form->{fx}{$accno}{$transdate}, - conv_date($transdate)); + conv_date($transdate), $accno); do_query($form, $dbh, $query, @values); } } diff --git a/SL/AR.pm b/SL/AR.pm index 96e66ef4b..02f15f396 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -244,10 +244,12 @@ sub post_transaction { # add recievables $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?)|; - @values = (conv_i($form->{id}), conv_i($form->{AR_amounts}{receivables}), - conv_i($form->{receivables}), conv_date($form->{transdate})); + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; + @values = (conv_i($form->{id}), $form->{AR_amounts}{receivables}, + conv_i($form->{receivables}), conv_date($form->{transdate}), + $form->{AR_amounts}{receivables}); do_query($form, $dbh, $query, @values); # add paid transactions @@ -286,10 +288,12 @@ sub post_transaction { if ($form->{receivables} != 0) { # add receivable $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 = ?), ?, ?, ?)|; - @values = (conv_i($form->{id}), conv_i($form->{AR}{receivables}), - $amount, conv_date($form->{"datepaid_$i"}), $project_id); + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; + @values = (conv_i($form->{id}), $form->{AR}{receivables}, + $amount, conv_date($form->{"datepaid_$i"}), $project_id, + $form->{AR}{receivables}); do_query($form, $dbh, $query, @values); } $form->{receivables} = $amount; @@ -299,11 +303,12 @@ sub post_transaction { # add payment $amount = $form->{"paid_$i"} * -1; $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; - @values = (conv_i($form->{id}), conv_i($form->{AR}{"paid_$i"}), $amount, + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; + @values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, - $form->{"memo_$i"}, $project_id); + $form->{"memo_$i"}, $project_id, $form->{AR}{"paid_$i"}); do_query($form, $dbh, $query, @values); # exchangerate difference for payment @@ -314,10 +319,12 @@ sub post_transaction { if ($amount != 0) { $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 't', 'f', ?)|; - @values = (conv_i($form->{id}), conv_i($form->{AR}{"paid_$i"}), - $amount, conv_date($form->{"datepaid_$i"}), $project_id); + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; + @values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, + $amount, conv_date($form->{"datepaid_$i"}), $project_id, + $form->{AR}{"paid_$i"}); do_query($form, $dbh, $query, @values); } @@ -332,10 +339,11 @@ sub post_transaction { $accno = ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}; $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 't', 'f', ?)|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = (conv_i($form->{id}), $accno, $amount, - conv_date($form->{"datepaid_$i"}), $project_id); + conv_date($form->{"datepaid_$i"}), $project_id, $accno); do_query($form, $dbh, $query, @values); } } @@ -424,8 +432,9 @@ sub post_payment { do_query($form, $dbh, $query, @values); $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|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . + qq| (SELECT taxkey_ FROM chart WHERE accno = ?))|; @values = (conv_i($form->{id}), $accno_ar, conv_i($amount), conv_date($form->{"datepaid_$i"}), $project_id); do_query($form, $dbh, $query, @values); @@ -444,8 +453,9 @@ sub post_payment { do_query($form, $dbh, $query, @values); $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = (conv_i($form->{id}), $accno, conv_i($form->{"paid_$i"}), conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, $form->{"memo_$i"}, $project_id); @@ -493,11 +503,13 @@ sub post_payment { do_query($form, $dbh, $query, @values); $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, project_id) | . - qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 'f', 't', ?)|; + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, project_id, taxkey) | . + qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 'f', 't', ?, | . + qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; @values = (conv_i($form->{id}), $accno, - conv_i($form->{fx}{$accno}{$transdate}), - conv_date($transdate), $project_id); + $form->{fx}{$accno}{$transdate}, + conv_date($transdate), $project_id, + $form->{fx}{$accno}{$transdate}); do_query($form, $dbh, $query, @values); } } -- 2.20.1