diff --git a/migration/i2.1/oracle/201503251255_IDEMPIERE-2540.sql b/migration/i2.1/oracle/201503251255_IDEMPIERE-2540.sql new file mode 100644 index 0000000000..c0ff655952 --- /dev/null +++ b/migration/i2.1/oracle/201503251255_IDEMPIERE-2540.sql @@ -0,0 +1,28 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-2540: Allowing Vendor qty break to specify breaks for all customers +-- Mar 25, 2015 12:46:56 PM IST +UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2015-03-25 12:46:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=56928 +; + +-- Mar 25, 2015 12:46:59 PM IST +ALTER TABLE M_ProductPriceVendorBreak MODIFY C_BPartner_ID NUMBER(10) DEFAULT NULL +; + +-- Mar 25, 2015 12:47:00 PM IST +ALTER TABLE M_ProductPriceVendorBreak MODIFY C_BPartner_ID NULL +; + +-- Mar 25, 2015 12:47:00 PM IST +ALTER TABLE M_ProductPriceVendorBreak DROP CONSTRAINT cbpartner_mproductpricevendorb +; + +-- Mar 25, 2015 12:47:00 PM IST +ALTER TABLE M_ProductPriceVendorBreak ADD CONSTRAINT cbpartner_mproductpricevendorb FOREIGN KEY (C_BPartner_ID) REFERENCES c_bpartner(c_bpartner_id) DEFERRABLE INITIALLY DEFERRED +; + +SELECT register_migration_script('201503251255_IDEMPIERE-2540') FROM dual +; + + diff --git a/migration/i2.1/postgresql/201503251255_IDEMPIERE-2540.sql b/migration/i2.1/postgresql/201503251255_IDEMPIERE-2540.sql new file mode 100644 index 0000000000..91ae3b6dc5 --- /dev/null +++ b/migration/i2.1/postgresql/201503251255_IDEMPIERE-2540.sql @@ -0,0 +1,25 @@ +-- IDEMPIERE-2540: Allowing Vendor qty break to specify breaks for all customers +-- Mar 25, 2015 12:46:56 PM IST +UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2015-03-25 12:46:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=56928 +; + +-- Mar 25, 2015 12:46:59 PM IST +INSERT INTO t_alter_column values('m_productpricevendorbreak','C_BPartner_ID','NUMERIC(10)',null,'NULL') +; + +-- Mar 25, 2015 12:47:00 PM IST +INSERT INTO t_alter_column values('m_productpricevendorbreak','C_BPartner_ID',null,'NULL',null) +; + +-- Mar 25, 2015 12:47:00 PM IST +ALTER TABLE M_ProductPriceVendorBreak DROP CONSTRAINT cbpartner_mproductpricevendorb +; + +-- Mar 25, 2015 12:47:00 PM IST +ALTER TABLE M_ProductPriceVendorBreak ADD CONSTRAINT cbpartner_mproductpricevendorb FOREIGN KEY (C_BPartner_ID) REFERENCES c_bpartner(c_bpartner_id) DEFERRABLE INITIALLY DEFERRED +; + +SELECT register_migration_script('201503251255_IDEMPIERE-2540') FROM dual +; + + diff --git a/org.adempiere.base/src/org/compiere/model/MProductPricing.java b/org.adempiere.base/src/org/compiere/model/MProductPricing.java index d309ff80ae..da08e5ecc8 100644 --- a/org.adempiere.base/src/org/compiere/model/MProductPricing.java +++ b/org.adempiere.base/src/org/compiere/model/MProductPricing.java @@ -52,7 +52,7 @@ public class MProductPricing m_Qty = Qty; m_isSOTrx = isSOTrx; int thereAreVendorBreakRecords = DB.getSQLValue(null, - "SELECT count(M_Product_ID) FROM M_ProductPriceVendorBreak WHERE M_Product_ID=? AND C_BPartner_ID=?", + "SELECT count(M_Product_ID) FROM M_ProductPriceVendorBreak WHERE M_Product_ID=? AND (C_BPartner_ID=? OR C_BPartner_ID is NULL)", m_M_Product_ID, m_C_BPartner_ID); m_useVendorBreak = thereAreVendorBreakRecords > 0; } // MProductPricing @@ -440,9 +440,9 @@ public class MProductPricing + " AND pp.IsActive='Y'" + " AND p.M_Product_ID=?" // #1 + " AND pv.M_PriceList_Version_ID=?" // #2 - + " AND pp.C_BPartner_ID=?" // #3 + + " AND (pp.C_BPartner_ID=? OR pp.C_BPartner_ID is NULL)" // #3 + " AND ?>=pp.BreakValue" // #4 - + " ORDER BY BreakValue DESC"; + + " ORDER BY pp.C_BPartner_ID, BreakValue DESC"; m_calculated = false; PreparedStatement pstmt = null; ResultSet rs = null; @@ -561,9 +561,9 @@ public class MProductPricing + " AND pp.IsActive='Y'" + " AND p.M_Product_ID=?" // #1 + " AND pv.M_PriceList_ID=?" // #2 - + " AND pp.C_BPartner_ID=?" // #3 + + " AND (pp.C_BPartner_ID=? OR pp.C_BPartner_ID is NULL)" // #3 + " AND ?>=pp.BreakValue" // #4 - + " ORDER BY pv.ValidFrom DESC, BreakValue DESC"; + + " ORDER BY pp.C_BPartner_ID, pv.ValidFrom DESC, BreakValue DESC"; m_calculated = false; if (m_PriceDate == null) m_PriceDate = new Timestamp (System.currentTimeMillis()); @@ -646,9 +646,9 @@ public class MProductPricing + " AND pp.IsActive='Y'" + " AND p.M_Product_ID=?" // #1 + " AND pl.M_PriceList_ID=?" // #2 - + " AND pp.C_BPartner_ID=?" // #3 + + " AND (pp.C_BPartner_ID=? OR pp.C_BPartner_ID is NULL)" // #3 + " AND ?>=pp.BreakValue" // #4 - + " ORDER BY pv.ValidFrom DESC, BreakValue DESC"; + + " ORDER BY pp.C_BPartner_ID, pv.ValidFrom DESC, BreakValue DESC"; m_calculated = false; if (m_PriceDate == null) m_PriceDate = new Timestamp (System.currentTimeMillis());