IDEMPIERE-386 Redesign ASI usage for FIFO. Based on Patch From Deepak.

This commit is contained in:
Heng Sin Low 2013-10-17 17:53:32 +08:00
parent 0029c6cd4f
commit 8b5da4d99f
35 changed files with 2171 additions and 236 deletions

View File

@ -0,0 +1,613 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Dec 25, 2012 10:54:46 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Element (ColumnName,AD_Element_ID,Help,EntityType,Description,Name,PrintName,AD_Element_UU,AD_Client_ID,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive) VALUES ('DateMaterialPolicy',202184,'This field is used to record time used for LIFO and FIFO material policy','D','Time used for LIFO and FIFO Material Policy','Date Material Policy','Date Material Policy','b45c798f-5957-4856-bc64-979c5dd54147',0,TO_DATE('2012-12-25 10:54:44','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2012-12-25 10:54:44','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y')
;
-- Dec 25, 2012 10:54:46 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Help,PO_Description,PO_Help,Description,Name,PrintName,PO_Name,PO_PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Help,t.PO_Description,t.PO_Help,t.Description,t.Name,t.PrintName,t.PO_Name,t.PO_PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=202184 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
;
-- Dec 25, 2012 10:56:17 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton,IsAlwaysUpdateable) VALUES (0,'N','N',0,200026,208340,'D','N','N','N',0,'N',7,'N',16,'N',202184,'N','Y','913e1eca-ca35-461a-ae0d-709589cd89d5','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_DATE('2012-12-25 10:56:16','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_DATE('2012-12-25 10:56:16','YYYY-MM-DD HH24:MI:SS'),100,0,'N','N')
;
-- Dec 25, 2012 10:56:17 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=208340 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Dec 25, 2012 10:56:39 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_StorageOnHand ADD DateMaterialPolicy DATE DEFAULT NULL
;
-- Dec 25, 2012 11:17:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Element (ColumnName,AD_Element_ID,EntityType,Name,PrintName,AD_Element_UU,AD_Client_ID,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive) VALUES ('UseGuaranteeDateForMPolicy',202185,'D','Use Guarantee Date for Material Policy','Use Guarantee Date for Material Policy','de278e48-9731-4100-bf5f-f8b74dc15807',0,TO_DATE('2012-12-25 11:17:32','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2012-12-25 11:17:32','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y')
;
-- Dec 25, 2012 11:17:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Help,PO_Description,PO_Help,Description,Name,PrintName,PO_Name,PO_PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Help,t.PO_Description,t.PO_Help,t.Description,t.Name,t.PrintName,t.PO_Name,t.PO_PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=202185 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
;
-- Dec 25, 2012 11:18:40 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,DefaultValue,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton,IsAlwaysUpdateable) VALUES (0,'N','N',0,560,208341,'D','N','N','N',0,'N',1,'N',20,'N',202185,'N','Y','3af336ad-d7c4-4bcc-b2dd-f7f23e39bc82','Y','UseGuaranteeDateForMPolicy','N','Use Guarantee Date for Material Policy','Y',100,TO_DATE('2012-12-25 11:18:39','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_DATE('2012-12-25 11:18:39','YYYY-MM-DD HH24:MI:SS'),100,0,'N','N')
;
-- Dec 25, 2012 11:18:40 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=208341 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Dec 25, 2012 11:18:47 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_AttributeSet ADD UseGuaranteeDateForMPolicy CHAR(1) DEFAULT 'N' CHECK (UseGuaranteeDateForMPolicy IN ('Y','N'))
;
-- Dec 25, 2012 11:21:32 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES ('N',461,36,'N','N',60867,'Y',201616,'N','D','M_AttributeSet_UU','N','Y','a02bb9da-705d-4ee5-9ba0-8809aaca675c',100,0,TO_DATE('2012-12-25 11:21:31','YYYY-MM-DD HH24:MI:SS'),0,100,TO_DATE('2012-12-25 11:21:31','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Dec 25, 2012 11:21:32 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201616 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Dec 25, 2012 11:21:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES ('N',461,1,'N','N',208341,'Y',201617,'N','D','Use Guarantee Date for Material Policy','N','Y','afec456c-437d-42ff-8b92-6d764569c8e4',100,0,TO_DATE('2012-12-25 11:21:32','YYYY-MM-DD HH24:MI:SS'),0,100,TO_DATE('2012-12-25 11:21:32','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Dec 25, 2012 11:21:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201617 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Dec 25, 2012 11:22:03 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=201616
;
-- Dec 25, 2012 11:22:03 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=201617
;
-- Dec 25, 2012 11:22:03 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y' WHERE AD_Field_ID=10419
;
-- Dec 25, 2012 11:23:29 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET XPosition=4,Updated=TO_DATE('2012-12-25 11:23:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201617
;
-- Dec 25, 2012 11:26:29 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET ColumnSpan=2, DisplayLogic='@IsGuaranteeDate@=Y', XPosition=5,Updated=TO_DATE('2012-12-25 11:26:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201617
;
-- Dec 25, 2012 8:12:36 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton,IsAlwaysUpdateable) VALUES (0,'N','N',0,762,208342,'D','N','N','N',0,'N',7,'N',16,'N',202184,'N','Y','f2ee4123-70c8-40d5-bb0a-38543c4b2522','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_DATE('2012-12-25 20:12:34','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_DATE('2012-12-25 20:12:34','YYYY-MM-DD HH24:MI:SS'),100,0,'N','N')
;
-- Dec 25, 2012 8:12:36 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=208342 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Dec 25, 2012 8:13:36 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET EntityType='D',Updated=TO_DATE('2012-12-25 20:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208342
;
-- Dec 25, 2012 8:13:42 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_InOutLineMA ADD DateMaterialPolicy DATE DEFAULT NULL
;
UPDATE M_InOutLineMA SET DateMaterialPolicy = (SELECT To_Date(io.MovementDate) FROM M_InOut io JOIN M_InOutLine iol ON (io.M_InOut_ID=iol.M_InOut_ID) WHERE iol.M_InOutLine_ID=M_InOutLineMA.M_InOutLine_ID) WHERE DateMaterialPolicy IS NULL
;
ALTER TABLE M_InOutLineMA MODIFY COLUMN DateMaterialPolicy NOT NULL
;
ALTER TABLE M_InOutLineMA DROP CONSTRAINT m_inoutlinema_pkey
;
ALTER TABLE M_InOutLineMA ADD CONSTRAINT m_inoutlinema_pkey PRIMARY KEY(m_inoutline_id, m_attributesetinstance_id, datematerialpolicy)
;
-- Dec 25, 2012 8:14:10 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,EntityType,Description,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES ('N',751,7,'N','N',208342,'Y',201618,'N','This field is used to record time used for LIFO and FIFO material policy','D','Time used for LIFO and FIFO Material Policy','Date Material Policy','N','Y','c489cb75-8f36-4818-a77c-a30ba8ae5ac2',100,0,TO_DATE('2012-12-25 20:14:09','YYYY-MM-DD HH24:MI:SS'),0,100,TO_DATE('2012-12-25 20:14:09','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Dec 25, 2012 8:14:10 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201618 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Dec 25, 2012 8:14:11 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES ('N',751,36,'N','N',60900,'Y',201619,'N','D','M_InOutLineMA_UU','N','Y','74956b1b-7def-46f8-a9a5-eeb0575fe4bb',100,0,TO_DATE('2012-12-25 20:14:10','YYYY-MM-DD HH24:MI:SS'),0,100,TO_DATE('2012-12-25 20:14:10','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Dec 25, 2012 8:14:11 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201619 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Dec 25, 2012 8:16:53 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=201619
;
-- Dec 25, 2012 8:16:53 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60,IsDisplayed='Y' WHERE AD_Field_ID=201618
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=12195
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=201619
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=12197
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=12198
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=12194
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=12196
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=201618
;
-- Jul 16, 2013 10:14:03 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,IsEncrypted,AD_Client_ID,EntityType,AD_Element_ID) VALUES (0,'N',0,764,210651,'N','N','N',0,'N',7,'N',16,'N','N','Y','b261acf8-ab20-4532-ad4e-fd1f122231cf','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_DATE('2013-07-16 10:14:02','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_DATE('2013-07-16 10:14:02','YYYY-MM-DD HH24:MI:SS'),100,'N','N','N',0,'D',202184)
;
-- Jul 16, 2013 10:14:04 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=210651 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Jul 16, 2013 10:14:26 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_MovementLineMA ADD DateMaterialPolicy DATE DEFAULT NULL
;
UPDATE M_MovementLineMA SET DateMaterialPolicy = (SELECT TO_Date(m.MovementDate) FROM M_Movement m JOIN M_MovementLine ml ON (m.M_Movement_ID=ml.M_Movement_ID) WHERE ml.M_MovementLine_ID=M_MovementLineMA.M_MovementLine_ID) WHERE DateMaterialPolicy IS NULL
;
ALTER TABLE M_MovementLineMA MODIFY DateMaterialPolicy NOT NULL
;
ALTER TABLE M_MovementLineMA DROP CONSTRAINT m_movementlinema_pkey
;
ALTER TABLE M_MovementLineMA ADD CONSTRAINT m_movementlinema_pkey PRIMARY KEY(m_movementline_id, m_attributesetinstance_id, datematerialpolicy)
;
-- Jul 16, 2013 10:18:20 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',750,36,'N','N',60914,60,'Y',202287,'N','M_MovementLineMA_UU','N','N','33f63b7c-5503-4f61-a18d-7ba082506da0',100,0,TO_DATE('2013-07-16 10:18:19','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-16 10:18:19','YYYY-MM-DD HH24:MI:SS'),'Y','N',0,2,'D')
;
-- Jul 16, 2013 10:18:20 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202287 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 16, 2013 10:18:21 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',750,7,'N','N',210651,70,'Y',202288,'N','This field is used to record time used for LIFO and FIFO material policy','Time used for LIFO and FIFO Material Policy','Date Material Policy','N','Y','c1bdc238-1b5a-4d3e-b321-86b285dd9a12',100,0,TO_DATE('2013-07-16 10:18:20','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-16 10:18:20','YYYY-MM-DD HH24:MI:SS'),'Y',0,2,'D')
;
-- Jul 16, 2013 10:18:21 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202288 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 16, 2013 10:19:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=40, IsDisplayed='Y', XPosition=4,Updated=TO_DATE('2013-07-16 10:19:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12188
;
-- Jul 16, 2013 10:19:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=50, IsDisplayed='Y', XPosition=1, ColumnSpan=2,Updated=TO_DATE('2013-07-16 10:19:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12191
;
-- Jul 16, 2013 10:19:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60,Updated=TO_DATE('2013-07-16 10:19:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202288
;
-- Jul 16, 2013 10:19:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=0,Updated=TO_DATE('2013-07-16 10:19:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202287
;
-- Jul 16, 2013 10:20:08 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60, IsDisplayed='Y', XPosition=4,Updated=TO_DATE('2013-07-16 10:20:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202288
;
-- Jul 16, 2013 10:21:06 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=40, IsDisplayed='Y', XPosition=4,Updated=TO_DATE('2013-07-16 10:21:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12194
;
-- Jul 16, 2013 10:21:06 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=50, IsDisplayed='Y', XPosition=1,Updated=TO_DATE('2013-07-16 10:21:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12196
;
-- Jul 16, 2013 10:21:06 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60, IsDisplayed='Y', XPosition=4,Updated=TO_DATE('2013-07-16 10:21:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201618
;
-- Jul 16, 2013 11:33:25 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,IsEncrypted,AD_Client_ID,EntityType,AD_Element_ID) VALUES (0,'N',0,763,210653,'N','N','N',0,'N',7,'N',16,'N','N','Y','b14bae38-065a-4daa-9ad5-94b96062e511','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_DATE('2013-07-16 11:33:24','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_DATE('2013-07-16 11:33:24','YYYY-MM-DD HH24:MI:SS'),100,'N','N','N',0,'D',202184)
;
-- Jul 16, 2013 11:33:25 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=210653 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Jul 16, 2013 11:35:42 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET EntityType='D',Updated=TO_DATE('2013-07-16 11:35:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210653
;
-- Jul 16, 2013 11:35:52 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_InventoryLineMA ADD DateMaterialPolicy DATE DEFAULT NULL
;
UPDATE M_InventoryLineMA SET DateMaterialPolicy = (SELECT Date(i.MovementDate) FROM M_Inventory i JOIN M_InventoryLine il ON (i.M_Inventory_ID=il.M_Inventory_ID) WHERE il.M_InventoryLine_ID=M_InventoryLineMA.M_InventoryLine_ID) WHERE DateMaterialPolicy IS NULL
;
ALTER TABLE M_InventoryLineMA MODIFY DateMaterialPolicy NOT NULL
;
ALTER TABLE M_InventoryLineMA ADD CONSTRAINT m_inventorylinema_pkey PRIMARY KEY(m_inventoryline_id, m_attributesetinstance_id, datematerialpolicy)
;
-- Jul 16, 2013 11:36:10 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',749,36,'N','N',60903,60,'Y',202289,'N','M_InventoryLineMA_UU','N','N','a3609970-e680-491b-a608-100617e5eb64',100,0,TO_DATE('2013-07-16 11:36:09','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-16 11:36:09','YYYY-MM-DD HH24:MI:SS'),'Y','N',0,2,'D')
;
-- Jul 16, 2013 11:36:10 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202289 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 16, 2013 11:36:11 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',749,7,'N','N',210653,70,'Y',202290,'N','This field is used to record time used for LIFO and FIFO material policy','Time used for LIFO and FIFO Material Policy','Date Material Policy','N','Y','4318813a-f3e7-43d6-a795-7682a2b37fd6',100,0,TO_DATE('2013-07-16 11:36:10','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-16 11:36:10','YYYY-MM-DD HH24:MI:SS'),'Y',0,2,'D')
;
-- Jul 16, 2013 11:36:11 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202290 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 16, 2013 11:36:34 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=40, IsDisplayed='Y', XPosition=4,Updated=TO_DATE('2013-07-16 11:36:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12182
;
-- Jul 16, 2013 11:36:34 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=50, IsDisplayed='Y', XPosition=1,Updated=TO_DATE('2013-07-16 11:36:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12184
;
-- Jul 16, 2013 11:36:34 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60, IsDisplayed='Y', XPosition=4,Updated=TO_DATE('2013-07-16 11:36:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202290
;
-- Jul 16, 2013 11:36:34 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=0,Updated=TO_DATE('2013-07-16 11:36:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202289
;
-- Jul 17, 2013 4:06:51 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_ProductionLine ADD DateMaterialPolicy DATE DEFAULT NULL
;
-- Jul 17, 2013 4:07:09 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',321,36,'N','N',60929,130,'Y',202335,'N','M_ProductionLine_UU','N','N','976abb9e-bb13-4a15-a379-e74764a407f0',100,0,TO_DATE('2013-07-17 16:07:08','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-17 16:07:08','YYYY-MM-DD HH24:MI:SS'),'Y','N',0,2,'D')
;
-- Jul 17, 2013 4:07:09 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202335 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 17, 2013 4:09:07 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,IsEncrypted,AD_Client_ID,EntityType,AD_Element_ID) VALUES (0,'N',0,765,210658,'N','N','N',0,'N',7,'N',16,'N','N','Y','7834c3ff-8c66-441c-bc49-9430e9861db2','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_DATE('2013-07-17 16:09:06','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_DATE('2013-07-17 16:09:06','YYYY-MM-DD HH24:MI:SS'),100,'N','N','N',0,'D',202184)
;
-- Jul 17, 2013 4:09:07 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=210658 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Jul 17, 2013 4:09:17 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_ProductionLineMA ADD DateMaterialPolicy DATE DEFAULT NULL
;
UPDATE M_ProductionLineMA SET DateMaterialPolicy = (SELECT TO_Date(p.MovementDate) FROM M_Production p JOIN M_ProductionLine pl ON (p.M_Production_ID=pl.M_Production_ID) WHERE pl.M_ProductionLine_ID=M_ProductionLineMA.M_ProductionLine_ID) WHERE DateMaterialPolicy IS NULL
;
ALTER TABLE M_ProductionLineMA MODIFY DateMaterialPolicy NOT NULL
;
ALTER TABLE M_ProductionLineMA DROP CONSTRAINT m_productionlinema_pkey
;
ALTER TABLE M_ProductionLineMA ADD CONSTRAINT m_productionlinema_pkey PRIMARY KEY(m_productionline_id, m_attributesetinstance_id, datematerialpolicy)
;
Update M_StorageOnHand Set DateMaterialPolicy = To_Date(Created)
;
-- Aug 3, 2013 2:45:42 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsMandatory='Y',Updated=TO_DATE('2013-08-03 14:45:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208340
;
-- Aug 3, 2013 2:46:05 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_StorageOnHand MODIFY DateMaterialPolicy DATE
;
-- Aug 3, 2013 2:46:05 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_StorageOnHand MODIFY DateMaterialPolicy NOT NULL
;
ALTER TABLE m_storageonhand DROP CONSTRAINT m_storageonhand_pkey
;
ALTER TABLE M_StorageOnHand ADD CONSTRAINT M_StorageOnHand_pkey PRIMARY KEY (m_product_id , m_locator_id , m_attributesetinstance_id, DateMaterialPolicy )
;
CREATE OR REPLACE VIEW m_storage
AS
SELECT s.m_product_id,
s.m_locator_id,
s.ad_client_id,
s.ad_org_id,
s.isactive,
s.created,
s.createdby,
s.updated,
s.updatedby,
s.qtyonhand,
0 AS qtyreserved,
0 AS qtyordered,
s.datelastinventory,
s.m_attributesetinstance_id,
s.m_storageonhand_uu AS m_storage_uu,
s.datematerialpolicy AS datematerialpolicy
FROM m_storageonhand s
UNION
SELECT sr.m_product_id,
w.m_reservelocator_id AS m_locator_id,
sr.ad_client_id,
sr.ad_org_id,
sr.isactive,
sr.created,
sr.createdby,
sr.updated,
sr.updatedby,
0 AS qtyonhand,
sr.qty AS qtyreserved,
0 AS qtyordered,
sr.datelastinventory,
sr.m_attributesetinstance_id,
sr.m_storagereservation_uu AS m_storage_uu,
null as datematerialpolicy
FROM m_storagereservation sr
JOIN m_warehouse w
ON sr.m_warehouse_id = w.m_warehouse_id
WHERE sr.issotrx = 'Y' and sr.qty <> 0
UNION
SELECT so.m_product_id,
w.m_reservelocator_id AS m_locator_id,
so.ad_client_id,
so.ad_org_id,
so.isactive,
so.created,
so.createdby,
so.updated,
so.updatedby,
0 AS qtyonhand,
0 AS qtyreserved,
so.qty AS qtyordered,
so.datelastinventory,
so.m_attributesetinstance_id,
so.m_storagereservation_uu AS m_storage_uu,
null as datematerialpolicy
FROM m_storagereservation so
JOIN m_warehouse w
ON so.m_warehouse_id = w.m_warehouse_id
WHERE so.issotrx = 'N' and so.qty <> 0
;
-- Oct 16, 2013 5:48:19 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,AD_Element_ID,IsSecure) VALUES (0,'N',1,250,1003519,'N','N','N',0,'N',7,'N',16,'N','N','N','e7fac848-ba58-41ac-81f3-bac9f3c81e62','N','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','N',TO_DATE('2013-10-16 17:48:19','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2013-10-16 17:48:19','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N',202184,'N')
;
-- Oct 16, 2013 5:48:56 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,EntityType,IsAdvancedField,IsDefaultFocus) VALUES (0,'N',53244,0,'N','N',1003519,110,'Y',1002071,'N','This field is used to record time used for LIFO and FIFO material policy','Time used for LIFO and FIFO Material Policy','Date Material Policy','cf628432-e15e-47fe-af1d-9803f5b155b8','Y','N',100,0,TO_DATE('2013-10-16 17:48:56','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-10-16 17:48:56','YYYY-MM-DD HH24:MI:SS'),'Y','Y',110,1,'N',0,2,1,'D','N','N')
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60, IsDisplayed='Y', XPosition=4,Updated=TO_DATE('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1002071
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=70,Updated=TO_DATE('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57394
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=80,Updated=TO_DATE('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57393
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=90,Updated=TO_DATE('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57395
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=100,Updated=TO_DATE('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57396
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=110,Updated=TO_DATE('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57399
;
-- Oct 16, 2013 5:50:26 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=60,Updated=TO_DATE('2013-10-16 17:50:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1002071
;
-- Oct 16, 2013 5:50:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=70,Updated=TO_DATE('2013-10-16 17:50:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57394
;
-- Oct 16, 2013 5:50:44 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=80,Updated=TO_DATE('2013-10-16 17:50:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57393
;
-- Oct 16, 2013 5:50:53 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=90,Updated=TO_DATE('2013-10-16 17:50:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57395
;
-- Oct 16, 2013 5:51:03 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=100,Updated=TO_DATE('2013-10-16 17:51:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57396
;
-- Oct 16, 2013 5:51:14 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=110,Updated=TO_DATE('2013-10-16 17:51:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57399
;
-- Oct 16, 2013 8:01:34 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_DATE('2013-10-16 20:01:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208340
;
-- Oct 16, 2013 8:03:45 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_DATE('2013-10-16 20:03:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208342
;
-- Oct 16, 2013 8:04:25 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_DATE('2013-10-16 20:04:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210653
;
-- Oct 16, 2013 8:05:02 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_DATE('2013-10-16 20:05:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210651
;
-- Oct 16, 2013 8:05:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_DATE('2013-10-16 20:05:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210658
;
-- Oct 16, 2013 8:06:41 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_DATE('2013-10-16 20:06:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=1003519
;
-- Oct 17, 2013 4:05:31 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_DATE('2013-10-17 16:05:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208340
;
-- Oct 17, 2013 4:06:52 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_DATE('2013-10-17 16:06:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208342
;
-- Oct 17, 2013 4:07:28 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_DATE('2013-10-17 16:07:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210653
;
-- Oct 17, 2013 4:08:06 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_DATE('2013-10-17 16:08:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210651
;
-- Oct 17, 2013 4:09:51 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_DATE('2013-10-17 16:09:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210658
;
SELECT register_migration_script('201310141246_IDEMPIERE-386.sql') FROM dual
;

View File

@ -0,0 +1,605 @@
-- Dec 25, 2012 10:54:46 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Element (ColumnName,AD_Element_ID,Help,EntityType,Description,Name,PrintName,AD_Element_UU,AD_Client_ID,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive) VALUES ('DateMaterialPolicy',202184,'This field is used to record time used for LIFO and FIFO material policy','D','Time used for LIFO and FIFO Material Policy','Date Material Policy','Date Material Policy','b45c798f-5957-4856-bc64-979c5dd54147',0,TO_TIMESTAMP('2012-12-25 10:54:44','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2012-12-25 10:54:44','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y')
;
-- Dec 25, 2012 10:54:46 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Help,PO_Description,PO_Help,Description,Name,PrintName,PO_Name,PO_PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Help,t.PO_Description,t.PO_Help,t.Description,t.Name,t.PrintName,t.PO_Name,t.PO_PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=202184 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
;
-- Dec 25, 2012 10:56:17 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton,IsAlwaysUpdateable) VALUES (0,'N','N',0,200026,208340,'D','N','N','N',0,'N',7,'N',16,'N',202184,'N','Y','913e1eca-ca35-461a-ae0d-709589cd89d5','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_TIMESTAMP('2012-12-25 10:56:16','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_TIMESTAMP('2012-12-25 10:56:16','YYYY-MM-DD HH24:MI:SS'),100,0,'N','N')
;
-- Dec 25, 2012 10:56:17 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=208340 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Dec 25, 2012 10:56:39 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_StorageOnHand ADD COLUMN DateMaterialPolicy TIMESTAMP DEFAULT NULL
;
-- Dec 25, 2012 11:17:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Element (ColumnName,AD_Element_ID,EntityType,Name,PrintName,AD_Element_UU,AD_Client_ID,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive) VALUES ('UseGuaranteeDateForMPolicy',202185,'D','Use Guarantee Date for Material Policy','Use Guarantee Date for Material Policy','de278e48-9731-4100-bf5f-f8b74dc15807',0,TO_TIMESTAMP('2012-12-25 11:17:32','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2012-12-25 11:17:32','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y')
;
-- Dec 25, 2012 11:17:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Help,PO_Description,PO_Help,Description,Name,PrintName,PO_Name,PO_PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Help,t.PO_Description,t.PO_Help,t.Description,t.Name,t.PrintName,t.PO_Name,t.PO_PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=202185 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
;
-- Dec 25, 2012 11:18:40 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,DefaultValue,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton,IsAlwaysUpdateable) VALUES (0,'N','N',0,560,208341,'D','N','N','N',0,'N',1,'N',20,'N',202185,'N','Y','3af336ad-d7c4-4bcc-b2dd-f7f23e39bc82','Y','UseGuaranteeDateForMPolicy','N','Use Guarantee Date for Material Policy','Y',100,TO_TIMESTAMP('2012-12-25 11:18:39','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_TIMESTAMP('2012-12-25 11:18:39','YYYY-MM-DD HH24:MI:SS'),100,0,'N','N')
;
-- Dec 25, 2012 11:18:40 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=208341 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Dec 25, 2012 11:18:47 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_AttributeSet ADD COLUMN UseGuaranteeDateForMPolicy CHAR(1) DEFAULT 'N' CHECK (UseGuaranteeDateForMPolicy IN ('Y','N'))
;
-- Dec 25, 2012 11:21:32 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES ('N',461,36,'N','N',60867,'Y',201616,'N','D','M_AttributeSet_UU','N','Y','a02bb9da-705d-4ee5-9ba0-8809aaca675c',100,0,TO_TIMESTAMP('2012-12-25 11:21:31','YYYY-MM-DD HH24:MI:SS'),0,100,TO_TIMESTAMP('2012-12-25 11:21:31','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Dec 25, 2012 11:21:32 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201616 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Dec 25, 2012 11:21:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES ('N',461,1,'N','N',208341,'Y',201617,'N','D','Use Guarantee Date for Material Policy','N','Y','afec456c-437d-42ff-8b92-6d764569c8e4',100,0,TO_TIMESTAMP('2012-12-25 11:21:32','YYYY-MM-DD HH24:MI:SS'),0,100,TO_TIMESTAMP('2012-12-25 11:21:32','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Dec 25, 2012 11:21:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201617 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Dec 25, 2012 11:22:03 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=201616
;
-- Dec 25, 2012 11:22:03 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=201617
;
-- Dec 25, 2012 11:22:03 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y' WHERE AD_Field_ID=10419
;
-- Dec 25, 2012 11:23:29 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET XPosition=4,Updated=TO_TIMESTAMP('2012-12-25 11:23:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201617
;
-- Dec 25, 2012 11:26:29 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET ColumnSpan=2, DisplayLogic='@IsGuaranteeDate@=Y', XPosition=5,Updated=TO_TIMESTAMP('2012-12-25 11:26:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201617
;
-- Dec 25, 2012 8:12:36 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton,IsAlwaysUpdateable) VALUES (0,'N','N',0,762,208342,'D','N','N','N',0,'N',7,'N',16,'N',202184,'N','Y','f2ee4123-70c8-40d5-bb0a-38543c4b2522','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_TIMESTAMP('2012-12-25 20:12:34','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_TIMESTAMP('2012-12-25 20:12:34','YYYY-MM-DD HH24:MI:SS'),100,0,'N','N')
;
-- Dec 25, 2012 8:12:36 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=208342 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Dec 25, 2012 8:13:36 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET EntityType='D',Updated=TO_TIMESTAMP('2012-12-25 20:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208342
;
-- Dec 25, 2012 8:13:42 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_InOutLineMA ADD COLUMN DateMaterialPolicy TIMESTAMP DEFAULT NULL
;
UPDATE M_InOutLineMA SET DateMaterialPolicy = (SELECT Date(io.MovementDate) FROM M_InOut io JOIN M_InOutLine iol ON (io.M_InOut_ID=iol.M_InOut_ID) WHERE iol.M_InOutLine_ID=M_InOutLineMA.M_InOutLine_ID) WHERE DateMaterialPolicy IS NULL
;
ALTER TABLE M_InOutLineMA ALTER COLUMN DateMaterialPolicy SET NOT NULL
;
ALTER TABLE M_InOutLineMA DROP CONSTRAINT m_inoutlinema_pkey
;
ALTER TABLE M_InOutLineMA ADD CONSTRAINT m_inoutlinema_pkey PRIMARY KEY(m_inoutline_id, m_attributesetinstance_id, datematerialpolicy)
;
-- Dec 25, 2012 8:14:10 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,EntityType,Description,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES ('N',751,7,'N','N',208342,'Y',201618,'N','This field is used to record time used for LIFO and FIFO material policy','D','Time used for LIFO and FIFO Material Policy','Date Material Policy','N','Y','c489cb75-8f36-4818-a77c-a30ba8ae5ac2',100,0,TO_TIMESTAMP('2012-12-25 20:14:09','YYYY-MM-DD HH24:MI:SS'),0,100,TO_TIMESTAMP('2012-12-25 20:14:09','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Dec 25, 2012 8:14:10 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201618 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Dec 25, 2012 8:14:11 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES ('N',751,36,'N','N',60900,'Y',201619,'N','D','M_InOutLineMA_UU','N','Y','74956b1b-7def-46f8-a9a5-eeb0575fe4bb',100,0,TO_TIMESTAMP('2012-12-25 20:14:10','YYYY-MM-DD HH24:MI:SS'),0,100,TO_TIMESTAMP('2012-12-25 20:14:10','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Dec 25, 2012 8:14:11 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201619 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Dec 25, 2012 8:16:53 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=201619
;
-- Dec 25, 2012 8:16:53 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60,IsDisplayed='Y' WHERE AD_Field_ID=201618
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=12195
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=201619
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=12197
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=12198
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=12194
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=12196
;
-- Dec 25, 2012 8:17:04 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=201618
;
-- Jul 16, 2013 10:14:03 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,IsEncrypted,AD_Client_ID,EntityType,AD_Element_ID) VALUES (0,'N',0,764,210651,'N','N','N',0,'N',7,'N',16,'N','N','Y','b261acf8-ab20-4532-ad4e-fd1f122231cf','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_TIMESTAMP('2013-07-16 10:14:02','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_TIMESTAMP('2013-07-16 10:14:02','YYYY-MM-DD HH24:MI:SS'),100,'N','N','N',0,'D',202184)
;
-- Jul 16, 2013 10:14:04 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=210651 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Jul 16, 2013 10:14:26 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_MovementLineMA ADD COLUMN DateMaterialPolicy TIMESTAMP DEFAULT NULL
;
UPDATE M_MovementLineMA SET DateMaterialPolicy = (SELECT Date(m.MovementDate) FROM M_Movement m JOIN M_MovementLine ml ON (m.M_Movement_ID=ml.M_Movement_ID) WHERE ml.M_MovementLine_ID=M_MovementLineMA.M_MovementLine_ID) WHERE DateMaterialPolicy IS NULL
;
ALTER TABLE M_MovementLineMA ALTER COLUMN DateMaterialPolicy SET NOT NULL
;
ALTER TABLE M_MovementLineMA DROP CONSTRAINT m_movementlinema_pkey
;
ALTER TABLE M_MovementLineMA ADD CONSTRAINT m_movementlinema_pkey PRIMARY KEY(m_movementline_id, m_attributesetinstance_id, datematerialpolicy)
;
-- Jul 16, 2013 10:18:20 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',750,36,'N','N',60914,60,'Y',202287,'N','M_MovementLineMA_UU','N','N','33f63b7c-5503-4f61-a18d-7ba082506da0',100,0,TO_TIMESTAMP('2013-07-16 10:18:19','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-16 10:18:19','YYYY-MM-DD HH24:MI:SS'),'Y','N',0,2,'D')
;
-- Jul 16, 2013 10:18:20 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202287 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 16, 2013 10:18:21 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',750,7,'N','N',210651,70,'Y',202288,'N','This field is used to record time used for LIFO and FIFO material policy','Time used for LIFO and FIFO Material Policy','Date Material Policy','N','Y','c1bdc238-1b5a-4d3e-b321-86b285dd9a12',100,0,TO_TIMESTAMP('2013-07-16 10:18:20','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-16 10:18:20','YYYY-MM-DD HH24:MI:SS'),'Y',0,2,'D')
;
-- Jul 16, 2013 10:18:21 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202288 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 16, 2013 10:19:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=40, IsDisplayed='Y', XPosition=4,Updated=TO_TIMESTAMP('2013-07-16 10:19:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12188
;
-- Jul 16, 2013 10:19:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=50, IsDisplayed='Y', XPosition=1, ColumnSpan=2,Updated=TO_TIMESTAMP('2013-07-16 10:19:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12191
;
-- Jul 16, 2013 10:19:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60,Updated=TO_TIMESTAMP('2013-07-16 10:19:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202288
;
-- Jul 16, 2013 10:19:33 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=0,Updated=TO_TIMESTAMP('2013-07-16 10:19:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202287
;
-- Jul 16, 2013 10:20:08 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60, IsDisplayed='Y', XPosition=4,Updated=TO_TIMESTAMP('2013-07-16 10:20:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202288
;
-- Jul 16, 2013 10:21:06 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=40, IsDisplayed='Y', XPosition=4,Updated=TO_TIMESTAMP('2013-07-16 10:21:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12194
;
-- Jul 16, 2013 10:21:06 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=50, IsDisplayed='Y', XPosition=1,Updated=TO_TIMESTAMP('2013-07-16 10:21:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12196
;
-- Jul 16, 2013 10:21:06 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60, IsDisplayed='Y', XPosition=4,Updated=TO_TIMESTAMP('2013-07-16 10:21:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201618
;
-- Jul 16, 2013 11:33:25 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,IsEncrypted,AD_Client_ID,EntityType,AD_Element_ID) VALUES (0,'N',0,763,210653,'N','N','N',0,'N',7,'N',16,'N','N','Y','b14bae38-065a-4daa-9ad5-94b96062e511','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_TIMESTAMP('2013-07-16 11:33:24','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_TIMESTAMP('2013-07-16 11:33:24','YYYY-MM-DD HH24:MI:SS'),100,'N','N','N',0,'D',202184)
;
-- Jul 16, 2013 11:33:25 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=210653 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Jul 16, 2013 11:35:42 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET EntityType='D',Updated=TO_TIMESTAMP('2013-07-16 11:35:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210653
;
-- Jul 16, 2013 11:35:52 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_InventoryLineMA ADD COLUMN DateMaterialPolicy TIMESTAMP DEFAULT NULL
;
UPDATE M_InventoryLineMA SET DateMaterialPolicy = (SELECT Date(i.MovementDate) FROM M_Inventory i JOIN M_InventoryLine il ON (i.M_Inventory_ID=il.M_Inventory_ID) WHERE il.M_InventoryLine_ID=M_InventoryLineMA.M_InventoryLine_ID) WHERE DateMaterialPolicy IS NULL
;
ALTER TABLE M_InventoryLineMA ALTER COLUMN DateMaterialPolicy SET NOT NULL
;
ALTER TABLE M_InventoryLineMA ADD CONSTRAINT m_inventorylinema_pkey PRIMARY KEY(m_inventoryline_id, m_attributesetinstance_id, datematerialpolicy)
;
-- Jul 16, 2013 11:36:10 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',749,36,'N','N',60903,60,'Y',202289,'N','M_InventoryLineMA_UU','N','N','a3609970-e680-491b-a608-100617e5eb64',100,0,TO_TIMESTAMP('2013-07-16 11:36:09','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-16 11:36:09','YYYY-MM-DD HH24:MI:SS'),'Y','N',0,2,'D')
;
-- Jul 16, 2013 11:36:10 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202289 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 16, 2013 11:36:11 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',749,7,'N','N',210653,70,'Y',202290,'N','This field is used to record time used for LIFO and FIFO material policy','Time used for LIFO and FIFO Material Policy','Date Material Policy','N','Y','4318813a-f3e7-43d6-a795-7682a2b37fd6',100,0,TO_TIMESTAMP('2013-07-16 11:36:10','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-16 11:36:10','YYYY-MM-DD HH24:MI:SS'),'Y',0,2,'D')
;
-- Jul 16, 2013 11:36:11 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202290 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 16, 2013 11:36:34 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=40, IsDisplayed='Y', XPosition=4,Updated=TO_TIMESTAMP('2013-07-16 11:36:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12182
;
-- Jul 16, 2013 11:36:34 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=50, IsDisplayed='Y', XPosition=1,Updated=TO_TIMESTAMP('2013-07-16 11:36:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12184
;
-- Jul 16, 2013 11:36:34 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60, IsDisplayed='Y', XPosition=4,Updated=TO_TIMESTAMP('2013-07-16 11:36:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202290
;
-- Jul 16, 2013 11:36:34 AM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=0,Updated=TO_TIMESTAMP('2013-07-16 11:36:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202289
;
-- Jul 17, 2013 4:07:09 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,AD_Client_ID,ColumnSpan,EntityType) VALUES ('N',321,36,'N','N',60929,130,'Y',202335,'N','M_ProductionLine_UU','N','N','976abb9e-bb13-4a15-a379-e74764a407f0',100,0,TO_TIMESTAMP('2013-07-17 16:07:08','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-17 16:07:08','YYYY-MM-DD HH24:MI:SS'),'Y','N',0,2,'D')
;
-- Jul 17, 2013 4:07:09 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=202335 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Jul 17, 2013 4:09:07 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,IsEncrypted,AD_Client_ID,EntityType,AD_Element_ID) VALUES (0,'N',0,765,210658,'N','N','N',0,'N',7,'N',16,'N','N','Y','7834c3ff-8c66-441c-bc49-9430e9861db2','Y','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','Y',100,TO_TIMESTAMP('2013-07-17 16:09:06','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_TIMESTAMP('2013-07-17 16:09:06','YYYY-MM-DD HH24:MI:SS'),100,'N','N','N',0,'D',202184)
;
-- Jul 17, 2013 4:09:07 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=210658 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Jul 17, 2013 4:09:17 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
ALTER TABLE M_ProductionLineMA ADD COLUMN DateMaterialPolicy TIMESTAMP DEFAULT NULL
;
UPDATE M_ProductionLineMA SET DateMaterialPolicy = (SELECT Date(p.MovementDate) FROM M_Production p JOIN M_ProductionLine pl ON (p.M_Production_ID=pl.M_Production_ID) WHERE pl.M_ProductionLine_ID=M_ProductionLineMA.M_ProductionLine_ID) WHERE DateMaterialPolicy IS NULL
;
ALTER TABLE M_ProductionLineMA ALTER COLUMN DateMaterialPolicy SET NOT NULL
;
ALTER TABLE M_ProductionLineMA DROP CONSTRAINT m_productionlinema_pkey
;
ALTER TABLE M_ProductionLineMA ADD CONSTRAINT m_productionlinema_pkey PRIMARY KEY(m_productionline_id, m_attributesetinstance_id, datematerialpolicy)
;
ALTER TABLE m_storageonhand DROP CONSTRAINT m_storageonhand_pkey
;
Update M_StorageOnHand SET DateMaterialPolicy = Date(Created)
;
-- Aug 3, 2013 2:45:42 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsMandatory='Y',Updated=TO_TIMESTAMP('2013-08-03 14:45:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208340
;
-- Aug 3, 2013 2:46:05 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO t_alter_column values('m_storageonhand','DateMaterialPolicy','TIMESTAMP',null,null)
;
-- Aug 3, 2013 2:46:05 PM IST
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO t_alter_column values('m_storageonhand','DateMaterialPolicy',null,'NOT NULL',null)
;
ALTER TABLE M_StorageOnHand ADD CONSTRAINT m_storageonhand_pkey PRIMARY KEY (m_product_id , m_locator_id , m_attributesetinstance_id, DateMaterialPolicy )
;
CREATE OR REPLACE VIEW m_storage
AS
SELECT s.m_product_id,
s.m_locator_id,
s.ad_client_id,
s.ad_org_id,
s.isactive,
s.created,
s.createdby,
s.updated,
s.updatedby,
s.qtyonhand,
0 AS qtyreserved,
0 AS qtyordered,
s.datelastinventory,
s.m_attributesetinstance_id,
s.m_storageonhand_uu AS m_storage_uu,
s.datematerialpolicy AS datematerialpolicy
FROM m_storageonhand s
UNION
SELECT sr.m_product_id,
w.m_reservelocator_id AS m_locator_id,
sr.ad_client_id,
sr.ad_org_id,
sr.isactive,
sr.created,
sr.createdby,
sr.updated,
sr.updatedby,
0 AS qtyonhand,
sr.qty AS qtyreserved,
0 AS qtyordered,
sr.datelastinventory,
sr.m_attributesetinstance_id,
sr.m_storagereservation_uu AS m_storage_uu,
null as datematerialpolicy
FROM m_storagereservation sr
JOIN m_warehouse w
ON sr.m_warehouse_id = w.m_warehouse_id
WHERE sr.issotrx = 'Y' and sr.qty <> 0
UNION
SELECT so.m_product_id,
w.m_reservelocator_id AS m_locator_id,
so.ad_client_id,
so.ad_org_id,
so.isactive,
so.created,
so.createdby,
so.updated,
so.updatedby,
0 AS qtyonhand,
0 AS qtyreserved,
so.qty AS qtyordered,
so.datelastinventory,
so.m_attributesetinstance_id,
so.m_storagereservation_uu AS m_storage_uu,
null as datematerialpolicy
FROM m_storagereservation so
JOIN m_warehouse w
ON so.m_warehouse_id = w.m_warehouse_id
WHERE so.issotrx = 'N' and so.qty <> 0
;
-- Oct 16, 2013 5:48:19 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,AD_Element_ID,IsSecure) VALUES (0,'N',1,250,1003519,'N','N','N',0,'N',7,'N',16,'N','N','N','e7fac848-ba58-41ac-81f3-bac9f3c81e62','N','DateMaterialPolicy','Time used for LIFO and FIFO Material Policy','This field is used to record time used for LIFO and FIFO material policy','Date Material Policy','N',TO_TIMESTAMP('2013-10-16 17:48:19','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2013-10-16 17:48:19','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N',202184,'N')
;
-- Oct 16, 2013 5:48:56 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,EntityType,IsAdvancedField,IsDefaultFocus) VALUES (0,'N',53244,0,'N','N',1003519,110,'Y',1002071,'N','This field is used to record time used for LIFO and FIFO material policy','Time used for LIFO and FIFO Material Policy','Date Material Policy','cf628432-e15e-47fe-af1d-9803f5b155b8','Y','N',100,0,TO_TIMESTAMP('2013-10-16 17:48:56','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-10-16 17:48:56','YYYY-MM-DD HH24:MI:SS'),'Y','Y',110,1,'N',0,2,1,'D','N','N')
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=60, IsDisplayed='Y', XPosition=4,Updated=TO_TIMESTAMP('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1002071
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=70,Updated=TO_TIMESTAMP('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57394
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=80,Updated=TO_TIMESTAMP('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57393
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=90,Updated=TO_TIMESTAMP('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57395
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=100,Updated=TO_TIMESTAMP('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57396
;
-- Oct 16, 2013 5:49:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNo=110,Updated=TO_TIMESTAMP('2013-10-16 17:49:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57399
;
-- Oct 16, 2013 5:50:26 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=60,Updated=TO_TIMESTAMP('2013-10-16 17:50:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1002071
;
-- Oct 16, 2013 5:50:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=70,Updated=TO_TIMESTAMP('2013-10-16 17:50:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57394
;
-- Oct 16, 2013 5:50:44 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=80,Updated=TO_TIMESTAMP('2013-10-16 17:50:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57393
;
-- Oct 16, 2013 5:50:53 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=90,Updated=TO_TIMESTAMP('2013-10-16 17:50:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57395
;
-- Oct 16, 2013 5:51:03 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=100,Updated=TO_TIMESTAMP('2013-10-16 17:51:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57396
;
-- Oct 16, 2013 5:51:14 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Field SET SeqNoGrid=110,Updated=TO_TIMESTAMP('2013-10-16 17:51:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57399
;
-- Oct 16, 2013 8:01:34 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_TIMESTAMP('2013-10-16 20:01:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208340
;
-- Oct 16, 2013 8:03:45 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_TIMESTAMP('2013-10-16 20:03:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208342
;
-- Oct 16, 2013 8:04:25 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_TIMESTAMP('2013-10-16 20:04:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210653
;
-- Oct 16, 2013 8:05:02 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_TIMESTAMP('2013-10-16 20:05:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210651
;
-- Oct 16, 2013 8:05:35 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_TIMESTAMP('2013-10-16 20:05:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210658
;
-- Oct 16, 2013 8:06:41 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET AD_Reference_ID=15,Updated=TO_TIMESTAMP('2013-10-16 20:06:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=1003519
;
-- Oct 17, 2013 4:05:31 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_TIMESTAMP('2013-10-17 16:05:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208340
;
-- Oct 17, 2013 4:06:52 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_TIMESTAMP('2013-10-17 16:06:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208342
;
-- Oct 17, 2013 4:07:28 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_TIMESTAMP('2013-10-17 16:07:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210653
;
-- Oct 17, 2013 4:08:06 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_TIMESTAMP('2013-10-17 16:08:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210651
;
-- Oct 17, 2013 4:09:51 PM MYT
-- IDEMPIERE-386 Redesign ASI usage for FIFO
UPDATE AD_Column SET IsParent='Y', IsUpdateable='N',Updated=TO_TIMESTAMP('2013-10-17 16:09:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210658
;
SELECT register_migration_script('201310141246_IDEMPIERE-386.sql') FROM dual
;

View File

@ -123,7 +123,7 @@ public class CalloutMovement extends CalloutEngine
int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, WindowNo, "M_AttributeSetInstance_ID");
BigDecimal available = Env.ZERO;
if (M_AttributeSetInstance_ID > 0) {
MStorageOnHand oh = MStorageOnHand.get(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, null);
MStorageOnHand oh = MStorageOnHand.get(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, null,null);
if (oh != null)
available = oh.getQtyOnHand();
} else {

View File

@ -21,6 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.Iterator;
import java.util.Vector;
import java.util.logging.Level;
@ -64,7 +65,7 @@ public class InventoryCountCreate extends SvrProcess
/** Inventory Line */
private MInventoryLine m_line = null;
private Timestamp oldDateMPolicy = null;
/**
* Prepare - e.g., get Parameters.
@ -160,8 +161,8 @@ public class InventoryCountCreate extends SvrProcess
}
StringBuilder sql = new StringBuilder("SELECT s.M_Product_ID, s.M_Locator_ID, s.M_AttributeSetInstance_ID,");
sql.append(" s.QtyOnHand, p.M_AttributeSet_ID ");
sql.append("FROM M_Product p");
sql.append(" s.QtyOnHand, p.M_AttributeSet_ID ,s.DateMaterialPolicy");
sql.append(" FROM M_Product p");
sql.append(" INNER JOIN M_StorageOnHand s ON (s.M_Product_ID=p.M_Product_ID)");
sql.append(" INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID) ");
sql.append("WHERE l.M_Warehouse_ID=?");
@ -224,6 +225,8 @@ public class InventoryCountCreate extends SvrProcess
if (QtyOnHand == null)
QtyOnHand = Env.ZERO;
int M_AttributeSet_ID = rs.getInt(5);
Timestamp dateMpolicy = rs.getTimestamp(6);
//
int compare = QtyOnHand.compareTo(Env.ZERO);
if (p_QtyRange == null
@ -233,7 +236,7 @@ public class InventoryCountCreate extends SvrProcess
|| (p_QtyRange.equals("N") && compare != 0))
{
count += createInventoryLine (M_Locator_ID, M_Product_ID,
M_AttributeSetInstance_ID, QtyOnHand, M_AttributeSet_ID);
M_AttributeSetInstance_ID, QtyOnHand, M_AttributeSet_ID,dateMpolicy);
}
}
}
@ -273,7 +276,7 @@ public class InventoryCountCreate extends SvrProcess
* @return lines added
*/
private int createInventoryLine (int M_Locator_ID, int M_Product_ID,
int M_AttributeSetInstance_ID, BigDecimal QtyOnHand, int M_AttributeSet_ID)
int M_AttributeSetInstance_ID, BigDecimal QtyOnHand, int M_AttributeSet_ID,Timestamp dateMPolicy)
{
boolean oneLinePerASI = false;
if (M_AttributeSet_ID != 0)
@ -301,7 +304,7 @@ public class InventoryCountCreate extends SvrProcess
if (QtyOnHand.signum() == 0)
return 0;
// Same ASI (usually 0)
if (m_line.getM_AttributeSetInstance_ID() == M_AttributeSetInstance_ID)
if (m_line.getM_AttributeSetInstance_ID() == M_AttributeSetInstance_ID && ((dateMPolicy==null && oldDateMPolicy==null) || (dateMPolicy!=null && dateMPolicy.equals(oldDateMPolicy)) || (oldDateMPolicy!=null && oldDateMPolicy.equals(dateMPolicy))))
{
m_line.setQtyBook(m_line.getQtyBook().add(QtyOnHand));
m_line.setQtyCount(m_line.getQtyCount().add(QtyOnHand));
@ -312,7 +315,7 @@ public class InventoryCountCreate extends SvrProcess
else if (m_line.getM_AttributeSetInstance_ID() != 0)
{
MInventoryLineMA ma = new MInventoryLineMA (m_line,
m_line.getM_AttributeSetInstance_ID(), m_line.getQtyBook());
m_line.getM_AttributeSetInstance_ID(), m_line.getQtyBook(),oldDateMPolicy);
if (!ma.save())
;
}
@ -320,9 +323,10 @@ public class InventoryCountCreate extends SvrProcess
m_line.setQtyBook(m_line.getQtyBook().add(QtyOnHand));
m_line.setQtyCount(m_line.getQtyCount().add(QtyOnHand));
m_line.saveEx();
//
MInventoryLineMA ma = new MInventoryLineMA (m_line,
M_AttributeSetInstance_ID, QtyOnHand);
M_AttributeSetInstance_ID, QtyOnHand,dateMPolicy);
if (!ma.save())
;
return 0;
@ -331,6 +335,8 @@ public class InventoryCountCreate extends SvrProcess
m_line = new MInventoryLine (m_inventory, M_Locator_ID,
M_Product_ID, M_AttributeSetInstance_ID,
QtyOnHand, QtyOnHand); // book/count
oldDateMPolicy = dateMPolicy;
if (m_line.save())
return 1;
return 0;

View File

@ -160,7 +160,7 @@ public class InventoryCountUpdate extends SvrProcess
continue;
// Save ASI
ma = new MInventoryLineMA (il,
storage.getM_AttributeSetInstance_ID(), storage.getQtyOnHand());
storage.getM_AttributeSetInstance_ID(), storage.getQtyOnHand(),storage.getDateMaterialPolicy());
if (!ma.save())
;
}

View File

@ -21,6 +21,7 @@ import java.sql.Timestamp;
import java.util.List;
import java.util.logging.Level;
import org.compiere.model.MAttributeSetInstance;
import org.compiere.model.MClient;
import org.compiere.model.MLocator;
import org.compiere.model.MProduct;
@ -155,11 +156,20 @@ public class M_Production_Run extends SvrProcess {
MovementType = MTransaction.MOVEMENTTYPE_Production_;
}
Timestamp dateMPolicy = production.getMovementDate();
if(pline.getM_AttributeSetInstance_ID()>0){
if(pline.getM_AttributeSetInstance_ID()>0){
MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), pline.getM_AttributeSetInstance_ID(), get_TrxName());
dateMPolicy = asi.getCreated();
}
}
if (!MStorageOnHand.add(getCtx(), locator.getM_Warehouse_ID(),
locator.getM_Locator_ID(),
pline.getM_Product_ID(),
pline.getM_AttributeSetInstance_ID(),
MovementQty,
dateMPolicy,
get_TrxName()))
{
raiseError("Cannot correct Inventory", "");

View File

@ -353,4 +353,13 @@ public interface I_M_AttributeSet
* User who updated this records
*/
public int getUpdatedBy();
/** Column name UseGuaranteeDateForMPolicy */
public static final String COLUMNNAME_UseGuaranteeDateForMPolicy = "UseGuaranteeDateForMPolicy";
/** Set Use Guarantee Date for Material Policy */
public void setUseGuaranteeDateForMPolicy (boolean UseGuaranteeDateForMPolicy);
/** Get Use Guarantee Date for Material Policy */
public boolean isUseGuaranteeDateForMPolicy();
}

View File

@ -78,6 +78,19 @@ public interface I_M_InOutLineMA
*/
public int getCreatedBy();
/** Column name DateMaterialPolicy */
public static final String COLUMNNAME_DateMaterialPolicy = "DateMaterialPolicy";
/** Set Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy);
/** Get Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";

View File

@ -78,6 +78,19 @@ public interface I_M_InventoryLineMA
*/
public int getCreatedBy();
/** Column name DateMaterialPolicy */
public static final String COLUMNNAME_DateMaterialPolicy = "DateMaterialPolicy";
/** Set Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy);
/** Get Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";

View File

@ -78,6 +78,19 @@ public interface I_M_MovementLineMA
*/
public int getCreatedBy();
/** Column name DateMaterialPolicy */
public static final String COLUMNNAME_DateMaterialPolicy = "DateMaterialPolicy";
/** Set Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy);
/** Get Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";

View File

@ -78,6 +78,19 @@ public interface I_M_ProductionLineMA
*/
public int getCreatedBy();
/** Column name DateMaterialPolicy */
public static final String COLUMNNAME_DateMaterialPolicy = "DateMaterialPolicy";
/** Set Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy);
/** Get Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";

View File

@ -91,6 +91,19 @@ public interface I_M_StorageOnHand
*/
public Timestamp getDateLastInventory();
/** Column name DateMaterialPolicy */
public static final String COLUMNNAME_DateMaterialPolicy = "DateMaterialPolicy";
/** Set Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy);
/** Get Date Material Policy.
* Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";

View File

@ -1329,10 +1329,14 @@ public class MInOut extends X_M_InOut implements DocAction
boolean sameWarehouse = true;
// Reservation ASI - assume none
int reservationAttributeSetInstance_ID = 0; // sLine.getM_AttributeSetInstance_ID();
int reservationWarehouse_ID = getM_Warehouse_ID();
if (oLine != null) {
reservationAttributeSetInstance_ID = oLine.getM_AttributeSetInstance_ID();
sameWarehouse = oLine.getM_Warehouse_ID()==getM_Warehouse_ID();
}
if(!sameWarehouse){
reservationWarehouse_ID = oLine.getM_Warehouse_ID();
}
//
if (sLine.getM_AttributeSetInstance_ID() == 0)
{
@ -1345,13 +1349,9 @@ public class MInOut extends X_M_InOut implements DocAction
if (MovementType.charAt(1) == '-') // C- Customer Shipment - V- Vendor Return
QtyMA = QtyMA.negate();
BigDecimal reservedDiff = Env.ZERO;
BigDecimal orderedDiff = Env.ZERO;
if (sLine.getC_OrderLine_ID() != 0)
{
if (isSOTrx())
reservedDiff = ma.getMovementQty().negate();
else
orderedDiff = ma.getMovementQty().negate();
reservedDiff = ma.getMovementQty().negate();
}
// Update Storage - see also VMatch.createMatchRecord
@ -1359,65 +1359,27 @@ public class MInOut extends X_M_InOut implements DocAction
sLine.getM_Locator_ID(),
sLine.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(),
QtyMA,
QtyMA,ma.getDateMaterialPolicy(),
get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory OnHand (MA) [" + product.getValue() + "] - " + lastError;
return DocAction.STATUS_Invalid;
}
if (sameWarehouse && reservedDiff.signum() != 0) {
if (!MStorageReservation.add(getCtx(), getM_Warehouse_ID(),
if (reservedDiff.signum() != 0) {
if (!MStorageReservation.add(getCtx(), reservationWarehouse_ID,
sLine.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
reservedDiff,
true,
isSOTrx(),
get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory Reserved (MA) [" + product.getValue() + "] - " + lastError;
m_processMsg = "Cannot correct Inventory " + (isSOTrx()? "Reserved" : "Ordered") + " (MA) - [" + product.getValue() + "] - " + lastError;
return DocAction.STATUS_Invalid;
}
}
if (sameWarehouse && orderedDiff.signum() != 0) {
if (!MStorageReservation.add(getCtx(), getM_Warehouse_ID(),
sLine.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
orderedDiff,
false,
get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory Ordered (MA) [" + product.getValue() + "] - " + lastError;
return DocAction.STATUS_Invalid;
}
}
if (!sameWarehouse) {
//correct qtyOrdered in warehouse of order
@SuppressWarnings("unused")
MWarehouse wh = MWarehouse.get(getCtx(), oLine.getM_Warehouse_ID());
if (reservedDiff.signum() != 0) {
if (!MStorageReservation.add(getCtx(), oLine.getM_Warehouse_ID(),
sLine.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
reservedDiff, true, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory Reserved (MA) in order warehouse [" + product.getValue() + "]";
return DocAction.STATUS_Invalid;
}
}
if (orderedDiff.signum() != 0) {
if (!MStorageReservation.add(getCtx(), oLine.getM_Warehouse_ID(),
sLine.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
orderedDiff, false, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory Ordered (MA) in order warehouse [" + product.getValue() + "]";
return DocAction.STATUS_Invalid;
}
}
}
// Create Transaction
mtrx = new MTransaction (getCtx(), sLine.getAD_Org_ID(),
MovementType, sLine.getM_Locator_ID(),
@ -1434,65 +1396,40 @@ public class MInOut extends X_M_InOut implements DocAction
// sLine.getM_AttributeSetInstance_ID() != 0
if (mtrx == null)
{
BigDecimal reservedDiff = sameWarehouse ? QtySO.negate() : Env.ZERO;
BigDecimal orderedDiff = sameWarehouse ? QtyPO.negate(): Env.ZERO;
BigDecimal reservedDiff = null;
if(isSOTrx())
reservedDiff = QtySO.negate();
else
reservedDiff = QtyPO.negate();
Timestamp dateMPolicy = getMovementDate();
if(sLine.getM_AttributeSetInstance_ID()>0){
I_M_AttributeSetInstance asi = sLine.getM_AttributeSetInstance();
dateMPolicy = asi.getCreated();
}
// Fallback: Update Storage - see also VMatch.createMatchRecord
if (!MStorageOnHand.add(getCtx(), getM_Warehouse_ID(),
sLine.getM_Locator_ID(),
sLine.getM_Product_ID(),
sLine.getM_AttributeSetInstance_ID(),
Qty, get_TrxName()))
Qty,dateMPolicy,get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory OnHand [" + product.getValue() + "] - " + lastError;
return DocAction.STATUS_Invalid;
}
if (reservedDiff.signum() != 0) {
if (!MStorageReservation.add(getCtx(), getM_Warehouse_ID(),
if (!MStorageReservation.add(getCtx(), reservationWarehouse_ID,
sLine.getM_Product_ID(),
sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
reservedDiff, true, get_TrxName()))
reservedDiff, isSOTrx(), get_TrxName()))
{
m_processMsg = "Cannot correct Inventory Reserved [" + product.getValue() + "]";
m_processMsg = "Cannot correct Inventory Reserved " + (isSOTrx()? "Reserved [" :"Ordered [") + product.getValue() + "]";
return DocAction.STATUS_Invalid;
}
}
if (orderedDiff.signum() != 0) {
if (!MStorageReservation.add(getCtx(), getM_Warehouse_ID(),
sLine.getM_Product_ID(),
sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
orderedDiff, false, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory Ordered [" + product.getValue() + "]";
return DocAction.STATUS_Invalid;
}
}
if (!sameWarehouse) {
//correct qtyOrdered in warehouse of order
@SuppressWarnings("unused")
MWarehouse wh = MWarehouse.get(getCtx(), oLine.getM_Warehouse_ID());
if (QtySO.signum() != 0) {
if (!MStorageReservation.add(getCtx(), oLine.getM_Warehouse_ID(),
sLine.getM_Product_ID(),
sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
QtySO.negate(), true, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory Reserved [" + product.getValue() + "]";
return DocAction.STATUS_Invalid;
}
}
if (QtyPO.signum() != 0) {
if (!MStorageReservation.add(getCtx(), oLine.getM_Warehouse_ID(),
sLine.getM_Product_ID(),
sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
QtyPO.negate(), false, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory Ordered [" + product.getValue() + "]";
return DocAction.STATUS_Invalid;
}
}
}
// FallBack: Create Transaction
mtrx = new MTransaction (getCtx(), sLine.getAD_Org_ID(),
MovementType, sLine.getM_Locator_ID(),
@ -1836,29 +1773,46 @@ public class MInOut extends X_M_InOut implements DocAction
if (product != null && line.getM_AttributeSetInstance_ID() == 0)
{
//Validate Transaction
if (getMovementType().compareTo(MInOut.MOVEMENTTYPE_CustomerReturns) == 0
|| getMovementType().compareTo(MInOut.MOVEMENTTYPE_VendorReceipts) == 0 )
if (getMovementType().compareTo(MInOut.MOVEMENTTYPE_VendorReceipts) == 0 )
{
MAttributeSetInstance asi = null;
//auto balance negative on hand
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), 0,
null, MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false, line.getM_Locator_ID(), get_TrxName());
for (MStorageOnHand storage : storages)
BigDecimal qtyToReceive = autoBalanceNegative(line, product);
//Allocate remaining qty.
if (qtyToReceive.compareTo(Env.ZERO)>0)
{
if (storage.getQtyOnHand().signum() < 0)
{
asi = new MAttributeSetInstance(getCtx(), storage.getM_AttributeSetInstance_ID(), get_TrxName());
break;
MInOutLineMA ma = MInOutLineMA.addOrCreate(line, 0, qtyToReceive, getMovementDate());
ma.saveEx();
}
} else if (getMovementType().compareTo(MInOut.MOVEMENTTYPE_CustomerReturns) == 0){
BigDecimal qtyToReturn = autoBalanceNegative(line, product);
if (line.getM_RMALine_ID()!=0 && qtyToReturn.compareTo(Env.ZERO)>0){
//Linking to shipment line
MRMALine rmaLine = new MRMALine(getCtx(), line.getM_RMALine_ID(), get_TrxName());
if(rmaLine.getM_InOutLine_ID()>0){
MInOutLineMA shipmentMAS[] = MInOutLineMA.get(getCtx(), rmaLine.getM_InOutLine_ID(), get_TrxName());
for(MInOutLineMA sMA : shipmentMAS){
BigDecimal lineMAQty = qtyToReturn;
if(lineMAQty.compareTo(sMA.getMovementQty())>0){
lineMAQty = sMA.getMovementQty();
}
MInOutLineMA ma = MInOutLineMA.addOrCreate(line, sMA.getM_AttributeSetInstance_ID(), lineMAQty, sMA.getDateMaterialPolicy());
ma.saveEx();
qtyToReturn = qtyToReturn.subtract(lineMAQty);
if(qtyToReturn.compareTo(Env.ZERO)==0)
break;
}
}
}
//always create asi so fifo/lifo work.
if (asi == null)
{
asi = MAttributeSetInstance.create(getCtx(), product, get_TrxName());
}
line.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
if (log.isLoggable(Level.CONFIG)) log.config("New ASI=" + line);
needSave = true;
if(qtyToReturn.compareTo(Env.ZERO)>0){
//Use movement data for Material policy if no linkage found to Shipment.
MInOutLineMA ma = MInOutLineMA.addOrCreate(line, 0, qtyToReturn, getMovementDate());
ma.saveEx();
}
}
// Create consume the Attribute Set Instance using policy FIFO/LIFO
else if(getMovementType().compareTo(MInOut.MOVEMENTTYPE_VendorReturns) == 0 || getMovementType().compareTo(MInOut.MOVEMENTTYPE_CustomerShipment) == 0)
@ -1866,7 +1820,7 @@ public class MInOut extends X_M_InOut implements DocAction
String MMPolicy = product.getMMPolicy();
Timestamp minGuaranteeDate = getMovementDate();
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),
minGuaranteeDate, MClient.MMPOLICY_FiFo.equals(MMPolicy), true, line.getM_Locator_ID(), get_TrxName());
minGuaranteeDate, MClient.MMPOLICY_FiFo.equals(MMPolicy), true, line.getM_Locator_ID(), get_TrxName(), true);
BigDecimal qtyToDeliver = line.getMovementQty();
for (MStorageOnHand storage: storages)
{
@ -1874,7 +1828,7 @@ public class MInOut extends X_M_InOut implements DocAction
{
MInOutLineMA ma = new MInOutLineMA (line,
storage.getM_AttributeSetInstance_ID(),
qtyToDeliver);
qtyToDeliver,storage.getDateMaterialPolicy());
ma.saveEx();
qtyToDeliver = Env.ZERO;
}
@ -1882,7 +1836,7 @@ public class MInOut extends X_M_InOut implements DocAction
{
MInOutLineMA ma = new MInOutLineMA (line,
storage.getM_AttributeSetInstance_ID(),
storage.getQtyOnHand());
storage.getQtyOnHand(),storage.getDateMaterialPolicy());
ma.saveEx();
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
if (log.isLoggable(Level.FINE)) log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
@ -1893,11 +1847,9 @@ public class MInOut extends X_M_InOut implements DocAction
}
if (qtyToDeliver.signum() != 0)
{
//deliver using new asi
MAttributeSetInstance asi = MAttributeSetInstance.create(getCtx(), product, get_TrxName());
int M_AttributeSetInstance_ID = asi.getM_AttributeSetInstance_ID();
MInOutLineMA ma = new MInOutLineMA (line, M_AttributeSetInstance_ID, qtyToDeliver);
{
//Over Delivery
MInOutLineMA ma = MInOutLineMA.addOrCreate(line, line.getM_AttributeSetInstance_ID(), qtyToDeliver, getMovementDate());
ma.saveEx();
if (log.isLoggable(Level.FINE)) log.fine("##: " + ma);
}
@ -1910,6 +1862,31 @@ public class MInOut extends X_M_InOut implements DocAction
}
} // checkMaterialPolicy
private BigDecimal autoBalanceNegative(MInOutLine line, MProduct product) {
MStorageOnHand[] storages = MStorageOnHand.getWarehouseNegative(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), 0,
null, MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), line.getM_Locator_ID(), get_TrxName(), true);
Timestamp dateMPolicy = null;
BigDecimal qtyToReceive = line.getMovementQty();
for (MStorageOnHand storage : storages)
{
if (storage.getQtyOnHand().signum() < 0 && qtyToReceive.compareTo(Env.ZERO)>0)
{
dateMPolicy = storage.getDateMaterialPolicy();
BigDecimal lineMAQty = qtyToReceive;
if(lineMAQty.compareTo(storage.getQtyOnHand().negate())>0)
lineMAQty = storage.getQtyOnHand().negate();
//Using ASI from storage record
MInOutLineMA ma = new MInOutLineMA (line, storage.getM_AttributeSetInstance_ID(), lineMAQty,dateMPolicy);
ma.saveEx();
qtyToReceive = qtyToReceive.subtract(lineMAQty);
}
}
return qtyToReceive;
}
/**************************************************************************
* Create Counter Document
@ -2191,7 +2168,7 @@ public class MInOut extends X_M_InOut implements DocAction
{
MInOutLineMA ma = new MInOutLineMA (rLine,
mas[j].getM_AttributeSetInstance_ID(),
mas[j].getMovementQty().negate());
mas[j].getMovementQty().negate(),mas[j].getDateMaterialPolicy());
ma.saveEx();
}
}

View File

@ -18,10 +18,13 @@ package org.compiere.model;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.List;
import java.util.Properties;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Util;
/**
* Shipment Material Allocation
@ -113,8 +116,9 @@ public class MInOutLineMA extends X_M_InOutLineMA
* @param parent parent
* @param M_AttributeSetInstance_ID asi
* @param MovementQty qty
* @param DateMaterialPolicy
*/
public MInOutLineMA (MInOutLine parent, int M_AttributeSetInstance_ID, BigDecimal MovementQty)
public MInOutLineMA (MInOutLine parent, int M_AttributeSetInstance_ID, BigDecimal MovementQty,Timestamp DateMaterialPolicy)
{
this (parent.getCtx(), 0, parent.get_TrxName());
setClientOrg(parent);
@ -122,7 +126,27 @@ public class MInOutLineMA extends X_M_InOutLineMA
//
setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
setMovementQty(MovementQty);
if (DateMaterialPolicy == null)
{
if (M_AttributeSetInstance_ID > 0)
{
MAttributeSetInstance asi = new MAttributeSetInstance(parent.getCtx(), M_AttributeSetInstance_ID, parent.get_TrxName());
DateMaterialPolicy = asi.getCreated();
}
else
{
DateMaterialPolicy = parent.getParent().getMovementDate();
}
}
setDateMaterialPolicy(DateMaterialPolicy);
} // MInOutLineMA
@Override
public void setDateMaterialPolicy(Timestamp DateMaterialPolicy) {
if (DateMaterialPolicy != null)
DateMaterialPolicy = Util.removeTime(DateMaterialPolicy);
super.setDateMaterialPolicy(DateMaterialPolicy);
}
/**
* String Representation
@ -138,4 +162,16 @@ public class MInOutLineMA extends X_M_InOutLineMA
return sb.toString ();
} // toString
public static MInOutLineMA addOrCreate(MInOutLine line, int M_AttributeSetInstance_ID, BigDecimal MovementQty, Timestamp DateMaterialPolicy)
{
Query query = new Query(Env.getCtx(), I_M_InOutLineMA.Table_Name, "M_InOutLine_ID=? AND M_AttributeSetInstance_ID=? AND DateMaterialPolicy=trunc(cast(? as date))",
line.get_TrxName());
MInOutLineMA po = query.setParameters(line.getM_InOutLine_ID(), M_AttributeSetInstance_ID, DateMaterialPolicy).first();
if (po == null)
po = new MInOutLineMA(line, M_AttributeSetInstance_ID, MovementQty, DateMaterialPolicy);
else
po.setMovementQty(po.getMovementQty().add(MovementQty));
return po;
}
} // MInOutLineMA

View File

@ -461,7 +461,7 @@ public class MInventory extends X_M_Inventory implements DocAction
line.getM_Locator_ID(),
line.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(),
QtyMA.negate(), get_TrxName()))
QtyMA.negate(),ma.getDateMaterialPolicy(), get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory (MA) - " + lastError;
@ -472,7 +472,7 @@ public class MInventory extends X_M_Inventory implements DocAction
if (MDocType.DOCSUBTYPEINV_PhysicalInventory.equals(docSubTypeInv))
{
MStorageOnHand storage = MStorageOnHand.get(getCtx(), line.getM_Locator_ID(),
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),ma.getDateMaterialPolicy(),get_TrxName());
storage.setDateLastInventory(getMovementDate());
if (!storage.save(get_TrxName()))
{
@ -507,12 +507,16 @@ public class MInventory extends X_M_Inventory implements DocAction
// Fallback
if (mtrx == null)
{
Timestamp dateMPolicy= getMovementDate();
I_M_AttributeSetInstance asi = line.getM_AttributeSetInstance();
dateMPolicy =asi.getCreated();
//Fallback: Update Storage - see also VMatch.createMatchRecord
if (!MStorageOnHand.add(getCtx(), getM_Warehouse_ID(),
line.getM_Locator_ID(),
line.getM_Product_ID(),
line.getM_AttributeSetInstance_ID(),
qtyDiff,get_TrxName()))
qtyDiff,dateMPolicy,get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError;
@ -523,7 +527,7 @@ public class MInventory extends X_M_Inventory implements DocAction
if (MDocType.DOCSUBTYPEINV_PhysicalInventory.equals(docSubTypeInv))
{
MStorageOnHand storage = MStorageOnHand.get(getCtx(), line.getM_Locator_ID(),
line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), get_TrxName());
line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),dateMPolicy, get_TrxName());
storage.setDateLastInventory(getMovementDate());
if (!storage.save(get_TrxName()))
@ -602,40 +606,49 @@ public class MInventory extends X_M_Inventory implements DocAction
MProduct product = MProduct.get(getCtx(), line.getM_Product_ID());
if (qtyDiff.signum() > 0) // Incoming Trx
{
MAttributeSetInstance asi = null;
//auto balance negative on hand
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), 0,
null, MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false, line.getM_Locator_ID(), get_TrxName());
MStorageOnHand[] storages = MStorageOnHand.getWarehouseNegative(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), 0,
null, MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), line.getM_Locator_ID(), get_TrxName(), true);
for (MStorageOnHand storage : storages)
{
if (storage.getQtyOnHand().signum() < 0)
{
asi = new MAttributeSetInstance(getCtx(), storage.getM_AttributeSetInstance_ID(), get_TrxName());
break;
BigDecimal maQty = qtyDiff;
if(maQty.compareTo(storage.getQtyOnHand().negate())>0)
{
maQty = storage.getQtyOnHand().negate();
}
//backward compatibility: -ve in MA is incoming trx, +ve in MA is outgoing trx
MInventoryLineMA lineMA = new MInventoryLineMA(line, storage.getM_AttributeSetInstance_ID(), maQty.negate(), storage.getDateMaterialPolicy());
lineMA.saveEx();
qtyDiff = qtyDiff.subtract(maQty);
if (qtyDiff.compareTo(Env.ZERO)==0)
break;
}
}
if (asi == null)
if(qtyDiff.compareTo(Env.ZERO)>0)
{
asi = MAttributeSetInstance.create(getCtx(), product, get_TrxName());
}
line.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
needSave = true;
MInventoryLineMA lineMA = MInventoryLineMA.addOrCreate(line, 0, qtyDiff.negate(), getMovementDate());
lineMA.saveEx();
}
}
else // Outgoing Trx
{
String MMPolicy = product.getMMPolicy();
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), 0,
null, MClient.MMPOLICY_FiFo.equals(MMPolicy), true, line.getM_Locator_ID(), get_TrxName());
null, MClient.MMPOLICY_FiFo.equals(MMPolicy), true, line.getM_Locator_ID(), get_TrxName(), true);
BigDecimal qtyToDeliver = qtyDiff.negate();
for (MStorageOnHand storage: storages)
{
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
{
MInventoryLineMA ma = new MInventoryLineMA (line,
storage.getM_AttributeSetInstance_ID(),
qtyToDeliver);
qtyToDeliver,storage.getDateMaterialPolicy());
ma.saveEx();
qtyToDeliver = Env.ZERO;
if (log.isLoggable(Level.FINE)) log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
@ -644,8 +657,8 @@ public class MInventory extends X_M_Inventory implements DocAction
{
MInventoryLineMA ma = new MInventoryLineMA (line,
storage.getM_AttributeSetInstance_ID(),
storage.getQtyOnHand());
ma.saveEx();
storage.getQtyOnHand(),storage.getDateMaterialPolicy());
ma.saveEx();
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
if (log.isLoggable(Level.FINE)) log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
}
@ -656,13 +669,9 @@ public class MInventory extends X_M_Inventory implements DocAction
// No AttributeSetInstance found for remainder
if (qtyToDeliver.signum() != 0)
{
//deliver using new asi
MAttributeSetInstance asi = MAttributeSetInstance.create(getCtx(), product, get_TrxName());
int M_AttributeSetInstance_ID = asi.getM_AttributeSetInstance_ID();
MInventoryLineMA ma = new MInventoryLineMA (line, M_AttributeSetInstance_ID , qtyToDeliver);
ma.saveEx();
if (log.isLoggable(Level.FINE)) log.fine("##: " + ma);
MInventoryLineMA lineMA = MInventoryLineMA.addOrCreate(line, 0, qtyToDeliver, getMovementDate());
lineMA.saveEx();
if (log.isLoggable(Level.FINE)) log.fine("##: " + lineMA);
}
} // outgoing Trx
@ -849,7 +858,7 @@ public class MInventory extends X_M_Inventory implements DocAction
{
MInventoryLineMA ma = new MInventoryLineMA (rLine,
mas[j].getM_AttributeSetInstance_ID(),
mas[j].getMovementQty().negate());
mas[j].getMovementQty().negate(),mas[j].getDateMaterialPolicy());
ma.saveEx();
}
}

View File

@ -19,12 +19,15 @@ package org.compiere.model;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Util;
/**
@ -138,8 +141,9 @@ public class MInventoryLineMA extends X_M_InventoryLineMA
* @param parent parent
* @param M_AttributeSetInstance_ID asi
* @param MovementQty qty
* @param DateMaterialPolicy
*/
public MInventoryLineMA (MInventoryLine parent, int M_AttributeSetInstance_ID, BigDecimal MovementQty)
public MInventoryLineMA (MInventoryLine parent, int M_AttributeSetInstance_ID, BigDecimal MovementQty,Timestamp DateMaterialPolicy)
{
this (parent.getCtx(), 0, parent.get_TrxName());
setClientOrg(parent);
@ -147,8 +151,28 @@ public class MInventoryLineMA extends X_M_InventoryLineMA
//
setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
setMovementQty(MovementQty);
if (DateMaterialPolicy == null)
{
if (M_AttributeSetInstance_ID > 0)
{
MAttributeSetInstance asi = new MAttributeSetInstance(parent.getCtx(), M_AttributeSetInstance_ID, parent.get_TrxName());
DateMaterialPolicy = asi.getCreated();
}
else
{
DateMaterialPolicy = parent.getParent().getMovementDate();
}
}
setDateMaterialPolicy(DateMaterialPolicy);
} // MInventoryLineMA
@Override
public void setDateMaterialPolicy(Timestamp DateMaterialPolicy) {
if (DateMaterialPolicy != null)
DateMaterialPolicy = Util.removeTime(DateMaterialPolicy);
super.setDateMaterialPolicy(DateMaterialPolicy);
}
/**
* String Representation
* @return info
@ -163,4 +187,15 @@ public class MInventoryLineMA extends X_M_InventoryLineMA
return sb.toString ();
} // toString
public static MInventoryLineMA addOrCreate(MInventoryLine line, int M_AttributeSetInstance_ID, BigDecimal MovementQty, Timestamp DateMaterialPolicy)
{
Query query = new Query(Env.getCtx(), I_M_InventoryLineMA.Table_Name, "M_InventoryLine_ID=? AND M_AttributeSetInstance_ID=? AND DateMaterialPolicy=trunc(cast(? as date))",
line.get_TrxName());
MInventoryLineMA po = query.setParameters(line.getM_InventoryLine_ID(), M_AttributeSetInstance_ID, DateMaterialPolicy).first();
if (po == null)
po = new MInventoryLineMA(line, M_AttributeSetInstance_ID, MovementQty, DateMaterialPolicy);
else
po.setMovementQty(po.getMovementQty().add(MovementQty));
return po;
}
} // MInventoryLineMA

View File

@ -406,7 +406,7 @@ public class MMovement extends X_M_Movement implements DocAction
line.getM_Locator_ID(),
line.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(),
ma.getMovementQty().negate(), get_TrxName()))
ma.getMovementQty().negate(),ma.getDateMaterialPolicy(), get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError;
@ -424,7 +424,7 @@ public class MMovement extends X_M_Movement implements DocAction
line.getM_LocatorTo_ID(),
line.getM_Product_ID(),
M_AttributeSetInstanceTo_ID,
ma.getMovementQty(), get_TrxName()))
ma.getMovementQty(),ma.getDateMaterialPolicy(), get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError;
@ -458,13 +458,17 @@ public class MMovement extends X_M_Movement implements DocAction
// Fallback - We have ASI
if (trxFrom == null)
{
I_M_AttributeSetInstance asi = line.getM_AttributeSetInstance();
Timestamp dateMPolicy= getMovementDate();
dateMPolicy = asi.getCreated();
MLocator locator = new MLocator (getCtx(), line.getM_Locator_ID(), get_TrxName());
//Update Storage
if (!MStorageOnHand.add(getCtx(),locator.getM_Warehouse_ID(),
line.getM_Locator_ID(),
line.getM_Product_ID(),
line.getM_AttributeSetInstance_ID(),
line.getMovementQty().negate(), get_TrxName()))
line.getMovementQty().negate(),dateMPolicy, get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError;
@ -476,7 +480,7 @@ public class MMovement extends X_M_Movement implements DocAction
line.getM_LocatorTo_ID(),
line.getM_Product_ID(),
line.getM_AttributeSetInstanceTo_ID(),
line.getMovementQty(), get_TrxName()))
line.getMovementQty(),dateMPolicy, get_TrxName()))
{
String lastError = CLogger.retrieveErrorString("");
m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError;
@ -568,7 +572,7 @@ public class MMovement extends X_M_Movement implements DocAction
{
MMovementLineMA ma = new MMovementLineMA (line,
storage.getM_AttributeSetInstance_ID(),
qtyToDeliver);
qtyToDeliver,storage.getDateMaterialPolicy());
ma.saveEx();
qtyToDeliver = Env.ZERO;
if (log.isLoggable(Level.FINE)) log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
@ -577,7 +581,7 @@ public class MMovement extends X_M_Movement implements DocAction
{
MMovementLineMA ma = new MMovementLineMA (line,
storage.getM_AttributeSetInstance_ID(),
storage.getQtyOnHand());
storage.getQtyOnHand(),storage.getDateMaterialPolicy());
ma.saveEx();
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
if (log.isLoggable(Level.FINE)) log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
@ -589,12 +593,10 @@ public class MMovement extends X_M_Movement implements DocAction
// No AttributeSetInstance found for remainder
if (qtyToDeliver.signum() != 0)
{
//deliver using new asi
MAttributeSetInstance asi = MAttributeSetInstance.create(getCtx(), product, get_TrxName());
int M_AttributeSetInstance_ID = asi.getM_AttributeSetInstance_ID();
MMovementLineMA ma = new MMovementLineMA (line, M_AttributeSetInstance_ID , qtyToDeliver);
MMovementLineMA ma = MMovementLineMA.addOrCreate(line, 0, qtyToDeliver, getMovementDate()) ;
ma.saveEx();
if (log.isLoggable(Level.FINE)) log.fine("##: " + ma);
}
} // attributeSetInstance
@ -787,7 +789,7 @@ public class MMovement extends X_M_Movement implements DocAction
{
MMovementLineMA ma = new MMovementLineMA (rLine,
mas[j].getM_AttributeSetInstance_ID(),
mas[j].getMovementQty().negate());
mas[j].getMovementQty().negate(),mas[j].getDateMaterialPolicy());
ma.saveEx();
}
}

View File

@ -19,12 +19,15 @@ package org.compiere.model;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Util;
/**
@ -139,8 +142,9 @@ public class MMovementLineMA extends X_M_MovementLineMA
* @param parent parent
* @param M_AttributeSetInstance_ID asi
* @param MovementQty qty
* @param DateMaterialPolicy
*/
public MMovementLineMA (MMovementLine parent, int M_AttributeSetInstance_ID, BigDecimal MovementQty)
public MMovementLineMA (MMovementLine parent, int M_AttributeSetInstance_ID, BigDecimal MovementQty,Timestamp DateMaterialPolicy)
{
this (parent.getCtx(), 0, parent.get_TrxName());
setClientOrg(parent);
@ -148,7 +152,27 @@ public class MMovementLineMA extends X_M_MovementLineMA
//
setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
setMovementQty(MovementQty);
if (DateMaterialPolicy == null)
{
if (M_AttributeSetInstance_ID > 0)
{
MAttributeSetInstance asi = new MAttributeSetInstance(parent.getCtx(), M_AttributeSetInstance_ID, parent.get_TrxName());
DateMaterialPolicy = asi.getCreated();
}
else
{
DateMaterialPolicy = parent.getParent().getMovementDate();
}
}
setDateMaterialPolicy(DateMaterialPolicy);
} // MMovementLineMA
@Override
public void setDateMaterialPolicy(Timestamp DateMaterialPolicy) {
if (DateMaterialPolicy != null)
DateMaterialPolicy = Util.removeTime(DateMaterialPolicy);
super.setDateMaterialPolicy(DateMaterialPolicy);
}
/**
* String Representation
@ -164,4 +188,15 @@ public class MMovementLineMA extends X_M_MovementLineMA
return sb.toString ();
} // toString
public static MMovementLineMA addOrCreate(MMovementLine line, int M_AttributeSetInstance_ID, BigDecimal MovementQty, Timestamp DateMaterialPolicy)
{
Query query = new Query(Env.getCtx(), I_M_MovementLineMA.Table_Name, "M_MovementLine_ID=? AND M_AttributeSetInstance_ID=? AND DateMaterialPolicy=trunc(cast(? as date))",
line.get_TrxName());
MMovementLineMA po = query.setParameters(line.getM_MovementLine_ID(), M_AttributeSetInstance_ID, DateMaterialPolicy).first();
if (po == null)
po = new MMovementLineMA(line, M_AttributeSetInstance_ID, MovementQty, DateMaterialPolicy);
else
po.setMovementQty(po.getMovementQty().add(MovementQty));
return po;
}
} // MMovementLineMA

View File

@ -802,6 +802,20 @@ public class MProduct extends X_M_Product
return MMPolicy;
}
/**
* Check if use GuaranteeDate for Material Policy
* @return
*/
public boolean isUseGuaranteeDateForMPolicy(){
MAttributeSet as = getAttributeSet();
if(as==null)
return false;
if(!as.isGuaranteeDate())
return false;
return as.isUseGuaranteeDateForMPolicy();
}
/**
* Check if ASI is mandatory
* @param isSOTrx is outgoing trx?

View File

@ -9,6 +9,7 @@ import java.util.logging.Level;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Util;
public class MProductionLine extends X_M_ProductionLine {
@ -89,8 +90,15 @@ public class MProductionLine extends X_M_ProductionLine {
if (log.isLoggable(Level.FINEST)) log.log(Level.FINEST, "asi Description is: " + asiString);
// create transactions for finished goods
if ( getMovementQty().compareTo(Env.ZERO) > 0 ) {
Timestamp dateMPolicy = date;
if(getM_AttributeSetInstance_ID()>0){
dateMPolicy = asi.getCreated();
}
dateMPolicy = Util.removeTime(dateMPolicy);
MProductionLineMA lineMA = new MProductionLineMA( this,
asi.get_ID(), getMovementQty());
asi.get_ID(), getMovementQty(),dateMPolicy);
if ( !lineMA.save(get_TrxName()) ) {
log.log(Level.SEVERE, "Could not save MA for " + toString());
errorString.append("Could not save MA for " + toString() + "\n" );
@ -105,7 +113,7 @@ public class MProductionLine extends X_M_ProductionLine {
errorString.append("Could not save transaction for " + toString() + "\n");
}
MStorageOnHand storage = MStorageOnHand.getCreate(getCtx(), getM_Locator_ID(),
getM_Product_ID(), asi.get_ID(), get_TrxName());
getM_Product_ID(), asi.get_ID(),dateMPolicy, get_TrxName());
storage.changeQtyOnHand(getMovementQty(), true);
if ( !storage.save(get_TrxName()) ) {
log.log(Level.SEVERE, "Could not update storage for " + toString());
@ -118,13 +126,12 @@ public class MProductionLine extends X_M_ProductionLine {
// create transactions and update stock used in production
MStorageOnHand[] storages = MStorageOnHand.getAll( getCtx(), getM_Product_ID(),
getM_Locator_ID(), get_TrxName());
getM_Locator_ID(), get_TrxName(), true, 120);
MProductionLineMA lineMA = null;
MTransaction matTrx = null;
BigDecimal qtyToMove = getMovementQty().negate();
for (int sl = 0; sl < storages.length; sl++) {
BigDecimal lineQty = storages[sl].getQtyOnHand();
@ -148,7 +155,7 @@ public class MProductionLine extends X_M_ProductionLine {
//storage matches specified ASI or is a costing asi (inc. 0)
// This process will move negative stock on hand quantities
{
lineMA = MProductionLineMA.get(this,storages[sl].getM_AttributeSetInstance_ID());
lineMA = MProductionLineMA.get(this,storages[sl].getM_AttributeSetInstance_ID(),storages[sl].getDateMaterialPolicy());
lineMA.setMovementQty(lineMA.getMovementQty().add(lineQty.negate()));
if ( !lineMA.save(get_TrxName()) ) {
log.log(Level.SEVERE, "Could not save MA for " + toString());
@ -192,16 +199,7 @@ public class MProductionLine extends X_M_ProductionLine {
}
else
{
MStorageOnHand storage = MStorageOnHand.get(Env.getCtx(), getM_Locator_ID(), getM_Product_ID(), 0, get_TrxName());
if (storage == null)
{
storage = new MStorageOnHand(Env.getCtx(), 0, get_TrxName());
storage.setM_Locator_ID(getM_Locator_ID());
storage.setM_Product_ID(getM_Product_ID());
storage.setM_AttributeSetInstance_ID(0);
storage.saveEx();
}
MStorageOnHand storage = MStorageOnHand.getCreate(Env.getCtx(), getM_Locator_ID(), getM_Product_ID(), 0, date, get_TrxName(), true);
BigDecimal lineQty = qtyToMove;
MAttributeSetInstance slASI = new MAttributeSetInstance(getCtx(),
@ -217,10 +215,7 @@ public class MProductionLine extends X_M_ProductionLine {
//storage matches specified ASI or is a costing asi (inc. 0)
// This process will move negative stock on hand quantities
{
//lineMA = new MProductionLineMA( this,
// storage.getM_AttributeSetInstance_ID(),
// lineQty.negate());
lineMA = MProductionLineMA.get(this,storage.getM_AttributeSetInstance_ID());
lineMA = MProductionLineMA.get(this,storage.getM_AttributeSetInstance_ID(),storage.getDateMaterialPolicy());
lineMA.setMovementQty(lineMA.getMovementQty().add(lineQty.negate()));
if ( !lineMA.save(get_TrxName()) ) {

View File

@ -2,10 +2,13 @@ package org.compiere.model;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Properties;
import org.compiere.model.X_M_ProductionLineMA;
import org.compiere.util.Env;
import org.compiere.util.Util;
public class MProductionLineMA extends X_M_ProductionLineMA {
/**
@ -16,12 +19,10 @@ public class MProductionLineMA extends X_M_ProductionLineMA {
public MProductionLineMA(Properties ctx, int M_ProductionLineMA_ID,
String trxName) {
super(ctx, M_ProductionLineMA_ID, trxName);
// TODO Auto-generated constructor stub
}
public MProductionLineMA(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
// TODO Auto-generated constructor stub
}
/**
@ -29,32 +30,52 @@ public class MProductionLineMA extends X_M_ProductionLineMA {
* @param parent
* @param asi
* @param qty
* @param ctx
* @param trxName
* @param dateMaterialPolicy
*/
public MProductionLineMA( MProductionLine parent, int asi, BigDecimal qty) {
public MProductionLineMA( MProductionLine parent, int asi, BigDecimal qty,Timestamp dateMaterialPolicy) {
super(parent.getCtx(),0,parent.get_TrxName());
setM_AttributeSetInstance_ID(asi);
setM_ProductionLine_ID(parent.get_ID());
setMovementQty(qty);
setAD_Org_ID(parent.getAD_Org_ID());
if (dateMaterialPolicy == null)
{
if (asi > 0)
{
MAttributeSetInstance masi = new MAttributeSetInstance(parent.getCtx(), asi, parent.get_TrxName());
dateMaterialPolicy = masi.getCreated();
}
else
{
dateMaterialPolicy = parent.getM_Production().getMovementDate();
}
}
setDateMaterialPolicy(dateMaterialPolicy);
}
public static MProductionLineMA get( MProductionLine parent, int asi ) {
@Override
public void setDateMaterialPolicy(Timestamp DateMaterialPolicy) {
if (DateMaterialPolicy != null)
DateMaterialPolicy = Util.removeTime(DateMaterialPolicy);
super.setDateMaterialPolicy(DateMaterialPolicy);
}
public static MProductionLineMA get( MProductionLine parent, int asi, Timestamp dateMPolicy ) {
String where = " M_ProductionLine_ID = ? AND M_AttributeSetInstance_ID = ? ";
if(dateMPolicy==null){
dateMPolicy = new Timestamp(new Date().getTime());
}
where = where + "AND DateMaterialPolicy = trunc(cast(? as date))";
MProductionLineMA lineMA = MTable.get(parent.getCtx(), MProductionLineMA.Table_Name).createQuery(where, parent.get_TrxName())
.setParameters(parent.getM_ProductionLine_ID(), asi).firstOnly();
.setParameters(parent.getM_ProductionLine_ID(), asi,dateMPolicy).first();
if (lineMA != null)
return lineMA;
else
return new MProductionLineMA( parent,
asi,
Env.ZERO);
Env.ZERO,dateMPolicy);
}
}

View File

@ -163,9 +163,17 @@ public class MProjectIssue extends X_C_ProjectIssue
mTrx.setC_ProjectIssue_ID(getC_ProjectIssue_ID());
//
MLocator loc = MLocator.get(getCtx(), getM_Locator_ID());
Timestamp dateMPolicy = getMovementDate();
if(getM_AttributeSetInstance_ID()>0){
MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), getM_AttributeSetInstance_ID(), get_TrxName());
dateMPolicy = asi.getCreated();
}
if (MStorageOnHand.add(getCtx(), loc.getM_Warehouse_ID(), getM_Locator_ID(),
getM_Product_ID(), getM_AttributeSetInstance_ID(),
getMovementQty().negate(), get_TrxName()))
getMovementQty().negate(),dateMPolicy, get_TrxName()))
{
if (mTrx.save(get_TrxName()))
{

View File

@ -22,6 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -30,6 +31,7 @@ import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
/**
* Inventory Storage Model
@ -50,20 +52,26 @@ public class MStorageOnHand extends X_M_StorageOnHand
* @param M_Locator_ID locator
* @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance
* @param dateMPolicy
* @param trxName transaction
* @return existing or null
*/
public static MStorageOnHand get (Properties ctx, int M_Locator_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, String trxName)
int M_Product_ID, int M_AttributeSetInstance_ID,Timestamp dateMPolicy, String trxName)
{
String sqlWhere = "M_Locator_ID=? AND M_Product_ID=? AND ";
if (M_AttributeSetInstance_ID == 0)
sqlWhere += "(M_AttributeSetInstance_ID=? OR M_AttributeSetInstance_ID IS NULL)";
else
sqlWhere += "M_AttributeSetInstance_ID=?";
if (M_AttributeSetInstance_ID == 0)
sqlWhere += "(M_AttributeSetInstance_ID=? OR M_AttributeSetInstance_ID IS NULL)";
else
sqlWhere += "M_AttributeSetInstance_ID=?";
if (dateMPolicy == null)
dateMPolicy = new Timestamp(new Date().getTime());
sqlWhere += " AND DateMaterialPolicy=trunc(cast(? as date))";
MStorageOnHand retValue = new Query(ctx, MStorageOnHand.Table_Name, sqlWhere, trxName)
.setParameters(M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID)
.setParameters(M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, dateMPolicy)
.first();
if (retValue == null) {
@ -131,12 +139,43 @@ public class MStorageOnHand extends X_M_StorageOnHand
*/
public static MStorageOnHand[] getAll (Properties ctx,
int M_Product_ID, int M_Locator_ID, String trxName)
{
return getAll(ctx, M_Product_ID, M_Locator_ID, trxName, false, 0);
}
/**
* Get all Storages for Product where QtyOnHand <> 0
* @param ctx context
* @param M_Product_ID product
* @param M_Locator_ID locator
* @param trxName transaction
* @return existing or null
*/
public static MStorageOnHand[] getAll (Properties ctx,
int M_Product_ID, int M_Locator_ID, String trxName, boolean forUpdate, int timeout)
{
String sqlWhere = "M_Product_ID=? AND M_Locator_ID=? AND QtyOnHand <> 0";
List<MStorageOnHand> list = new Query(ctx, MStorageOnHand.Table_Name, sqlWhere, trxName)
.setParameters(M_Product_ID, M_Locator_ID)
.setOrderBy(MStorageOnHand.COLUMNNAME_M_AttributeSetInstance_ID)
.list();
Query query = new Query(ctx, MStorageOnHand.Table_Name, sqlWhere, trxName)
.setParameters(M_Product_ID, M_Locator_ID);
MProduct product = new MProduct(ctx, M_Product_ID, trxName);
if (product.isUseGuaranteeDateForMPolicy())
{
query.addJoinClause(" LEFT OUTER JOIN M_AttributeSetInstance asi ON (M_StorageOnHand.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) ")
.setOrderBy("asi."+I_M_AttributeSetInstance.COLUMNNAME_GuaranteeDate);
}
else
{
query.setOrderBy(MStorageOnHand.COLUMNNAME_DateMaterialPolicy);
}
if (forUpdate)
{
query.setForUpdate(forUpdate);
if (timeout > 0)
{
query.setQueryTimeout(timeout);
}
}
List<MStorageOnHand> list = query.list();
MStorageOnHand[] retValue = new MStorageOnHand[list.size()];
list.toArray(retValue);
@ -205,6 +244,49 @@ public class MStorageOnHand extends X_M_StorageOnHand
public static MStorageOnHand[] getWarehouse (Properties ctx, int M_Warehouse_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate,
boolean FiFo, boolean positiveOnly, int M_Locator_ID, String trxName)
{
return getWarehouse(ctx, M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID, minGuaranteeDate, FiFo,
positiveOnly, M_Locator_ID, trxName, false);
}
/**
* Get Storage Info for Warehouse or locator
* @param ctx context
* @param M_Warehouse_ID ignore if M_Locator_ID > 0
* @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance id, 0 to retrieve all instance
* @param minGuaranteeDate optional minimum guarantee date if all attribute instances
* @param FiFo first in-first-out
* @param positiveOnly if true, only return storage records with qtyOnHand > 0
* @param M_Locator_ID optional locator id
* @param trxName transaction
* @param forUpdate
* @return existing - ordered by location priority (desc) and/or guarantee date
*/
public static MStorageOnHand[] getWarehouse (Properties ctx, int M_Warehouse_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate,
boolean FiFo, boolean positiveOnly, int M_Locator_ID, String trxName, boolean forUpdate)
{
return getWarehouse(ctx, M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID, minGuaranteeDate, FiFo, positiveOnly, M_Locator_ID, trxName, forUpdate, 0);
}
/**
* Get Storage Info for Warehouse or locator
* @param ctx context
* @param M_Warehouse_ID ignore if M_Locator_ID > 0
* @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance id, 0 to retrieve all instance
* @param minGuaranteeDate optional minimum guarantee date if all attribute instances
* @param FiFo first in-first-out
* @param positiveOnly if true, only return storage records with qtyOnHand > 0
* @param M_Locator_ID optional locator id
* @param trxName transaction
* @param forUpdate
* @return existing - ordered by location priority (desc) and/or guarantee date
*/
public static MStorageOnHand[] getWarehouse (Properties ctx, int M_Warehouse_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate,
boolean FiFo, boolean positiveOnly, int M_Locator_ID, String trxName, boolean forUpdate, int timeout)
{
if ((M_Warehouse_ID == 0 && M_Locator_ID == 0) || M_Product_ID == 0)
return new MStorageOnHand[0];
@ -217,7 +299,7 @@ public class MStorageOnHand extends X_M_StorageOnHand
// Specific Attribute Set Instance
String sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID,"
+ "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy,"
+ "s.QtyOnHand,s.DateLastInventory "
+ "s.QtyOnHand,s.DateLastInventory,s.DateMaterialPolicy "
+ "FROM M_StorageOnHand s"
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) ";
if (M_Locator_ID > 0)
@ -234,16 +316,16 @@ public class MStorageOnHand extends X_M_StorageOnHand
{
sql += " AND s.QtyOnHand <> 0 ";
}
sql += "ORDER BY l.PriorityNo DESC, M_AttributeSetInstance_ID";
sql += "ORDER BY l.PriorityNo DESC, DateMaterialPolicy ";
if (!FiFo)
sql += " DESC";
// All Attribute Set Instances
if (allAttributeInstances)
{
sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID,"
+ "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy,"
+ "s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU "
+ "FROM M_StorageOnHand s"
+ " s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy,"
+ " s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU,s.DateMaterialPolicy "
+ " FROM M_StorageOnHand s"
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID)"
+ " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) ";
if (M_Locator_ID > 0)
@ -259,22 +341,27 @@ public class MStorageOnHand extends X_M_StorageOnHand
{
sql += " AND s.QtyOnHand <> 0 ";
}
if (minGuaranteeDate != null)
{
sql += "AND (asi.GuaranteeDate IS NULL OR asi.GuaranteeDate>?) ";
sql += "ORDER BY l.PriorityNo DESC, " +
"asi.GuaranteeDate, M_AttributeSetInstance_ID";
}
MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
if(product.isUseGuaranteeDateForMPolicy()){
sql += "ORDER BY l.PriorityNo DESC, asi.GuaranteeDate";
if (!FiFo)
sql += " DESC";
sql += ", s.QtyOnHand DESC";
}
else
{
sql += "ORDER BY l.PriorityNo DESC, l.M_Locator_ID, s.M_AttributeSetInstance_ID";
sql += "ORDER BY l.PriorityNo DESC, l.M_Locator_ID, s.DateMaterialPolicy";
if (!FiFo)
sql += " DESC";
sql += ", s.QtyOnHand DESC";
}
sql += ", s.QtyOnHand DESC";
}
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -295,7 +382,14 @@ public class MStorageOnHand extends X_M_StorageOnHand
while (rs.next())
{
if(rs.getBigDecimal(11).signum() != 0)
list.add (new MStorageOnHand (ctx, rs, trxName));
{
MStorageOnHand storage = new MStorageOnHand (ctx, rs, trxName);
if (!Util.isEmpty(trxName) && forUpdate)
{
DB.getDatabase().forUpdate(storage, timeout);
}
list.add (storage);
}
}
}
catch (Exception e)
@ -312,7 +406,168 @@ public class MStorageOnHand extends X_M_StorageOnHand
return retValue;
} // getWarehouse
/**
* Get Storage Info for Warehouse or locator
* @param ctx context
* @param M_Warehouse_ID ignore if M_Locator_ID > 0
* @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance id, 0 to retrieve all instance
* @param minGuaranteeDate optional minimum guarantee date if all attribute instances
* @param FiFo first in-first-out
* @param M_Locator_ID optional locator id
* @param trxName transaction
* @return existing - ordered by location priority (desc) and/or guarantee date
*/
public static MStorageOnHand[] getWarehouseNegative (Properties ctx, int M_Warehouse_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate,
boolean FiFo, int M_Locator_ID, String trxName)
{
return getWarehouseNegative(ctx, M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID, minGuaranteeDate, FiFo, M_Locator_ID, trxName, false);
}
/**
* Get Storage Info for Warehouse or locator
* @param ctx context
* @param M_Warehouse_ID ignore if M_Locator_ID > 0
* @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance id, 0 to retrieve all instance
* @param minGuaranteeDate optional minimum guarantee date if all attribute instances
* @param FiFo first in-first-out
* @param M_Locator_ID optional locator id
* @param trxName transaction
* @param forUpdate
* @return existing - ordered by location priority (desc) and/or guarantee date
*/
public static MStorageOnHand[] getWarehouseNegative (Properties ctx, int M_Warehouse_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate,
boolean FiFo, int M_Locator_ID, String trxName, boolean forUpdate)
{
return getWarehouseNegative(ctx, M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID, minGuaranteeDate, FiFo, M_Locator_ID, trxName, forUpdate, 0);
}
/**
* Get Storage Info for Warehouse or locator
* @param ctx context
* @param M_Warehouse_ID ignore if M_Locator_ID > 0
* @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance id, 0 to retrieve all instance
* @param minGuaranteeDate optional minimum guarantee date if all attribute instances
* @param FiFo first in-first-out
* @param M_Locator_ID optional locator id
* @param trxName transaction
* @param forUpdate
* @param timeout
* @return existing - ordered by location priority (desc) and/or guarantee date
*/
public static MStorageOnHand[] getWarehouseNegative (Properties ctx, int M_Warehouse_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate,
boolean FiFo, int M_Locator_ID, String trxName, boolean forUpdate, int timeout)
{
if ((M_Warehouse_ID == 0 && M_Locator_ID == 0) || M_Product_ID == 0)
return new MStorageOnHand[0];
boolean allAttributeInstances = false;
if (M_AttributeSetInstance_ID == 0)
allAttributeInstances = true;
ArrayList<MStorageOnHand> list = new ArrayList<MStorageOnHand>();
// Specific Attribute Set Instance
String sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID,"
+ "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy,"
+ "s.QtyOnHand,s.DateLastInventory,s.DateMaterialPolicy "
+ "FROM M_StorageOnHand s"
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) ";
if (M_Locator_ID > 0)
sql += "WHERE l.M_Locator_ID = ?";
else
sql += "WHERE l.M_Warehouse_ID=?";
sql += " AND s.M_Product_ID=?"
+ " AND COALESCE(s.M_AttributeSetInstance_ID,0)=? "
+ " AND s.QtyOnHand < 0 ";
sql += "ORDER BY l.PriorityNo DESC, DateMaterialPolicy ";
if (!FiFo)
sql += " DESC";
// All Attribute Set Instances
if (allAttributeInstances)
{
sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID,"
+ "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy,"
+ "s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU,s.DateMaterialPolicy "
+ "FROM M_StorageOnHand s"
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID)"
+ " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) ";
if (M_Locator_ID > 0)
sql += "WHERE l.M_Locator_ID = ?";
else
sql += "WHERE l.M_Warehouse_ID=?";
sql += " AND s.M_Product_ID=? "
+ " AND s.QtyOnHand < 0 ";
if (minGuaranteeDate != null)
{
sql += "AND (asi.GuaranteeDate IS NULL OR asi.GuaranteeDate>?) ";
}
MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
if(product.isUseGuaranteeDateForMPolicy()){
sql += "ORDER BY l.PriorityNo DESC, " +
"asi.GuaranteeDate";
if (!FiFo)
sql += " DESC";
}
else
{
sql += "ORDER BY l.PriorityNo DESC, l.M_Locator_ID, s.DateMaterialPolicy";
if (!FiFo)
sql += " DESC";
}
sql += ", s.QtyOnHand DESC";
}
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, M_Locator_ID > 0 ? M_Locator_ID : M_Warehouse_ID);
pstmt.setInt(2, M_Product_ID);
if (!allAttributeInstances)
{
pstmt.setInt(3, M_AttributeSetInstance_ID);
}
else if (minGuaranteeDate != null)
{
pstmt.setTimestamp(3, minGuaranteeDate);
}
rs = pstmt.executeQuery();
while (rs.next())
{
if(rs.getBigDecimal(11).signum() != 0)
{
MStorageOnHand storage = new MStorageOnHand (ctx, rs, trxName);
if (!Util.isEmpty(trxName) && forUpdate)
{
DB.getDatabase().forUpdate(storage, timeout);
}
list.add(storage);
}
}
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
MStorageOnHand[] retValue = new MStorageOnHand[list.size()];
list.toArray(retValue);
return retValue;
} // getWarehouse
/**
* Create or Get Storage Info
* @param ctx context
@ -323,22 +578,62 @@ public class MStorageOnHand extends X_M_StorageOnHand
* @return existing/new or null
*/
public static MStorageOnHand getCreate (Properties ctx, int M_Locator_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, String trxName)
int M_Product_ID, int M_AttributeSetInstance_ID,Timestamp dateMPolicy, String trxName)
{
return getCreate(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, dateMPolicy, trxName, false);
}
/**
* Create or Get Storage Info
* @param ctx context
* @param M_Locator_ID locator
* @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance
* @param trxName transaction
* @param forUpdate
* @return existing/new or null
*/
public static MStorageOnHand getCreate (Properties ctx, int M_Locator_ID,
int M_Product_ID, int M_AttributeSetInstance_ID,Timestamp dateMPolicy, String trxName, boolean forUpdate)
{
return getCreate(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, dateMPolicy, trxName, forUpdate, 0);
}
/**
* Create or Get Storage Info
* @param ctx context
* @param M_Locator_ID locator
* @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance
* @param trxName transaction
* @param forUpdate
* @param timeout
* @return existing/new or null
*/
public static MStorageOnHand getCreate (Properties ctx, int M_Locator_ID,
int M_Product_ID, int M_AttributeSetInstance_ID,Timestamp dateMPolicy, String trxName, boolean forUpdate, int timeout)
{
if (M_Locator_ID == 0)
throw new IllegalArgumentException("M_Locator_ID=0");
if (M_Product_ID == 0)
throw new IllegalArgumentException("M_Product_ID=0");
MStorageOnHand retValue = get(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, trxName);
if (dateMPolicy == null)
dateMPolicy = new Timestamp(new Date().getTime());
MStorageOnHand retValue = get(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID,dateMPolicy, trxName);
if (retValue != null)
{
if (forUpdate)
DB.getDatabase().forUpdate(retValue, timeout);
return retValue;
}
// Insert row based on locator
MLocator locator = new MLocator (ctx, M_Locator_ID, trxName);
if (locator.get_ID() != M_Locator_ID)
throw new IllegalArgumentException("Not found M_Locator_ID=" + M_Locator_ID);
//
retValue = new MStorageOnHand (locator, M_Product_ID, M_AttributeSetInstance_ID);
retValue = new MStorageOnHand (locator, M_Product_ID, M_AttributeSetInstance_ID,dateMPolicy);
retValue.saveEx(trxName);
if (s_log.isLoggable(Level.FINE)) s_log.fine("New " + retValue);
return retValue;
@ -360,14 +655,13 @@ public class MStorageOnHand extends X_M_StorageOnHand
*/
public static boolean add (Properties ctx, int M_Warehouse_ID, int M_Locator_ID,
int M_Product_ID, int M_AttributeSetInstance_ID,
BigDecimal diffQtyOnHand, String trxName)
BigDecimal diffQtyOnHand,Timestamp dateMPolicy, String trxName)
{
if (diffQtyOnHand == null || diffQtyOnHand.signum() == 0)
return true;
// Get Storage
MStorageOnHand storage = getCreate (ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, trxName);
DB.getDatabase().forUpdate(storage, 120);
MStorageOnHand storage = getCreate (ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID,dateMPolicy, trxName, true, 120);
// Verify
if (storage.getM_Locator_ID() != M_Locator_ID
&& storage.getM_Product_ID() != M_Product_ID
@ -481,13 +775,14 @@ public class MStorageOnHand extends X_M_StorageOnHand
* @param M_Product_ID product
* @param M_AttributeSetInstance_ID attribute
*/
private MStorageOnHand (MLocator locator, int M_Product_ID, int M_AttributeSetInstance_ID)
private MStorageOnHand (MLocator locator, int M_Product_ID, int M_AttributeSetInstance_ID,Timestamp dateMPolicy)
{
this (locator.getCtx(), 0, locator.get_TrxName());
setClientOrg(locator);
setM_Locator_ID (locator.getM_Locator_ID());
setM_Product_ID (M_Product_ID);
setM_AttributeSetInstance_ID (M_AttributeSetInstance_ID);
setDateMaterialPolicy(dateMPolicy);
} // MStorageOnHand
/** Log */

View File

@ -1331,6 +1331,8 @@ public abstract class PO
pstmt.setInt(i+1, ((Integer)m_IDs[i]).intValue());
else if (oo instanceof Boolean)
pstmt.setString(i+1, ((Boolean) m_IDs[i] ? "Y" : "N"));
else if (oo instanceof Timestamp)
pstmt.setTimestamp(i+1, (Timestamp)m_IDs[i]);
else
pstmt.setString(i+1, m_IDs[i].toString());
}

View File

@ -739,14 +739,36 @@ public class POInfo implements Serializable
* @return stringbuilder
*/
public StringBuilder buildSelect()
{
return buildSelect(false, false);
}
/**
* Build select clause
* @param fullyQualified
* @param noVirtualColumn
* @return stringbuilder
*/
public StringBuilder buildSelect(boolean fullyQualified, boolean noVirtualColumn)
{
StringBuilder sql = new StringBuilder("SELECT ");
int size = getColumnCount();
int count = 0;
for (int i = 0; i < size; i++)
{
if (i != 0)
boolean virtual = isVirtualColumn(i);
if (virtual && noVirtualColumn)
continue;
count++;
if (count > 1)
sql.append(",");
sql.append(getColumnSQL(i)); // Normal and Virtual Column
String columnSQL = getColumnSQL(i);
if (fullyQualified && !virtual)
sql.append(getTableName()).append(".");
sql.append(columnSQL); // Normal and Virtual Column
if (fullyQualified && !virtual)
sql.append(" AS ").append(m_columns[i].ColumnName);
}
sql.append(" FROM ").append(getTableName());
return sql;

View File

@ -78,6 +78,10 @@ public class Query
private boolean onlyActiveRecords = false;
private boolean onlyClient_ID = false;
private int onlySelection_ID = -1;
private boolean forUpdate = false;
private boolean noVirtualColumn = false;
private int queryTimeout = 0;
private List<String> joinClauseList = new ArrayList<String>();
/**
*
@ -214,6 +218,34 @@ public class Query
return this;
}
/**
* Add FOR UPDATE clause
* @param forUpdate
*/
public Query setForUpdate(boolean forUpdate)
{
this.forUpdate = forUpdate;
return this;
}
public Query setNoVirtualColumn(boolean noVirtualColumn)
{
this.noVirtualColumn = noVirtualColumn;
return this;
}
public Query setQueryTimeout(int seconds)
{
this.queryTimeout = seconds;
return this;
}
public Query addJoinClause(String joinClause)
{
joinClauseList.add(joinClause);
return this;
}
/**
* Return a list of all po that match the query criteria.
* @return List
@ -352,6 +384,8 @@ public class Query
}
StringBuilder selectClause = new StringBuilder("SELECT ");
if (!joinClauseList.isEmpty())
selectClause.append(table.getTableName()).append(".");
selectClause.append(keys[0]);
selectClause.append(" FROM ").append(table.getTableName());
String sql = buildSQL(selectClause, true);
@ -561,6 +595,8 @@ public class Query
for (int i = 0; i < keys.length; i++) {
if (i > 0)
sqlBuffer.append(", ");
if (!joinClauseList.isEmpty())
sqlBuffer.append(table.getTableName()).append(".");
sqlBuffer.append(keys[i]);
}
sqlBuffer.append(" FROM ").append(table.getTableName());
@ -642,7 +678,14 @@ public class Query
{
throw new IllegalStateException("No POInfo found for AD_Table_ID="+table.getAD_Table_ID());
}
selectClause = info.buildSelect();
selectClause = info.buildSelect(!joinClauseList.isEmpty(), noVirtualColumn);
}
if (!joinClauseList.isEmpty())
{
for(String joinClause : joinClauseList)
{
selectClause.append(" ").append(joinClause);
}
}
StringBuilder whereBuffer = new StringBuilder();
@ -656,12 +699,16 @@ public class Query
{
if (whereBuffer.length() > 0)
whereBuffer.append(" AND ");
if (!joinClauseList.isEmpty())
whereBuffer.append(table.getTableName()).append(".");
whereBuffer.append("IsActive=?");
}
if (this.onlyClient_ID) //red1
{
if (whereBuffer.length() > 0)
whereBuffer.append(" AND ");
if (!joinClauseList.isEmpty())
whereBuffer.append(table.getTableName()).append(".");
whereBuffer.append("AD_Client_ID=?");
}
if (this.onlySelection_ID > 0)
@ -693,6 +740,8 @@ public class Query
MRole role = MRole.getDefault(this.ctx, false);
sql = role.addAccessSQL(sql, table.getTableName(), applyAccessFilterFullyQualified, applyAccessFilterRW);
}
if (forUpdate)
sql = sql + " FOR UPDATE";
if (log.isLoggable(Level.FINEST)) log.finest("TableName = "+table.getTableName()+"... SQL = " +sql); //red1 - to assist in debugging SQL
return sql;
}
@ -718,6 +767,10 @@ public class Query
DB.setParameter(pstmt, i++, this.onlySelection_ID);
if (log.isLoggable(Level.FINEST)) log.finest("Parameter Selection AD_PInstance_ID = "+this.onlySelection_ID);
}
if (queryTimeout > 0)
{
pstmt.setQueryTimeout(queryTimeout);
}
return pstmt.executeQuery();
}
@ -734,6 +787,8 @@ public class Query
}
StringBuilder selectClause = new StringBuilder("SELECT ");
if (!joinClauseList.isEmpty())
selectClause.append(table.getTableName()).append(".");
selectClause.append(keys[0]);
selectClause.append(" FROM ").append(table.getTableName());
String sql = buildSQL(selectClause, true);

View File

@ -495,4 +495,25 @@ public class X_M_AttributeSet extends PO implements I_M_AttributeSet, I_Persiste
{
return (String)get_Value(COLUMNNAME_SerNoCharSOverwrite);
}
/** Set Use Guarantee Date for Material Policy.
@param UseGuaranteeDateForMPolicy Use Guarantee Date for Material Policy */
public void setUseGuaranteeDateForMPolicy (boolean UseGuaranteeDateForMPolicy)
{
set_Value (COLUMNNAME_UseGuaranteeDateForMPolicy, Boolean.valueOf(UseGuaranteeDateForMPolicy));
}
/** Get Use Guarantee Date for Material Policy.
@return Use Guarantee Date for Material Policy */
public boolean isUseGuaranteeDateForMPolicy ()
{
Object oo = get_Value(COLUMNNAME_UseGuaranteeDateForMPolicy);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
}

View File

@ -19,6 +19,7 @@ package org.compiere.model;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
@ -74,6 +75,23 @@ public class X_M_InOutLineMA extends PO implements I_M_InOutLineMA, I_Persistent
return sb.toString();
}
/** Set Date Material Policy.
@param DateMaterialPolicy
Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy)
{
set_Value (COLUMNNAME_DateMaterialPolicy, DateMaterialPolicy);
}
/** Get Date Material Policy.
@return Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy ()
{
return (Timestamp)get_Value(COLUMNNAME_DateMaterialPolicy);
}
public I_M_AttributeSetInstance getM_AttributeSetInstance() throws RuntimeException
{
return (I_M_AttributeSetInstance)MTable.get(getCtx(), I_M_AttributeSetInstance.Table_Name)

View File

@ -19,6 +19,7 @@ package org.compiere.model;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
@ -32,7 +33,7 @@ public class X_M_InventoryLineMA extends PO implements I_M_InventoryLineMA, I_Pe
/**
*
*/
private static final long serialVersionUID = 20130626L;
private static final long serialVersionUID = 20130716L;
/** Standard Constructor */
public X_M_InventoryLineMA (Properties ctx, int M_InventoryLineMA_ID, String trxName)
@ -74,6 +75,23 @@ public class X_M_InventoryLineMA extends PO implements I_M_InventoryLineMA, I_Pe
return sb.toString();
}
/** Set Date Material Policy.
@param DateMaterialPolicy
Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy)
{
set_Value (COLUMNNAME_DateMaterialPolicy, DateMaterialPolicy);
}
/** Get Date Material Policy.
@return Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy ()
{
return (Timestamp)get_Value(COLUMNNAME_DateMaterialPolicy);
}
public I_M_AttributeSetInstance getM_AttributeSetInstance() throws RuntimeException
{
return (I_M_AttributeSetInstance)MTable.get(getCtx(), I_M_AttributeSetInstance.Table_Name)

View File

@ -19,6 +19,7 @@ package org.compiere.model;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
@ -32,7 +33,7 @@ public class X_M_MovementLineMA extends PO implements I_M_MovementLineMA, I_Pers
/**
*
*/
private static final long serialVersionUID = 20130626L;
private static final long serialVersionUID = 20130716L;
/** Standard Constructor */
public X_M_MovementLineMA (Properties ctx, int M_MovementLineMA_ID, String trxName)
@ -73,6 +74,23 @@ public class X_M_MovementLineMA extends PO implements I_M_MovementLineMA, I_Pers
return sb.toString();
}
/** Set Date Material Policy.
@param DateMaterialPolicy
Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy)
{
set_Value (COLUMNNAME_DateMaterialPolicy, DateMaterialPolicy);
}
/** Get Date Material Policy.
@return Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy ()
{
return (Timestamp)get_Value(COLUMNNAME_DateMaterialPolicy);
}
public I_M_AttributeSetInstance getM_AttributeSetInstance() throws RuntimeException
{
return (I_M_AttributeSetInstance)MTable.get(getCtx(), I_M_AttributeSetInstance.Table_Name)

View File

@ -19,6 +19,7 @@ package org.compiere.model;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
@ -32,7 +33,7 @@ public class X_M_ProductionLineMA extends PO implements I_M_ProductionLineMA, I_
/**
*
*/
private static final long serialVersionUID = 20130626L;
private static final long serialVersionUID = 20130717L;
/** Standard Constructor */
public X_M_ProductionLineMA (Properties ctx, int M_ProductionLineMA_ID, String trxName)
@ -74,6 +75,23 @@ public class X_M_ProductionLineMA extends PO implements I_M_ProductionLineMA, I_
return sb.toString();
}
/** Set Date Material Policy.
@param DateMaterialPolicy
Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy)
{
set_Value (COLUMNNAME_DateMaterialPolicy, DateMaterialPolicy);
}
/** Get Date Material Policy.
@return Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy ()
{
return (Timestamp)get_Value(COLUMNNAME_DateMaterialPolicy);
}
public I_M_AttributeSetInstance getM_AttributeSetInstance() throws RuntimeException
{
return (I_M_AttributeSetInstance)MTable.get(getCtx(), I_M_AttributeSetInstance.Table_Name)

View File

@ -92,6 +92,23 @@ public class X_M_StorageOnHand extends PO implements I_M_StorageOnHand, I_Persis
return (Timestamp)get_Value(COLUMNNAME_DateLastInventory);
}
/** Set Date Material Policy.
@param DateMaterialPolicy
Time used for LIFO and FIFO Material Policy
*/
public void setDateMaterialPolicy (Timestamp DateMaterialPolicy)
{
set_Value (COLUMNNAME_DateMaterialPolicy, DateMaterialPolicy);
}
/** Get Date Material Policy.
@return Time used for LIFO and FIFO Material Policy
*/
public Timestamp getDateMaterialPolicy ()
{
return (Timestamp)get_Value(COLUMNNAME_DateMaterialPolicy);
}
public I_M_AttributeSetInstance getM_AttributeSetInstance() throws RuntimeException
{
return (I_M_AttributeSetInstance)MTable.get(getCtx(), I_M_AttributeSetInstance.Table_Name)

View File

@ -19,8 +19,10 @@ package org.compiere.util;
import java.awt.Color;
import java.awt.font.TextAttribute;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@ -682,4 +684,13 @@ public class Util
/* */
}
public static Timestamp removeTime(Timestamp ts) {
Calendar cal = Calendar.getInstance();
cal.setTime(ts);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return new Timestamp(cal.getTimeInMillis());
}
} // Util

View File

@ -880,7 +880,7 @@ public class MDDOrder extends X_DD_Order implements DocAction
if (!MStorageOnHand.add(getCtx(), locator_to.getM_Warehouse_ID(), locator_to.getM_Locator_ID(),
line.getM_Product_ID(),
line.getM_AttributeSetInstance_ID(),
Env.ZERO, get_TrxName()))
Env.ZERO,null, get_TrxName()))
{
throw new AdempiereException();
}
@ -888,7 +888,7 @@ public class MDDOrder extends X_DD_Order implements DocAction
if (!MStorageOnHand.add(getCtx(), locator_from.getM_Warehouse_ID(), locator_from.getM_Locator_ID(),
line.getM_Product_ID(),
line.getM_AttributeSetInstanceTo_ID(),
Env.ZERO, get_TrxName()))
Env.ZERO,null, get_TrxName()))
{
throw new AdempiereException();
}

View File

@ -45,7 +45,7 @@ public class MStorageTest extends AdempiereTestCase
loc.saveEx();
//
BigDecimal targetQty = BigDecimal.valueOf(qtyOnHand).setScale(12, BigDecimal.ROUND_HALF_UP);
MStorageOnHand s1 = MStorageOnHand.getCreate(getCtx(), loc.get_ID(), product_id, 0, getTrxName());
MStorageOnHand s1 = MStorageOnHand.getCreate(getCtx(), loc.get_ID(), product_id, 0,null, getTrxName());
s1.setQtyOnHand(targetQty);
s1.saveEx();
//