From: Sven Schöling Date: Fri, 11 Jan 2013 12:40:11 +0000 (+0100) Subject: Revert "Probleme bei Mwst-Wechsel" X-Git-Tag: release-3.1.0beta1~752 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8eca5e84a3f8ebecfb93b593e4540edfa755dcc8;p=kivitendo-erp.git Revert "Probleme bei Mwst-Wechsel" This reverts commit 072919154edb34f4afed6bf93fdbdae5b0969385. --- diff --git a/SL/CA.pm b/SL/CA.pm index aa9f4fe0e..577d6b98a 100644 --- a/SL/CA.pm +++ b/SL/CA.pm @@ -273,7 +273,7 @@ sub all_transactions { $query = qq|SELECT a.id, a.reference, a.description, ac.transdate, ac.chart_id, | . qq| $false AS invoice, ac.amount, 'gl' as module, | . - qq§(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = ac.tax_id) AS taxinfo, ac.source || ' ' || ac.memo AS memo § . + qq§(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = (SELECT tax_id FROM taxkeys WHERE taxkey_id = ac.taxkey AND taxkeys.startdate <= ac.transdate ORDER BY taxkeys.startdate DESC LIMIT 1)) AS taxinfo, ac.source || ' ' || ac.memo AS memo § . qq|FROM acc_trans ac, gl a | . $dpt_join . qq|WHERE | . $where . $dpt_where . $project . @@ -285,7 +285,7 @@ sub all_transactions { qq|SELECT a.id, a.invnumber, c.name, ac.transdate, ac.chart_id, | . qq| a.invoice, ac.amount, 'ar' as module, | . - qq§(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = ac.tax_id) AS taxinfo, ac.source || ' ' || ac.memo AS memo § . + qq§(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = (SELECT tax_id FROM taxkeys WHERE taxkey_id = ac.taxkey AND taxkeys.startdate <= ac.transdate ORDER BY taxkeys.startdate DESC LIMIT 1)) AS taxinfo, ac.source || ' ' || ac.memo AS memo § . qq|FROM acc_trans ac, customer c, ar a | . $dpt_join . qq|WHERE | . $where . $dpt_where . $project . @@ -298,7 +298,7 @@ sub all_transactions { qq|SELECT a.id, a.invnumber, v.name, ac.transdate, ac.chart_id, | . qq| a.invoice, ac.amount, 'ap' as module, | . - qq§(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = ac.tax_id) AS taxinfo, ac.source || ' ' || ac.memo AS memo § . + qq§(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = (SELECT tax_id FROM taxkeys WHERE taxkey_id = ac.taxkey AND taxkeys.startdate <= ac.transdate ORDER BY taxkeys.startdate DESC LIMIT 1)) AS taxinfo, ac.source || ' ' || ac.memo AS memo § . qq|FROM acc_trans ac, vendor v, ap a | . $dpt_join . qq|WHERE | . $where . $dpt_where . $project . diff --git a/SL/Form.pm b/SL/Form.pm index f966a2d6f..c6fd5744a 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2812,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|; diff --git a/SL/GL.pm b/SL/GL.pm index 315406345..80c5fda6e 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -664,12 +664,26 @@ sub transaction { (SELECT c1.accno FROM chart c1, tax t1 WHERE (t1.id = t.id) AND (c1.id = t.chart_id)) AS taxaccno, - a.tax_id AS tax_id + (SELECT tk.tax_id + FROM taxkeys tk + WHERE (tk.chart_id = a.chart_id) AND (tk.startdate <= a.transdate) + ORDER BY tk.startdate desc LIMIT 1) AS tax_id FROM acc_trans a 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) + (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 LIKE '%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|;