spa pricing
authorGreg Pazo <gpazo@xtuple.com>
Sat, 12 Apr 2014 04:02:38 +0000 (00:02 -0400)
committerGreg Pazo <gpazo@xtuple.com>
Sat, 12 Apr 2014 04:02:38 +0000 (00:02 -0400)
foundation-database/public/functions/itemcost.sql

index 6625b7c..d9d43d6 100644 (file)
@@ -1,8 +1,34 @@
-CREATE OR REPLACE FUNCTION itemCost(INTEGER) RETURNS NUMERIC STABLE AS $$
--- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
+CREATE OR REPLACE FUNCTION itemCost(pItemid INTEGER,
+                                    pCustid INTEGER,
+                                    pShiptoid INTEGER,
+                                    pQty NUMERIC,
+                                    pQtyUOM INTEGER,
+                                    pPriceUOM INTEGER,
+                                    pCurrid INTEGER,
+                                    pEffective DATE,
+                                    pAsOf DATE,
+                                    pSiteid INTEGER) RETURNS NUMERIC STABLE 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.
+--
+-- Overload for future costing enhancements
+--
+DECLARE
+  _cost NUMERIC := 0.0;
+BEGIN
+  SELECT itemcost(itemsite_id) INTO _cost
+  FROM itemsite
+  WHERE (itemsite_item_id=pItemid)
+    AND (itemsite_warehous_id=pSiteid);
+
+  RETURN _cost;
+END;
+$$ LANGUAGE 'plpgsql';
+
+CREATE OR REPLACE FUNCTION itemCost(pItemsiteid INTEGER) RETURNS NUMERIC STABLE 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;
   _cost NUMERIC;
 BEGIN
   SELECT CASE WHEN (itemsite_costmethod='A' AND itemsite_qtyonhand != 0.0) THEN (itemsite_value / itemsite_qtyonhand)
@@ -15,4 +41,3 @@ BEGIN
   RETURN _cost;
 END;
 $$ LANGUAGE 'plpgsql';
-