From: garyhgohoos Date: Tue, 10 Jun 2014 14:50:49 +0000 (-0400) Subject: Issue #23573:check for unposted receipts X-Git-Tag: v4.5.0-r1590-3~1^2~10^2 X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=35883e9db36b24b8d5494b9dbf7b452486d1cdb7;p=xtuple Issue #23573:check for unposted receipts --- diff --git a/foundation-database/public/functions/unreleasepurchaseorder.sql b/foundation-database/public/functions/unreleasepurchaseorder.sql index f5a585d7a..47a8db456 100644 --- a/foundation-database/public/functions/unreleasepurchaseorder.sql +++ b/foundation-database/public/functions/unreleasepurchaseorder.sql @@ -4,12 +4,14 @@ CREATE OR REPLACE FUNCTION unreleasePurchaseOrder(pPoheadid INTEGER) RETURNS INT BEGIN IF ( ( SELECT (COUNT(*) > 0) - FROM poitem + FROM poitem LEFT OUTER JOIN recv ON (recv_order_type='PO' AND + recv_orderitem_id=poitem_id) WHERE ( (poitem_pohead_id=pPoheadid) AND ( (poitem_status='C') OR (poitem_qty_received > 0.0) OR (poitem_qty_returned > 0.0) OR - (poitem_qty_vouchered > 0.0) ) ) ) ) THEN + (poitem_qty_vouchered > 0.0) OR + (recv_id IS NOT NULL) ) ) ) ) THEN RETURN -1; END IF;