From 385cbd1cf4c2d1216ecca9253babc42561d381ee Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Thu, 30 Oct 2008 01:21:21 +0000 Subject: [PATCH] delete old function --- .../functions/Bom_Qty_Available.sql | 34 --------- .../postgresql/functions/Bom_Qty_OnHand.sql | 74 ------------------- .../postgresql/functions/Bom_Qty_Ordered.sql | 74 ------------------- .../postgresql/functions/Bom_Qty_Reserved.sql | 74 ------------------- 4 files changed, 256 deletions(-) delete mode 100644 db/ddlutils/postgresql/functions/Bom_Qty_Available.sql delete mode 100644 db/ddlutils/postgresql/functions/Bom_Qty_OnHand.sql delete mode 100644 db/ddlutils/postgresql/functions/Bom_Qty_Ordered.sql delete mode 100644 db/ddlutils/postgresql/functions/Bom_Qty_Reserved.sql diff --git a/db/ddlutils/postgresql/functions/Bom_Qty_Available.sql b/db/ddlutils/postgresql/functions/Bom_Qty_Available.sql deleted file mode 100644 index fd8af3d7ad..0000000000 --- a/db/ddlutils/postgresql/functions/Bom_Qty_Available.sql +++ /dev/null @@ -1,34 +0,0 @@ -/* - *This file is part of Adempiere ERP Bazaar - *http://www.adempiere.org - * - *Copyright (C) 2006 Timo Kontro - *Copyright (C) 1999-2006 ComPiere, inc - * - *This program is free software; you can redistribute it and/or - *modify it under the terms of the GNU General Public License - *as published by the Free Software Foundation; either version 2 - *of the License, or (at your option) any later version. - * - *This program is distributed in the hope that it will be useful, - *but WITHOUT ANY WARRANTY; without even the implied warranty of - *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *GNU General Public License for more details. - * - *You should have received a copy of the GNU General Public License - *along with this program; if not, write to the Free Software - *Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.of - */ - -SET search_path = adempiere, pg_catalog; - -CREATE OR REPLACE FUNCTION bomqtyavailable( - IN INTEGER, -- $1 product id - IN INTEGER, -- $2 warehouse id - IN INTEGER -- $3 locator id -) RETURNS NUMERIC AS -$$ - BEGIN - RETURN (bomqtyonhand($1,$2,$3) - bomqtyreserved($1,$2,$3)); - END; -$$ LANGUAGE plpgsql; diff --git a/db/ddlutils/postgresql/functions/Bom_Qty_OnHand.sql b/db/ddlutils/postgresql/functions/Bom_Qty_OnHand.sql deleted file mode 100644 index abf0e342ab..0000000000 --- a/db/ddlutils/postgresql/functions/Bom_Qty_OnHand.sql +++ /dev/null @@ -1,74 +0,0 @@ -/* - *This file is part of Adempiere ERP Bazaar - *http://www.adempiere.org - * - *Copyright (C) 2006 Timo Kontro - *Copyright (C) 1999-2006 ComPiere, inc - * - *This program is free software; you can redistribute it and/or - *modify it under the terms of the GNU General Public License - *as published by the Free Software Foundation; either version 2 - *of the License, or (at your option) any later version. - * - *This program is distributed in the hope that it will be useful, - *but WITHOUT ANY WARRANTY; without even the implied warranty of - *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *GNU General Public License for more details. - * - *You should have received a copy of the GNU General Public License - *along with this program; if not, write to the Free Software - *Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.of - */ - -SET search_path = adempiere, pg_catalog; - -CREATE OR REPLACE FUNCTION bomqtyonhand( - IN INTEGER, -- $1 product id - IN INTEGER, -- $2 warehouse id - IN INTEGER -- $3 locator id -) RETURNS NUMERIC AS -$$ - DECLARE - warehouse_id INTEGER; - isbom BOOLEAN; - isstocked BOOLEAN; - ptype CHAR(1); - bom RECORD; - qty NUMERIC; - quantity NUMERIC; - precision INTEGER; - BEGIN - quantity := 99999; - SELECT (t.isbom = 'Y'), t.producttype, (t.isstocked = 'Y') - INTO isbom, ptype, isstocked FROM m_product AS t - WHERE t.m_product_id = $1; - IF ptype = "I" AND isstocked THEN - IF COALESCE($3, 0) <> 0 THEN - SELECT t.qtyonhand INTO qty FROM m_storage t - WHERE m_product_id = $1 AND t.m_locator_id= $3; - quantity := COALESCE(qty,0); - ELSIF COALESCE($2, 0) <> 0 THEN - SELECT t.qtyonhand INTO qty FROM m_storage t - WHERE m_product_id = $1 AND EXISTS ( - SELECT * FROM m_locator l WHERE t.m_locator_id = l.m_locator_id - AND l.m_warehouse_id = $2); - quantity := COALESCE(qty,0); - END IF; - ELSIF isbom THEN - FOR bom IN SELECT b.m_productbom_id, b.bomqty, p.isbom, p.isstocked, - p.producttype FROM m_product_bom b, m_product p - WHERE b.m_productbom_id=p.m_product_id AND b.m_product_id = $1 - LOOP - qty = bomqtyonhand(bom.m_productbom_id, warehouse_id, $3); - SELECT t.stdprecision INTO precision - FROM c_uom t INNER JOIN m_product p - ON t.c_uom_id = p.c_uom_id - WHERE p.m_product_id = bom.m_productbom_id; - qty := ROUND((qty/bom.bomqty),precision); - quantity := LEAST(qty, quantity); - END LOOP; - END IF; - - RETURN quantity; - END; -$$ LANGUAGE plpgsql; diff --git a/db/ddlutils/postgresql/functions/Bom_Qty_Ordered.sql b/db/ddlutils/postgresql/functions/Bom_Qty_Ordered.sql deleted file mode 100644 index 22d3763223..0000000000 --- a/db/ddlutils/postgresql/functions/Bom_Qty_Ordered.sql +++ /dev/null @@ -1,74 +0,0 @@ -/* - *This file is part of Adempiere ERP Bazaar - *http://www.adempiere.org - * - *Copyright (C) 2006 Timo Kontro - *Copyright (C) 1999-2006 ComPiere, inc - * - *This program is free software; you can redistribute it and/or - *modify it under the terms of the GNU General Public License - *as published by the Free Software Foundation; either version 2 - *of the License, or (at your option) any later version. - * - *This program is distributed in the hope that it will be useful, - *but WITHOUT ANY WARRANTY; without even the implied warranty of - *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *GNU General Public License for more details. - * - *You should have received a copy of the GNU General Public License - *along with this program; if not, write to the Free Software - *Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.of - */ - -SET search_path = adempiere, pg_catalog; - -CREATE OR REPLACE FUNCTION bomqtyordered( - IN INTEGER, -- $1 product id - IN INTEGER, -- $2 warehouse id - IN INTEGER -- $3 locator id -) RETURNS NUMERIC AS -$$ - DECLARE - warehouse_id INTEGER; - isbom BOOLEAN; - isstocked BOOLEAN; - ptype CHAR(1); - bom RECORD; - qty NUMERIC; - quantity NUMERIC; - precision INTEGER; - BEGIN - quantity := 99999; - SELECT (t.isbom = 'Y'), t.producttype, (t.isstocked = 'Y') - INTO isbom, ptype, isstocked FROM m_product AS t - WHERE t.m_product_id = $1; - IF ptype = "I" AND isstocked THEN - IF COALESCE($3, 0) <> 0 THEN - SELECT t.qtyordered INTO qty FROM m_storage t - WHERE m_product_id = $1 AND t.m_locator_id= $3; - quantity := COALESCE(qty,0); - ELSIF COALESCE($2, 0) <> 0 THEN - SELECT t.qtyordered INTO qty FROM m_storage t - WHERE m_product_id = $1 AND EXISTS ( - SELECT * FROM m_locator l WHERE t.m_locator_id = l.m_locator_id - AND l.m_warehouse_id = $2); - quantity := COALESCE(qty,0); - END IF; - ELSIF isbom THEN - FOR bom IN SELECT b.m_productbom_id, b.bomqty, p.isbom, p.isstocked, - p.producttype FROM m_product_bom b, m_product p - WHERE b.m_productbom_id=p.m_product_id AND b.m_product_id = $1 - LOOP - qty = bomqtyordered(bom.m_productbom_id, warehouse_id, $3); - SELECT t.stdprecision INTO precision - FROM c_uom t INNER JOIN m_product p - ON t.c_uom_id = p.c_uom_id - WHERE p.m_product_id = bom.m_productbom_id; - qty := ROUND((qty/bom.bomqty),precision); - quantity := LEAST(qty, quantity); - END LOOP; - END IF; - - RETURN quantity; - END; -$$ LANGUAGE plpgsql; diff --git a/db/ddlutils/postgresql/functions/Bom_Qty_Reserved.sql b/db/ddlutils/postgresql/functions/Bom_Qty_Reserved.sql deleted file mode 100644 index effec1fb18..0000000000 --- a/db/ddlutils/postgresql/functions/Bom_Qty_Reserved.sql +++ /dev/null @@ -1,74 +0,0 @@ -/* - *This file is part of Adempiere ERP Bazaar - *http://www.adempiere.org - * - *Copyright (C) 2006 Timo Kontro - *Copyright (C) 1999-2006 ComPiere, inc - * - *This program is free software; you can redistribute it and/or - *modify it under the terms of the GNU General Public License - *as published by the Free Software Foundation; either version 2 - *of the License, or (at your option) any later version. - * - *This program is distributed in the hope that it will be useful, - *but WITHOUT ANY WARRANTY; without even the implied warranty of - *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *GNU General Public License for more details. - * - *You should have received a copy of the GNU General Public License - *along with this program; if not, write to the Free Software - *Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.of - */ - -SET search_path = adempiere, pg_catalog; - -CREATE OR REPLACE FUNCTION bomqtyreserved( - IN INTEGER, -- $1 product id - IN INTEGER, -- $2 warehouse id - IN INTEGER -- $3 locator id -) RETURNS NUMERIC AS -$$ - DECLARE - warehouse_id INTEGER; - isbom BOOLEAN; - isstocked BOOLEAN; - ptype CHAR(1); - bom RECORD; - qty NUMERIC; - quantity NUMERIC; - precision INTEGER; - BEGIN - quantity := 99999; - SELECT (t.isbom = 'Y'), t.producttype, (t.isstocked = 'Y') - INTO isbom, ptype, isstocked FROM m_product AS t - WHERE t.m_product_id = $1; - IF ptype = "I" AND isstocked THEN - IF COALESCE($3, 0) <> 0 THEN - SELECT t.qtyreserved INTO qty FROM m_storage t - WHERE m_product_id = $1 AND t.m_locator_id= $3; - quantity := COALESCE(qty,0); - ELSIF COALESCE($2, 0) <> 0 THEN - SELECT t.qtyreserved INTO qty FROM m_storage t - WHERE m_product_id = $1 AND EXISTS ( - SELECT * FROM m_locator l WHERE t.m_locator_id = l.m_locator_id - AND l.m_warehouse_id = $2); - quantity := COALESCE(qty,0); - END IF; - ELSIF isbom THEN - FOR bom IN SELECT b.m_productbom_id, b.bomqty, p.isbom, p.isstocked, - p.producttype FROM m_product_bom b, m_product p - WHERE b.m_productbom_id=p.m_product_id AND b.m_product_id = $1 - LOOP - qty = bomqtyreserved(bom.m_productbom_id, warehouse_id, $3); - SELECT t.stdprecision INTO precision - FROM c_uom t INNER JOIN m_product p - ON t.c_uom_id = p.c_uom_id - WHERE p.m_product_id = bom.m_productbom_id; - qty := ROUND((qty/bom.bomqty),precision); - quantity := LEAST(qty, quantity); - END LOOP; - END IF; - - RETURN quantity; - END; -$$ LANGUAGE plpgsql;