1 CREATE OR REPLACE FUNCTION itemCost(pItemid INTEGER,
10 pSiteid INTEGER) RETURNS NUMERIC STABLE AS $$
11 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
12 -- See www.xtuple.com/CPAL for the full text of the software license.
14 -- Overload for future costing enhancements
19 SELECT itemcost(itemsite_id) INTO _cost
21 WHERE (itemsite_item_id=pItemid)
22 AND (itemsite_warehous_id=pSiteid);
26 $$ LANGUAGE 'plpgsql';
28 CREATE OR REPLACE FUNCTION itemCost(pItemsiteid INTEGER) RETURNS NUMERIC STABLE AS $$
29 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
30 -- See www.xtuple.com/CPAL for the full text of the software license.
34 SELECT CASE WHEN (itemsite_costmethod='A' AND itemsite_qtyonhand != 0.0) THEN (itemsite_value / itemsite_qtyonhand)
35 WHEN (itemsite_costmethod='A' AND itemsite_qtyonhand = 0.0) THEN 0.0
36 WHEN (itemsite_costmethod='N') THEN 0.0
37 ELSE stdCost(itemsite_item_id)
40 WHERE(itemsite_id=pItemsiteid);
43 $$ LANGUAGE 'plpgsql';