From: Sven Schöling Date: Thu, 24 Sep 2009 11:05:17 +0000 (+0200) Subject: Inner Join vermeiden um leere Rechnungen nicht zu verlieren X-Git-Tag: release-2.6.1beta1~275^2~5 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e5ea1c8392d571fbac87d9bb79bcc2709f6deb6e;p=kivitendo-erp.git Inner Join vermeiden um leere Rechnungen nicht zu verlieren Fix für Bug 1155 --- 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}) {