Issue #23507:initial commit
[xtuple] / foundation-database / public / functions / detailedqoh.sql
index aea3e77..d18a526 100644 (file)
@@ -1,30 +1,27 @@
-CREATE OR REPLACE FUNCTION detailedQOH(INTEGER, BOOLEAN) RETURNS NUMERIC AS '
+CREATE OR REPLACE FUNCTION detailedQOH(pItemsiteid INTEGER,
+                                       pABS BOOLEAN) RETURNS NUMERIC AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
 DECLARE
-  pItemsiteid ALIAS FOR $1;
-  pABS ALIAS FOR $2;
   _qoh NUMERIC;
 
 BEGIN
 
   IF (pABS) THEN
     SELECT SUM(noNeg(itemloc_qty)) INTO _qoh
-    FROM itemloc LEFT OUTER JOIN location ON (itemloc_location_id=location_id)
-    WHERE ( ( (location_id IS NULL) OR (location_netable) )
-     AND (itemloc_itemsite_id=pItemsiteid) );
+    FROM itemloc
+    WHERE (itemloc_itemsite_id=pItemsiteid);
   ELSE
     SELECT SUM(itemloc_qty) INTO _qoh
-    FROM itemloc LEFT OUTER JOIN location ON (itemloc_location_id=location_id)
-    WHERE ( ( (location_id IS NULL) OR (location_netable) )
-     AND (itemloc_itemsite_id=pItemsiteid) );
+    FROM itemloc
+    WHERE (itemloc_itemsite_id=pItemsiteid);
   END IF;
 
   IF (_qoh IS NULL) THEN
-    _qoh := 0;
+    _qoh := 0.0;
   END IF;
 
   RETURN _qoh;
 
 END;
-' LANGUAGE 'plpgsql';
+$$ LANGUAGE plpgsql;