diff --git a/db/ddlutils/oracle/build-ddl.xml b/db/ddlutils/oracle/build-ddl.xml index 8bf269bfbe..eccad4b03b 100644 --- a/db/ddlutils/oracle/build-ddl.xml +++ b/db/ddlutils/oracle/build-ddl.xml @@ -45,8 +45,8 @@ - - + + @@ -56,8 +56,8 @@ - - + + @@ -67,8 +67,8 @@ - - + + @@ -91,13 +91,39 @@ + + + + + + + + + + + + + + + - + + + + + + + + + + + + diff --git a/db/ddlutils/oracle/build.xml b/db/ddlutils/oracle/build.xml index 3fd7768fab..122c2f1a7f 100644 --- a/db/ddlutils/oracle/build.xml +++ b/db/ddlutils/oracle/build.xml @@ -33,23 +33,18 @@ - - - + - - - - - - - + + + + @@ -62,11 +57,6 @@ - - - - - @@ -75,7 +65,7 @@ - + @@ -84,6 +74,15 @@ + + + + + + + + + diff --git a/db/ddlutils/oracle/functions-decl.sql b/db/ddlutils/oracle/functions-decl.sql new file mode 100644 index 0000000000..d50194dbfa --- /dev/null +++ b/db/ddlutils/oracle/functions-decl.sql @@ -0,0 +1,283 @@ +CREATE OR REPLACE FUNCTION acctBalance +( + p_Account_ID IN NUMBER, + p_AmtDr IN NUMBER, + p_AmtCr IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETUNR 0; +END; +/ + +CREATE OR REPLACE FUNCTION bomPriceLimit +( + Product_ID IN NUMBER, + PriceList_Version_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION bomPriceList +( + Product_ID IN NUMBER, + PriceList_Version_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION bomPriceStd +( + Product_ID IN NUMBER, + PriceList_Version_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION bomQtyAvailable +( + Product_ID IN NUMBER, + Warehouse_ID IN NUMBER, + Locator_ID IN NUMBER -- Only used, if warehouse is null +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION bomQtyOnHand +( + Product_ID IN NUMBER, + Warehouse_ID IN NUMBER, + Locator_ID IN NUMBER -- Only used, if warehouse is null +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION bomQtyOrdered +( + p_Product_ID IN NUMBER, + p_Warehouse_ID IN NUMBER, + p_Locator_ID IN NUMBER -- Only used, if warehouse is null +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION bomQtyReserved +( + p_Product_ID IN NUMBER, + p_Warehouse_ID IN NUMBER, + p_Locator_ID IN NUMBER -- Only used, if warehouse is null +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION currencyBase +( + p_Amount IN NUMBER, + p_CurFrom_ID IN NUMBER, + p_ConvDate IN DATE, + p_Client_ID IN NUMBER, + p_Org_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION bpartnerRemitLocation +( + p_C_BPartner_ID C_BPartner.C_BPartner_ID%TYPE +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION currencyConvert +( + p_Amount IN NUMBER, + p_CurFrom_ID IN NUMBER, + p_CurTo_ID IN NUMBER, + p_ConvDate IN DATE, + p_ConversionType_ID IN NUMBER, + p_Client_ID IN NUMBER, + p_Org_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION currencyRate +( + p_CurFrom_ID IN NUMBER, + p_CurTo_ID IN NUMBER, + p_ConvDate IN DATE, + p_ConversionType_ID IN NUMBER, + p_Client_ID IN NUMBER, + p_Org_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION currencyRound +( + p_Amount IN NUMBER, + p_CurTo_ID IN NUMBER, + p_Costing IN VARCHAR2 -- Default 'N' +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION invoiceDiscount +( + p_C_Invoice_ID IN NUMBER, + p_PayDate IN DATE, + p_C_InvoicePaySchedule_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION invoiceOpen +( + p_C_Invoice_ID IN NUMBER, + p_C_InvoicePaySchedule_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION invoicePaid +( + p_C_Invoice_ID IN NUMBER, + p_C_Currency_ID IN NUMBER, + p_MultiplierAP IN NUMBER -- DEFAULT 1 +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION paymentAllocated +( + p_C_Payment_ID IN NUMBER, + p_C_Currency_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION paymentAvailable +( + p_C_Payment_ID IN NUMBER +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION paymentTermDiscount +( + Amount IN NUMBER, + Currency_ID IN NUMBER, + PaymentTerm_ID IN NUMBER, + DocDate IN DATE, + PayDate IN DATE +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION paymentTermDueDate +( + PaymentTerm_ID IN NUMBER, + DocDate IN DATE +) +RETURN DATE AS +BEGIN + RETURN NULL; +END; +/ + +CREATE OR REPLACE FUNCTION paymentTermDueDays +( + PaymentTerm_ID IN NUMBER, + DocDate IN DATE, + PayDate IN DATE +) +RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +CREATE OR REPLACE FUNCTION DBA_ConstraintCmd +( + p_ConstraintName IN VARCHAR2 +) +RETURN VARCHAR2 AS +BEGIN + RETURN NULL; +END; +/ + +CREATE OR REPLACE FUNCTION DBA_DisplayType +( + AD_Reference_ID IN NUMBER +) +RETURN VARCHAR2 AS +BEGIN + RETURN NULL; +END; +/ + +CREATE OR REPLACE FUNCTION productAttribute +( + p_M_AttributeSetInstance_ID IN NUMBER +) +RETURN VARCHAR2 AS +BEGIN + RETURN NULL; +END; +/ + diff --git a/db/ddlutils/oracle/procedures/M_PriceList_Create.sql b/db/ddlutils/oracle/procedures/M_PriceList_Create.sql index 5c18436699..d343b3e749 100644 --- a/db/ddlutils/oracle/procedures/M_PriceList_Create.sql +++ b/db/ddlutils/oracle/procedures/M_PriceList_Create.sql @@ -4,10 +4,10 @@ CREATE OR REPLACE PROCEDURE M_PriceList_Create ) AS /************************************************************************* - * The contents of this file are subject to the Adempiere License. You may - * obtain a copy of the License at http://www.adempiere.org/license.html + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either - * express or implied. See the License for details. Code: Adempiere ERP+CRM + * express or implied. See the License for details. Code: Compiere ERP+CRM * Copyright (C) 1999-2003 Jorg Janke, ComPiere, Inc. All Rights Reserved. ************************************************************************* * $Id: M_PriceList_Create.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $ @@ -16,6 +16,7 @@ AS * Description: * Create PriceList by copying purchase prices (M_Product_PO) * and applying product category discounts (M_CategoryDiscount) + * Carlos Ruiz - globalqss - Make T_Selection tables permanent ************************************************************************/ -- Logistice ResultStr VARCHAR2(2000); @@ -173,15 +174,15 @@ BEGIN -- DBMS_OUTPUT.PUT_LINE(ResultStr); -- Clear Temporary Table - DELETE FROM T_Selection; + DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID; -- ----------------------------------- -- Create Selection in temporary table -- ----------------------------------- IF (v_PriceList_Version_Base_ID IS NULL) THEN -- Create Selection from M_Product_PO - INSERT INTO T_Selection (T_Selection_ID) - SELECT DISTINCT po.M_Product_ID + INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) + SELECT DISTINCT PInstance_ID, po.M_Product_ID FROM M_Product p, M_Product_PO po WHERE p.M_Product_ID=po.M_Product_ID AND (p.AD_Client_ID=v_Client_ID OR p.AD_Client_ID=0) @@ -192,8 +193,8 @@ BEGIN AND (dl.M_Product_ID IS NULL OR p.M_Product_ID=dl.M_Product_ID); ELSE -- Create Selection from existing PriceList - INSERT INTO T_Selection (T_Selection_ID) - SELECT DISTINCT p.M_Product_ID + INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) + SELECT DISTINCT PInstance_ID, p.M_Product_ID FROM M_Product p, M_ProductPrice pp WHERE p.M_Product_ID=pp.M_Product_ID AND pp.M_PriceList_Version_ID=v_PriceList_Version_Base_ID @@ -213,7 +214,8 @@ BEGIN ResultStr := ResultStr || ', Delete'; DELETE M_ProductPrice pp WHERE pp.M_PriceList_Version_ID = p_PriceList_Version_ID - AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID); + AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID + AND s.AD_PInstance_ID = PInstance_ID); Message := ', @Deleted@=' || SQL%ROWCOUNT; END IF; @@ -243,7 +245,8 @@ BEGIN COALESCE(currencyConvert(po.PricePO, po.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0) FROM M_Product_PO po - WHERE EXISTS (SELECT * FROM T_Selection s WHERE po.M_Product_ID=s.T_Selection_ID) + WHERE EXISTS (SELECT * FROM T_Selection s WHERE po.M_Product_ID=s.T_Selection_ID + AND s.AD_PInstance_ID = PInstance_ID) AND po.IsCurrentVendor='Y' AND po.IsActive='Y'; ELSE -- Copy and Convert from other PriceList_Version @@ -268,7 +271,8 @@ BEGIN INNER JOIN M_PriceList_Version plv ON (pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID) INNER JOIN M_PriceList pl ON (plv.M_PriceList_ID=pl.M_PriceList_ID) WHERE pp.M_PriceList_Version_ID=v_PriceList_Version_Base_ID - AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID) + AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID + AND s.AD_PInstance_ID = PInstance_ID) AND pp.IsActive='Y'; END IF; Message := Message || ', @Inserted@=' || SQL%ROWCOUNT; @@ -286,7 +290,8 @@ BEGIN + dl.Limit_AddAmt) * (1 - dl.Limit_Discount/100) WHERE M_PriceList_Version_ID=p_PriceList_Version_ID AND EXISTS (SELECT * FROM T_Selection s - WHERE s.T_Selection_ID=p.M_Product_ID); + WHERE s.T_Selection_ID=p.M_Product_ID + AND s.AD_PInstance_ID = PInstance_ID); -- -------- -- Rounding (AD_Reference_ID=155) @@ -319,7 +324,8 @@ BEGIN ROUND(PriceLimit, v_StdPrecision))-- Currency WHERE M_PriceList_Version_ID=p_PriceList_Version_ID AND EXISTS (SELECT * FROM T_Selection s - WHERE s.T_Selection_ID=p.M_Product_ID); + WHERE s.T_Selection_ID=p.M_Product_ID + AND s.AD_PInstance_ID = PInstance_ID); Message := Message || ', @Updated@=' || SQL%ROWCOUNT; -- Fixed Price overwrite @@ -330,7 +336,8 @@ BEGIN PriceLimit = DECODE(dl.Limit_Base, 'F', dl.Limit_Fixed, PriceLimit) WHERE M_PriceList_Version_ID=p_PriceList_Version_ID AND EXISTS (SELECT * FROM T_Selection s - WHERE s.T_Selection_ID=p.M_Product_ID); + WHERE s.T_Selection_ID=p.M_Product_ID + AND s.AD_PInstance_ID = PInstance_ID); -- Log Info INSERT INTO AD_PInstance_Log (AD_PInstance_ID, Log_ID, P_ID, P_NUMBER, P_MSG) @@ -341,7 +348,7 @@ BEGIN END LOOP; -- For all DiscountLines -- Delete Temporary Selection - DELETE FROM T_Selection; + DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID; <> @@ -371,4 +378,4 @@ EXCEPTION RETURN; END M_PriceList_Create; -/ +/ \ No newline at end of file diff --git a/db/ddlutils/oracle/procedures/M_Product_BOM_Check.sql b/db/ddlutils/oracle/procedures/M_Product_BOM_Check.sql index 94c845e410..d91a117fed 100644 --- a/db/ddlutils/oracle/procedures/M_Product_BOM_Check.sql +++ b/db/ddlutils/oracle/procedures/M_Product_BOM_Check.sql @@ -3,10 +3,10 @@ CREATE OR REPLACE PROCEDURE M_Product_BOM_Check PInstance_ID IN NUMBER ) /************************************************************************* - * The contents of this file are subject to the Adempiere License. You may - * obtain a copy of the License at http://www.adempiere.org/license.html + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either - * express or implied. See the License for details. Code: Adempiere ERP+CRM + * express or implied. See the License for details. Code: Compiere ERP+CRM * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. ************************************************************************* * $Id: M_Product_BOM_Check.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $ @@ -66,43 +66,44 @@ BEGIN -- Checking BOM Structure ResultStr := 'InsertingRoot'; -- Table to put all BOMs - duplicate will cause exception - DELETE FROM T_Selection2 WHERE Query_ID = 0; - INSERT INTO T_Selection2 (Query_ID, T_Selection_ID) VALUES (0, Record_ID); + DELETE FROM T_Selection2 WHERE Query_ID = 0 AND AD_PInstance_ID = PInstance_ID; + INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) VALUES (PInstance_ID, 0, Record_ID); -- Table of root modes - DELETE FROM T_Selection; - INSERT INTO T_Selection (T_Selection_ID) VALUES (Record_ID); + DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID; + INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) VALUES (PInstance_ID, Record_ID); LOOP -- How many do we have? SELECT COUNT(*) INTO CountNo - FROM T_Selection; + FROM T_Selection + WHERE AD_PInstance_ID = PInstance_ID; -- Nothing to do EXIT WHEN (CountNo = 0); -- Insert BOM Nodes into "All" table - INSERT INTO T_Selection2 (Query_ID, T_Selection_ID) - SELECT 0, p.M_Product_ID + INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) + SELECT PInstance_ID, 0, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS (SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID - AND b.M_Product_ID IN (SELECT T_Selection_ID FROM T_Selection)); + AND b.M_Product_ID IN (SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID)); -- Insert BOM Nodes into temporary table - DELETE FROM T_Selection2 WHERE Query_ID = 1; - INSERT INTO T_Selection2 (Query_ID, T_Selection_ID) - SELECT 1, p.M_Product_ID + DELETE FROM T_Selection2 WHERE Query_ID = 1 AND AD_PInstance_ID = PInstance_ID; + INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) + SELECT PInstance_ID, 1, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS (SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID - AND b.M_Product_ID IN (SELECT T_Selection_ID FROM T_Selection)); + AND b.M_Product_ID IN (SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID)); -- Copy into root table - DELETE FROM T_Selection; - INSERT INTO T_Selection (T_Selection_ID) - SELECT T_Selection_ID + DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID; + INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) + SELECT PInstance_ID, T_Selection_ID FROM T_Selection2 - WHERE Query_ID = 1; + WHERE Query_ID = 1 AND AD_PInstance_ID = PInstance_ID; END LOOP; @@ -144,4 +145,4 @@ EXCEPTION RETURN; END M_Product_BOM_Check; -/ +/ \ No newline at end of file diff --git a/db/ddlutils/oracle/temptables.sql b/db/ddlutils/oracle/temptables.sql deleted file mode 100644 index 1b3718755f..0000000000 --- a/db/ddlutils/oracle/temptables.sql +++ /dev/null @@ -1,20 +0,0 @@ -DROP TABLE T_Selection CASCADE CONSTRAINTS; - -CREATE GLOBAL TEMPORARY TABLE T_Selection -( - T_Selection_ID NUMBER(10, 0) NOT NULL - CONSTRAINT T_Selection_Key PRIMARY KEY -) -ON COMMIT DELETE ROWS; - - -DROP TABLE T_Selection2; - -CREATE GLOBAL TEMPORARY TABLE T_Selection2 -( - Query_ID NUMBER NOT NULL, - T_Selection_ID NUMBER(10) NOT NULL, - CONSTRAINT T_Selection2_Key PRIMARY KEY (Query_ID,T_Selection_ID) -) -ON COMMIT PRESERVE ROWS; -