From: Moritz Bunkus Date: Fri, 1 Aug 2008 09:01:21 +0000 (+0000) Subject: Query für die Artikelstammdaten: Falsches Joinen. Wenn die UNION aus invoice/orderite... X-Git-Tag: release-2.6.0beta1~14 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2b688418ad0392b739240ffa4de1ab9d12ad4031;p=kivitendo-erp.git Query für die Artikelstammdaten: Falsches Joinen. Wenn die UNION aus invoice/orderitems mit ar/ap/oe gejoint wird, dann muss darauf geachtet werden, dass Zeilen aus invoice nur mit ar/ap und Zeilen aus orderitems nur mit oe gejoint wird. Grund ist, dass ar.id und ap.id den Zähler glid benutzen, während oe.id den Zähler id benutzt. Daraus resultierten Verbindungen mit Zeilen aus orderitems mit Zeilen aus ar/ap, sprich es wurden Rechnungen gefunden, in denen die Artikel gar nicht auftauchten. --- diff --git a/SL/IC.pm b/SL/IC.pm index 67d38d72d..45fcebb1b 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -780,10 +780,10 @@ sub all_parts { ) AS ioi ON ioi.parts_id = p.id|, apoe => q|LEFT JOIN ( - SELECT id, transdate, 'ir' AS module, ordnumber, quonumber, invnumber, FALSE AS quotation, NULL AS customer_id, vendor_id, NULL AS deliverydate FROM ap UNION - SELECT id, transdate, 'is' AS module, ordnumber, quonumber, invnumber, FALSE AS quotation, customer_id, NULL AS vendor_id, deliverydate FROM ar UNION - SELECT id, transdate, 'oe' AS module, ordnumber, quonumber, NULL AS invnumber, quotation, customer_id, vendor_id, NULL AS deliverydate FROM oe - ) AS apoe ON ioi.trans_id = apoe.id|, + SELECT id, transdate, 'ir' AS module, ordnumber, quonumber, invnumber, FALSE AS quotation, NULL AS customer_id, vendor_id, NULL AS deliverydate, 'invoice' AS ioi FROM ap UNION + SELECT id, transdate, 'is' AS module, ordnumber, quonumber, invnumber, FALSE AS quotation, customer_id, NULL AS vendor_id, deliverydate, 'invoice' AS ioi FROM ar UNION + SELECT id, transdate, 'oe' AS module, ordnumber, quonumber, NULL AS invnumber, quotation, customer_id, vendor_id, NULL AS deliverydate, 'orderitems' AS ioi FROM oe + ) AS apoe ON ((ioi.trans_id = apoe.id) AND (ioi.ioi = apoe.ioi))|, cv => q|LEFT JOIN ( SELECT id, name, 'customer' AS cv FROM customer UNION