modify code related with M_Storage

This commit is contained in:
Edwin Ang 2012-10-29 15:14:45 +07:00
parent 0731626ca0
commit 31ee8bc837
30 changed files with 79 additions and 69 deletions

View File

@ -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 { private BigDecimal setQtyBook (int M_AttributeSetInstance_ID, int M_Product_ID, int M_Locator_ID) throws Exception {
// Set QtyBook from first storage location // Set QtyBook from first storage location
BigDecimal bd = null; BigDecimal bd = null;
String sql = "SELECT QtyOnHand FROM M_Storage " String sql = "SELECT QtyOnHand FROM M_StorageOnHand "
+ "WHERE M_Product_ID=?" // 1 + "WHERE M_Product_ID=?" // 1
+ " AND M_Locator_ID=?" // 2 + " AND M_Locator_ID=?" // 2
+ " AND M_AttributeSetInstance_ID=?"; + " AND M_AttributeSetInstance_ID=?";
if (M_AttributeSetInstance_ID == 0) if (M_AttributeSetInstance_ID == 0)
sql = "SELECT SUM(QtyOnHand) FROM M_Storage " sql = "SELECT SUM(QtyOnHand) FROM M_StorageOnHand "
+ "WHERE M_Product_ID=?" // 1 + "WHERE M_Product_ID=?" // 1
+ " AND M_Locator_ID=?"; // 2 + " AND M_Locator_ID=?"; // 2

View File

@ -20,6 +20,7 @@ package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Properties; import java.util.Properties;
import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
/** /**
@ -117,11 +118,15 @@ public class CalloutMovement extends CalloutEngine
if (MovementQty == null) if (MovementQty == null)
MovementQty = (BigDecimal) mTab.getValue("MovementQty"); MovementQty = (BigDecimal) mTab.getValue("MovementQty");
int M_Locator_ID = Env.getContextAsInt(ctx, WindowNo, "M_Locator_ID"); int M_Locator_ID = Env.getContextAsInt(ctx, WindowNo, "M_Locator_ID");
// If no locator, don't check anything and assume is ok // If no locator, don't check anything and assume is ok
if (M_Locator_ID <= 0) if (M_Locator_ID <= 0)
return; 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"); 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) if (available == null)
available = Env.ZERO; available = Env.ZERO;
if (available.signum() == 0) if (available.signum() == 0)

View File

@ -135,13 +135,13 @@ public class InventoryCountCreate extends SvrProcess
// Create Null Storage records // Create Null Storage records
if (p_QtyRange != null && p_QtyRange.equals("=")) 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("(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,");
sql.append(" M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID,"); 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("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(" 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("FROM M_Locator l");
sql.append(" INNER JOIN M_Product p ON (l.AD_Client_ID=p.AD_Client_ID) "); sql.append(" INNER JOIN M_Product p ON (l.AD_Client_ID=p.AD_Client_ID) ");
sql.append("WHERE l.M_Warehouse_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.M_Locator_ID=").append(p_M_Locator_ID);
sql.append(" AND l.IsDefault='Y'") sql.append(" AND l.IsDefault='Y'")
.append(" AND p.IsActive='Y' AND p.IsStocked='Y' and p.ProductType='I'") .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(" 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("WHERE sl.M_Warehouse_ID=l.M_Warehouse_ID")
.append(" AND s.M_Product_ID=p.M_Product_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,"); 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(" s.QtyOnHand, p.M_AttributeSet_ID ");
sql.append("FROM M_Product p"); 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(" INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID) ");
sql.append("WHERE l.M_Warehouse_ID=?"); sql.append("WHERE l.M_Warehouse_ID=?");
sql.append(" AND p.IsActive='Y' AND p.IsStocked='Y' and p.ProductType='I'"); sql.append(" AND p.IsActive='Y' AND p.IsStocked='Y' and p.ProductType='I'");

View File

@ -92,14 +92,14 @@ public class InventoryCountUpdate extends SvrProcess
// ASI // ASI
sql = new StringBuilder("UPDATE M_InventoryLine l ") sql = new StringBuilder("UPDATE M_InventoryLine l ")
.append("SET (QtyBook,QtyCount) = ") .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("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(" AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),")
.append(" Updated=SysDate,") .append(" Updated=SysDate,")
.append(" UpdatedBy=").append(getAD_User_ID()) .append(" UpdatedBy=").append(getAD_User_ID())
// //
.append(" WHERE M_Inventory_ID=").append(p_M_Inventory_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("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(" AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID)");
int no = DB.executeUpdate(sql.toString(), get_TrxName()); int no = DB.executeUpdate(sql.toString(), get_TrxName());

View File

@ -175,7 +175,7 @@ public class InventoryValue extends SvrProcess
// Get current QtyOnHand with ASI // Get current QtyOnHand with ASI
sql = new StringBuilder ("UPDATE T_InventoryValue iv SET QtyOnHand = ") 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(" 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("WHERE iv.M_Product_ID=s.M_Product_ID")
.append(" AND iv.M_Warehouse_ID=l.M_Warehouse_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); log.fine("QtHand with ASI=" + no);
// Get current QtyOnHand without ASI // Get current QtyOnHand without ASI
sql = new StringBuilder ("UPDATE T_InventoryValue iv SET QtyOnHand = ") 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(" 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("WHERE iv.M_Product_ID=s.M_Product_ID")
.append(" AND iv.M_Warehouse_ID=l.M_Warehouse_ID) ") .append(" AND iv.M_Warehouse_ID=l.M_Warehouse_ID) ")

View File

@ -143,7 +143,6 @@ public class M_Production_Run extends SvrProcess {
{ {
BigDecimal QtyAvailable = MStorageReservation.getQtyAvailable( BigDecimal QtyAvailable = MStorageReservation.getQtyAvailable(
locator.getM_Warehouse_ID(), locator.getM_Warehouse_ID(),
locator.getM_Locator_ID(),
pline.getM_Product_ID(), pline.getM_Product_ID(),
pline.getM_AttributeSetInstance_ID(), pline.getM_AttributeSetInstance_ID(),
get_TrxName()); get_TrxName());

View File

@ -140,7 +140,7 @@ public class OrgOwnership extends SvrProcess
// Set Storage // Set Storage
sql = new StringBuilder(); 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("SET AD_Org_ID=").append(p_AD_Org_ID)
.append(" WHERE EXISTS ") .append(" WHERE EXISTS ")
.append("(SELECT * FROM M_Locator l WHERE l.M_Locator_ID=s.M_Locator_ID") .append("(SELECT * FROM M_Locator l WHERE l.M_Locator_ID=s.M_Locator_ID")

View File

@ -249,12 +249,12 @@ public class ReplenishReport extends SvrProcess
log.fine("Insert (BP) #" + no); log.fine("Insert (BP) #" + no);
} }
sql = new StringBuilder("UPDATE T_Replenish t SET "); 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(" 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("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_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID),"); sql.append(" 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("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_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID)"); sql.append(" AND l.M_Warehouse_ID=t.M_Warehouse_ID)");
if (p_C_DocType_ID != 0) if (p_C_DocType_ID != 0)
sql.append(", C_DocType_ID=").append(p_C_DocType_ID); sql.append(", C_DocType_ID=").append(p_C_DocType_ID);
sql.append(" WHERE AD_PInstance_ID=").append(getAD_PInstance_ID()); sql.append(" WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());

View File

@ -271,10 +271,10 @@ public class ReplenishReportProduction extends SvrProcess
sql = new StringBuilder("UPDATE T_Replenish t SET "); 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_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(" 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("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_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID),"); sql.append(" 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("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_Locator_ID=s.M_Locator_ID AND l.M_Warehouse_ID=t.M_Warehouse_ID)"); sql.append(" AND l.M_Warehouse_ID=t.M_Warehouse_ID)");
if (p_C_DocType_ID != 0) if (p_C_DocType_ID != 0)
sql.append(", C_DocType_ID=").append(p_C_DocType_ID); sql.append(", C_DocType_ID=").append(p_C_DocType_ID);
sql.append(" WHERE AD_PInstance_ID=").append(getAD_PInstance_ID()); sql.append(" WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());

View File

@ -68,7 +68,7 @@ public class StorageCleanup extends SvrProcess
{ {
log.info(""); log.info("");
// Clean up empty Storage // 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" + "WHERE QtyOnHand = 0 AND QtyReserved = 0 AND QtyOrdered = 0"
+ " AND Created < SysDate-3"; + " AND Created < SysDate-3";
int no = DB.executeUpdate(sql, get_TrxName()); int no = DB.executeUpdate(sql, get_TrxName());
@ -76,7 +76,7 @@ public class StorageCleanup extends SvrProcess
// //
sql = "SELECT * " sql = "SELECT * "
+ "FROM M_Storage s " + "FROM M_StorageOnHand s "
+ "WHERE AD_Client_ID = ?" + "WHERE AD_Client_ID = ?"
+ " AND QtyOnHand < 0" + " AND QtyOnHand < 0"
// Instance Attribute // Instance Attribute
@ -89,7 +89,7 @@ public class StorageCleanup extends SvrProcess
// + " AND s.M_Product_ID=sl.M_Product_ID" // + " AND s.M_Product_ID=sl.M_Product_ID"
// + " AND s.M_Locator_ID=sl.M_Locator_ID)" // + " AND s.M_Locator_ID=sl.M_Locator_ID)"
// Stock in same Warehouse // 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 " + " INNER JOIN M_Locator swl ON (sw.M_Locator_ID=swl.M_Locator_ID), M_Locator sl "
+ "WHERE sw.QtyOnHand > 0" + "WHERE sw.QtyOnHand > 0"
+ " AND s.M_Product_ID=sw.M_Product_ID" + " AND s.M_Product_ID=sw.M_Product_ID"
@ -250,7 +250,7 @@ public class StorageCleanup extends SvrProcess
{ {
ArrayList<MStorageOnHand> list = new ArrayList<MStorageOnHand>(); ArrayList<MStorageOnHand> list = new ArrayList<MStorageOnHand>();
String sql = "SELECT * " String sql = "SELECT * "
+ "FROM M_Storage s " + "FROM M_StorageOnHand s "
+ "WHERE QtyOnHand > 0" + "WHERE QtyOnHand > 0"
+ " AND M_Product_ID=?" + " AND M_Product_ID=?"
// Empty ASI // Empty ASI

View File

@ -188,9 +188,9 @@ public class AccessSqlParserTest extends TestCase
*/ */
public void testProductInstanceAttributeQuery() 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)<TO_DATE('2003-10-16','YYYY-MM-DD') AND asi.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=103 AND Value LIKE '33') AND (M_Attribute_ID=102 AND M_AttributeValue_ID=106))) AND p.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=101 AND M_AttributeValue_ID=105) AND (M_Attribute_ID=100 AND M_AttributeValue_ID=102)) AND p.AD_Client_ID IN(0,11) AND p.AD_Org_ID IN(0,11,12) ORDER BY QtyAvailable DESC, Margin DESC"; 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_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 AND asi.SerNo LIKE '33' AND asi.Lot LIKE '33' AND asi.M_Lot_ID=101 AND TRUNC(asi.GuaranteeDate)<TO_DATE('2003-10-16','YYYY-MM-DD') AND asi.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=103 AND Value LIKE '33') AND (M_Attribute_ID=102 AND M_AttributeValue_ID=106))) AND p.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=101 AND M_AttributeValue_ID=105) AND (M_Attribute_ID=100 AND M_AttributeValue_ID=102)) AND p.AD_Client_ID IN(0,11) AND p.AD_Org_ID IN(0,11,12) ORDER BY QtyAvailable DESC, Margin DESC";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[M_AttributeInstance|M_Storage=s,M_AttributeSetInstance=asi|M_AttributeInstance|M_Product=p,M_ProductPrice=pr,M_AttributeSet=pa|3]", fixture.toString()); assertEquals("AccessSqlParser[M_AttributeInstance|M_StorageOnHand=s,M_AttributeSetInstance=asi|M_AttributeInstance|M_Product=p,M_ProductPrice=pr,M_AttributeSet=pa|3]", fixture.toString());
} }
/** /**

View File

@ -1002,7 +1002,7 @@ public class MCostDetail extends X_M_CostDetail
* Solution: * Solution:
* Make sure the current qty is reflecting the actual qty in storage * Make sure the current qty is reflecting the actual qty in storage
*/ */
StringBuilder sql = new StringBuilder("SELECT COALESCE(SUM(QtyOnHand),0) FROM M_Storage") StringBuilder sql = new StringBuilder("SELECT COALESCE(SUM(QtyOnHand),0) FROM M_StorageOnHand")
.append(" WHERE AD_Client_ID=").append(cost.getAD_Client_ID()) .append(" WHERE AD_Client_ID=").append(cost.getAD_Client_ID())
.append(" AND M_Product_ID=").append(cost.getM_Product_ID()); .append(" AND M_Product_ID=").append(cost.getM_Product_ID());
//Costing Level //Costing Level
@ -1159,7 +1159,7 @@ public class MCostDetail extends X_M_CostDetail
MCostElement[] lce = MCostElement.getNonCostingMethods(this); MCostElement[] lce = MCostElement.getNonCostingMethods(this);
if (lce.length > 0) if (lce.length > 0)
{ {
StringBuilder sql = new StringBuilder("SELECT COALESCE(SUM(QtyOnHand),0) FROM M_Storage") StringBuilder sql = new StringBuilder("SELECT COALESCE(SUM(QtyOnHand),0) FROM M_StorageOnHand")
.append(" WHERE AD_Client_ID=").append(cost.getAD_Client_ID()) .append(" WHERE AD_Client_ID=").append(cost.getAD_Client_ID())
.append(" AND M_Product_ID=").append(cost.getM_Product_ID()); .append(" AND M_Product_ID=").append(cost.getM_Product_ID());
//Costing Level //Costing Level

View File

@ -332,7 +332,7 @@ public final class MLocatorLookup extends Lookup implements Serializable
sql.append(" AND (IsDefault='Y' ") // Default Locator sql.append(" AND (IsDefault='Y' ") // Default Locator
.append("OR EXISTS (SELECT * FROM M_Product p ") // Product 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("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=?))"); .append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))");
sql.append(" ORDER BY "); sql.append(" ORDER BY ");
if (local_only_warehouse_id == 0) if (local_only_warehouse_id == 0)

View File

@ -580,8 +580,7 @@ public class MProduct extends X_M_Product
for (int i = 0; i < onHandStorages.length; i++) for (int i = 0; i < onHandStorages.length; i++)
{ {
OnHand = OnHand.add(onHandStorages[i].getQtyOnHand()); OnHand = OnHand.add(onHandStorages[i].getQtyOnHand());
//Ordered = Ordered.add(storages[i].getQtyOrdered());
//Reserved = Reserved.add(storages[i].getQtyReserved());
} }
for (int i = 0; i < reservationStorages.length; i++) for (int i = 0; i < reservationStorages.length; i++)
{ {
@ -720,26 +719,23 @@ public class MProduct extends X_M_Product
// Check Storage // Check Storage
if (isStocked() || PRODUCTTYPE_Item.equals(getProductType())) if (isStocked() || PRODUCTTYPE_Item.equals(getProductType()))
{ {
// large modified related to storages by zuhri
MStorageOnHand[] onHandStorages = MStorageOnHand.getOfProduct(getCtx(), get_ID(), get_TrxName()); MStorageOnHand[] onHandStorages = MStorageOnHand.getOfProduct(getCtx(), get_ID(), get_TrxName());
MStorageReservation[] reservationStorages = MStorageReservation.getOfProduct(getCtx(), get_ID(), get_TrxName()); MStorageReservation[] reserves = MStorageReservation.getOfProduct(getCtx(), get_ID(), get_TrxName());
BigDecimal OnHand = Env.ZERO; BigDecimal OnHand = Env.ZERO;
BigDecimal Ordered = Env.ZERO; BigDecimal Ordered = Env.ZERO;
BigDecimal Reserved = Env.ZERO; BigDecimal Reserved = Env.ZERO;
for (int i = 0; i < onHandStorages.length; i++) for (int i = 0; i < onHandStorages.length; i++)
{ {
OnHand = OnHand.add(onHandStorages[i].getQtyOnHand()); OnHand = OnHand.add(onHandStorages[i].getQtyOnHand());
//Ordered = Ordered.add(storages[i].getQtyOrdered());
//Reserved = Reserved.add(storages[i].getQtyReserved());
} }
for (int i = 0; i < reservationStorages.length; i++)
{ for (int i = 0; i < reserves.length; i++)
if(reservationStorages[i].isSOTrx()) {
Reserved = Reserved.add(reservationStorages[i].getQty()); Ordered = OnHand.add(reserves[i].getQtyOrdered());
else Reserved = OnHand.add(reserves[i].getQtyReserved());
Ordered = Ordered.add(reservationStorages[i].getQty());
} }
// end large modified related to storages by zuhri
String errMsg = ""; String errMsg = "";
if (OnHand.signum() != 0) if (OnHand.signum() != 0)
errMsg = "@QtyOnHand@ = " + OnHand; errMsg = "@QtyOnHand@ = " + OnHand;

View File

@ -105,6 +105,13 @@ public class MStorageReservation extends X_M_StorageReservation {
return qty; return qty;
} }
public static BigDecimal getQtyOrdered (int M_Warehouse_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, String trxName)
{
BigDecimal retValue = null;
return retValue;
}
/** /**
* Get Available Qty. * Get Available Qty.
* The call is accurate only if there is a storage record * The call is accurate only if there is a storage record
@ -123,5 +130,15 @@ public class MStorageReservation extends X_M_StorageReservation {
BigDecimal retValue = qtyOnHand.subtract(qtyReserved); BigDecimal retValue = qtyOnHand.subtract(qtyReserved);
return retValue; return retValue;
} }
public BigDecimal getQtyOrdered() {
// TODO Auto-generated method stub
return null;
}
public BigDecimal getQtyReserved() {
// TODO Auto-generated method stub
return null;
}
} }

View File

@ -213,7 +213,7 @@ public class MWarehouse extends X_M_Warehouse
with negative onhand. */ with negative onhand. */
if (is_ValueChanged("IsDisallowNegativeInv") && isDisallowNegativeInv()) if (is_ValueChanged("IsDisallowNegativeInv") && isDisallowNegativeInv())
{ {
String sql = "SELECT M_Product_ID FROM M_Storage s "+ String sql = "SELECT M_Product_ID FROM M_StorageOnHand s "+
"WHERE s.M_Locator_ID IN (SELECT M_Locator_ID FROM M_Locator l " + "WHERE s.M_Locator_ID IN (SELECT M_Locator_ID FROM M_Locator l " +
"WHERE M_Warehouse_ID=? )" + "WHERE M_Warehouse_ID=? )" +
" GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID " + " GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID " +

View File

@ -49,14 +49,14 @@ public class MStorageTest extends AdempiereTestCase
s1.setQtyOnHand(targetQty); s1.setQtyOnHand(targetQty);
s1.saveEx(); s1.saveEx();
// //
BigDecimal qty = MStorageReservation.getQtyAvailable(wh.get_ID(), loc.get_ID(), product_id, 0, getTrxName()).setScale(12, BigDecimal.ROUND_HALF_UP); BigDecimal qty = MStorageReservation.getQtyAvailable(wh.get_ID(), product_id, 0, getTrxName()).setScale(12, BigDecimal.ROUND_HALF_UP);
assertEquals("Error on locator "+locatorValue, targetQty, qty); assertEquals("Error on locator "+locatorValue, targetQty, qty);
// //
return loc; return loc;
} }
private void assertWarehouseQty(MWarehouse wh, BigDecimal targetQty) private void assertWarehouseQty(MWarehouse wh, BigDecimal targetQty)
{ {
BigDecimal qty = MStorageReservation.getQtyAvailable(wh.get_ID(), 0, product_id, 0, getTrxName()); BigDecimal qty = MStorageReservation.getQtyAvailable(wh.get_ID(), product_id, 0, getTrxName());
qty = qty.setScale(12, BigDecimal.ROUND_HALF_UP); qty = qty.setScale(12, BigDecimal.ROUND_HALF_UP);
targetQty = targetQty.setScale(12, BigDecimal.ROUND_HALF_UP); targetQty = targetQty.setScale(12, BigDecimal.ROUND_HALF_UP);
assertEquals(targetQty, qty); assertEquals(targetQty, qty);

View File

@ -185,9 +185,7 @@ public class InventoryTest extends AdempiereTestCase
ArrayList<Object> params = new ArrayList<Object>(); ArrayList<Object> params = new ArrayList<Object>();
String sql = "SELECT" String sql = "SELECT"
+" COALESCE(SUM(QtyOnHand),0)" +" COALESCE(SUM(QtyOnHand),0)"
+",COALESCE(SUM(QtyReserved),0)" +" FROM M_StorageOnHand"
+",COALESCE(SUM(QtyOrdered),0)"
+" FROM M_Storage"
+" WHERE M_Locator_ID=? AND M_Product_ID=?"; +" WHERE M_Locator_ID=? AND M_Product_ID=?";
params.add(locator.get_ID()); params.add(locator.get_ID());
params.add(product.get_ID()); params.add(product.get_ID());
@ -199,8 +197,6 @@ public class InventoryTest extends AdempiereTestCase
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
BigDecimal qtyOnHand = Env.ZERO; BigDecimal qtyOnHand = Env.ZERO;
BigDecimal qtyOrdered = Env.ZERO;
BigDecimal qtyReserved = Env.ZERO;
try try
{ {
pstmt = DB.prepareStatement(sql, trxName); pstmt = DB.prepareStatement(sql, trxName);
@ -209,8 +205,6 @@ public class InventoryTest extends AdempiereTestCase
if (rs.next()) if (rs.next())
{ {
qtyOnHand = rs.getBigDecimal(1); qtyOnHand = rs.getBigDecimal(1);
qtyReserved = rs.getBigDecimal(2);
qtyOrdered = rs.getBigDecimal(3);
} }
} }
catch (SQLException e) catch (SQLException e)
@ -225,8 +219,7 @@ public class InventoryTest extends AdempiereTestCase
// //
// //
assertEquals("QtyOnHand not match "+doc, doc.Qty, qtyOnHand); 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) private void dumpStatus(MMDocument doc, String trxName)

View File

@ -519,7 +519,7 @@ public class VAttributeGrid extends CPanel
formatted = ""; formatted = "";
if (m_M_Warehouse_ID != 0) 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) if (qty == null)
formatted = "-"; formatted = "-";
else else

View File

@ -512,7 +512,7 @@ public class InfoPAttribute extends CDialog
// finish Instance Attributes // finish Instance Attributes
if (sb.length() > 0) 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) " + " INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) "
+ "WHERE s.M_Product_ID=p.M_Product_ID"); + "WHERE s.M_Product_ID=p.M_Product_ID");
sb.append(")"); sb.append(")");

View File

@ -1246,7 +1246,7 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered),"
+ " productAttribute(s.M_AttributeSetInstance_ID), 0,"; + " productAttribute(s.M_AttributeSetInstance_ID), 0,";
sql += " w.Name, l.Value " 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_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) " + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) "
+ "WHERE M_Product_ID=?"; + "WHERE M_Product_ID=?";

View File

@ -566,7 +566,7 @@ public class InvoiceHistory extends CDialog
sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered),"
+ " productAttribute(s.M_AttributeSetInstance_ID), 0,"; + " productAttribute(s.M_AttributeSetInstance_ID), 0,";
sql += " w.Name, l.Value " 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_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) " + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) "
+ "WHERE M_Product_ID=?"; + "WHERE M_Product_ID=?";

View File

@ -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), 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 */ /** 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_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)" + " 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)"; + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)";

View File

@ -456,7 +456,7 @@ public class VLocator extends JComponent
sql.append(" AND (IsDefault='Y' ") // Default Locator sql.append(" AND (IsDefault='Y' ") // Default Locator
.append("OR EXISTS (SELECT * FROM M_Product p ") // Product 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("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=?))"); .append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))");
String finalSql = MRole.getDefault(Env.getCtx(), false).addAccessSQL( String finalSql = MRole.getDefault(Env.getCtx(), false).addAccessSQL(
sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);

View File

@ -349,7 +349,7 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
sql.append(" AND (IsDefault='Y' ") // Default Locator sql.append(" AND (IsDefault='Y' ") // Default Locator
.append("OR EXISTS (SELECT * FROM M_Product p ") // Product 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("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=?))"); .append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))");
String finalSql = MRole.getDefault(Env.getCtx(), false).addAccessSQL( String finalSql = MRole.getDefault(Env.getCtx(), false).addAccessSQL(

View File

@ -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), 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 */ /** 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_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)" + " 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)"; + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)";

View File

@ -614,7 +614,7 @@ public class InfoPAttributePanel extends Window implements EventListener
// finish Instance Attributes // finish Instance Attributes
if (sb.length() > 0) 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) " + " INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) "
+ "WHERE s.M_Product_ID=p.M_Product_ID"); + "WHERE s.M_Product_ID=p.M_Product_ID");
sb.append(")"); sb.append(")");

View File

@ -1453,7 +1453,7 @@ public class InfoProductPanel extends InfoPanel implements EventListener
sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered),"
+ " productAttribute(s.M_AttributeSetInstance_ID), 0,"; + " productAttribute(s.M_AttributeSetInstance_ID), 0,";
sql += " w.Name, l.Value " 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_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) " + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) "
+ "WHERE M_Product_ID=?"; + "WHERE M_Product_ID=?";

View File

@ -599,7 +599,7 @@ public class InvoiceHistory extends Window implements EventListener
sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered),"
+ " productAttribute(s.M_AttributeSetInstance_ID), 0,"; + " productAttribute(s.M_AttributeSetInstance_ID), 0,";
sql += " w.Name, l.Value " 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_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) " + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) "
+ "WHERE M_Product_ID=?"; + "WHERE M_Product_ID=?";

View File

@ -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), 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 */ /** 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_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)" + " 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)"; + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)";