[ 1780765 ] MProductPricing.calculatePL
This commit is contained in:
parent
f30db41702
commit
7bbcd19503
|
@ -23,21 +23,19 @@
|
||||||
/*
|
/*
|
||||||
* Loops recursively through BOM and returns BOM's total limit price.
|
* Loops recursively through BOM and returns BOM's total limit price.
|
||||||
*/
|
*/
|
||||||
CREATE OR REPLACE FUNCTION bompricelimit(
|
CREATE OR REPLACE FUNCTION bompricelimit("numeric", "numeric")
|
||||||
IN NUMERIC, -- $1 product id
|
RETURNS "numeric" AS
|
||||||
IN NUMERIC -- $2 pricelist version id
|
$BODY$
|
||||||
) RETURNS NUMERIC AS
|
|
||||||
$$
|
|
||||||
DECLARE
|
DECLARE
|
||||||
price NUMERIC;
|
price NUMERIC;
|
||||||
productprice NUMERIC;
|
productprice NUMERIC;
|
||||||
boms RECORD;
|
boms RECORD;
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT COALESCE(t.PriceLimit,0) INTO price FROM m_productprice as t
|
SELECT COALESCE(t.PriceLimit,0) INTO price FROM m_productprice t
|
||||||
WHERE t.m_pricelist_version_id = $2 AND t.m_product_id = $1;
|
WHERE t.m_pricelist_version_id = $2 AND t.m_product_id = $1;
|
||||||
IF price = 0 THEN
|
IF price = 0 THEN
|
||||||
FOR boms IN SELECT t.m_productbom_id, t.bomqty
|
FOR boms IN SELECT t.m_productbom_id, t.bomqty
|
||||||
FROM t.m_product_bom
|
FROM m_product_bom t
|
||||||
WHERE t.m_product_id = $1
|
WHERE t.m_product_id = $1
|
||||||
LOOP
|
LOOP
|
||||||
productprice := bompricelimit(boms.m_productbom_id, $2);
|
productprice := bompricelimit(boms.m_productbom_id, $2);
|
||||||
|
@ -46,4 +44,5 @@ $$
|
||||||
END IF;
|
END IF;
|
||||||
return price;
|
return price;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql STABLE STRICT;
|
$BODY$
|
||||||
|
LANGUAGE 'plpgsql' STABLE STRICT;
|
||||||
|
|
Loading…
Reference in New Issue