From 8b256677d0ee2f05205ee23fc7579b46e89d5fa1 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sun, 19 Jan 2014 13:27:24 -0500 Subject: [PATCH 1/5] IDEMPIERE-1700 Java error creating a new Price List Version / Thanks to Sergio Oropeza (soropeza) --- .../compiere/process/M_PriceList_Create.java | 35 +++++++------------ .../src/org/compiere/db/StatementProxy.java | 4 ++- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/M_PriceList_Create.java b/org.adempiere.base.process/src/org/compiere/process/M_PriceList_Create.java index ff144aed40..f4b63d123c 100644 --- a/org.adempiere.base.process/src/org/compiere/process/M_PriceList_Create.java +++ b/org.adempiere.base.process/src/org/compiere/process/M_PriceList_Create.java @@ -90,7 +90,7 @@ public class M_PriceList_Create extends SvrProcess { protected String doIt() throws Exception { StringBuilder sql = new StringBuilder(); StringBuilder sqlupd = new StringBuilder(); - StringBuilder sqldel = new StringBuilder(); + String sqldel; StringBuilder sqlins = new StringBuilder(); int cntu = 0; int cntd = 0; @@ -233,12 +233,10 @@ public class M_PriceList_Create extends SvrProcess { // Delete Old Data // if (p_DeleteOld.equals("Y")) { - sqldel.append("DELETE M_ProductPrice ") - .append(" WHERE M_PriceList_Version_ID = ") - .append(p_PriceList_Version_ID); - cntd = DB.executeUpdate(sqldel.toString(), get_TrxName()); + sqldel = "DELETE M_ProductPrice WHERE M_PriceList_Version_ID=?"; + cntd = DB.executeUpdate(sqldel, p_PriceList_Version_ID, get_TrxName()); if (cntd == -1) - raiseError(" DELETE M_ProductPrice ", sqldel.toString()); + raiseError(" DELETE M_ProductPrice ", sqldel); totd += cntd; message = new StringBuilder("@Deleted@=").append(cntd).append(" - "); if (log.isLoggable(Level.FINE)) log.fine("Deleted " + cntd); @@ -287,12 +285,10 @@ public class M_PriceList_Create extends SvrProcess { // //Clear Temporary Table // - sqldel = new StringBuilder("DELETE FROM T_Selection WHERE AD_PInstance_ID="); - sqldel.append(m_AD_PInstance_ID); - - cntd = DB.executeUpdate(sqldel.toString(), get_TrxName()); + sqldel = "DELETE FROM T_Selection WHERE AD_PInstance_ID=?"; + cntd = DB.executeUpdate(sqldel, m_AD_PInstance_ID, get_TrxName()); if (cntd == -1) - raiseError(" DELETE T_Selection ", sqldel.toString()); + raiseError(" DELETE T_Selection ", sqldel); totd += cntd; if (log.isLoggable(Level.FINE)) log.fine("Deleted " + cntd); // @@ -404,15 +400,10 @@ public class M_PriceList_Create extends SvrProcess { v_temp = rsCurgen.getInt("M_PriceList_Version_Base_ID"); if (rsCurgen.wasNull() || v_temp != p_PriceList_Version_ID) { - sqldel = new StringBuilder("DELETE M_ProductPrice pp"); - sqldel.append(" WHERE pp.M_PriceList_Version_ID = "); - sqldel.append(p_PriceList_Version_ID); - sqldel.append(" AND EXISTS (SELECT t_selection_id FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID"); - sqldel.append(" AND s.AD_PInstance_ID=").append(m_AD_PInstance_ID).append(")"); - - cntd = DB.executeUpdate(sqldel.toString(), get_TrxName()); + sqldel = "DELETE M_ProductPrice pp WHERE pp.M_PriceList_Version_ID=? AND EXISTS (SELECT t_selection_id FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID AND s.AD_PInstance_ID=?)"; + cntd = DB.executeUpdate(sqldel, new Object[]{p_PriceList_Version_ID, m_AD_PInstance_ID}, false, get_TrxName()); if (cntd == -1) - raiseError(" DELETE M_ProductPrice ", sqldel.toString()); + raiseError(" DELETE M_ProductPrice ", sqldel); totd += cntd; message.append(", @Deleted@=").append(cntd); if (log.isLoggable(Level.FINE)) log.fine("Deleted " + cntd); @@ -831,10 +822,10 @@ public class M_PriceList_Create extends SvrProcess { // // Delete Temporary Selection // - sqldel = new StringBuilder("DELETE FROM T_Selection "); - cntd = DB.executeUpdate(sqldel.toString(), get_TrxName()); + sqldel = "DELETE FROM T_Selection WHERE AD_PInstance_ID=?"; + cntd = DB.executeUpdate(sqldel, m_AD_PInstance_ID, get_TrxName()); if (cntd == -1) - raiseError(" DELETE T_Selection ", sqldel.toString()); + raiseError(" DELETE T_Selection ", sqldel); totd += cntd; if (log.isLoggable(Level.FINE)) log.fine("Deleted " + cntd); diff --git a/org.adempiere.base/src/org/compiere/db/StatementProxy.java b/org.adempiere.base/src/org/compiere/db/StatementProxy.java index 13cb249deb..ee592f0348 100644 --- a/org.adempiere.base/src/org/compiere/db/StatementProxy.java +++ b/org.adempiere.base/src/org/compiere/db/StatementProxy.java @@ -115,7 +115,9 @@ public class StatementProxy implements InvocationHandler { logOperation = "Delete"; } if (logOperation != null) { - logSql = logSql.substring(0, logSql.indexOf(' ')); + int idxspace = logSql.indexOf(' '); + if (idxspace > 0) + logSql = logSql.substring(0, logSql.indexOf(' ')); if (log.isLoggable(Level.FINE)) log.fine((DisplayType.getDateFormat(DisplayType.DateTime)).format(new Date(System.currentTimeMillis()))+","+logOperation+","+logSql+","+(p_vo.getTrxName() != null ? p_vo.getTrxName() : "")+" (begin)"); } } From 17e085641c9c1fe4422be512b928f515ab33ce93 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sun, 19 Jan 2014 14:47:23 -0500 Subject: [PATCH 2/5] IDEMPIERE-1693 In InfoProductWindow, tab "Available to Promise" can change by change level of log. Should make a checkbox for it. / based on patch from hieplq --- .../oracle/201401161604_IDEMPIERE-1693.sql | 11 +++++++ .../201401161604_IDEMPIERE-1693.sql | 8 +++++ .../webui/info/InfoProductWindow.java | 29 ++++++++++++++++--- .../adempiere/webui/panel/InvoiceHistory.java | 17 ++++++----- 4 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 migration/i2.0/oracle/201401161604_IDEMPIERE-1693.sql create mode 100644 migration/i2.0/postgresql/201401161604_IDEMPIERE-1693.sql diff --git a/migration/i2.0/oracle/201401161604_IDEMPIERE-1693.sql b/migration/i2.0/oracle/201401161604_IDEMPIERE-1693.sql new file mode 100644 index 0000000000..26edb6ec5f --- /dev/null +++ b/migration/i2.0/oracle/201401161604_IDEMPIERE-1693.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Jan 16, 2014 11:33:27 AM ICT +-- IDEMPIERE-1693 In InfoProductWindow, tab "Available to Promise" can change by change level of log. Should make a checkbox for it. +INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','Show detail','Show detail locator info in "Available to promise" tab',200252,'D','693d3147-e09b-4e69-9ada-23ff6c1289fc','showDetailAtp','Y',TO_DATE('2014-01-16 11:33:27','YYYY-MM-DD HH24:MI:SS'),100,100,TO_DATE('2014-01-16 11:33:27','YYYY-MM-DD HH24:MI:SS'),0,0) +; + + +SELECT register_migration_script('201401161604_IDEMPIERE-1693.sql') FROM dual +; diff --git a/migration/i2.0/postgresql/201401161604_IDEMPIERE-1693.sql b/migration/i2.0/postgresql/201401161604_IDEMPIERE-1693.sql new file mode 100644 index 0000000000..a3cffad7ac --- /dev/null +++ b/migration/i2.0/postgresql/201401161604_IDEMPIERE-1693.sql @@ -0,0 +1,8 @@ +-- Jan 16, 2014 11:33:27 AM ICT +-- IDEMPIERE-1693 In InfoProductWindow, tab "Available to Promise" can change by change level of log. Should make a checkbox for it. +INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','Show detail','Show detail locator info in "Available to promise" tab',200252,'D','693d3147-e09b-4e69-9ada-23ff6c1289fc','showDetailAtp','Y',TO_TIMESTAMP('2014-01-16 11:33:27','YYYY-MM-DD HH24:MI:SS'),100,100,TO_TIMESTAMP('2014-01-16 11:33:27','YYYY-MM-DD HH24:MI:SS'),0,0) +; + + +SELECT register_migration_script('201401161604_IDEMPIERE-1693.sql') FROM dual +; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java index e150327078..42345f04d7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java @@ -13,6 +13,7 @@ import java.util.logging.Level; import org.adempiere.webui.component.Borderlayout; import org.adempiere.webui.component.Button; +import org.adempiere.webui.component.Checkbox; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ListModelTable; import org.adempiere.webui.component.ListboxFactory; @@ -31,7 +32,6 @@ import org.adempiere.webui.session.SessionManager; import org.compiere.minigrid.ColumnInfo; import org.compiere.model.MDocType; import org.compiere.model.MRole; -import org.compiere.util.CLogMgt; import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -48,11 +48,10 @@ import org.zkoss.zul.South; * */ public class InfoProductWindow extends InfoWindow { - /** * */ - private static final long serialVersionUID = 4939032152860189380L; + private static final long serialVersionUID = 4817648658129732541L; private Tabbox tabbedPane; private WListbox warehouseTbl; @@ -64,6 +63,9 @@ public class InfoProductWindow extends InfoWindow { //Available to Promise Tab private WListbox m_tableAtp; + // Group atp by warehouse or non + private Checkbox chbShowDetailAtp; + //IDEMPIERE-337 private WListbox productpriceTbl; private String m_sqlProductprice; @@ -275,6 +277,21 @@ public class InfoProductWindow extends InfoWindow { desktopTabPanel = new Tabpanel(); desktopTabPanel.setHeight("100%"); desktopTabPanel.appendChild(m_tableAtp); + // IDEMPIERE-1692 + chbShowDetailAtp = new Checkbox(); + chbShowDetailAtp.setLabel(Msg.getMsg(Env.getCtx(), "showDetailAtp", true)); + chbShowDetailAtp.setTooltiptext(Msg.getMsg(Env.getCtx(), "showDetailAtp", false)); + chbShowDetailAtp.addActionListener(new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + if (contentPanel.getLayout() != null) { + int M_Warehouse_ID = getSelectedWarehouseId(); + int m_M_Product_ID = getSelectedRowKey(); + initAtpTab(M_Warehouse_ID, m_M_Product_ID); + } + } + }); + desktopTabPanel.appendChild(chbShowDetailAtp); tabPanels.appendChild(desktopTabPanel); tab = new Tab(Msg.translate(Env.getCtx(), "Price")); @@ -631,7 +648,7 @@ public class InfoProductWindow extends InfoWindow { columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); // Fill Storage Data - boolean showDetail = CLogMgt.isLevelFine(); + boolean showDetail = isShowDetailATP(); String sql = "SELECT s.QtyOnHand, s.QtyReserved, s.QtyOrdered," + " productAttribute(s.M_AttributeSetInstance_ID), s.M_AttributeSetInstance_ID,"; if (!showDetail) @@ -777,6 +794,10 @@ public class InfoProductWindow extends InfoWindow { m_tableAtp.autoSize(); } // initAtpTab + public boolean isShowDetailATP() { + return chbShowDetailAtp.isChecked(); + } + @Override protected void showHistory() { log.info(""); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InvoiceHistory.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InvoiceHistory.java index d815761a8e..c8ae1a0c08 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InvoiceHistory.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InvoiceHistory.java @@ -34,9 +34,9 @@ import org.adempiere.webui.component.Tabpanels; import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.WListbox; import org.adempiere.webui.component.Window; +import org.adempiere.webui.info.InfoProductWindow; import org.compiere.model.MDocType; import org.compiere.model.MPriceList; -import org.compiere.util.CLogMgt; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; @@ -60,7 +60,9 @@ public class InvoiceHistory extends Window implements EventListener /** * */ - private static final long serialVersionUID = -7426909865199278220L; + private static final long serialVersionUID = 8742214467478030802L; + + boolean showDetailATP = false; /** * Show History @@ -94,6 +96,8 @@ public class InvoiceHistory extends Window implements EventListener this.setSclass("popup-dialog"); AEnv.showCenterWindow(parent, this); + if (parent instanceof InfoProductWindow) + showDetailATP = ((InfoProductWindow)parent).isShowDetailATP(); } // InvoiceHistory private int m_C_BPartner_ID; @@ -598,10 +602,9 @@ public class InvoiceHistory extends Window implements EventListener columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); // Fill Storage Data - boolean showDetail = CLogMgt.isLevelFine(); String sql = "SELECT s.QtyOnHand, s.QtyReserved, s.QtyOrdered," + " productAttribute(s.M_AttributeSetInstance_ID), s.M_AttributeSetInstance_ID,"; - if (!showDetail) + if (!showDetailATP) sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," + " productAttribute(s.M_AttributeSetInstance_ID), 0,"; sql += " w.Name, l.Value " @@ -614,7 +617,7 @@ public class InvoiceHistory extends Window implements EventListener if (m_M_AttributeSetInstance_ID > 0) sql += " AND s.M_AttributeSetInstance_ID=?"; sql += " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)"; - if (!showDetail) + if (!showDetailATP) sql += " GROUP BY productAttribute(s.M_AttributeSetInstance_ID), w.Name, l.Value"; sql += " ORDER BY l.Value"; @@ -643,7 +646,7 @@ public class InvoiceHistory extends Window implements EventListener line.add(new Double(rs.getDouble(2))); // QtyReserved line.add(rs.getString(7)); // Locator String asi = rs.getString(4); - if (showDetail && (asi == null || asi.length() == 0)) + if (showDetailATP && (asi == null || asi.length() == 0)) asi = "{" + rs.getInt(5) + "}"; line.add(asi); // ASI line.add(null); // DocumentNo @@ -710,7 +713,7 @@ public class InvoiceHistory extends Window implements EventListener line.add(qtyReserved); // QtyReserved line.add(null); // Locator String asi = rs.getString(3); - if (showDetail && (asi == null || asi.length() == 0)) + if (showDetailATP && (asi == null || asi.length() == 0)) asi = "{" + rs.getInt(4) + "}"; line.add(asi); // ASI line.add(rs.getString(7)); // DocumentNo From e060114381083425cbad481bc072264a12feca2f Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Tue, 21 Jan 2014 11:45:50 +0800 Subject: [PATCH 3/5] IDEMPIERE-1702 Incorrect report result when there are more than 2 print formats with different report view where clause --- org.adempiere.base/src/org/compiere/print/DataEngine.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/print/DataEngine.java b/org.adempiere.base/src/org/compiere/print/DataEngine.java index 9a09e332b9..7741fe0e1e 100644 --- a/org.adempiere.base/src/org/compiere/print/DataEngine.java +++ b/org.adempiere.base/src/org/compiere/print/DataEngine.java @@ -138,6 +138,7 @@ public class DataEngine */ public PrintData getPrintData (Properties ctx, MPrintFormat format, MQuery query, boolean summary) { + MQuery queryCopy = query.deepCopy(); /** Report Summary FR [ 2011569 ]**/ m_summary = summary; @@ -167,7 +168,7 @@ public class DataEngine // Add WhereClause restriction from AD_ReportView - teo_sarca BF [ 1761891 ] String whereClause = rs.getString(4); if (!Util.isEmpty(whereClause)) - query.addRestriction(whereClause); + queryCopy.addRestriction(whereClause); } } catch (SQLException e) @@ -196,11 +197,11 @@ public class DataEngine if (hasVT) { tableName += "t"; - format.setTranslationViewQuery (query); + format.setTranslationViewQuery (queryCopy); } } // - PrintData pd = getPrintDataInfo (ctx, format, query, reportName, tableName); + PrintData pd = getPrintDataInfo (ctx, format, queryCopy, reportName, tableName); if (pd == null) return null; loadPrintData(pd, format); From 2395338c24ac968c74258f6389e81eaceb2acd49 Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Thu, 23 Jan 2014 14:25:40 +0800 Subject: [PATCH 4/5] 1003322 2Pack enhancement for TrekGlobal Extension Development - Inactive 'Update System Maintained Application Dictionary' field from 'Pack In' window - Default trum to false for User Level --- migration/i2.0/oracle/201401231413_1003322.sql | 10 ++++++++++ migration/i2.0/postgresql/201401231413_1003322.sql | 7 +++++++ .../src/org/adempiere/pipo2/PoExporter.java | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 migration/i2.0/oracle/201401231413_1003322.sql create mode 100644 migration/i2.0/postgresql/201401231413_1003322.sql diff --git a/migration/i2.0/oracle/201401231413_1003322.sql b/migration/i2.0/oracle/201401231413_1003322.sql new file mode 100644 index 0000000000..825b4a4d0a --- /dev/null +++ b/migration/i2.0/oracle/201401231413_1003322.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Jan 23, 2014 12:54:26 PM SGT +-- 1003322 2Pack enhancement for Extension Development +UPDATE AD_Field SET IsActive='N',Updated=TO_DATE('2014-01-23 12:54:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50152 +; + +SELECT register_migration_script('201401231413_1003322.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i2.0/postgresql/201401231413_1003322.sql b/migration/i2.0/postgresql/201401231413_1003322.sql new file mode 100644 index 0000000000..ce9018c893 --- /dev/null +++ b/migration/i2.0/postgresql/201401231413_1003322.sql @@ -0,0 +1,7 @@ +-- Jan 23, 2014 12:54:26 PM SGT +-- 1003322 2Pack enhancement for Extension Development +UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2014-01-23 12:54:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50152 +; + +SELECT register_migration_script('201401231413_1003322.sql') FROM dual +; \ No newline at end of file diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java index ea01ee7c68..fbe671655d 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java @@ -31,7 +31,7 @@ public class PoExporter { try { //default trim to false for print item label since trailing space is commonly use //for formatting purpose - if (qName.equalsIgnoreCase("PrintName")) { + if (qName.equalsIgnoreCase("PrintName") || qName.equalsIgnoreCase("UserLevel")) { atts.addAttribute("", "", "trim", "CDATA", "false"); } transformerHandler.startElement("", "", qName, atts); From 6a4151faab47cdfcdb5d8a6e38e1a25666aa0beb Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 24 Jan 2014 16:55:53 -0500 Subject: [PATCH 5/5] hg backout dfc4781 / IDEMPIERE-1574 Sales Order Line lets Price under the Price Limit when updating --- org.adempiere.base/src/org/compiere/model/MInvoiceLine.java | 2 +- org.adempiere.base/src/org/compiere/model/MOrderLine.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java index 9809c9e095..db148fb27e 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java @@ -865,7 +865,7 @@ public class MInvoiceLine extends X_C_InvoiceLine enforce = false; // Check Price Limit? if (enforce && getPriceLimit() != Env.ZERO - && getPriceEntered().compareTo(getPriceLimit()) < 0) + && getPriceActual().compareTo(getPriceLimit()) < 0) { log.saveError("UnderLimitPrice", "PriceEntered=" + getPriceEntered() + ", PriceLimit=" + getPriceLimit()); return false; diff --git a/org.adempiere.base/src/org/compiere/model/MOrderLine.java b/org.adempiere.base/src/org/compiere/model/MOrderLine.java index 32e8209510..b9a7b31640 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrderLine.java +++ b/org.adempiere.base/src/org/compiere/model/MOrderLine.java @@ -834,7 +834,7 @@ public class MOrderLine extends X_C_OrderLine enforce = false; // Check Price Limit? if (enforce && getPriceLimit() != Env.ZERO - && getPriceEntered().compareTo(getPriceLimit()) < 0) + && getPriceActual().compareTo(getPriceLimit()) < 0) { log.saveError("UnderLimitPrice", "PriceEntered=" + getPriceEntered() + ", PriceLimit=" + getPriceLimit()); return false;