X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/2a4516c122395c29a8fd57d5a7a53a1c6b6c2ca4..d1408ca13458a782cbde2b768cdd7abdbdcb9348:/SL/IR.pm diff --git a/SL/IR.pm b/SL/IR.pm index e1d1011aa..11c69de8c 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -270,14 +270,15 @@ sub post_invoice { # allocated >= 0 # add entry for inventory, this one is for the sold item $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?), - (SELECT tax_id + (SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? - ORDER BY startdate DESC LIMIT 1))|; - @values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{inventory_accno_id}, $ref->{transdate}); + ORDER BY startdate DESC LIMIT 1), + (SELECT chart_link FROM chart WHERE id = ?))|; + @values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{inventory_accno_id}, $ref->{transdate}, $ref->{inventory_accno_id}); do_query($form, $dbh, $query, @values); # add expense @@ -288,8 +289,9 @@ sub post_invoice { FROM chart WHERE accno = ?) AND startdate <= ? - ORDER BY startdate DESC LIMIT 1))|; - @values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{expense_accno_id}, $ref->{transdate}); + ORDER BY startdate DESC LIMIT 1), + (SELECT chart_link FROM chart WHERE id = ?))|; + @values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{expense_accno_id}, $ref->{transdate}, $ref->{expense_accno_id}); do_query($form, $dbh, $query, @values); } }; @@ -492,7 +494,7 @@ sub post_invoice { next if $payments_only || !$form->{amount}{$trans_id}{$accno}; - $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id) + $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id, chart_link) VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), ?, (SELECT tax_id @@ -501,9 +503,10 @@ sub post_invoice { FROM chart WHERE accno = ?) AND startdate <= ? - ORDER BY startdate DESC LIMIT 1))|; + ORDER BY startdate DESC LIMIT 1), + (SELECT link FROM chart WHERE accno = ?))|; @values = ($trans_id, $accno, $form->{amount}{$trans_id}{$accno}, - conv_date($form->{invdate}), $accno, $project_id, $accno, conv_date($form->{invdate})); + conv_date($form->{invdate}), $accno, $project_id, $accno, conv_date($form->{invdate}), $accno); do_query($form, $dbh, $query, @values); } } @@ -538,7 +541,7 @@ sub post_invoice { # record AP if ($form->{amount}{ $form->{id} }{ $form->{AP} } != 0) { - $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id) + $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id, chart_link) VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), ?, (SELECT tax_id @@ -547,9 +550,10 @@ sub post_invoice { FROM chart WHERE accno = ?) AND startdate <= ? - ORDER BY startdate DESC LIMIT 1))|; + ORDER BY startdate DESC LIMIT 1), + (SELECT link FROM chart WHERE accno = ?))|; @values = (conv_i($form->{id}), $form->{AP}, $amount, - $form->{"datepaid_$i"}, $form->{AP}, $project_id, $form->{AP}, conv_date($form->{"datepaid_$i"})); + $form->{"datepaid_$i"}, $form->{AP}, $project_id, $form->{AP}, conv_date($form->{"datepaid_$i"}), $form->{AP}); do_query($form, $dbh, $query, @values); } @@ -557,7 +561,7 @@ sub post_invoice { my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig)); $query = - qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id, tax_id) + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id, tax_id, chart_link) VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), ?, (SELECT tax_id @@ -565,9 +569,10 @@ sub post_invoice { WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? - ORDER BY startdate DESC LIMIT 1))|; + ORDER BY startdate DESC LIMIT 1), + (SELECT link FROM chart WHERE accno = ?))|; @values = (conv_i($form->{id}), $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"}, - $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id, $accno, conv_date($form->{"datepaid_$i"})); + $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id, $accno, conv_date($form->{"datepaid_$i"}), $accno); do_query($form, $dbh, $query, @values); $exchangerate = 0; @@ -605,7 +610,7 @@ sub post_invoice { $form->{fx}{$accno}{$transdate} = $form->round_amount($form->{fx}{$accno}{$transdate}, 2); next if ($form->{fx}{$accno}{$transdate} == 0); - $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id, tax_id) + $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id, tax_id, chart_link) VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1', 0, ?, (SELECT tax_id FROM taxkeys @@ -613,8 +618,9 @@ sub post_invoice { FROM chart WHERE accno = ?) AND startdate <= ? - ORDER BY startdate DESC LIMIT 1))|; - @values = (conv_i($form->{id}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $project_id, $accno, $form->{fx}{$accno}{$transdate}); + ORDER BY startdate DESC LIMIT 1), + (SELECT link FROM chart WHERE accno = ?))|; + @values = (conv_i($form->{id}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $project_id, $accno, $form->{fx}{$accno}{$transdate}, $accno); do_query($form, $dbh, $query, @values); } } @@ -658,7 +664,7 @@ sub post_invoice { invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?, intnotes = ?, curr = ?, storno_id = ?, storno = ?, cp_id = ?, employee_id = ?, department_id = ?, - globalproject_id = ? + globalproject_id = ?, direct_debit = ? WHERE id = ?|; @values = ( $form->{invnumber}, $form->{ordnumber}, $form->{quonumber}, conv_date($form->{invdate}), @@ -668,6 +674,7 @@ sub post_invoice { $form->{intnotes}, $form->{currency}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f', conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}), conv_i($form->{globalproject_id}), + $form->{direct_debit} ? 't' : 'f', conv_i($form->{id}) ); do_query($form, $dbh, $query, @values); @@ -911,7 +918,7 @@ sub retrieve_invoice { $query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate, orddate, quodate, globalproject_id, ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate, - intnotes, curr AS currency + intnotes, curr AS currency, direct_debit FROM ap WHERE id = ?|; $ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id})); @@ -1061,7 +1068,7 @@ sub get_vendor { v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount, v.creditlimit, v.terms, v.notes AS intnotes, v.email, v.cc, v.bcc, v.language_id, v.payment_id, - v.street, v.zipcode, v.city, v.country, v.taxzone_id, v.curr, + v.street, v.zipcode, v.city, v.country, v.taxzone_id, v.curr, v.direct_debit, $duedate + COALESCE(pt.terms_netto, 0) AS duedate, b.description AS business FROM vendor v