Work in progress - preparing release 3.5.1
Fix [ 1974314 ] Difference in oracle and postgres seeds
This commit is contained in:
parent
ee89bad80b
commit
461d04ce46
|
@ -1,92 +0,0 @@
|
||||||
CREATE OR REPLACE PROCEDURE AD_PrintPaper_Default
|
|
||||||
(
|
|
||||||
p_AD_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
|
|
||||||
* 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
|
|
||||||
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
|
|
||||||
*************************************************************************
|
|
||||||
* $Id: AD_PrintPaper_Default.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
|
|
||||||
***
|
|
||||||
* Title: Set Current Format as Default
|
|
||||||
* Description:
|
|
||||||
************************************************************************/
|
|
||||||
AS
|
|
||||||
-- Logistice
|
|
||||||
v_ResultStr VARCHAR2(2000);
|
|
||||||
v_Message VARCHAR2(2000);
|
|
||||||
p_Record_ID NUMBER;
|
|
||||||
-- Parameter
|
|
||||||
CURSOR Cur_Parameter (PInstance NUMBER) IS
|
|
||||||
SELECT i.Record_ID, p.ParameterName, p.P_String, p.P_Number, p.P_Date
|
|
||||||
FROM AD_PInstance i, AD_PInstance_Para p
|
|
||||||
WHERE i.AD_PInstance_ID=PInstance
|
|
||||||
AND i.AD_PInstance_ID=p.AD_PInstance_ID(+)
|
|
||||||
ORDER BY p.SeqNo;
|
|
||||||
-- Parameter Variables
|
|
||||||
p_AD_Client_ID NUMBER := NULL;
|
|
||||||
|
|
||||||
BEGIN
|
|
||||||
-- Update AD_PInstance
|
|
||||||
DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_AD_PInstance_ID);
|
|
||||||
v_ResultStr := 'PInstanceNotFound';
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Created = SysDate,
|
|
||||||
IsProcessing = 'Y'
|
|
||||||
WHERE AD_PInstance_ID=p_AD_PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
-- Get Parameters
|
|
||||||
v_ResultStr := 'ReadingParameters';
|
|
||||||
FOR p IN Cur_Parameter (p_AD_PInstance_ID) LOOP
|
|
||||||
p_Record_ID := p.Record_ID;
|
|
||||||
IF (p.ParameterName = 'AD_Client_ID') THEN
|
|
||||||
p_AD_Client_ID := p.P_Number;
|
|
||||||
DBMS_OUTPUT.PUT_LINE(' AD_Client_ID=' || p_AD_Client_ID);
|
|
||||||
ELSE
|
|
||||||
DBMS_OUTPUT.PUT_LINE('*** Unknown Parameter=' || p.ParameterName);
|
|
||||||
END IF;
|
|
||||||
END LOOP; -- Get Parameter
|
|
||||||
DBMS_OUTPUT.PUT_LINE(' Record_ID=' || p_Record_ID);
|
|
||||||
|
|
||||||
|
|
||||||
v_ResultStr := 'Updating';
|
|
||||||
UPDATE AD_PrintFormat pf
|
|
||||||
SET AD_PrintPaper_ID = p_Record_ID
|
|
||||||
WHERE (AD_Client_ID = p_AD_Client_ID OR p_AD_Client_ID IS NULL)
|
|
||||||
AND EXISTS (SELECT * FROM AD_PrintPaper pp
|
|
||||||
WHERE pf.AD_PrintPaper_ID=pp.AD_PrintPaper_ID
|
|
||||||
AND IsLandscape = (SELECT IsLandscape FROM AD_PrintPaper
|
|
||||||
WHERE AD_PrintPaper_ID=p_Record_ID));
|
|
||||||
v_Message := '@Copied@=' || SQL%ROWCOUNT;
|
|
||||||
|
|
||||||
<<FINISH_PROCESS>>
|
|
||||||
-- Update AD_PInstance
|
|
||||||
DBMS_OUTPUT.PUT_LINE('Updating PInstance - Finished ' || v_Message);
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Updated = SysDate,
|
|
||||||
IsProcessing = 'N',
|
|
||||||
Result = 1, -- success
|
|
||||||
ErrorMsg = v_Message
|
|
||||||
WHERE AD_PInstance_ID=p_AD_PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
RETURN;
|
|
||||||
|
|
||||||
EXCEPTION
|
|
||||||
WHEN OTHERS THEN
|
|
||||||
v_ResultStr := v_ResultStr || ': ' || SQLERRM || ' - ' || v_Message;
|
|
||||||
DBMS_OUTPUT.PUT_LINE(v_ResultStr);
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Updated = SysDate,
|
|
||||||
IsProcessing = 'N',
|
|
||||||
Result = 0, -- failure
|
|
||||||
ErrorMsg = v_ResultStr
|
|
||||||
WHERE AD_PInstance_ID=p_AD_PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
RETURN;
|
|
||||||
|
|
||||||
END AD_PrintPaper_Default;
|
|
||||||
/
|
|
|
@ -1,388 +0,0 @@
|
||||||
CREATE OR REPLACE PROCEDURE M_PriceList_Create
|
|
||||||
(
|
|
||||||
PInstance_ID IN NUMBER
|
|
||||||
)
|
|
||||||
AS
|
|
||||||
/*************************************************************************
|
|
||||||
* 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: 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 $
|
|
||||||
***
|
|
||||||
* Title: Create Pricelist
|
|
||||||
* 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);
|
|
||||||
Message VARCHAR2(2000) := '';
|
|
||||||
NoRate EXCEPTION;
|
|
||||||
-- Parameter
|
|
||||||
CURSOR Cur_Parameter (PInstance NUMBER) IS
|
|
||||||
SELECT i.Record_ID, p.ParameterName, p.P_String, p.P_Number, p.P_Date
|
|
||||||
FROM AD_PInstance i, AD_PInstance_Para p
|
|
||||||
WHERE i.AD_PInstance_ID=PInstance
|
|
||||||
AND i.AD_PInstance_ID=p.AD_PInstance_ID(+)
|
|
||||||
ORDER BY p.SeqNo;
|
|
||||||
-- Parameter Variables
|
|
||||||
p_PriceList_Version_ID NUMBER;
|
|
||||||
p_DeleteOld CHAR(1) := 'N';
|
|
||||||
--
|
|
||||||
v_Currency_ID NUMBER;
|
|
||||||
v_Client_ID NUMBER;
|
|
||||||
v_Org_ID NUMBER;
|
|
||||||
v_UpdatedBy NUMBER;
|
|
||||||
v_StdPrecision NUMBER;
|
|
||||||
v_DiscountSchema_ID NUMBER;
|
|
||||||
v_PriceList_Version_Base_ID NUMBER;
|
|
||||||
--
|
|
||||||
v_NextNo NUMBER := 0;
|
|
||||||
|
|
||||||
-- Get PL Parameter
|
|
||||||
CURSOR Cur_DiscountLine (DiscountSchema_ID NUMBER) IS
|
|
||||||
SELECT *
|
|
||||||
FROM M_DiscountSchemaLine
|
|
||||||
WHERE M_DiscountSchema_ID=DiscountSchema_ID
|
|
||||||
AND IsActive='Y'
|
|
||||||
ORDER BY SeqNo;
|
|
||||||
|
|
||||||
BEGIN
|
|
||||||
-- Update AD_PInstance
|
|
||||||
DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing');
|
|
||||||
ResultStr := 'PInstanceNotFound';
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Created = SysDate,
|
|
||||||
IsProcessing = 'Y'
|
|
||||||
WHERE AD_PInstance_ID=PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
-- Get Parameters
|
|
||||||
ResultStr := 'ReadingParameters';
|
|
||||||
FOR p IN Cur_Parameter (PInstance_ID) LOOP
|
|
||||||
p_PriceList_Version_ID := p.Record_ID;
|
|
||||||
IF (p.ParameterName = 'DeleteOld') THEN
|
|
||||||
p_DeleteOld := p.P_String;
|
|
||||||
DBMS_OUTPUT.PUT_LINE(' DeleteOld=' || p_DeleteOld);
|
|
||||||
ELSE
|
|
||||||
DBMS_OUTPUT.PUT_LINE('*** Unknown Parameter=' || p.ParameterName);
|
|
||||||
END IF;
|
|
||||||
END LOOP; -- Get Parameter
|
|
||||||
DBMS_OUTPUT.PUT_LINE(' PriceList_Version_ID=' || p_PriceList_Version_ID);
|
|
||||||
|
|
||||||
-- Checking Prerequisites
|
|
||||||
-- -- PO Prices must exists
|
|
||||||
ResultStr := 'CorrectingProductPO';
|
|
||||||
DBMS_OUTPUT.PUT_LINE(ResultStr);
|
|
||||||
UPDATE M_Product_PO
|
|
||||||
SET PriceList = 0
|
|
||||||
WHERE PriceList IS NULL;
|
|
||||||
UPDATE M_Product_PO
|
|
||||||
SET PriceLastPO = 0
|
|
||||||
WHERE PriceLastPO IS NULL;
|
|
||||||
UPDATE M_Product_PO
|
|
||||||
SET PricePO = PriceLastPO
|
|
||||||
WHERE (PricePO IS NULL OR PricePO = 0) AND PriceLastPO <> 0;
|
|
||||||
UPDATE M_Product_PO
|
|
||||||
SET PricePO = 0
|
|
||||||
WHERE PricePO IS NULL;
|
|
||||||
-- Set default current vendor
|
|
||||||
UPDATE M_Product_PO p
|
|
||||||
SET IsCurrentVendor = 'Y'
|
|
||||||
WHERE IsCurrentVendor = 'N'
|
|
||||||
AND NOT EXISTS
|
|
||||||
(SELECT pp.M_Product_ID FROM M_Product_PO pp
|
|
||||||
WHERE pp.M_Product_ID=p.M_Product_ID
|
|
||||||
GROUP BY pp.M_Product_ID HAVING COUNT(*) > 1);
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make sure that we have only one active product
|
|
||||||
*/
|
|
||||||
ResultStr := 'CorrectingDuplicates';
|
|
||||||
DBMS_OUTPUT.PUT_LINE(ResultStr);
|
|
||||||
DECLARE
|
|
||||||
-- All duplicate products
|
|
||||||
CURSOR Cur_Duplicates IS
|
|
||||||
SELECT DISTINCT M_Product_ID
|
|
||||||
FROM M_Product_PO po
|
|
||||||
WHERE IsCurrentVendor='Y' AND IsActive='Y'
|
|
||||||
AND EXISTS ( SELECT M_Product_ID FROM M_Product_PO x
|
|
||||||
WHERE x.M_Product_ID=po.M_Product_ID
|
|
||||||
GROUP BY M_Product_ID HAVING COUNT(*) > 1 )
|
|
||||||
ORDER BY 1;
|
|
||||||
-- All vendors of Product - expensive first
|
|
||||||
CURSOR Cur_Vendors (Product_ID NUMBER) IS
|
|
||||||
SELECT M_Product_ID, C_BPartner_ID
|
|
||||||
FROM M_Product_PO
|
|
||||||
WHERE IsCurrentVendor='Y' AND IsActive='Y'
|
|
||||||
AND M_Product_ID=Product_ID
|
|
||||||
ORDER BY PriceList DESC;
|
|
||||||
--
|
|
||||||
Product_ID NUMBER;
|
|
||||||
BPartner_ID NUMBER;
|
|
||||||
BEGIN
|
|
||||||
FOR dupl IN Cur_Duplicates LOOP
|
|
||||||
OPEN Cur_Vendors (dupl.M_Product_ID);
|
|
||||||
FETCH Cur_Vendors INTO Product_ID, BPartner_ID; -- Leave First
|
|
||||||
LOOP
|
|
||||||
FETCH Cur_Vendors INTO Product_ID, BPartner_ID; -- Get Record ID
|
|
||||||
EXIT WHEN Cur_Vendors%NOTFOUND;
|
|
||||||
--
|
|
||||||
DBMS_OUTPUT.PUT_LINE(' Record: ' || Product_ID || ' / ' || BPartner_ID);
|
|
||||||
UPDATE M_Product_PO
|
|
||||||
SET IsCurrentVendor='N'
|
|
||||||
WHERE M_Product_ID=Product_ID AND C_BPartner_ID=BPartner_ID;
|
|
||||||
END LOOP;
|
|
||||||
CLOSE Cur_Vendors;
|
|
||||||
END LOOP;
|
|
||||||
COMMIT;
|
|
||||||
END;
|
|
||||||
|
|
||||||
/** Delete Old Data */
|
|
||||||
ResultStr := 'DeletingOld';
|
|
||||||
IF (p_DeleteOld = 'Y') THEN
|
|
||||||
DELETE M_ProductPrice
|
|
||||||
WHERE M_PriceList_Version_ID = p_PriceList_Version_ID;
|
|
||||||
Message := '@Deleted@=' || SQL%ROWCOUNT || ' - ';
|
|
||||||
DBMS_OUTPUT.PUT_LINE(Message);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- Get PriceList Info
|
|
||||||
ResultStr := 'GetPLInfo';
|
|
||||||
DBMS_OUTPUT.PUT_LINE(ResultStr);
|
|
||||||
SELECT p.C_Currency_ID, c.StdPrecision,
|
|
||||||
v.AD_Client_ID, v.AD_Org_ID, v.UpdatedBy,
|
|
||||||
v.M_DiscountSchema_ID, M_PriceList_Version_Base_ID
|
|
||||||
INTO v_Currency_ID, v_StdPrecision,
|
|
||||||
v_Client_ID, v_Org_ID, v_UpdatedBy,
|
|
||||||
v_DiscountSchema_ID, v_PriceList_Version_Base_ID
|
|
||||||
FROM M_PriceList p, M_PriceList_Version v, C_Currency c
|
|
||||||
WHERE p.M_PriceList_ID=v.M_PriceList_ID
|
|
||||||
AND p.C_Currency_ID=c.C_Currency_ID
|
|
||||||
AND v.M_PriceList_Version_ID=p_PriceList_Version_ID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* For All Discount Lines in Sequence
|
|
||||||
*/
|
|
||||||
FOR dl IN Cur_DiscountLine (v_DiscountSchema_ID) LOOP
|
|
||||||
ResultStr := 'Parameter Seq=' || dl.SeqNo;
|
|
||||||
-- DBMS_OUTPUT.PUT_LINE(ResultStr);
|
|
||||||
|
|
||||||
-- Clear Temporary Table
|
|
||||||
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 (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)
|
|
||||||
AND p.IsActive='Y' AND po.IsActive='Y' AND po.IsCurrentVendor='Y'
|
|
||||||
-- Optional Restrictions
|
|
||||||
AND (dl.M_Product_Category_ID IS NULL OR p.M_Product_Category_ID IN (
|
|
||||||
SELECT M_Product_Category_ID FROM M_Product_Category
|
|
||||||
START WITH M_Product_Category_ID=dl.M_Product_Category_ID
|
|
||||||
CONNECT BY M_Product_Category_Parent_ID = PRIOR M_Product_Category_ID
|
|
||||||
))
|
|
||||||
AND (dl.C_BPartner_ID IS NULL OR po.C_BPartner_ID=dl.C_BPartner_ID)
|
|
||||||
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 (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
|
|
||||||
AND p.IsActive='Y' AND pp.IsActive='Y'
|
|
||||||
-- Optional Restrictions
|
|
||||||
AND (dl.M_Product_Category_ID IS NULL OR p.M_Product_Category_ID IN (
|
|
||||||
SELECT M_Product_Category_ID FROM M_Product_Category
|
|
||||||
START WITH M_Product_Category_ID=dl.M_Product_Category_ID
|
|
||||||
CONNECT BY M_Product_Category_Parent_ID = PRIOR M_Product_Category_ID
|
|
||||||
))
|
|
||||||
AND (dl.C_BPartner_ID IS NULL OR EXISTS
|
|
||||||
(SELECT * FROM M_Product_PO po WHERE po.M_Product_ID=p.M_Product_ID AND po.C_BPartner_ID=dl.C_BPartner_ID))
|
|
||||||
AND (dl.M_Product_ID IS NULL OR p.M_Product_ID=dl.M_Product_ID);
|
|
||||||
END IF;
|
|
||||||
Message := Message || '@Selected@=' || SQL%ROWCOUNT;
|
|
||||||
-- DBMS_OUTPUT.PUT_LINE(Message);
|
|
||||||
|
|
||||||
-- Delete Prices in Selection, so that we can insert
|
|
||||||
IF (v_PriceList_Version_Base_ID IS NULL
|
|
||||||
OR v_PriceList_Version_Base_ID <> p_PriceList_Version_ID) THEN
|
|
||||||
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 s.AD_PInstance_ID = PInstance_ID);
|
|
||||||
Message := ', @Deleted@=' || SQL%ROWCOUNT;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- --------------------
|
|
||||||
-- Copy (Insert) Prices
|
|
||||||
-- --------------------
|
|
||||||
IF (v_PriceList_Version_Base_ID = p_PriceList_Version_ID) THEN
|
|
||||||
-- We have Prices already
|
|
||||||
NULL;
|
|
||||||
ELSIF (v_PriceList_Version_Base_ID IS NULL) THEN
|
|
||||||
-- Copy and Convert from Product_PO
|
|
||||||
ResultStr := ResultStr || ',Copy_PO';
|
|
||||||
INSERT INTO M_ProductPrice
|
|
||||||
(M_PriceList_Version_ID, M_Product_ID,
|
|
||||||
AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
|
|
||||||
PriceList, PriceStd, PriceLimit)
|
|
||||||
SELECT
|
|
||||||
p_PriceList_Version_ID, po.M_Product_ID,
|
|
||||||
v_Client_ID, v_Org_ID, 'Y', SysDate, v_UpdatedBy, SysDate, v_UpdatedBy,
|
|
||||||
-- Price List
|
|
||||||
COALESCE(currencyConvert(po.PriceList,
|
|
||||||
po.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0),
|
|
||||||
-- Price Std
|
|
||||||
COALESCE(currencyConvert(po.PriceList,
|
|
||||||
po.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0),
|
|
||||||
-- Price Limit
|
|
||||||
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
|
|
||||||
AND s.AD_PInstance_ID = PInstance_ID)
|
|
||||||
AND po.IsCurrentVendor='Y' AND po.IsActive='Y';
|
|
||||||
ELSE
|
|
||||||
-- Copy and Convert from other PriceList_Version
|
|
||||||
ResultStr := ResultStr || ',Copy_PL';
|
|
||||||
INSERT INTO M_ProductPrice
|
|
||||||
(M_PriceList_Version_ID, M_Product_ID,
|
|
||||||
AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
|
|
||||||
PriceList, PriceStd, PriceLimit)
|
|
||||||
SELECT
|
|
||||||
p_PriceList_Version_ID, pp.M_Product_ID,
|
|
||||||
v_Client_ID, v_Org_ID, 'Y', SysDate, v_UpdatedBy, SysDate, v_UpdatedBy,
|
|
||||||
-- Price List
|
|
||||||
COALESCE(currencyConvert(pp.PriceList,
|
|
||||||
pl.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0),
|
|
||||||
-- Price Std
|
|
||||||
COALESCE(currencyConvert(pp.PriceStd,
|
|
||||||
pl.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0),
|
|
||||||
-- Price Limit
|
|
||||||
COALESCE(currencyConvert(pp.PriceLimit,
|
|
||||||
pl.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0)
|
|
||||||
FROM M_ProductPrice pp
|
|
||||||
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 s.AD_PInstance_ID = PInstance_ID)
|
|
||||||
AND pp.IsActive='Y';
|
|
||||||
END IF;
|
|
||||||
Message := Message || ', @Inserted@=' || SQL%ROWCOUNT;
|
|
||||||
|
|
||||||
-- -----------
|
|
||||||
-- Calculation
|
|
||||||
-- -----------
|
|
||||||
ResultStr := ResultStr || ',Calc';
|
|
||||||
UPDATE M_ProductPrice p
|
|
||||||
SET PriceList = (DECODE(dl.List_Base, 'S', PriceStd, 'X', PriceLimit, PriceList)
|
|
||||||
+ dl.List_AddAmt) * (1 - dl.List_Discount/100),
|
|
||||||
PriceStd = (DECODE(dl.Std_Base, 'L', PriceList, 'X', PriceLimit, PriceStd)
|
|
||||||
+ dl.Std_AddAmt) * (1 - dl.Std_Discount/100),
|
|
||||||
PriceLimit = (DECODE(dl.Limit_Base, 'L', PriceList, 'S', PriceStd, PriceLimit)
|
|
||||||
+ 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
|
|
||||||
AND s.AD_PInstance_ID = PInstance_ID);
|
|
||||||
|
|
||||||
-- --------
|
|
||||||
-- Rounding (AD_Reference_ID=155)
|
|
||||||
-- --------
|
|
||||||
ResultStr := ResultStr || ',Round';
|
|
||||||
UPDATE M_ProductPrice p
|
|
||||||
SET PriceList = DECODE(dl.List_Rounding,
|
|
||||||
'N', PriceList,
|
|
||||||
'0', ROUND(PriceList, 0), -- Even .00
|
|
||||||
'D', ROUND(PriceList, 1), -- Dime .10
|
|
||||||
'T', ROUND(PriceList, -1), -- Ten 10.00
|
|
||||||
'5', ROUND(PriceList*20,0)/20, -- Nickle .05
|
|
||||||
'Q', ROUND(PriceList*4,0)/4, -- Quarter .25
|
|
||||||
ROUND(PriceList, v_StdPrecision)),-- Currency
|
|
||||||
PriceStd = DECODE(dl.Std_Rounding,
|
|
||||||
'N', PriceStd,
|
|
||||||
'0', ROUND(PriceStd, 0), -- Even .00
|
|
||||||
'D', ROUND(PriceStd, 1), -- Dime .10
|
|
||||||
'T', ROUND(PriceStd, -1), -- Ten 10.00
|
|
||||||
'5', ROUND(PriceStd*20,0)/20, -- Nickle .05
|
|
||||||
'Q', ROUND(PriceStd*4,0)/4, -- Quarter .25
|
|
||||||
ROUND(PriceStd, v_StdPrecision)), -- Currency
|
|
||||||
PriceLimit = DECODE(dl.Limit_Rounding,
|
|
||||||
'N', PriceLimit,
|
|
||||||
'0', ROUND(PriceLimit, 0), -- Even .00
|
|
||||||
'D', ROUND(PriceLimit, 1), -- Dime .10
|
|
||||||
'T', ROUND(PriceLimit, -1), -- Ten 10.00
|
|
||||||
'5', ROUND(PriceLimit*20,0)/20, -- Nickle .05
|
|
||||||
'Q', ROUND(PriceLimit*4,0)/4, -- Quarter .25
|
|
||||||
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
|
|
||||||
AND s.AD_PInstance_ID = PInstance_ID);
|
|
||||||
Message := Message || ', @Updated@=' || SQL%ROWCOUNT;
|
|
||||||
|
|
||||||
-- Fixed Price overwrite
|
|
||||||
ResultStr := ResultStr || ',Fix';
|
|
||||||
UPDATE M_ProductPrice p
|
|
||||||
SET PriceList = DECODE(dl.List_Base, 'F', dl.List_Fixed, PriceList),
|
|
||||||
PriceStd = DECODE(dl.Std_Base, 'F', dl.Std_Fixed, PriceStd),
|
|
||||||
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
|
|
||||||
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)
|
|
||||||
VALUES (PInstance_ID, v_NextNo, null, dl.SeqNo, Message);
|
|
||||||
--
|
|
||||||
v_NextNo := v_NextNo + 1;
|
|
||||||
Message := '';
|
|
||||||
END LOOP; -- For all DiscountLines
|
|
||||||
|
|
||||||
-- Delete Temporary Selection
|
|
||||||
DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID;
|
|
||||||
|
|
||||||
|
|
||||||
<<FINISH_PROCESS>>
|
|
||||||
-- Update AD_PInstance
|
|
||||||
DBMS_OUTPUT.PUT_LINE(Message);
|
|
||||||
DBMS_OUTPUT.PUT_LINE('Updating PInstance - Finished');
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Updated = SysDate,
|
|
||||||
IsProcessing = 'N',
|
|
||||||
Result = 1, -- success
|
|
||||||
ErrorMsg = Message
|
|
||||||
WHERE AD_PInstance_ID=PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
RETURN;
|
|
||||||
|
|
||||||
EXCEPTION
|
|
||||||
WHEN OTHERS THEN
|
|
||||||
ResultStr := ResultStr || ':' || SQLERRM || ' ' || Message;
|
|
||||||
DBMS_OUTPUT.PUT_LINE(ResultStr);
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Updated = SysDate,
|
|
||||||
IsProcessing = 'N',
|
|
||||||
Result = 0, -- failure
|
|
||||||
ErrorMsg = ResultStr
|
|
||||||
WHERE AD_PInstance_ID=PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
RETURN;
|
|
||||||
|
|
||||||
END M_PriceList_Create;
|
|
|
@ -1,148 +0,0 @@
|
||||||
CREATE OR REPLACE PROCEDURE M_Product_BOM_Check
|
|
||||||
(
|
|
||||||
PInstance_ID IN NUMBER
|
|
||||||
)
|
|
||||||
/*************************************************************************
|
|
||||||
* 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: 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 $
|
|
||||||
***
|
|
||||||
* Title: Check BOM Structure (free of cycles)
|
|
||||||
* Description:
|
|
||||||
* Tree cannot contain BOMs which are already referenced
|
|
||||||
************************************************************************/
|
|
||||||
AS
|
|
||||||
-- Logistice
|
|
||||||
ResultStr VARCHAR2(2000);
|
|
||||||
Message VARCHAR2(2000);
|
|
||||||
Record_ID NUMBER;
|
|
||||||
-- Parameter
|
|
||||||
CURSOR Cur_Parameter (PInstance NUMBER) IS
|
|
||||||
SELECT i.Record_ID, p.ParameterName, p.P_String, p.P_Number, p.P_Date
|
|
||||||
FROM AD_PInstance i, AD_PInstance_Para p
|
|
||||||
WHERE i.AD_PInstance_ID=PInstance
|
|
||||||
AND i.AD_PInstance_ID=p.AD_PInstance_ID(+)
|
|
||||||
ORDER BY p.SeqNo;
|
|
||||||
-- Variables
|
|
||||||
Verified CHAR(1) := 'Y';
|
|
||||||
IsBOM CHAR(1);
|
|
||||||
CountNo NUMBER;
|
|
||||||
|
|
||||||
BEGIN
|
|
||||||
-- Update AD_PInstance
|
|
||||||
DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || PInstance_ID);
|
|
||||||
ResultStr := 'PInstanceNotFound';
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Created = SysDate,
|
|
||||||
IsProcessing = 'Y'
|
|
||||||
WHERE AD_PInstance_ID=PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
-- Get Parameters
|
|
||||||
ResultStr := 'ReadingParameters';
|
|
||||||
FOR p IN Cur_Parameter (PInstance_ID) LOOP
|
|
||||||
Record_ID := p.Record_ID;
|
|
||||||
END LOOP; -- Get Parameter
|
|
||||||
DBMS_OUTPUT.PUT_LINE(' Record_ID=' || Record_ID);
|
|
||||||
|
|
||||||
-- Record ID is M_Product_ID of product to be tested
|
|
||||||
SELECT IsBOM
|
|
||||||
INTO IsBOM
|
|
||||||
FROM M_Product
|
|
||||||
WHERE M_Product_ID=Record_ID;
|
|
||||||
|
|
||||||
-- No BOM - should not happen, but no problem
|
|
||||||
IF (IsBOM = 'N') THEN
|
|
||||||
GOTO FINISH_PROCESS;
|
|
||||||
-- Did not find product
|
|
||||||
ELSIF (IsBOM <> 'Y') THEN
|
|
||||||
RETURN;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- Checking BOM Structure
|
|
||||||
ResultStr := 'InsertingRoot';
|
|
||||||
-- Table to put all BOMs - duplicate will cause exception
|
|
||||||
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 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
|
|
||||||
WHERE AD_PInstance_ID = PInstance_ID;
|
|
||||||
-- Nothing to do
|
|
||||||
EXIT WHEN (CountNo = 0);
|
|
||||||
|
|
||||||
-- Insert BOM Nodes into "All" table
|
|
||||||
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 WHERE AD_PInstance_ID = PInstance_ID));
|
|
||||||
|
|
||||||
-- Insert BOM Nodes into temporary table
|
|
||||||
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 WHERE AD_PInstance_ID = PInstance_ID));
|
|
||||||
|
|
||||||
-- Copy into root table
|
|
||||||
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 AND AD_PInstance_ID = PInstance_ID;
|
|
||||||
|
|
||||||
END LOOP;
|
|
||||||
|
|
||||||
<<FINISH_PROCESS>>
|
|
||||||
-- OK
|
|
||||||
Message := 'OK';
|
|
||||||
UPDATE M_Product
|
|
||||||
SET IsVerified = 'Y'
|
|
||||||
WHERE M_Product_ID=Record_ID;
|
|
||||||
|
|
||||||
-- Update AD_PInstance
|
|
||||||
DBMS_OUTPUT.PUT_LINE('Updating PInstance - Finished ' || Message);
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Updated = SysDate,
|
|
||||||
IsProcessing = 'N',
|
|
||||||
Result = 1, -- success
|
|
||||||
ErrorMsg = Message
|
|
||||||
WHERE AD_PInstance_ID=PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
RETURN;
|
|
||||||
|
|
||||||
EXCEPTION
|
|
||||||
WHEN OTHERS THEN
|
|
||||||
ResultStr := ResultStr || ': ' || SQLERRM || ' - ' || Message;
|
|
||||||
DBMS_OUTPUT.PUT_LINE(ResultStr);
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Updated = SysDate,
|
|
||||||
IsProcessing = 'N',
|
|
||||||
Result = 0, -- failure
|
|
||||||
ErrorMsg = ResultStr
|
|
||||||
WHERE AD_PInstance_ID=PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
--
|
|
||||||
UPDATE M_Product
|
|
||||||
SET IsVerified = 'N'
|
|
||||||
WHERE M_Product_ID=Record_ID;
|
|
||||||
COMMIT;
|
|
||||||
--
|
|
||||||
RETURN;
|
|
||||||
|
|
||||||
END M_Product_BOM_Check;
|
|
||||||
/
|
|
|
@ -1,298 +0,0 @@
|
||||||
CREATE OR REPLACE PROCEDURE M_Production_Run
|
|
||||||
(
|
|
||||||
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
|
|
||||||
* 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
|
|
||||||
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
|
|
||||||
*************************************************************************
|
|
||||||
* $Id: M_Production_Run.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
|
|
||||||
***
|
|
||||||
* Title: Production of BOMs
|
|
||||||
* Description:
|
|
||||||
* 1) Creating ProductionLines when IsCreated = 'N'
|
|
||||||
* 2) Posting the Lines (optionally only when fully stocked)
|
|
||||||
************************************************************************/
|
|
||||||
AS
|
|
||||||
-- Logistice
|
|
||||||
ResultStr VARCHAR2(2000);
|
|
||||||
Message VARCHAR2(2000);
|
|
||||||
Record_ID NUMBER;
|
|
||||||
-- Parameter
|
|
||||||
CURSOR Cur_Parameter (PInstance NUMBER) IS
|
|
||||||
SELECT i.Record_ID, p.ParameterName, p.P_String, p.P_Number, p.P_Date
|
|
||||||
FROM AD_PInstance i, AD_PInstance_Para p
|
|
||||||
WHERE i.AD_PInstance_ID=PInstance
|
|
||||||
AND i.AD_PInstance_ID=p.AD_PInstance_ID(+)
|
|
||||||
ORDER BY p.SeqNo;
|
|
||||||
-- Parameter Variables
|
|
||||||
MustBeStocked CHAR(1);
|
|
||||||
IsCreated CHAR(1);
|
|
||||||
Processed CHAR(1);
|
|
||||||
Client_ID NUMBER;
|
|
||||||
Org_ID NUMBER;
|
|
||||||
--
|
|
||||||
Line NUMBER;
|
|
||||||
NextNo NUMBER;
|
|
||||||
CountNo NUMBER;
|
|
||||||
-- ProductionPlan
|
|
||||||
CURSOR CUR_PP IS
|
|
||||||
SELECT *
|
|
||||||
FROM M_ProductionPlan
|
|
||||||
WHERE M_Production_ID=Record_ID
|
|
||||||
ORDER BY Line, M_Product_ID;
|
|
||||||
-- BOM Lines
|
|
||||||
CURSOR CUR_BOM (Product_ID NUMBER) IS
|
|
||||||
SELECT *
|
|
||||||
FROM M_Product_BOM
|
|
||||||
WHERE M_Product_ID=Product_ID
|
|
||||||
ORDER BY Line;
|
|
||||||
-- ProductionLines which are non-stocked BOMs (need to be resolved)
|
|
||||||
CURSOR CUR_PLineBOM (ProductionPlan_ID NUMBER) IS
|
|
||||||
SELECT pl.M_ProductionLine_ID, pl.Line, pl.M_Product_ID, pl.MovementQty
|
|
||||||
FROM M_ProductionLine pl, M_Product p
|
|
||||||
WHERE pl.M_ProductionPlan_ID=ProductionPlan_ID
|
|
||||||
AND pl.M_Product_ID=p.M_Product_ID
|
|
||||||
AND pl.Line<>100 -- Origin Line
|
|
||||||
AND p.IsBOM='Y' AND p.IsStocked='N';
|
|
||||||
|
|
||||||
-- Posting
|
|
||||||
CURSOR CUR_PL_Post IS
|
|
||||||
SELECT pl.M_ProductionLine_ID, pl.AD_Client_ID, pl.AD_Org_ID, p.MovementDate,
|
|
||||||
pl.M_Product_ID, pl.M_AttributeSetInstance_ID, pl.MovementQty, pl.M_Locator_ID
|
|
||||||
FROM M_Production p, M_ProductionLine pl, M_ProductionPlan pp
|
|
||||||
WHERE p.M_Production_ID=pp.M_Production_ID
|
|
||||||
AND pp.M_ProductionPlan_ID=pl.M_ProductionPlan_ID
|
|
||||||
AND pp.M_Production_ID=Record_ID
|
|
||||||
ORDER BY pp.Line, pl.Line;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BEGIN
|
|
||||||
-- Update AD_PInstance
|
|
||||||
DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || PInstance_ID);
|
|
||||||
ResultStr := 'PInstanceNotFound';
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Created = SysDate,
|
|
||||||
IsProcessing = 'Y'
|
|
||||||
WHERE AD_PInstance_ID=PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
-- Get Parameters
|
|
||||||
ResultStr := 'ReadingParameters';
|
|
||||||
FOR p IN Cur_Parameter (PInstance_ID) LOOP
|
|
||||||
Record_ID := p.Record_ID;
|
|
||||||
IF (p.ParameterName = 'MustBeStocked') THEN
|
|
||||||
MustBeStocked := p.P_String;
|
|
||||||
DBMS_OUTPUT.PUT_LINE(' MustBeStocked=' || MustBeStocked);
|
|
||||||
ELSE
|
|
||||||
DBMS_OUTPUT.PUT_LINE('*** Unknown Parameter=' || p.ParameterName);
|
|
||||||
END IF;
|
|
||||||
END LOOP; -- Get Parameter
|
|
||||||
DBMS_OUTPUT.PUT_LINE(' Record_ID=' || Record_ID);
|
|
||||||
|
|
||||||
-- Processing??? Lock ????
|
|
||||||
-- TODO
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Info + Lock
|
|
||||||
*/
|
|
||||||
ResultStr := 'ReadingRecord';
|
|
||||||
SELECT IsCreated, Processed, AD_Client_ID, AD_Org_ID
|
|
||||||
INTO IsCreated, Processed, Client_ID, Org_ID
|
|
||||||
FROM M_Production
|
|
||||||
WHERE M_Production_ID=Record_ID
|
|
||||||
FOR UPDATE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No Action
|
|
||||||
*/
|
|
||||||
IF (Processed <> 'N') THEN
|
|
||||||
Message := '@AlreadyPosted@';
|
|
||||||
GOTO FINISH_PROCESS;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* Create Lines
|
|
||||||
*/
|
|
||||||
IF (IsCreated <> 'Y') THEN
|
|
||||||
-- For every Production Plan
|
|
||||||
FOR pp IN CUR_PP LOOP
|
|
||||||
-- Delete prior lines
|
|
||||||
DELETE M_ProductionLine
|
|
||||||
WHERE M_ProductionPlan_ID=pp.M_ProductionPlan_ID;
|
|
||||||
-- DBMS_OUTPUT.PUT_LINE('ProductionPlan=' || pp.M_ProductionPlan_ID);
|
|
||||||
-- Create BOM Line
|
|
||||||
ResultStr := 'CreatingLine BOM';
|
|
||||||
Line := 100; -- OriginLine
|
|
||||||
AD_Sequence_Next('M_ProductionLine', pp.AD_Client_ID, NextNo);
|
|
||||||
INSERT INTO M_ProductionLine
|
|
||||||
(M_ProductionLine_ID, M_ProductionPlan_ID, Line,
|
|
||||||
AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
|
|
||||||
M_Product_ID, MovementQty, M_Locator_ID, Description)
|
|
||||||
VALUES
|
|
||||||
(NextNo, pp.M_ProductionPlan_ID, Line,
|
|
||||||
pp.AD_Client_ID,pp.AD_Org_ID,'Y',SysDate,0,SysDate,0,
|
|
||||||
pp.M_Product_ID, pp.ProductionQty, pp.M_Locator_ID, pp.Description);
|
|
||||||
|
|
||||||
-- Create First Level
|
|
||||||
FOR bom IN CUR_BOM (pp.M_Product_ID) LOOP
|
|
||||||
ResultStr := 'CreatingLine Products';
|
|
||||||
Line := Line + 100;
|
|
||||||
AD_Sequence_Next('M_ProductionLine', pp.AD_Client_ID, NextNo);
|
|
||||||
INSERT INTO M_ProductionLine
|
|
||||||
(M_ProductionLine_ID, M_ProductionPlan_ID, Line,
|
|
||||||
AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
|
|
||||||
M_Product_ID, MovementQty, M_Locator_ID)
|
|
||||||
VALUES
|
|
||||||
(NextNo, pp.M_ProductionPlan_ID, Line,
|
|
||||||
pp.AD_Client_ID,pp.AD_Org_ID,'Y',SysDate,0,SysDate,0,
|
|
||||||
bom.M_ProductBOM_ID, -pp.ProductionQty*bom.BOMQty, pp.M_Locator_ID);
|
|
||||||
END LOOP;
|
|
||||||
|
|
||||||
-- While we have BOMs
|
|
||||||
LOOP
|
|
||||||
-- Are there non-stored BOMs to list details?
|
|
||||||
ResultStr := 'CreatingLine CheckBOM';
|
|
||||||
SELECT COUNT(*) INTO CountNo
|
|
||||||
FROM M_ProductionLine pl, M_Product p
|
|
||||||
WHERE pl.M_Product_ID=p.M_Product_ID
|
|
||||||
AND pl.M_ProductionPlan_ID=pp.M_ProductionPlan_ID
|
|
||||||
AND pl.Line<>100 -- Origin Line
|
|
||||||
AND p.IsBOM='Y' AND p.IsStocked='N';
|
|
||||||
-- Nothing to do
|
|
||||||
EXIT WHEN (CountNo = 0);
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Resolve BOMs in ProductLine which are not stocked
|
|
||||||
FOR pl IN CUR_PLineBOM (pp.M_ProductionPlan_ID) LOOP
|
|
||||||
ResultStr := 'CreatingLineBOM Resolution';
|
|
||||||
Line := pl.Line;
|
|
||||||
-- Resolve BOM Line in product line
|
|
||||||
FOR bom IN CUR_BOM (pl.M_Product_ID) LOOP
|
|
||||||
ResultStr := 'CreatingLine Products2';
|
|
||||||
Line := Line + 10;
|
|
||||||
AD_Sequence_Next('M_ProductionLine', pp.AD_Client_ID, NextNo);
|
|
||||||
INSERT INTO M_ProductionLine
|
|
||||||
(M_ProductionLine_ID, M_ProductionPlan_ID, Line,
|
|
||||||
AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
|
|
||||||
M_Product_ID, MovementQty, M_Locator_ID)
|
|
||||||
VALUES
|
|
||||||
(NextNo, pp.M_ProductionPlan_ID, Line,
|
|
||||||
pp.AD_Client_ID,pp.AD_Org_ID,'Y',SysDate,0,SysDate,0,
|
|
||||||
bom.M_ProductBOM_ID, pl.MovementQty*bom.BOMQty, pp.M_Locator_ID);
|
|
||||||
END LOOP;
|
|
||||||
-- Delete BOM line
|
|
||||||
DELETE M_ProductionLine
|
|
||||||
WHERE M_ProductionLine_ID=pl.M_ProductionLine_ID;
|
|
||||||
END LOOP;
|
|
||||||
END LOOP; -- While we have BOMs
|
|
||||||
|
|
||||||
END LOOP; -- For every Production Plan
|
|
||||||
|
|
||||||
-- Modifying locator to have sufficient stock
|
|
||||||
|
|
||||||
|
|
||||||
-- Indicate that it is Created
|
|
||||||
UPDATE M_Production
|
|
||||||
SET IsCreated='Y'
|
|
||||||
WHERE M_Production_ID=Record_ID;
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* Post Lines
|
|
||||||
*/
|
|
||||||
ELSE
|
|
||||||
-- All Production Lines
|
|
||||||
FOR pl IN CUR_PL_Post LOOP
|
|
||||||
-- M_ProductionLine_ID, AD_Client_ID, AD_Org_ID, MovementDate, M_Product_ID, MovementQty, M_Locator_ID
|
|
||||||
-- DBMS_OUTPUT.PUT_LINE('ProductionLine=' || pl.M_ProductionLine_ID);
|
|
||||||
-- DBMS_OUTPUT.PUT_LINE(' Qty=' || pl.MovementQty || ', OnHand=' || BOM_Qty_OnHand(pl.M_Product_ID, NULL, pl.M_Locator_ID));
|
|
||||||
-- Check Stock levels for reductions
|
|
||||||
IF (pl.MovementQty < 0 AND MustBeStocked <> 'N'
|
|
||||||
AND bomQtyOnHand(pl.M_Product_ID, NULL, pl.M_Locator_ID)+pl.MovementQty < 0) THEN
|
|
||||||
ROLLBACK;
|
|
||||||
SELECT '@NotEnoughStocked@: ' || Name INTO Message
|
|
||||||
FROM M_Product WHERE M_Product_ID=pl.M_Product_ID;
|
|
||||||
GOTO FINISH_PROCESS;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- Adjust Quantity at Location
|
|
||||||
UPDATE M_Storage
|
|
||||||
SET QtyOnHand = QtyOnHand + pl.MovementQty,
|
|
||||||
Updated = SysDate
|
|
||||||
WHERE M_Locator_ID = pl.M_Locator_ID
|
|
||||||
AND M_AttributeSetInstance_ID = COALESCE(pl.M_AttributeSetInstance_ID,0)
|
|
||||||
AND M_Product_ID = pl.M_Product_ID;
|
|
||||||
-- Product not on Stock yet
|
|
||||||
IF (SQL%ROWCOUNT = 0) THEN
|
|
||||||
INSERT INTO M_Storage
|
|
||||||
(M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID,
|
|
||||||
AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
|
|
||||||
QtyOnHand, QtyReserved, QtyOrdered)
|
|
||||||
VALUES
|
|
||||||
(pl.M_Product_ID, pl.M_Locator_ID, COALESCE(pl.M_AttributeSetInstance_ID,0),
|
|
||||||
pl.AD_Client_ID, pl.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,
|
|
||||||
pl.MovementQty, 0, 0);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- Create Transaction Entry
|
|
||||||
ResultStr := 'CreateTransaction';
|
|
||||||
AD_Sequence_Next('M_Transaction', pl.AD_Org_ID, NextNo);
|
|
||||||
INSERT INTO M_Transaction
|
|
||||||
(M_Transaction_ID, M_ProductionLine_ID,
|
|
||||||
AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
|
|
||||||
MovementType, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID,
|
|
||||||
MovementDate, MovementQty)
|
|
||||||
VALUES
|
|
||||||
(NextNo, pl.M_ProductionLine_ID,
|
|
||||||
pl.AD_Client_ID, pl.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,
|
|
||||||
'P+', pl.M_Locator_ID, pl.M_Product_ID, COALESCE(pl.M_AttributeSetInstance_ID,0), -- not distinguishing between assemby/disassembly
|
|
||||||
pl.MovementDate, pl.MovementQty);
|
|
||||||
--
|
|
||||||
UPDATE M_ProductionLine
|
|
||||||
SET Processed='Y'
|
|
||||||
WHERE M_ProductionLine_ID=pl.M_ProductionLine_ID;
|
|
||||||
END LOOP;
|
|
||||||
|
|
||||||
-- Indicate that we are done
|
|
||||||
UPDATE M_Production
|
|
||||||
SET Processed='Y'
|
|
||||||
WHERE M_Production_ID=Record_ID;
|
|
||||||
UPDATE M_ProductionPlan
|
|
||||||
SET Processed='Y'
|
|
||||||
WHERE M_Production_ID=Record_ID;
|
|
||||||
|
|
||||||
END IF;
|
|
||||||
-- Only commit when entire job successful
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
<<FINISH_PROCESS>>
|
|
||||||
-- Update AD_PInstance
|
|
||||||
DBMS_OUTPUT.PUT_LINE('Updating PInstance - Finished ' || Message);
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Updated = SysDate,
|
|
||||||
IsProcessing = 'N',
|
|
||||||
Result = 1, -- success
|
|
||||||
ErrorMsg = Message
|
|
||||||
WHERE AD_PInstance_ID=PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
RETURN;
|
|
||||||
|
|
||||||
EXCEPTION
|
|
||||||
WHEN OTHERS THEN
|
|
||||||
ResultStr := ResultStr || ': ' || SQLERRM || ' - ' || Message;
|
|
||||||
DBMS_OUTPUT.PUT_LINE(ResultStr);
|
|
||||||
UPDATE AD_PInstance
|
|
||||||
SET Updated = SysDate,
|
|
||||||
IsProcessing = 'N',
|
|
||||||
Result = 0, -- failure
|
|
||||||
ErrorMsg = ResultStr
|
|
||||||
WHERE AD_PInstance_ID=PInstance_ID;
|
|
||||||
COMMIT;
|
|
||||||
RETURN;
|
|
||||||
|
|
||||||
END M_Production_Run;
|
|
||||||
/
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
UPDATE AD_COLUMN SET entitytype = 'D' WHERE entitytype != 'D' AND ad_column_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_ELEMENT SET entitytype = 'D' WHERE entitytype != 'D' AND AD_ELEMENT_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_FIELD SET entitytype = 'D' WHERE entitytype != 'D' AND AD_FIELD_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_MENU SET entitytype = 'D' WHERE entitytype != 'D' AND AD_MENU_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_MESSAGE SET entitytype = 'D' WHERE entitytype != 'D' AND AD_MESSAGE_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS SET entitytype = 'D' WHERE entitytype != 'D' AND AD_PROCESS_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS_PARA SET entitytype = 'D' WHERE entitytype != 'D' AND AD_PROCESS_PARA_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_REFERENCE SET entitytype = 'D' WHERE entitytype != 'D' AND AD_REFERENCE_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_REF_LIST SET entitytype = 'D' WHERE entitytype != 'D' AND AD_REF_LIST_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_TAB SET entitytype = 'D' WHERE entitytype != 'D' AND AD_TAB_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_TABLE SET entitytype = 'D' WHERE entitytype != 'D' AND AD_TABLE_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_WINDOW SET entitytype = 'D' WHERE entitytype != 'D' AND AD_WINDOW_id < 1000000;
|
|
@ -0,0 +1,77 @@
|
||||||
|
-- May 27, 2008 10:09:08 PM COT
|
||||||
|
-- [ 1974314 ] Difference in oracle and postgres seeds
|
||||||
|
UPDATE AD_Element SET Help='Configuration Level for this parameter
|
||||||
|
S - just allowed system configuration
|
||||||
|
C - client configurable parameter
|
||||||
|
O - org configurable parameter', Name='Configuration Level', PrintName='Configuration Level for this parameter',Updated=TO_DATE('2008-05-27 22:09:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53229
|
||||||
|
;
|
||||||
|
|
||||||
|
-- May 27, 2008 10:09:08 PM COT
|
||||||
|
UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=53229
|
||||||
|
;
|
||||||
|
|
||||||
|
-- May 27, 2008 10:09:08 PM COT
|
||||||
|
UPDATE AD_Column SET ColumnName='ConfigurationLevel', Name='Configuration Level', Description='Configuration Level for this parameter', Help='Configuration Level for this parameter
|
||||||
|
S - just allowed system configuration
|
||||||
|
C - client configurable parameter
|
||||||
|
O - org configurable parameter' WHERE AD_Element_ID=53229
|
||||||
|
;
|
||||||
|
|
||||||
|
-- May 27, 2008 10:09:08 PM COT
|
||||||
|
UPDATE AD_Field SET Name='Configuration Level', Description='Configuration Level for this parameter', Help='Configuration Level for this parameter
|
||||||
|
S - just allowed system configuration
|
||||||
|
C - client configurable parameter
|
||||||
|
O - org configurable parameter' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53229) AND IsCentrallyMaintained='Y'
|
||||||
|
;
|
||||||
|
|
||||||
|
-- May 27, 2008 10:09:09 PM COT
|
||||||
|
UPDATE AD_Process_Para SET ColumnName='ConfigurationLevel', Name='Configuration Level', Description='Configuration Level for this parameter', Help='Configuration Level for this parameter
|
||||||
|
S - just allowed system configuration
|
||||||
|
C - client configurable parameter
|
||||||
|
O - org configurable parameter', AD_Element_ID=53229 WHERE UPPER(ColumnName)='CONFIGURATIONLEVEL' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- May 27, 2008 10:09:09 PM COT
|
||||||
|
UPDATE AD_Process_Para SET ColumnName='ConfigurationLevel', Name='Configuration Level', Description='Configuration Level for this parameter', Help='Configuration Level for this parameter
|
||||||
|
S - just allowed system configuration
|
||||||
|
C - client configurable parameter
|
||||||
|
O - org configurable parameter' WHERE AD_Element_ID=53229 AND IsCentrallyMaintained='Y'
|
||||||
|
;
|
||||||
|
|
||||||
|
-- May 27, 2008 10:09:09 PM COT
|
||||||
|
UPDATE AD_PrintFormatItem pi SET PrintName='Configuration Level for this parameter', Name='Configuration Level' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=53229)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- May 27, 2008 10:09:09 PM COT
|
||||||
|
UPDATE AD_PrintFormatItem pi SET PrintName='Configuration Level for this parameter', Name='Configuration Level' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=53229)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- May 27, 2008 10:13:38 PM COT
|
||||||
|
UPDATE AD_Message SET MsgTip='The program assumes build version {0}, but database has build version {1}.
|
||||||
|
This is likely to cause hard to fix errors.
|
||||||
|
Please contact administrator.',Updated=TO_DATE('2008-05-27 22:13:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=53025
|
||||||
|
;
|
||||||
|
|
||||||
|
-- May 27, 2008 10:13:38 PM COT
|
||||||
|
UPDATE AD_Message_Trl SET IsTranslated='N' WHERE AD_Message_ID=53025
|
||||||
|
;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS SET procedurename = null, classname = 'org.compiere.process.M_PriceList_Create'
|
||||||
|
where ad_process_id = 103;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS SET procedurename = null, classname = 'org.compiere.process.M_Product_BOM_Check'
|
||||||
|
where ad_process_id = 136;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS SET procedurename = null, classname = 'org.compiere.process.M_Production_Run'
|
||||||
|
where ad_process_id = 137;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS SET procedurename = null, classname = 'org.compiere.process.AD_PrintPaper_Default'
|
||||||
|
where ad_process_id = 191;
|
||||||
|
|
||||||
|
DROP PROCEDURE M_PriceList_Create;
|
||||||
|
|
||||||
|
DROP PROCEDURE M_Product_BOM_Check;
|
||||||
|
|
||||||
|
DROP PROCEDURE M_Production_Run;
|
||||||
|
|
||||||
|
DROP PROCEDURE AD_PrintPaper_Default;
|
|
@ -0,0 +1,23 @@
|
||||||
|
UPDATE AD_COLUMN SET entitytype = 'D' WHERE entitytype != 'D' AND ad_column_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_ELEMENT SET entitytype = 'D' WHERE entitytype != 'D' AND AD_ELEMENT_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_FIELD SET entitytype = 'D' WHERE entitytype != 'D' AND AD_FIELD_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_MENU SET entitytype = 'D' WHERE entitytype != 'D' AND AD_MENU_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_MESSAGE SET entitytype = 'D' WHERE entitytype != 'D' AND AD_MESSAGE_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS SET entitytype = 'D' WHERE entitytype != 'D' AND AD_PROCESS_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS_PARA SET entitytype = 'D' WHERE entitytype != 'D' AND AD_PROCESS_PARA_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_REFERENCE SET entitytype = 'D' WHERE entitytype != 'D' AND AD_REFERENCE_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_REF_LIST SET entitytype = 'D' WHERE entitytype != 'D' AND AD_REF_LIST_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_TAB SET entitytype = 'D' WHERE entitytype != 'D' AND AD_TAB_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_TABLE SET entitytype = 'D' WHERE entitytype != 'D' AND AD_TABLE_id < 1000000;
|
||||||
|
|
||||||
|
UPDATE AD_WINDOW SET entitytype = 'D' WHERE entitytype != 'D' AND AD_WINDOW_id < 1000000;
|
|
@ -0,0 +1,33 @@
|
||||||
|
UPDATE AD_PROCESS_PARA
|
||||||
|
SET defaultvalue = 'http://www.adempiere.org'
|
||||||
|
WHERE ad_process_para_id = 53023;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS_PARA
|
||||||
|
SET name = 'Purchase Price List Version', iscentrallymaintained='Y'
|
||||||
|
WHERE ad_process_para_id = 53025;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS_PARA
|
||||||
|
SET name = 'Generate Fields', iscentrallymaintained='Y'
|
||||||
|
WHERE ad_process_para_id = 53127;
|
||||||
|
|
||||||
|
UPDATE AD_PROCESS_PARA
|
||||||
|
SET name = 'Scripts Path', iscentrallymaintained='Y'
|
||||||
|
WHERE ad_process_para_id = 53131;
|
||||||
|
|
||||||
|
UPDATE AD_FIELD
|
||||||
|
SET help = 'Either add missing accounts - or copy and overwrite all default accounts. If you copy and overwrite the current default values, you may have to repeat previous updates (e.g. set the bank account asset accounts, ...). If no Accounting Schema is selected all Accounting Schemas will be updated / inserted.'
|
||||||
|
where ad_field_id = 3823;
|
||||||
|
|
||||||
|
update ad_ref_list
|
||||||
|
set name = 'PO/SO Commitment & Reservation'
|
||||||
|
where ad_ref_list_id = 53223;
|
||||||
|
|
||||||
|
update ad_ref_list
|
||||||
|
set name = 'PO/SO Commitment'
|
||||||
|
where ad_ref_list_id = 53225;
|
||||||
|
|
||||||
|
UPDATE ad_process
|
||||||
|
SET help = 'Either add missing accounts - or copy and overwrite all default accounts. If you copy and overwrite the current default values, you may have to repeat previous updates (e.g. set the bank account asset accounts, ...). If no Accounting Schema is selected all Accounting Schemas will be updated / inserted.',
|
||||||
|
classname = 'org.compiere.process.AcctSchemaDefaultCopy'
|
||||||
|
where ad_process_id = 108;
|
||||||
|
|
Loading…
Reference in New Issue