IDEMPIERE-2811 Each Record should have a primary key / Implement for M_ProductPrice / Peer review

This commit is contained in:
Carlos Ruiz 2015-10-16 10:19:26 -05:00
parent 77e1325b9e
commit 993901c7d7
4 changed files with 19 additions and 15 deletions

View File

@ -20,7 +20,7 @@ ALTER TABLE M_ProductPrice ADD M_ProductPrice_ID NUMBER(10) DEFAULT NULL
--CHUCK added here --CHUCK added here
--oracle --oracle
ALTER TABLE m_productprice DROP CONSTRAINT m_productprice_pkey; ALTER TABLE m_productprice DROP CONSTRAINT m_productpice_key CASCADE;
--CHUCK added here --CHUCK added here
--set the values for the keys --set the values for the keys
@ -48,6 +48,10 @@ INSERT INTO AD_IndexColumn (AD_Client_ID,AD_Org_ID,AD_IndexColumn_ID,AD_IndexCol
ALTER TABLE M_ProductPrice ADD CONSTRAINT m_productprice_unique_idx UNIQUE (M_PriceList_Version_ID,M_Product_ID) ALTER TABLE M_ProductPrice ADD CONSTRAINT m_productprice_unique_idx UNIQUE (M_PriceList_Version_ID,M_Product_ID)
; ;
-- Carlos - rename old unique key index
ALTER INDEX M_PRODUCTPICE_KEY RENAME TO M_PRODUCTPRICE_UNIQUE_IDX
;
-- Oct 8, 2015 2:23:10 PM CDT -- Oct 8, 2015 2:23:10 PM CDT
INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,ColumnSpan) VALUES (203893,'Product Price','Intersection between a Product and a Price List Version',183,212276,'N',22,'N','N','N','N',0,0,'Y',TO_DATE('2015-10-08 14:23:05','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2015-10-08 14:23:05','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','eb261ad2-c016-4281-adc9-c16742b0c125','N',2) INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,ColumnSpan) VALUES (203893,'Product Price','Intersection between a Product and a Price List Version',183,212276,'N',22,'N','N','N','N',0,0,'Y',TO_DATE('2015-10-08 14:23:05','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2015-10-08 14:23:05','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','eb261ad2-c016-4281-adc9-c16742b0c125','N',2)
; ;

View File

@ -17,7 +17,7 @@ ALTER TABLE M_ProductPrice ADD COLUMN M_ProductPrice_ID NUMERIC(10) DEFAULT NULL
--Chuck added here --Chuck added here
--drop current primary key --drop current primary key
alter table m_productprice drop constraint if exists m_productprice_pkey; alter table m_productprice drop constraint m_productprice_pkey;
--Chuck added here --Chuck added here
--set the values for the keys --set the values for the keys

View File

@ -414,6 +414,8 @@ public class M_PriceList_Create extends SvrProcess {
// Copy (Insert) Prices // Copy (Insert) Prices
// //
v_temp = rsCurgen.getInt("M_PriceList_Version_Base_ID"); v_temp = rsCurgen.getInt("M_PriceList_Version_Base_ID");
int seqproductpriceid = MSequence.get(getCtx(), "M_ProductPrice").get_ID();
int currentUserID = Env.getAD_User_ID(getCtx());
if (v_temp == p_PriceList_Version_ID) if (v_temp == p_PriceList_Version_ID)
// //
// We have Prices already // We have Prices already
@ -426,6 +428,7 @@ public class M_PriceList_Create extends SvrProcess {
{ {
sqlins = new StringBuilder("INSERT INTO M_ProductPrice "); sqlins = new StringBuilder("INSERT INTO M_ProductPrice ");
sqlins.append("(M_ProductPrice_ID"); sqlins.append("(M_ProductPrice_ID");
sqlins.append(" ,M_ProductPrice_UU");
sqlins.append(" ,M_PriceList_Version_ID"); sqlins.append(" ,M_PriceList_Version_ID");
sqlins.append(" ,M_Product_ID "); sqlins.append(" ,M_Product_ID ");
sqlins.append(" ,AD_Client_ID"); sqlins.append(" ,AD_Client_ID");
@ -439,9 +442,8 @@ public class M_PriceList_Create extends SvrProcess {
sqlins.append(" , PriceStd"); sqlins.append(" , PriceStd");
sqlins.append(" , PriceLimit) "); sqlins.append(" , PriceLimit) ");
sqlins.append("SELECT "); sqlins.append("SELECT ");
sqlins.append("nextIdFunc("); sqlins.append(" nextIdFunc(").append(seqproductpriceid).append(",'N')");
sqlins.append( MSequence.get(getCtx(), "M_ProductPrice").get_ID()); sqlins.append(" , generate_uuid(),");
sqlins.append(",'N') ,");
sqlins.append(p_PriceList_Version_ID); sqlins.append(p_PriceList_Version_ID);
sqlins.append(" ,po.M_Product_ID "); sqlins.append(" ,po.M_Product_ID ");
sqlins.append(" ,"); sqlins.append(" ,");
@ -450,9 +452,9 @@ public class M_PriceList_Create extends SvrProcess {
sqlins.append(rsCurgen.getInt("AD_Org_ID")); sqlins.append(rsCurgen.getInt("AD_Org_ID"));
sqlins.append(" ,'Y'"); sqlins.append(" ,'Y'");
sqlins.append(" ,SysDate,"); sqlins.append(" ,SysDate,");
sqlins.append(rsCurgen.getInt("UpdatedBy")); sqlins.append(currentUserID);
sqlins.append(" ,SysDate,"); sqlins.append(" ,SysDate,");
sqlins.append(rsCurgen.getInt("UpdatedBy")); sqlins.append(currentUserID);
// //
//Price List //Price List
// //
@ -563,22 +565,21 @@ public class M_PriceList_Create extends SvrProcess {
//Copy and Convert from other PriceList_Version //Copy and Convert from other PriceList_Version
// //
sqlins = new StringBuilder("INSERT INTO M_ProductPrice "); sqlins = new StringBuilder("INSERT INTO M_ProductPrice ");
sqlins.append(" (M_ProductPrice_ID, M_PriceList_Version_ID, M_Product_ID,"); sqlins.append(" (M_ProductPrice_ID, M_ProductPrice_UU, M_PriceList_Version_ID, M_Product_ID,");
sqlins.append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,"); sqlins.append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,");
sqlins.append(" PriceList, PriceStd, PriceLimit)"); sqlins.append(" PriceList, PriceStd, PriceLimit)");
sqlins.append(" SELECT "); sqlins.append(" SELECT ");
sqlins.append("nextIdFunc("); sqlins.append("nextIdFunc(").append(seqproductpriceid).append(",'N')");
sqlins.append( MSequence.get(getCtx(), "M_ProductPrice").get_ID()); sqlins.append(", generate_uuid(),");
sqlins.append(",'N') ,");
sqlins.append(p_PriceList_Version_ID); sqlins.append(p_PriceList_Version_ID);
sqlins.append(", pp.M_Product_ID,"); sqlins.append(", pp.M_Product_ID,");
sqlins.append(rsCurgen.getInt("AD_Client_ID")); sqlins.append(rsCurgen.getInt("AD_Client_ID"));
sqlins.append(", "); sqlins.append(", ");
sqlins.append(rsCurgen.getInt("AD_Org_ID")); sqlins.append(rsCurgen.getInt("AD_Org_ID"));
sqlins.append(", 'Y', SysDate, "); sqlins.append(", 'Y', SysDate, ");
sqlins.append(rsCurgen.getInt("UpdatedBy")); sqlins.append(currentUserID);
sqlins.append(", SysDate, "); sqlins.append(", SysDate, ");
sqlins.append(rsCurgen.getInt("UpdatedBy")); sqlins.append(currentUserID);
sqlins.append(" ,"); sqlins.append(" ,");
// Price List // Price List
sqlins.append("COALESCE(currencyConvert(pp.PriceList, pl.C_Currency_ID, "); sqlins.append("COALESCE(currencyConvert(pp.PriceList, pl.C_Currency_ID, ");
@ -617,7 +618,7 @@ public class M_PriceList_Create extends SvrProcess {
sqlins.append(rsCurgen.getInt("M_PriceList_Version_Base_ID")); sqlins.append(rsCurgen.getInt("M_PriceList_Version_Base_ID"));
sqlins.append(" AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID"); sqlins.append(" AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID");
sqlins.append(" AND s.AD_PInstance_ID=").append(m_AD_PInstance_ID).append(")"); sqlins.append(" AND s.AD_PInstance_ID=").append(m_AD_PInstance_ID).append(")");
sqlins.append("AND pp.IsActive='Y'"); sqlins.append(" AND pp.IsActive='Y'");
pstmt = DB.prepareStatement(sqlins.toString(), pstmt = DB.prepareStatement(sqlins.toString(),
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_INSENSITIVE,

View File

@ -21,7 +21,6 @@ import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env;
/** /**
* Product Price * Product Price