From ede4f3288297f01494fd5bbacf375f86448d8f3c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 7 Nov 2012 14:45:14 +0100 Subject: [PATCH] =?utf8?q?Gel=C3=B6schte=20Positionen=20in=20Lieferscheine?= =?utf8?q?n=20im=20Lieferplaner=20ber=C3=BCcksichtigen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit behebt #2018 --- SL/Controller/DeliveryPlan.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/SL/Controller/DeliveryPlan.pm b/SL/Controller/DeliveryPlan.pm index 5937c5b7f..980234ef5 100644 --- a/SL/Controller/DeliveryPlan.pm +++ b/SL/Controller/DeliveryPlan.pm @@ -119,6 +119,26 @@ sub setup_for_list { rl.from_table ='oe' AND rl.to_table = 'delivery_orders' ) + + UNION ALL + + -- 5. In case someone deleted a line of the delivery_order there will be a record_link (4 fails) + -- but there won't be a delivery_order_items to find (3 fails too). Search for orphaned orderitems this way + SELECT oi.id FROM orderitems AS oi, oe, record_links AS rl + WHERE + rl.from_table = 'oe' AND + rl.to_table = 'delivery_orders' AND + + oi.trans_id = rl.from_id AND + oi.parts_id NOT IN ( + SELECT doi.parts_id FROM delivery_order_items AS doi WHERE doi.delivery_order_id = rl.to_id + ) AND + + oe.id = oi.trans_id AND + + oe.customer_id IS NOT NULL AND + (oe.quotation = 'f' OR oe.quotation IS NULL) AND + NOT oe.closed " ], ) ]; -- 2.20.1