From 61521abcdc794a08848e454b70c5959f914de7dc Mon Sep 17 00:00:00 2001 From: garyhgohoos Date: Thu, 22 May 2014 10:19:22 -0400 Subject: [PATCH] Issue #23666:incorporate item_listcost --- foundation-database/public/functions/itemcost.sql | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/foundation-database/public/functions/itemcost.sql b/foundation-database/public/functions/itemcost.sql index d9d43d6a5..0d7530517 100644 --- a/foundation-database/public/functions/itemcost.sql +++ b/foundation-database/public/functions/itemcost.sql @@ -16,10 +16,16 @@ CREATE OR REPLACE FUNCTION itemCost(pItemid INTEGER, DECLARE _cost NUMERIC := 0.0; BEGIN - SELECT itemcost(itemsite_id) INTO _cost - FROM itemsite - WHERE (itemsite_item_id=pItemid) - AND (itemsite_warehous_id=pSiteid); + IF (fetchMetricBool('WholesalePriceCosting')) THEN + SELECT item_listcost INTO _cost + FROM item + WHERE (item_id=pItemid); + ELSE + SELECT itemcost(itemsite_id) INTO _cost + FROM itemsite + WHERE (itemsite_item_id=pItemid) + AND (itemsite_warehous_id=pSiteid); + END IF; RETURN _cost; END; -- 2.39.2