diff --git a/migration/i2.0/oracle/201312131644_IDEMPIERE-1597.sql b/migration/i2.0/oracle/201312131644_IDEMPIERE-1597.sql new file mode 100644 index 0000000000..e3dc3004f4 --- /dev/null +++ b/migration/i2.0/oracle/201312131644_IDEMPIERE-1597.sql @@ -0,0 +1,23 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Dec 13, 2013 4:13:06 PM COT +-- IDEMPIERE-1597 Price List and Date must be not-updateable +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Price list cannot be changed because the order contains product lines',200243,'D','41c5bae2-77e0-4beb-a562-3f3ae465cb90','CannotChangePl','Y',TO_DATE('2013-12-13 16:13:05','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-12-13 16:13:05','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Dec 13, 2013 4:15:35 PM COT +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Date Ordered cannot be changed because the order contains product lines and the change falls in a differente price list version',200244,'D','8264d9e8-2b91-4aa2-ba80-82171b747254','CannotChangeDateOrdered','Y',TO_DATE('2013-12-13 16:15:34','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-12-13 16:15:34','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Dec 13, 2013 4:23:13 PM COT +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Price list cannot be changed because the invoice contains product lines',200245,'D','4d860b4e-0cd0-491f-a68d-e8a4b0ffb8f8','CannotChangePlIn','Y',TO_DATE('2013-12-13 16:23:12','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-12-13 16:23:12','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Dec 13, 2013 4:24:15 PM COT +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Date Invoiced cannot be changed because the invoice contains product lines and the change falls in a differente price list version',200246,'D','411625c7-21ee-48e0-8350-5e59f7fb9ecd','CannotChangeDateInvoiced','Y',TO_DATE('2013-12-13 16:24:14','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-12-13 16:24:14','YYYY-MM-DD HH24:MI:SS'),0) +; + +SELECT register_migration_script('201312131644_IDEMPIERE-1597.sql') FROM dual +; + diff --git a/migration/i2.0/postgresql/201312131644_IDEMPIERE-1597.sql b/migration/i2.0/postgresql/201312131644_IDEMPIERE-1597.sql new file mode 100644 index 0000000000..352b2367cc --- /dev/null +++ b/migration/i2.0/postgresql/201312131644_IDEMPIERE-1597.sql @@ -0,0 +1,20 @@ +-- Dec 13, 2013 4:13:06 PM COT +-- IDEMPIERE-1597 Price List and Date must be not-updateable +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Price list cannot be changed because the order contains product lines',200243,'D','41c5bae2-77e0-4beb-a562-3f3ae465cb90','CannotChangePl','Y',TO_TIMESTAMP('2013-12-13 16:13:05','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-12-13 16:13:05','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Dec 13, 2013 4:15:35 PM COT +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Date Ordered cannot be changed because the order contains product lines and the change falls in a differente price list version',200244,'D','8264d9e8-2b91-4aa2-ba80-82171b747254','CannotChangeDateOrdered','Y',TO_TIMESTAMP('2013-12-13 16:15:34','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-12-13 16:15:34','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Dec 13, 2013 4:23:13 PM COT +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Price list cannot be changed because the invoice contains product lines',200245,'D','4d860b4e-0cd0-491f-a68d-e8a4b0ffb8f8','CannotChangePlIn','Y',TO_TIMESTAMP('2013-12-13 16:23:12','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-12-13 16:23:12','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Dec 13, 2013 4:24:15 PM COT +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Date Invoiced cannot be changed because the invoice contains product lines and the change falls in a differente price list version',200246,'D','411625c7-21ee-48e0-8350-5e59f7fb9ecd','CannotChangeDateInvoiced','Y',TO_TIMESTAMP('2013-12-13 16:24:14','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-12-13 16:24:14','YYYY-MM-DD HH24:MI:SS'),0) +; + +SELECT register_migration_script('201312131644_IDEMPIERE-1597.sql') FROM dual +; + diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportBankStatement.java b/org.adempiere.base.process/src/org/compiere/process/ImportBankStatement.java index 64c0aa482d..526d8b1d7c 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportBankStatement.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportBankStatement.java @@ -364,7 +364,7 @@ public class ImportBankStatement extends SvrProcess //Import Bank Statement sql = new StringBuilder("SELECT * FROM I_BankStatement") .append(" WHERE I_IsImported='N'") - .append(" ORDER BY C_BankAccount_ID, Name, StatementDate, ReferenceNo"); + .append(" ORDER BY C_BankAccount_ID, Name, StatementDate, EftStatementReference"); MBankStatement statement = null; MBankAccount account = null; diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 3165845c59..5ac7f638ed 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -989,7 +989,27 @@ public class MInvoice extends X_C_Invoice implements DocAction if (order.getC_CashPlanLine_ID() > 0) setC_CashPlanLine_ID(order.getC_CashPlanLine_ID()); } - + + // IDEMPIERE-1597 Price List and Date must be not-updateable + if (!newRecord && (is_ValueChanged(COLUMNNAME_M_PriceList_ID) || is_ValueChanged(COLUMNNAME_DateInvoiced))) { + int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM C_InvoiceLine WHERE C_Invoice_ID=? AND M_Product_ID>0", getC_Invoice_ID()); + if (cnt > 0) { + if (is_ValueChanged(COLUMNNAME_M_PriceList_ID)) { + log.saveError("Error", Msg.getMsg(getCtx(), "CannotChangePlIn")); + return false; + } + if (is_ValueChanged(COLUMNNAME_DateInvoiced)) { + MPriceList pList = MPriceList.get(getCtx(), getM_PriceList_ID(), null); + MPriceListVersion plOld = pList.getPriceListVersion((Timestamp)get_ValueOld(COLUMNNAME_DateInvoiced)); + MPriceListVersion plNew = pList.getPriceListVersion((Timestamp)get_Value(COLUMNNAME_DateInvoiced)); + if (plNew == null || !plNew.equals(plOld)) { + log.saveError("Error", Msg.getMsg(getCtx(), "CannotChangeDateInvoiced")); + return false; + } + } + } + } + return true; } // beforeSave diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index 68902816b9..aea06a3374 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -1068,7 +1068,27 @@ public class MOrder extends X_C_Order implements DocAction } } } - + + // IDEMPIERE-1597 Price List and Date must be not-updateable + if (!newRecord && (is_ValueChanged(COLUMNNAME_M_PriceList_ID) || is_ValueChanged(COLUMNNAME_DateOrdered))) { + int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM C_OrderLine WHERE C_Order_ID=? AND M_Product_ID>0", getC_Order_ID()); + if (cnt > 0) { + if (is_ValueChanged(COLUMNNAME_M_PriceList_ID)) { + log.saveError("Error", Msg.getMsg(getCtx(), "CannotChangePl")); + return false; + } + if (is_ValueChanged(COLUMNNAME_DateOrdered)) { + MPriceList pList = MPriceList.get(getCtx(), getM_PriceList_ID(), null); + MPriceListVersion plOld = pList.getPriceListVersion((Timestamp)get_ValueOld(COLUMNNAME_DateOrdered)); + MPriceListVersion plNew = pList.getPriceListVersion((Timestamp)get_Value(COLUMNNAME_DateOrdered)); + if (plNew == null || !plNew.equals(plOld)) { + log.saveError("Error", Msg.getMsg(getCtx(), "CannotChangeDateOrdered")); + return false; + } + } + } + } + return true; } // beforeSave diff --git a/org.adempiere.base/src/org/compiere/model/MPriceList.java b/org.adempiere.base/src/org/compiere/model/MPriceList.java index d72eb6732e..4d312dbc39 100644 --- a/org.adempiere.base/src/org/compiere/model/MPriceList.java +++ b/org.adempiere.base/src/org/compiere/model/MPriceList.java @@ -240,9 +240,6 @@ public class MPriceList extends X_M_PriceList { if (valid == null) valid = new Timestamp (System.currentTimeMillis()); - // Assume there is no later - if (m_plv != null && m_plv.getValidFrom().before(valid)) - return m_plv; final String whereClause = "M_PriceList_ID=? AND TRUNC(ValidFrom)<=?"; m_plv = new Query(getCtx(), I_M_PriceList_Version.Table_Name, whereClause, get_TrxName()) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index 7e9821408f..63b3257cb4 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -1688,14 +1688,16 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements ADTabpanel adtabpanel = (ADTabpanel) iadtabpanel; Grid grid = adtabpanel.getGridView().getListbox(); Columns columns = grid.getColumns(); - List list = columns.getChildren(); - for(int i = 0; i < list.size(); i++) - { - Component c = (Component) list.get(i); - if (c instanceof Column) { - Column column = (Column) c; - if (!"natural".equals(column.getSortDirection())) { - return column; + if (columns != null) { + List list = columns.getChildren(); + for(int i = 0; i < list.size(); i++) + { + Component c = (Component) list.get(i); + if (c instanceof Column) { + Column column = (Column) c; + if (!"natural".equals(column.getSortDirection())) { + return column; + } } } }