1 CREATE OR REPLACE FUNCTION unreleasePurchaseOrder(pPoheadid INTEGER) RETURNS INTEGER AS $$
2 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
3 -- See www.xtuple.com/CPAL for the full text of the software license.
6 IF ( ( SELECT (COUNT(*) > 0)
8 WHERE ( (poitem_pohead_id=pPoheadid)
9 AND ( (poitem_status='C') OR
10 (poitem_qty_received > 0.0) OR
11 (poitem_qty_returned > 0.0) OR
12 (poitem_qty_vouchered > 0.0) ) ) ) ) THEN
16 IF ( ( SELECT (pohead_status='O')
18 WHERE (pohead_id=pPoheadid) ) ) THEN
20 --update status and erase the date that the order was released on
22 SET pohead_status='U', pohead_released = NULL
23 WHERE (pohead_id=pPoheadid);
27 --update status and erase the duedates at release
29 SET poitem_status='U', poitem_rlsd_duedate = NULL
30 WHERE (poitem_pohead_id=pPoheadid);
35 $$ LANGUAGE 'plpgsql';