diff --git a/base/src/org/compiere/model/CalloutRequisition.java b/base/src/org/compiere/model/CalloutRequisition.java index cdd549a673..7299f68b33 100644 --- a/base/src/org/compiere/model/CalloutRequisition.java +++ b/base/src/org/compiere/model/CalloutRequisition.java @@ -20,6 +20,7 @@ import java.math.BigDecimal; import java.sql.Timestamp; import java.util.Properties; +import org.adempiere.model.GridTabWrapper; import org.compiere.util.Env; /** @@ -45,40 +46,18 @@ public class CalloutRequisition extends CalloutEngine Integer M_Product_ID = (Integer)value; if (M_Product_ID == null || M_Product_ID.intValue() == 0) return ""; - // setCalloutActive(true); - // - /** Set Attribute - if (Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_Product_ID") == M_Product_ID.intValue() - && Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID") != 0) - mTab.setValue("M_AttributeSetInstance_ID", new Integer(Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID"))); - else - mTab.setValue("M_AttributeSetInstance_ID", null); - **/ - int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, WindowNo, "C_BPartner_ID"); - BigDecimal Qty = (BigDecimal)mTab.getValue("Qty"); - boolean isSOTrx = false; - MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), - C_BPartner_ID, Qty, isSOTrx); - // - int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); - pp.setM_PriceList_ID(M_PriceList_ID); - int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID"); - pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); - Timestamp orderDate = (Timestamp)mTab.getValue("DateRequired"); - pp.setPriceDate(orderDate); - // - mTab.setValue("PriceActual", pp.getPriceStd()); - Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N"); // not used - Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N"); + final I_M_Requisition req = GridTabWrapper.create(mTab, I_M_Requisition.class); + final I_M_RequisitionLine line = GridTabWrapper.create(mTab, I_M_RequisitionLine.class); + setPrice(ctx, WindowNo, req, line); + MProduct product = MProduct.get(ctx, M_Product_ID); + line.setC_UOM_ID(product.getC_UOM_ID()); - // setCalloutActive(false); return ""; } // product - + /** - * Order Line - Amount. - * - called from Qty, PriceActual - * - calculates LineNetAmt + * Requisition line - Qty + * - Price, LineNetAmt * @param ctx context * @param WindowNo current Window No * @param mTab Grid Tab @@ -90,44 +69,47 @@ public class CalloutRequisition extends CalloutEngine { if (isCalloutActive() || value == null) return ""; - + + final I_M_Requisition req = GridTabWrapper.create(mTab, I_M_Requisition.class); + final I_M_RequisitionLine line = GridTabWrapper.create(mTab, I_M_RequisitionLine.class); // Qty changed - recalc price - if (mField.getColumnName().equals("Qty") + if (mField.getColumnName().equals(I_M_RequisitionLine.COLUMNNAME_Qty) && "Y".equals(Env.getContext(ctx, WindowNo, "DiscountSchema"))) { - int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, WindowNo, "M_Product_ID"); - int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, WindowNo, "C_BPartner_ID"); - BigDecimal Qty = (BigDecimal)value; - boolean isSOTrx = false; - MProductPricing pp = new MProductPricing (M_Product_ID, - C_BPartner_ID, Qty, isSOTrx); - // - int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); - pp.setM_PriceList_ID(M_PriceList_ID); - int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID"); - pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); - Timestamp orderDate = (Timestamp)mTab.getValue("DateInvoiced"); - pp.setPriceDate(orderDate); - // - mTab.setValue("PriceActual", pp.getPriceStd()); + setPrice(ctx, WindowNo, req, line); } int StdPrecision = Env.getContextAsInt(ctx, WindowNo, "StdPrecision"); - BigDecimal Qty = (BigDecimal)mTab.getValue("Qty"); - BigDecimal PriceActual = (BigDecimal)mTab.getValue("PriceActual"); - - // get values + BigDecimal Qty = line.getQty(); + BigDecimal PriceActual = line.getPriceActual(); log.fine("amt - Qty=" + Qty + ", Price=" + PriceActual + ", Precision=" + StdPrecision); // Multiply BigDecimal LineNetAmt = Qty.multiply(PriceActual); if (LineNetAmt.scale() > StdPrecision) LineNetAmt = LineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); - mTab.setValue("LineNetAmt", LineNetAmt); + line.setLineNetAmt(LineNetAmt); log.info("amt - LineNetAmt=" + LineNetAmt); // return ""; } // amt - + private void setPrice(Properties ctx, int WindowNo, I_M_Requisition req, I_M_RequisitionLine line) + { + int C_BPartner_ID = line.getC_BPartner_ID(); + BigDecimal Qty = line.getQty(); + boolean isSOTrx = false; + MProductPricing pp = new MProductPricing (line.getM_Product_ID(), C_BPartner_ID, Qty, isSOTrx); + // + int M_PriceList_ID = req.getM_PriceList_ID(); + pp.setM_PriceList_ID(M_PriceList_ID); + int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID"); + pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); + Timestamp orderDate = req.getDateRequired(); + pp.setPriceDate(orderDate); + // + line.setPriceActual(pp.getPriceStd()); + Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N"); // not used + Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N"); + } } // CalloutRequisition diff --git a/base/src/org/compiere/model/I_M_RequisitionLine.java b/base/src/org/compiere/model/I_M_RequisitionLine.java index a46dc8893d..5a0f28d968 100644 --- a/base/src/org/compiere/model/I_M_RequisitionLine.java +++ b/base/src/org/compiere/model/I_M_RequisitionLine.java @@ -107,6 +107,21 @@ public interface I_M_RequisitionLine public I_C_OrderLine getC_OrderLine() throws RuntimeException; + /** Column name C_UOM_ID */ + public static final String COLUMNNAME_C_UOM_ID = "C_UOM_ID"; + + /** Set UOM. + * Unit of Measure + */ + public void setC_UOM_ID (int C_UOM_ID); + + /** Get UOM. + * Unit of Measure + */ + public int getC_UOM_ID(); + + public I_C_UOM getC_UOM() throws RuntimeException; + /** Column name Created */ public static final String COLUMNNAME_Created = "Created"; @@ -203,6 +218,19 @@ public interface I_M_RequisitionLine public I_M_Product getM_Product() throws RuntimeException; + /** Column name M_RequisitionLine_ID */ + public static final String COLUMNNAME_M_RequisitionLine_ID = "M_RequisitionLine_ID"; + + /** Set Requisition Line. + * Material Requisition Line + */ + public void setM_RequisitionLine_ID (int M_RequisitionLine_ID); + + /** Get Requisition Line. + * Material Requisition Line + */ + public int getM_RequisitionLine_ID(); + /** Column name M_Requisition_ID */ public static final String COLUMNNAME_M_Requisition_ID = "M_Requisition_ID"; @@ -218,19 +246,6 @@ public interface I_M_RequisitionLine public I_M_Requisition getM_Requisition() throws RuntimeException; - /** Column name M_RequisitionLine_ID */ - public static final String COLUMNNAME_M_RequisitionLine_ID = "M_RequisitionLine_ID"; - - /** Set Requisition Line. - * Material Requisition Line - */ - public void setM_RequisitionLine_ID (int M_RequisitionLine_ID); - - /** Get Requisition Line. - * Material Requisition Line - */ - public int getM_RequisitionLine_ID(); - /** Column name PriceActual */ public static final String COLUMNNAME_PriceActual = "PriceActual"; diff --git a/base/src/org/compiere/model/MRequisitionLine.java b/base/src/org/compiere/model/MRequisitionLine.java index 1cc4a6182f..26aeadb974 100644 --- a/base/src/org/compiere/model/MRequisitionLine.java +++ b/base/src/org/compiere/model/MRequisitionLine.java @@ -37,6 +37,8 @@ import org.compiere.util.Msg; *
  • BF [ 2419978 ] Voiding PO, requisition don't set on NULL *
  • BF [ 2608617 ] Error when I want to delete a PO document *
  • BF [ 2609604 ] Add M_RequisitionLine.C_BPartner_ID + *
  • FR [ 2841841 ] Requisition Improvements + * https://sourceforge.net/tracker/?func=detail&aid=2841841&group_id=176962&atid=879335 */ public class MRequisitionLine extends X_M_RequisitionLine { @@ -184,6 +186,12 @@ public class MRequisitionLine extends X_M_RequisitionLine return m_parent; } // getParent + @Override + public I_M_Requisition getM_Requisition() + { + return getParent(); + } + /** * @return Date when this product is required by planner * @see MRequisition#getDateRequired() @@ -265,6 +273,11 @@ public class MRequisitionLine extends X_M_RequisitionLine setC_Charge_ID(0); if (getM_AttributeSetInstance_ID() != 0 && getC_Charge_ID() != 0) setM_AttributeSetInstance_ID(0); + // Product UOM + if (getM_Product_ID() > 0 && getC_UOM_ID() <= 0) + { + setC_UOM_ID(getM_Product().getC_UOM_ID()); + } // if (getPriceActual().signum() == 0) setPrice(); @@ -299,6 +312,12 @@ public class MRequisitionLine extends X_M_RequisitionLine return updateHeader(); } // afterDelete + @Override + public I_M_Product getM_Product() + { + return MProduct.get(getCtx(), getM_Product_ID()); + } + /** * Update Header * @return header updated diff --git a/base/src/org/compiere/model/X_M_RequisitionLine.java b/base/src/org/compiere/model/X_M_RequisitionLine.java index feab67f83c..b358e2d554 100644 --- a/base/src/org/compiere/model/X_M_RequisitionLine.java +++ b/base/src/org/compiere/model/X_M_RequisitionLine.java @@ -45,8 +45,8 @@ public class X_M_RequisitionLine extends PO implements I_M_RequisitionLine, I_Pe setLine (0); // @SQL=SELECT COALESCE(MAX(Line),0)+10 AS DefaultValue FROM M_RequisitionLine WHERE M_Requisition_ID=@M_Requisition_ID@ setLineNetAmt (Env.ZERO); - setM_Requisition_ID (0); setM_RequisitionLine_ID (0); + setM_Requisition_ID (0); setPriceActual (Env.ZERO); setQty (Env.ZERO); // 1 @@ -198,6 +198,45 @@ public class X_M_RequisitionLine extends PO implements I_M_RequisitionLine, I_Pe return ii.intValue(); } + public I_C_UOM getC_UOM() throws RuntimeException + { + Class clazz = MTable.getClass(I_C_UOM.Table_Name); + I_C_UOM result = null; + try { + Constructor constructor = null; + constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class}); + result = (I_C_UOM)constructor.newInstance(new Object[] {getCtx(), new Integer(getC_UOM_ID()), get_TrxName()}); + } catch (Exception e) { + log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e); + log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz); + throw new RuntimeException( e ); + } + return result; + } + + /** Set UOM. + @param C_UOM_ID + Unit of Measure + */ + public void setC_UOM_ID (int C_UOM_ID) + { + if (C_UOM_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_UOM_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_UOM_ID, Integer.valueOf(C_UOM_ID)); + } + + /** Get UOM. + @return Unit of Measure + */ + public int getC_UOM_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_UOM_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + /** Set Description. @param Description Optional short description of the record @@ -325,6 +364,29 @@ public class X_M_RequisitionLine extends PO implements I_M_RequisitionLine, I_Pe return ii.intValue(); } + /** Set Requisition Line. + @param M_RequisitionLine_ID + Material Requisition Line + */ + public void setM_RequisitionLine_ID (int M_RequisitionLine_ID) + { + if (M_RequisitionLine_ID < 1) + set_ValueNoCheck (COLUMNNAME_M_RequisitionLine_ID, null); + else + set_ValueNoCheck (COLUMNNAME_M_RequisitionLine_ID, Integer.valueOf(M_RequisitionLine_ID)); + } + + /** Get Requisition Line. + @return Material Requisition Line + */ + public int getM_RequisitionLine_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_RequisitionLine_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + public I_M_Requisition getM_Requisition() throws RuntimeException { Class clazz = MTable.getClass(I_M_Requisition.Table_Name); @@ -364,29 +426,6 @@ public class X_M_RequisitionLine extends PO implements I_M_RequisitionLine, I_Pe return ii.intValue(); } - /** Set Requisition Line. - @param M_RequisitionLine_ID - Material Requisition Line - */ - public void setM_RequisitionLine_ID (int M_RequisitionLine_ID) - { - if (M_RequisitionLine_ID < 1) - set_ValueNoCheck (COLUMNNAME_M_RequisitionLine_ID, null); - else - set_ValueNoCheck (COLUMNNAME_M_RequisitionLine_ID, Integer.valueOf(M_RequisitionLine_ID)); - } - - /** Get Requisition Line. - @return Material Requisition Line - */ - public int getM_RequisitionLine_ID () - { - Integer ii = (Integer)get_Value(COLUMNNAME_M_RequisitionLine_ID); - if (ii == null) - return 0; - return ii.intValue(); - } - /** Set Unit Price. @param PriceActual Actual Price diff --git a/migration/353a-trunk/oracle/535_FR2841841_RequisitionImprovements.sql b/migration/353a-trunk/oracle/535_FR2841841_RequisitionImprovements.sql new file mode 100644 index 0000000000..d58dcf2e3b --- /dev/null +++ b/migration/353a-trunk/oracle/535_FR2841841_RequisitionImprovements.sql @@ -0,0 +1,148 @@ +-- 21.08.2009 13:12:04 EEST +-- Requisition Improvements +INSERT INTO AD_Column (AD_Column_ID,IsParent,AD_Client_ID,AD_Org_ID,IsAutocomplete,AD_Table_ID,Help,FieldLength,Created,CreatedBy,Updated,Version,IsActive,Description,ColumnName,IsKey,AD_Reference_ID,IsTranslated,IsMandatory,IsIdentifier,SeqNo,IsSelectionColumn,IsSyncDatabase,AD_Element_ID,IsUpdateable,EntityType,Name,UpdatedBy,IsAlwaysUpdateable,IsEncrypted,IsAllowLogging) VALUES (57955,'N',0,0,'N',703,'The UOM defines a unique non monetary Unit of Measure',10,TO_DATE('2009-08-21 13:12:02','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2009-08-21 13:12:02','YYYY-MM-DD HH24:MI:SS'),0,'Y','Unit of Measure','C_UOM_ID','N',30,'N','N','N',0,'N','N',215,'N','D','UOM',0,'N','N','Y') +; + +-- 21.08.2009 13:12:04 EEST +-- Requisition Improvements +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) 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 FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=57955 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID) +; + +-- 21.08.2009 13:12:06 EEST +-- Requisition Improvements +INSERT INTO AD_Field (IsFieldOnly,DisplayLength,AD_Field_ID,Help,IsEncrypted,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,UpdatedBy,IsActive,Created,IsSameLine,IsHeading,CreatedBy,AD_Client_ID,Updated,Description,AD_Org_ID,IsReadOnly,IsCentrallyMaintained,EntityType) VALUES ('N',10,57388,'The UOM defines a unique non monetary Unit of Measure','N','UOM',642,57955,'N',0,'Y',TO_DATE('2009-08-21 13:12:04','YYYY-MM-DD HH24:MI:SS'),'N','N',0,0,TO_DATE('2009-08-21 13:12:04','YYYY-MM-DD HH24:MI:SS'),'Unit of Measure',0,'N','Y','D') +; + +-- 21.08.2009 13:12:06 EEST +-- Requisition Improvements +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57388 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +-- 21.08.2009 13:12:07 EEST +-- Requisition Improvements +INSERT INTO AD_Field (IsFieldOnly,DisplayLength,AD_Field_ID,Help,IsEncrypted,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,UpdatedBy,IsActive,Created,IsSameLine,IsHeading,CreatedBy,AD_Client_ID,Updated,Description,AD_Org_ID,IsReadOnly,IsCentrallyMaintained,EntityType) VALUES ('N',10,57389,'The UOM defines a unique non monetary Unit of Measure','N','UOM',768,57955,'N',0,'Y',TO_DATE('2009-08-21 13:12:06','YYYY-MM-DD HH24:MI:SS'),'N','N',0,0,TO_DATE('2009-08-21 13:12:06','YYYY-MM-DD HH24:MI:SS'),'Unit of Measure',0,'N','Y','D') +; + +-- 21.08.2009 13:12:07 EEST +-- Requisition Improvements +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57389 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +-- 21.08.2009 13:12:14 EEST +-- Requisition Improvements +ALTER TABLE M_RequisitionLine ADD C_UOM_ID NUMBER(10) DEFAULT NULL +; + +-- 21.08.2009 13:13:59 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=57388 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=13014 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=10037 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=10034 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=10036 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=10035 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=10196 +; + +-- 21.08.2009 13:15:19 EEST +-- Requisition Improvements +UPDATE AD_Field SET IsSameLine='Y', IsReadOnly='Y', DisplayLogic='@C_Charge_ID@!0',Updated=TO_DATE('2009-08-21 13:15:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57388 +; + +-- 21.08.2009 13:15:27 EEST +-- Requisition Improvements +UPDATE AD_Field SET DisplayLogic='@C_Charge_ID@=0',Updated=TO_DATE('2009-08-21 13:15:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57388 +; + +-- 21.08.2009 13:15:42 EEST +-- Requisition Improvements +UPDATE AD_Field SET DisplayLogic='@C_Charge_ID@=0',Updated=TO_DATE('2009-08-21 13:15:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=10043 +; + +-- 21.08.2009 13:38:07 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=57389 +; + +-- 21.08.2009 13:38:07 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=12483 +; + +-- 21.08.2009 13:38:07 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=12487 +; + +-- 21.08.2009 13:38:07 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=12479 +; + +-- 21.08.2009 13:38:21 EEST +-- Requisition Improvements +UPDATE AD_Field SET IsSameLine='Y',Updated=TO_DATE('2009-08-21 13:38:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57389 +; + +-- 21.08.2009 13:38:30 EEST +-- Requisition Improvements +UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_DATE('2009-08-21 13:38:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57389 +; + +-- 21.08.2009 13:40:49 EEST +-- Requisition Improvements +INSERT INTO AD_Val_Rule (Name,Type,Code,CreatedBy,Updated,UpdatedBy,Created,AD_Val_Rule_ID,AD_Client_ID,IsActive,AD_Org_ID,EntityType) VALUES ('M_Product(Purchased)','S','M_Product.IsSummary=''N'' AND M_Product.IsActive=''Y'' AND M_Product.IsPurchased=''Y''',0,TO_DATE('2009-08-21 13:40:48','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2009-08-21 13:40:48','YYYY-MM-DD HH24:MI:SS'),52058,0,'Y',0,'D') +; + +-- 21.08.2009 13:40:49 EEST +-- Requisition Improvements +-- INSERT INTO AD_Val_Rule_Trl (AD_Language,AD_Val_Rule_ID, Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Val_Rule_ID, t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Val_Rule t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Val_Rule_ID=52058 AND EXISTS (SELECT * FROM AD_Val_Rule_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Val_Rule_ID!=t.AD_Val_Rule_ID) +-- ; + +-- 21.08.2009 13:42:15 EEST +-- Requisition Improvements +UPDATE AD_Column SET AD_Val_Rule_ID=52058,Updated=TO_DATE('2009-08-21 13:42:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=11501 +; + +update M_RequisitionLine rl set +C_UOM_ID=(select p.C_UOM_ID from M_Product p where p.M_Product_ID=rl.M_Product_ID) +where M_Product_ID is not null and C_UOM_ID is null; + +/* Update M_Product.IsPurchased: +update M_Product p set IsPurchased='Y' +where p.IsPurchased='N' and p.IsActive='Y' and p.IsSummary='N' +and ( + exists (select 1 from M_RequisitionLine rl where rl.M_Product_ID=p.M_Product_ID) + or exists (select 1 from C_OrderLine ol + inner join C_Order o on (o.C_Order_ID=ol.C_Order_ID) + where ol.M_Product_ID=p.M_Product_ID and o.IsSOTrx='N') + or exists (select 1 from C_InvoiceLine il + inner join C_Invoice i on (i.C_Invoice_ID=il.C_Invoice_ID) + where il.M_Product_ID=p.M_Product_ID and i.IsSOTrx='N') +) +; +*/ diff --git a/migration/353a-trunk/postgresql/535_FR2841841_RequisitionImprovements.sql b/migration/353a-trunk/postgresql/535_FR2841841_RequisitionImprovements.sql new file mode 100644 index 0000000000..1215f13ce1 --- /dev/null +++ b/migration/353a-trunk/postgresql/535_FR2841841_RequisitionImprovements.sql @@ -0,0 +1,148 @@ +-- 21.08.2009 13:12:04 EEST +-- Requisition Improvements +INSERT INTO AD_Column (AD_Column_ID,IsParent,AD_Client_ID,AD_Org_ID,IsAutocomplete,AD_Table_ID,Help,FieldLength,Created,CreatedBy,Updated,Version,IsActive,Description,ColumnName,IsKey,AD_Reference_ID,IsTranslated,IsMandatory,IsIdentifier,SeqNo,IsSelectionColumn,IsSyncDatabase,AD_Element_ID,IsUpdateable,EntityType,Name,UpdatedBy,IsAlwaysUpdateable,IsEncrypted,IsAllowLogging) VALUES (57955,'N',0,0,'N',703,'The UOM defines a unique non monetary Unit of Measure',10,TO_TIMESTAMP('2009-08-21 13:12:02','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2009-08-21 13:12:02','YYYY-MM-DD HH24:MI:SS'),0,'Y','Unit of Measure','C_UOM_ID','N',30,'N','N','N',0,'N','N',215,'N','D','UOM',0,'N','N','Y') +; + +-- 21.08.2009 13:12:04 EEST +-- Requisition Improvements +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) 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 FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=57955 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID) +; + +-- 21.08.2009 13:12:06 EEST +-- Requisition Improvements +INSERT INTO AD_Field (IsFieldOnly,DisplayLength,AD_Field_ID,Help,IsEncrypted,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,UpdatedBy,IsActive,Created,IsSameLine,IsHeading,CreatedBy,AD_Client_ID,Updated,Description,AD_Org_ID,IsReadOnly,IsCentrallyMaintained,EntityType) VALUES ('N',10,57388,'The UOM defines a unique non monetary Unit of Measure','N','UOM',642,57955,'N',0,'Y',TO_TIMESTAMP('2009-08-21 13:12:04','YYYY-MM-DD HH24:MI:SS'),'N','N',0,0,TO_TIMESTAMP('2009-08-21 13:12:04','YYYY-MM-DD HH24:MI:SS'),'Unit of Measure',0,'N','Y','D') +; + +-- 21.08.2009 13:12:06 EEST +-- Requisition Improvements +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57388 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +-- 21.08.2009 13:12:07 EEST +-- Requisition Improvements +INSERT INTO AD_Field (IsFieldOnly,DisplayLength,AD_Field_ID,Help,IsEncrypted,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,UpdatedBy,IsActive,Created,IsSameLine,IsHeading,CreatedBy,AD_Client_ID,Updated,Description,AD_Org_ID,IsReadOnly,IsCentrallyMaintained,EntityType) VALUES ('N',10,57389,'The UOM defines a unique non monetary Unit of Measure','N','UOM',768,57955,'N',0,'Y',TO_TIMESTAMP('2009-08-21 13:12:06','YYYY-MM-DD HH24:MI:SS'),'N','N',0,0,TO_TIMESTAMP('2009-08-21 13:12:06','YYYY-MM-DD HH24:MI:SS'),'Unit of Measure',0,'N','Y','D') +; + +-- 21.08.2009 13:12:07 EEST +-- Requisition Improvements +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57389 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +-- 21.08.2009 13:12:14 EEST +-- Requisition Improvements +ALTER TABLE M_RequisitionLine ADD COLUMN C_UOM_ID NUMERIC(10) DEFAULT NULL +; + +-- 21.08.2009 13:13:59 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=57388 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=13014 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=10037 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=10034 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=10036 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=10035 +; + +-- 21.08.2009 13:14:00 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=10196 +; + +-- 21.08.2009 13:15:19 EEST +-- Requisition Improvements +UPDATE AD_Field SET IsSameLine='Y', IsReadOnly='Y', DisplayLogic='@C_Charge_ID@!0',Updated=TO_TIMESTAMP('2009-08-21 13:15:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57388 +; + +-- 21.08.2009 13:15:27 EEST +-- Requisition Improvements +UPDATE AD_Field SET DisplayLogic='@C_Charge_ID@=0',Updated=TO_TIMESTAMP('2009-08-21 13:15:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57388 +; + +-- 21.08.2009 13:15:42 EEST +-- Requisition Improvements +UPDATE AD_Field SET DisplayLogic='@C_Charge_ID@=0',Updated=TO_TIMESTAMP('2009-08-21 13:15:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=10043 +; + +-- 21.08.2009 13:38:07 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=57389 +; + +-- 21.08.2009 13:38:07 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=12483 +; + +-- 21.08.2009 13:38:07 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=12487 +; + +-- 21.08.2009 13:38:07 EEST +-- Requisition Improvements +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=12479 +; + +-- 21.08.2009 13:38:21 EEST +-- Requisition Improvements +UPDATE AD_Field SET IsSameLine='Y',Updated=TO_TIMESTAMP('2009-08-21 13:38:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57389 +; + +-- 21.08.2009 13:38:30 EEST +-- Requisition Improvements +UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_TIMESTAMP('2009-08-21 13:38:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57389 +; + +-- 21.08.2009 13:40:49 EEST +-- Requisition Improvements +INSERT INTO AD_Val_Rule (Name,Type,Code,CreatedBy,Updated,UpdatedBy,Created,AD_Val_Rule_ID,AD_Client_ID,IsActive,AD_Org_ID,EntityType) VALUES ('M_Product(Purchased)','S','M_Product.IsSummary=''N'' AND M_Product.IsActive=''Y'' AND M_Product.IsPurchased=''Y''',0,TO_TIMESTAMP('2009-08-21 13:40:48','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2009-08-21 13:40:48','YYYY-MM-DD HH24:MI:SS'),52058,0,'Y',0,'D') +; + +-- 21.08.2009 13:40:49 EEST +-- Requisition Improvements +-- INSERT INTO AD_Val_Rule_Trl (AD_Language,AD_Val_Rule_ID, Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Val_Rule_ID, t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Val_Rule t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Val_Rule_ID=52058 AND EXISTS (SELECT * FROM AD_Val_Rule_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Val_Rule_ID!=t.AD_Val_Rule_ID) +-- ; + +-- 21.08.2009 13:42:15 EEST +-- Requisition Improvements +UPDATE AD_Column SET AD_Val_Rule_ID=52058,Updated=TO_TIMESTAMP('2009-08-21 13:42:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=11501 +; + +update M_RequisitionLine rl set +C_UOM_ID=(select p.C_UOM_ID from M_Product p where p.M_Product_ID=rl.M_Product_ID) +where M_Product_ID is not null and C_UOM_ID is null; + +/* Update M_Product.IsPurchased: +update M_Product p set IsPurchased='Y' +where p.IsPurchased='N' and p.IsActive='Y' and p.IsSummary='N' +and ( + exists (select 1 from M_RequisitionLine rl where rl.M_Product_ID=p.M_Product_ID) + or exists (select 1 from C_OrderLine ol + inner join C_Order o on (o.C_Order_ID=ol.C_Order_ID) + where ol.M_Product_ID=p.M_Product_ID and o.IsSOTrx='N') + or exists (select 1 from C_InvoiceLine il + inner join C_Invoice i on (i.C_Invoice_ID=il.C_Invoice_ID) + where il.M_Product_ID=p.M_Product_ID and i.IsSOTrx='N') +) +; +*/