From 31ee8bc837b798f892a8d2d2bd4d71c5d6b23890 Mon Sep 17 00:00:00 2001 From: Edwin Ang Date: Mon, 29 Oct 2012 15:14:45 +0700 Subject: [PATCH] modify code related with M_Storage --- .../org/compiere/model/CalloutInventory.java | 4 ++-- .../org/compiere/model/CalloutMovement.java | 7 +++++- .../process/InventoryCountCreate.java | 10 ++++----- .../process/InventoryCountUpdate.java | 4 ++-- .../org/compiere/process/InventoryValue.java | 4 ++-- .../compiere/process/M_Production_Run.java | 1 - .../org/compiere/process/OrgOwnership.java | 2 +- .../org/compiere/process/ReplenishReport.java | 10 ++++----- .../process/ReplenishReportProduction.java | 8 +++---- .../org/compiere/process/StorageCleanup.java | 8 +++---- .../compiere/model/AccessSqlParserTest.java | 4 ++-- .../src/org/compiere/model/MCostDetail.java | 4 ++-- .../org/compiere/model/MLocatorLookup.java | 2 +- .../src/org/compiere/model/MProduct.java | 22 ++++++++----------- .../compiere/model/MStorageReservation.java | 17 ++++++++++++++ .../src/org/compiere/model/MWarehouse.java | 2 +- .../src/test/functional/MStorageTest.java | 4 ++-- .../functional/inventory/InventoryTest.java | 11 ++-------- .../compiere/apps/form/VAttributeGrid.java | 2 +- .../compiere/apps/search/InfoPAttribute.java | 2 +- .../org/compiere/apps/search/InfoProduct.java | 2 +- .../compiere/apps/search/InvoiceHistory.java | 2 +- .../apps/search/PAttributeInstance.java | 2 +- .../src/org/compiere/grid/ed/VLocator.java | 2 +- .../webui/editor/WLocatorEditor.java | 2 +- .../panel/InfoPAttributeInstancePanel.java | 2 +- .../webui/panel/InfoPAttributePanel.java | 2 +- .../webui/panel/InfoProductPanel.java | 2 +- .../adempiere/webui/panel/InvoiceHistory.java | 2 +- .../webui/window/WPAttributeInstance.java | 2 +- 30 files changed, 79 insertions(+), 69 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java index 382b439e59..324518cf06 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java @@ -147,12 +147,12 @@ public class CalloutInventory extends CalloutEngine private BigDecimal setQtyBook (int M_AttributeSetInstance_ID, int M_Product_ID, int M_Locator_ID) throws Exception { // Set QtyBook from first storage location BigDecimal bd = null; - String sql = "SELECT QtyOnHand FROM M_Storage " + String sql = "SELECT QtyOnHand FROM M_StorageOnHand " + "WHERE M_Product_ID=?" // 1 + " AND M_Locator_ID=?" // 2 + " AND M_AttributeSetInstance_ID=?"; if (M_AttributeSetInstance_ID == 0) - sql = "SELECT SUM(QtyOnHand) FROM M_Storage " + sql = "SELECT SUM(QtyOnHand) FROM M_StorageOnHand " + "WHERE M_Product_ID=?" // 1 + " AND M_Locator_ID=?"; // 2 diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutMovement.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutMovement.java index a197a2827f..8d776803b6 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutMovement.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutMovement.java @@ -20,6 +20,7 @@ package org.compiere.model; import java.math.BigDecimal; import java.util.Properties; +import org.compiere.util.DB; import org.compiere.util.Env; /** @@ -117,11 +118,15 @@ public class CalloutMovement extends CalloutEngine if (MovementQty == null) MovementQty = (BigDecimal) mTab.getValue("MovementQty"); int M_Locator_ID = Env.getContextAsInt(ctx, WindowNo, "M_Locator_ID"); + // If no locator, don't check anything and assume is ok if (M_Locator_ID <= 0) return; + //@win - IDEMPIERE-385 + int M_Warehouse_ID = DB.getSQLValue(null, "SELECT M_Warehouse_ID FROM M_Locator WHERE M_Locator_ID=?"); + // int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, WindowNo, "M_AttributeSetInstance_ID"); - BigDecimal available = MStorageReservation.getQtyAvailable(0, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, null); + BigDecimal available = MStorageReservation.getQtyAvailable(M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID, null); if (available == null) available = Env.ZERO; if (available.signum() == 0) diff --git a/org.adempiere.base.process/src/org/compiere/process/InventoryCountCreate.java b/org.adempiere.base.process/src/org/compiere/process/InventoryCountCreate.java index 8a6e836b7a..e100a29071 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InventoryCountCreate.java +++ b/org.adempiere.base.process/src/org/compiere/process/InventoryCountCreate.java @@ -135,13 +135,13 @@ public class InventoryCountCreate extends SvrProcess // Create Null Storage records if (p_QtyRange != null && p_QtyRange.equals("=")) { - StringBuilder sql = new StringBuilder("INSERT INTO M_Storage "); + StringBuilder sql = new StringBuilder("INSERT INTO M_StorageOnHand "); sql.append("(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,"); sql.append(" M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID,"); - sql.append(" QtyOnHand, QtyReserved, QtyOrdered, DateLastInventory) "); + sql.append(" QtyOnHand, DateLastInventory) "); sql.append("SELECT l.AD_CLIENT_ID, l.AD_ORG_ID, 'Y', SysDate, 0,SysDate, 0,"); sql.append(" l.M_Locator_ID, p.M_Product_ID, 0,"); - sql.append(" 0,0,0,null "); + sql.append(" 0,null "); sql.append("FROM M_Locator l"); sql.append(" INNER JOIN M_Product p ON (l.AD_Client_ID=p.AD_Client_ID) "); sql.append("WHERE l.M_Warehouse_ID="); @@ -151,7 +151,7 @@ public class InventoryCountCreate extends SvrProcess sql.append(" AND l.M_Locator_ID=").append(p_M_Locator_ID); sql.append(" AND l.IsDefault='Y'") .append(" AND p.IsActive='Y' AND p.IsStocked='Y' and p.ProductType='I'") - .append(" AND NOT EXISTS (SELECT * FROM M_Storage s") + .append(" AND NOT EXISTS (SELECT * FROM M_StorageOnHand s") .append(" INNER JOIN M_Locator sl ON (s.M_Locator_ID=sl.M_Locator_ID) ") .append("WHERE sl.M_Warehouse_ID=l.M_Warehouse_ID") .append(" AND s.M_Product_ID=p.M_Product_ID)"); @@ -162,7 +162,7 @@ public class InventoryCountCreate extends SvrProcess StringBuilder sql = new StringBuilder("SELECT s.M_Product_ID, s.M_Locator_ID, s.M_AttributeSetInstance_ID,"); sql.append(" s.QtyOnHand, p.M_AttributeSet_ID "); sql.append("FROM M_Product p"); - sql.append(" INNER JOIN M_Storage s ON (s.M_Product_ID=p.M_Product_ID)"); + sql.append(" INNER JOIN M_StorageOnHand s ON (s.M_Product_ID=p.M_Product_ID)"); sql.append(" INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID) "); sql.append("WHERE l.M_Warehouse_ID=?"); sql.append(" AND p.IsActive='Y' AND p.IsStocked='Y' and p.ProductType='I'"); diff --git a/org.adempiere.base.process/src/org/compiere/process/InventoryCountUpdate.java b/org.adempiere.base.process/src/org/compiere/process/InventoryCountUpdate.java index ae6c157c55..e75cc51f0d 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InventoryCountUpdate.java +++ b/org.adempiere.base.process/src/org/compiere/process/InventoryCountUpdate.java @@ -92,14 +92,14 @@ public class InventoryCountUpdate extends SvrProcess // ASI sql = new StringBuilder("UPDATE M_InventoryLine l ") .append("SET (QtyBook,QtyCount) = ") - .append("(SELECT QtyOnHand,QtyOnHand FROM M_Storage s ") + .append("(SELECT QtyOnHand,QtyOnHand FROM M_StorageOnHand s ") .append("WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID") .append(" AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),") .append(" Updated=SysDate,") .append(" UpdatedBy=").append(getAD_User_ID()) // .append(" WHERE M_Inventory_ID=").append(p_M_Inventory_ID) - .append(" AND EXISTS (SELECT * FROM M_Storage s ") + .append(" AND EXISTS (SELECT * FROM M_StorageOnHand s ") .append("WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID") .append(" AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID)"); int no = DB.executeUpdate(sql.toString(), get_TrxName()); diff --git a/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java b/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java index 5b3e5535b1..fddca19018 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java +++ b/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java @@ -175,7 +175,7 @@ public class InventoryValue extends SvrProcess // Get current QtyOnHand with ASI sql = new StringBuilder ("UPDATE T_InventoryValue iv SET QtyOnHand = ") - .append("(SELECT SUM(QtyOnHand) FROM M_Storage s") + .append("(SELECT SUM(QtyOnHand) FROM M_StorageOnHand s") .append(" INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) ") .append("WHERE iv.M_Product_ID=s.M_Product_ID") .append(" AND iv.M_Warehouse_ID=l.M_Warehouse_ID") @@ -186,7 +186,7 @@ public class InventoryValue extends SvrProcess log.fine("QtHand with ASI=" + no); // Get current QtyOnHand without ASI sql = new StringBuilder ("UPDATE T_InventoryValue iv SET QtyOnHand = ") - .append("(SELECT SUM(QtyOnHand) FROM M_Storage s") + .append("(SELECT SUM(QtyOnHand) FROM M_StorageOnHand s") .append(" INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) ") .append("WHERE iv.M_Product_ID=s.M_Product_ID") .append(" AND iv.M_Warehouse_ID=l.M_Warehouse_ID) ") diff --git a/org.adempiere.base.process/src/org/compiere/process/M_Production_Run.java b/org.adempiere.base.process/src/org/compiere/process/M_Production_Run.java index 01cefa90a5..e3c849730c 100644 --- a/org.adempiere.base.process/src/org/compiere/process/M_Production_Run.java +++ b/org.adempiere.base.process/src/org/compiere/process/M_Production_Run.java @@ -143,7 +143,6 @@ public class M_Production_Run extends SvrProcess { { BigDecimal QtyAvailable = MStorageReservation.getQtyAvailable( locator.getM_Warehouse_ID(), - locator.getM_Locator_ID(), pline.getM_Product_ID(), pline.getM_AttributeSetInstance_ID(), get_TrxName()); diff --git a/org.adempiere.base.process/src/org/compiere/process/OrgOwnership.java b/org.adempiere.base.process/src/org/compiere/process/OrgOwnership.java index b79160b080..ec7cf3c77c 100644 --- a/org.adempiere.base.process/src/org/compiere/process/OrgOwnership.java +++ b/org.adempiere.base.process/src/org/compiere/process/OrgOwnership.java @@ -140,7 +140,7 @@ public class OrgOwnership extends SvrProcess // Set Storage sql = new StringBuilder(); - sql.append("UPDATE M_Storage s ") + sql.append("UPDATE M_StorageOnHand s ") .append("SET AD_Org_ID=").append(p_AD_Org_ID) .append(" WHERE EXISTS ") .append("(SELECT * FROM M_Locator l WHERE l.M_Locator_ID=s.M_Locator_ID") diff --git a/org.adempiere.base.process/src/org/compiere/process/ReplenishReport.java b/org.adempiere.base.process/src/org/compiere/process/ReplenishReport.java index 831d56e9c1..56b124b3a6 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ReplenishReport.java +++ b/org.adempiere.base.process/src/org/compiere/process/ReplenishReport.java @@ -249,12 +249,12 @@ public class ReplenishReport extends SvrProcess log.fine("Insert (BP) #" + no); } sql = new StringBuilder("UPDATE T_Replenish t SET "); - sql.append("QtyOnHand = (SELECT COALESCE(SUM(QtyOnHand),0) FROM M_Storage s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); + sql.append("QtyOnHand = (SELECT COALESCE(SUM(QtyOnHand),0) FROM M_StorageOnHand s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); sql.append(" AND l.M_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID),"); - sql.append("QtyReserved = (SELECT COALESCE(SUM(QtyReserved),0) FROM M_Storage s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); - sql.append(" AND l.M_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID),"); - sql.append("QtyOrdered = (SELECT COALESCE(SUM(QtyOrdered),0) FROM M_Storage s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); - sql.append(" AND l.M_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID)"); + sql.append("QtyReserved = (SELECT COALESCE(SUM(QtyReserved),0) FROM M_StorageReservation s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); + sql.append(" AND l.M_Warehouse_ID=t.M_Warehouse_ID),"); + sql.append("QtyOrdered = (SELECT COALESCE(SUM(QtyOrdered),0) FROM M_StorageReservation s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); + sql.append(" AND l.M_Warehouse_ID=t.M_Warehouse_ID)"); if (p_C_DocType_ID != 0) sql.append(", C_DocType_ID=").append(p_C_DocType_ID); sql.append(" WHERE AD_PInstance_ID=").append(getAD_PInstance_ID()); diff --git a/org.adempiere.base.process/src/org/compiere/process/ReplenishReportProduction.java b/org.adempiere.base.process/src/org/compiere/process/ReplenishReportProduction.java index bb176e69fa..0db921456e 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ReplenishReportProduction.java +++ b/org.adempiere.base.process/src/org/compiere/process/ReplenishReportProduction.java @@ -271,10 +271,10 @@ public class ReplenishReportProduction extends SvrProcess sql = new StringBuilder("UPDATE T_Replenish t SET "); sql.append("QtyOnHand = (SELECT COALESCE(SUM(QtyOnHand),0) FROM M_Storage s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); sql.append(" AND l.M_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID),"); - sql.append("QtyReserved = (SELECT COALESCE(SUM(QtyReserved),0) FROM M_Storage s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); - sql.append(" AND l.M_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID),"); - sql.append("QtyOrdered = (SELECT COALESCE(SUM(QtyOrdered),0) FROM M_Storage s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); - sql.append(" AND l.M_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID)"); + sql.append("QtyReserved = (SELECT COALESCE(SUM(QtyReserved),0) FROM M_StorageReservation s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); + sql.append(" AND l.M_Warehouse_ID=t.M_Warehouse_ID),"); + sql.append("QtyOrdered = (SELECT COALESCE(SUM(QtyOrdered),0) FROM M_StorageReservation s, M_Locator l WHERE t.M_Product_ID=s.M_Product_ID"); + sql.append(" AND l.M_Warehouse_ID=t.M_Warehouse_ID)"); if (p_C_DocType_ID != 0) sql.append(", C_DocType_ID=").append(p_C_DocType_ID); sql.append(" WHERE AD_PInstance_ID=").append(getAD_PInstance_ID()); diff --git a/org.adempiere.base.process/src/org/compiere/process/StorageCleanup.java b/org.adempiere.base.process/src/org/compiere/process/StorageCleanup.java index f3c4310731..863330efee 100644 --- a/org.adempiere.base.process/src/org/compiere/process/StorageCleanup.java +++ b/org.adempiere.base.process/src/org/compiere/process/StorageCleanup.java @@ -68,7 +68,7 @@ public class StorageCleanup extends SvrProcess { log.info(""); // Clean up empty Storage - String sql = "DELETE FROM M_Storage " + String sql = "DELETE FROM M_StorageOnHand " + "WHERE QtyOnHand = 0 AND QtyReserved = 0 AND QtyOrdered = 0" + " AND Created < SysDate-3"; int no = DB.executeUpdate(sql, get_TrxName()); @@ -76,7 +76,7 @@ public class StorageCleanup extends SvrProcess // sql = "SELECT * " - + "FROM M_Storage s " + + "FROM M_StorageOnHand s " + "WHERE AD_Client_ID = ?" + " AND QtyOnHand < 0" // Instance Attribute @@ -89,7 +89,7 @@ public class StorageCleanup extends SvrProcess // + " AND s.M_Product_ID=sl.M_Product_ID" // + " AND s.M_Locator_ID=sl.M_Locator_ID)" // Stock in same Warehouse - + " AND EXISTS (SELECT * FROM M_Storage sw" + + " AND EXISTS (SELECT * FROM M_StorageOnHand sw" + " INNER JOIN M_Locator swl ON (sw.M_Locator_ID=swl.M_Locator_ID), M_Locator sl " + "WHERE sw.QtyOnHand > 0" + " AND s.M_Product_ID=sw.M_Product_ID" @@ -250,7 +250,7 @@ public class StorageCleanup extends SvrProcess { ArrayList list = new ArrayList(); String sql = "SELECT * " - + "FROM M_Storage s " + + "FROM M_StorageOnHand s " + "WHERE QtyOnHand > 0" + " AND M_Product_ID=?" // Empty ASI diff --git a/org.adempiere.base/src/org/compiere/model/AccessSqlParserTest.java b/org.adempiere.base/src/org/compiere/model/AccessSqlParserTest.java index 81efc99a9d..dae566bbbc 100644 --- a/org.adempiere.base/src/org/compiere/model/AccessSqlParserTest.java +++ b/org.adempiere.base/src/org/compiere/model/AccessSqlParserTest.java @@ -188,9 +188,9 @@ public class AccessSqlParserTest extends TestCase */ public void testProductInstanceAttributeQuery() { - String sql = "SELECT p.M_Product_ID, p.Discontinued, p.Value, p.Name, BOM_Qty_Available(p.M_Product_ID,?) AS QtyAvailable, bomQtyList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd, BOM_Qty_OnHand(p.M_Product_ID,?) AS QtyOnHand, BOM_Qty_Reserved(p.M_Product_ID,?) AS QtyReserved, BOM_Qty_Ordered(p.M_Product_ID,?) AS QtyOrdered, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin, bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit, pa.IsInstanceAttribute FROM M_Product p INNER JOIN M_ProductPrice pr ON (p.M_Product_ID=pr.M_Product_ID) LEFT OUTER JOIN M_AttributeSet pa ON (p.M_AttributeSet_ID=pa.M_AttributeSet_ID) WHERE p.IsSummary='N' AND p.IsActive='Y' AND pr.IsActive='Y' AND pr.M_PriceList_Version_ID=? AND EXISTS (SELECT * FROM M_Storage s INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) WHERE s.M_Product_ID=p.M_Product_ID AND asi.SerNo LIKE '33' AND asi.Lot LIKE '33' AND asi.M_Lot_ID=101 AND TRUNC(asi.GuaranteeDate) params = new ArrayList(); String sql = "SELECT" +" COALESCE(SUM(QtyOnHand),0)" - +",COALESCE(SUM(QtyReserved),0)" - +",COALESCE(SUM(QtyOrdered),0)" - +" FROM M_Storage" + +" FROM M_StorageOnHand" +" WHERE M_Locator_ID=? AND M_Product_ID=?"; params.add(locator.get_ID()); params.add(product.get_ID()); @@ -199,8 +197,6 @@ public class InventoryTest extends AdempiereTestCase PreparedStatement pstmt = null; ResultSet rs = null; BigDecimal qtyOnHand = Env.ZERO; - BigDecimal qtyOrdered = Env.ZERO; - BigDecimal qtyReserved = Env.ZERO; try { pstmt = DB.prepareStatement(sql, trxName); @@ -209,8 +205,6 @@ public class InventoryTest extends AdempiereTestCase if (rs.next()) { qtyOnHand = rs.getBigDecimal(1); - qtyReserved = rs.getBigDecimal(2); - qtyOrdered = rs.getBigDecimal(3); } } catch (SQLException e) @@ -225,8 +219,7 @@ public class InventoryTest extends AdempiereTestCase // // assertEquals("QtyOnHand not match "+doc, doc.Qty, qtyOnHand); - assertEquals("QtyReserved not match "+doc, doc.QtyReserved, qtyReserved); - assertEquals("QtyOrdered not match "+doc, doc.QtyOrdered, qtyOrdered); + } private void dumpStatus(MMDocument doc, String trxName) diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAttributeGrid.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VAttributeGrid.java index 01ff562713..e097b3af35 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAttributeGrid.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VAttributeGrid.java @@ -519,7 +519,7 @@ public class VAttributeGrid extends CPanel formatted = ""; if (m_M_Warehouse_ID != 0) { - BigDecimal qty = MStorageReservation.getQtyAvailable(m_M_Warehouse_ID, 0, M_Product_ID, 0, null); + BigDecimal qty = MStorageReservation.getQtyAvailable(m_M_Warehouse_ID, M_Product_ID, 0, null); if (qty == null) formatted = "-"; else diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPAttribute.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPAttribute.java index 3a49c78d8d..65dbace003 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPAttribute.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPAttribute.java @@ -512,7 +512,7 @@ public class InfoPAttribute extends CDialog // finish Instance Attributes if (sb.length() > 0) { - sb.insert(0, " AND EXISTS (SELECT * FROM M_Storage s" + sb.insert(0, " AND EXISTS (SELECT * FROM M_StorageOnHand s" + " INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) " + "WHERE s.M_Product_ID=p.M_Product_ID"); sb.append(")"); diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java index 4ac9588740..11c4ae9f22 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java @@ -1246,7 +1246,7 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," + " productAttribute(s.M_AttributeSetInstance_ID), 0,"; sql += " w.Name, l.Value " - + "FROM M_Storage s" + + "FROM M_StorageOnHand s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) " + "WHERE M_Product_ID=?"; diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java index aef7cc3b94..5b789b2072 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java @@ -566,7 +566,7 @@ public class InvoiceHistory extends CDialog sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," + " productAttribute(s.M_AttributeSetInstance_ID), 0,"; sql += " w.Name, l.Value " - + "FROM M_Storage s" + + "FROM M_StorageOnHand s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) " + "WHERE M_Product_ID=?"; diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/PAttributeInstance.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/PAttributeInstance.java index 4e1c05bbe2..66be052e8f 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/PAttributeInstance.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/PAttributeInstance.java @@ -178,7 +178,7 @@ public class PAttributeInstance extends CDialog new ColumnInfo(Msg.translate(Env.getCtx(), "ShelfLifeRemainingPct"), "CASE WHEN p.GuaranteeDays > 0 THEN TRUNC(((daysbetween(asi.GuaranteeDate, SYSDATE))/p.GuaranteeDays)*100) ELSE 0 END", Integer.class), }; /** From Clause */ - private static String s_sqlFrom = "M_Storage s" + private static String s_sqlFrom = "M_StorageOnHand s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)" + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)"; diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocator.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocator.java index 16a1055739..67ee41bc05 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocator.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocator.java @@ -456,7 +456,7 @@ public class VLocator extends JComponent sql.append(" AND (IsDefault='Y' ") // Default Locator .append("OR EXISTS (SELECT * FROM M_Product p ") // Product Locator .append("WHERE p.M_Locator_ID=M_Locator.M_Locator_ID AND p.M_Product_ID=?)") - .append("OR EXISTS (SELECT * FROM M_Storage s ") // Storage Locator + .append("OR EXISTS (SELECT * FROM M_StorageOnHand s ") // Storage Locator .append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))"); String finalSql = MRole.getDefault(Env.getCtx(), false).addAccessSQL( sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java index 31f72186eb..f19624bc23 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java @@ -349,7 +349,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro sql.append(" AND (IsDefault='Y' ") // Default Locator .append("OR EXISTS (SELECT * FROM M_Product p ") // Product Locator .append("WHERE p.M_Locator_ID=M_Locator.M_Locator_ID AND p.M_Product_ID=?)") - .append("OR EXISTS (SELECT * FROM M_Storage s ") // Storage Locator + .append("OR EXISTS (SELECT * FROM M_StorageOnHand s ") // Storage Locator .append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))"); String finalSql = MRole.getDefault(Env.getCtx(), false).addAccessSQL( diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPAttributeInstancePanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPAttributeInstancePanel.java index f5e390fb67..23a17c2722 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPAttributeInstancePanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPAttributeInstancePanel.java @@ -166,7 +166,7 @@ public class InfoPAttributeInstancePanel extends Window implements EventListener new ColumnInfo(Msg.translate(Env.getCtx(), "ShelfLifeRemainingPct"), "CASE WHEN p.GuaranteeDays > 0 THEN TRUNC(((daysbetween(asi.GuaranteeDate, SYSDATE))/p.GuaranteeDays)*100) ELSE 0 END", Integer.class), }; /** From Clause */ - private static String s_sqlFrom = "M_Storage s" + private static String s_sqlFrom = "M_StorageOnHand s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)" + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPAttributePanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPAttributePanel.java index 4e17950667..454f7c673d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPAttributePanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPAttributePanel.java @@ -614,7 +614,7 @@ public class InfoPAttributePanel extends Window implements EventListener // finish Instance Attributes if (sb.length() > 0) { - sb.insert(0, " AND EXISTS (SELECT * FROM M_Storage s" + sb.insert(0, " AND EXISTS (SELECT * FROM M_StorageOnHand s" + " INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) " + "WHERE s.M_Product_ID=p.M_Product_ID"); sb.append(")"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java index e88b7150a2..07f1e31d26 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java @@ -1453,7 +1453,7 @@ public class InfoProductPanel extends InfoPanel implements EventListener sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," + " productAttribute(s.M_AttributeSetInstance_ID), 0,"; sql += " w.Name, l.Value " - + "FROM M_Storage s" + + "FROM M_StorageOnHand s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) " + "WHERE M_Product_ID=?"; 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 5e2b7c1ec8..60e0b658cc 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 @@ -599,7 +599,7 @@ public class InvoiceHistory extends Window implements EventListener sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," + " productAttribute(s.M_AttributeSetInstance_ID), 0,"; sql += " w.Name, l.Value " - + "FROM M_Storage s" + + "FROM M_StorageOnHand s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) " + "WHERE M_Product_ID=?"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeInstance.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeInstance.java index db3650136d..30fdf38d95 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeInstance.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeInstance.java @@ -173,7 +173,7 @@ public class WPAttributeInstance extends Window implements EventListener new ColumnInfo(Msg.translate(Env.getCtx(), "ShelfLifeRemainingPct"), "CASE WHEN p.GuaranteeDays > 0 THEN TRUNC(((daysbetween(asi.GuaranteeDate, SYSDATE))/p.GuaranteeDays)*100) ELSE 0 END", Integer.class), }; /** From Clause */ - private static String s_sqlFrom = "M_Storage s" + private static String s_sqlFrom = "M_StorageOnHand s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)" + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)";