IDEMPIERE-1597 Price List and Date must be not-updateable
This commit is contained in:
parent
2a366b9c52
commit
5f9c1f7dc8
|
@ -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
|
||||
;
|
||||
|
|
@ -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
|
||||
;
|
||||
|
|
@ -986,7 +986,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
|
||||
|
||||
|
|
|
@ -1066,7 +1066,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
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue