From: G. Richardson Date: Tue, 22 Jan 2019 14:05:14 +0000 (+0100) Subject: Refactoring sql-Abfrage für Steuertabelle X-Git-Tag: release-3.5.6.1~544 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=c3500451e73d6bcd253c1df2b148a94bc774b29f;p=kivitendo-erp.git Refactoring sql-Abfrage für Steuertabelle statt 2 subselects pro Automatik- und Skontokonto, jeweils ein Join, um die Kontonummer und Kontenbeschreibung direkt auszulesen. --- diff --git a/SL/AM.pm b/SL/AM.pm index a2ae7d59c..a06f8b309 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1024,13 +1024,16 @@ sub taxes { t.taxkey, t.taxdescription, round(t.rate * 100, 2) AS rate, - (SELECT accno FROM chart WHERE id = chart_id) AS taxnumber, - (SELECT description FROM chart WHERE id = chart_id) AS account_description, - (SELECT accno FROM chart WHERE id = skonto_sales_chart_id) AS skonto_chart_accno, - (SELECT description FROM chart WHERE id = skonto_sales_chart_id) AS skonto_chart_description, - (SELECT accno FROM chart WHERE id = skonto_purchase_chart_id) AS skonto_chart_purchase_accno, - (SELECT description FROM chart WHERE id = skonto_purchase_chart_id) AS skonto_chart_purchase_description + tc.accno AS taxnumber, + tc.description AS account_description, + ssc.accno AS skonto_chart_accno, + ssc.description AS skonto_chart_description, + spc.accno AS skonto_chart_purchase_accno, + spc.description AS skonto_chart_purchase_description FROM tax t + LEFT JOIN chart tc ON (tc.id = t.chart_id) + LEFT JOIN chart ssc ON (ssc.id = t.skonto_sales_chart_id) + LEFT JOIN chart spc ON (spc.id = t.skonto_purchase_chart_id) ORDER BY taxkey, rate|; my $sth = $dbh->prepare($query);