From e4af904c3d38c8dc8fc493270c318e6372d39cba Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 15 Apr 2009 16:09:30 +0000 Subject: [PATCH] provide option to leave lineitem_details when purging PO if the li points to a picklist git-svn-id: svn://svn.open-ils.org/ILS/trunk@12882 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/support-scripts/test-scripts/purge_po.sql | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/support-scripts/test-scripts/purge_po.sql b/Open-ILS/src/support-scripts/test-scripts/purge_po.sql index 8dced970fc..0aeb0aa62e 100644 --- a/Open-ILS/src/support-scripts/test-scripts/purge_po.sql +++ b/Open-ILS/src/support-scripts/test-scripts/purge_po.sql @@ -2,7 +2,7 @@ -- Removes all traces of a purchase order, including the PO, lineitems, -- lineitem_details, bibs, copies, callnumbers, and debits -CREATE OR REPLACE FUNCTION acq.purge_po (po_id INT) RETURNS VOID AS $$ +CREATE OR REPLACE FUNCTION acq.purge_po (po_id INT, purge_items BOOLEAN) RETURNS VOID AS $$ DECLARE li RECORD; BEGIN @@ -15,11 +15,17 @@ BEGIN DELETE FROM acq.fund_debit WHERE id in ( SELECT fund_debit FROM acq.lineitem_detail WHERE lineitem = li.id); - DELETE FROM acq.lineitem_detail WHERE lineitem = li.id; + IF li.picklist IS NULL THEN + IF purge_items THEN + DELETE FROM acq.lineitem_detail WHERE lineitem = li.id; + ELSE + UPDATE acq.lineitem_detail SET eg_copy_id = NULL WHERE lineitem = li.id; + END IF; DELETE FROM acq.lineitem_attr WHERE lineitem = li.id; DELETE from acq.lineitem WHERE id = li.id; ELSE + DELETE FROM acq.lineitem_detail WHERE lineitem = li.id; UPDATE acq.lineitem SET purchase_order = NULL, eg_bib_id = NULL, state = 'new' WHERE id = li.id; END IF; END LOOP; -- 2.11.0