From 7309c8368f158c25874c600a5f8a18e20bf8ce4f Mon Sep 17 00:00:00 2001 From: Greg Pazo Date: Sat, 12 Apr 2014 00:02:38 -0400 Subject: [PATCH] spa pricing --- .../public/functions/itemcost.sql | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/foundation-database/public/functions/itemcost.sql b/foundation-database/public/functions/itemcost.sql index 6625b7c1d..d9d43d6a5 100644 --- a/foundation-database/public/functions/itemcost.sql +++ b/foundation-database/public/functions/itemcost.sql @@ -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'; - -- 2.39.2