X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/072919154edb34f4afed6bf93fdbdae5b0969385..8ae2bc4fb4c72f3ac907a3e47c0cbd5da23f62c5:/SL/Form.pm?ds=sidebyside diff --git a/SL/Form.pm b/SL/Form.pm index b34458ef6..c6fd5744a 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2736,6 +2736,9 @@ sub create_links { $self->{TAX} = selectall_hashref_query($self, $dbh, $query); } + my $extra_columns = ''; + $extra_columns .= 'a.direct_debit, ' if $module eq 'AR'; + if ($self->{id}) { $query = qq|SELECT @@ -2743,7 +2746,7 @@ sub create_links { a.duedate, a.ordnumber, a.taxincluded, a.curr AS currency, a.notes, a.intnotes, a.department_id, a.amount AS oldinvtotal, a.paid AS oldtotalpaid, a.employee_id, a.gldate, a.type, - a.globalproject_id, + a.globalproject_id, ${extra_columns} c.name AS $table, d.description AS department, e.name AS employee @@ -2809,7 +2812,14 @@ sub create_links { FROM acc_trans a LEFT JOIN chart c ON (c.id = a.chart_id) LEFT JOIN project p ON (p.id = a.project_id) - LEFT JOIN tax t ON (t.id= a.tax_id) + LEFT JOIN tax t ON (t.id= (SELECT tk.tax_id FROM taxkeys tk + WHERE (tk.taxkey_id=a.taxkey) AND + ((CASE WHEN a.chart_id IN (SELECT chart_id FROM taxkeys WHERE taxkey_id = a.taxkey) + THEN tk.chart_id = a.chart_id + ELSE 1 = 1 + END) + OR (c.link='%tax%')) AND + (startdate <= a.transdate) ORDER BY startdate DESC LIMIT 1)) WHERE a.trans_id = ? AND a.fx_transaction = '0' ORDER BY a.acc_trans_id, a.transdate|;