From e5ea1c8392d571fbac87d9bb79bcc2709f6deb6e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 24 Sep 2009 13:05:17 +0200 Subject: [PATCH] Inner Join vermeiden um leere Rechnungen nicht zu verlieren MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix für Bug 1155 --- SL/AP.pm | 12 ++++++++---- SL/AR.pm | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/SL/AP.pm b/SL/AP.pm index 6ec28627c..6bc1095b4 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -401,15 +401,19 @@ sub ap_transactions { qq| v.vendornumber, v.country, v.ustid, | . qq| tz.description AS taxzone, | . qq| pt.description AS payment_terms, | . - qq{ ch.accno || ' -- ' || ch.description AS charts } . + qq{ ( SELECT ch.accno || ' -- ' || ch.description + FROM acc_trans at + LEFT JOIN chart ch ON ch.id = at.chart_id + WHERE ch.link ~ 'AP[[:>:]]' + AND at.trans_id = a.id + LIMIT 1 + ) AS charts } . qq|FROM ap a | . qq|JOIN vendor v ON (a.vendor_id = v.id) | . qq|LEFT JOIN employee e ON (a.employee_id = e.id) | . qq|LEFT JOIN project pr ON (a.globalproject_id = pr.id) | . qq|LEFT JOIN tax_zones tz ON (tz.id = v.taxzone_id)| . - qq|LEFT JOIN payment_terms pt ON (pt.id = v.payment_id)| . - qq|LEFT JOIN acc_trans at ON (at.trans_id = a.id)| . - qq|INNER JOIN chart ch ON (ch.id = at.chart_id AND ch.link ~ 'AP[[:>:]]')|; + qq|LEFT JOIN payment_terms pt ON (pt.id = v.payment_id)|; my $where = ''; my @values; diff --git a/SL/AR.pm b/SL/AR.pm index 88ee519f0..a211b1fcf 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -424,16 +424,20 @@ sub ar_transactions { qq| e2.name AS salesman, | . qq| tz.description AS taxzone, | . qq| pt.description AS payment_terms, | . - qq{ ch.accno || ' -- ' || ch.description AS charts } . + qq{ ( SELECT ch.accno || ' -- ' || ch.description + FROM acc_trans at + LEFT JOIN chart ch ON ch.id = at.chart_id + WHERE ch.link ~ 'AR[[:>:]]' + AND at.trans_id = a.id + LIMIT 1 + ) AS charts } . qq|FROM ar a | . qq|JOIN customer c ON (a.customer_id = c.id) | . qq|LEFT JOIN employee e ON (a.employee_id = e.id) | . qq|LEFT JOIN employee e2 ON (a.salesman_id = e2.id) | . qq|LEFT JOIN project pr ON (a.globalproject_id = pr.id)| . qq|LEFT JOIN tax_zones tz ON (tz.id = c.taxzone_id)| . - qq|LEFT JOIN payment_terms pt ON (pt.id = c.payment_id)| . - qq|LEFT JOIN acc_trans at ON (at.trans_id = a.id)| . - qq|INNER JOIN chart ch ON (ch.id = at.chart_id AND ch.link ~ 'AR[[:>:]]')|; + qq|LEFT JOIN payment_terms pt ON (pt.id = c.payment_id)|; my $where = "1 = 1"; if ($form->{customer_id}) { -- 2.20.1