BF [2987605] - Attribute Set Instance dialog: select existing ASI

https://sourceforge.net/tracker/?func=detail&aid=2987605&group_id=176962&atid=879332
This commit is contained in:
trifonnt 2010-04-15 09:15:53 +00:00
parent eb2dd63503
commit 0d4f86628e
2 changed files with 39 additions and 32 deletions

View File

@ -74,7 +74,7 @@ public class PAttributeInstance extends CDialog
super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true); super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true);
init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID); init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID);
AEnv.showCenterWindow(parent, this); AEnv.showCenterWindow(parent, this);
} // PAttributeInstance }
/** /**
* Constructor * Constructor
@ -91,7 +91,7 @@ public class PAttributeInstance extends CDialog
super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true); super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true);
init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID); init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID);
AEnv.showCenterWindow(parent, this); AEnv.showCenterWindow(parent, this);
} // PAttributeInstance }
/** /**
* Initialization * Initialization
@ -117,7 +117,7 @@ public class PAttributeInstance extends CDialog
{ {
log.log(Level.SEVERE, "", e); log.log(Level.SEVERE, "", e);
} }
} // init }
private CPanel mainPanel = new CPanel(); private CPanel mainPanel = new CPanel();
private BorderLayout mainLayout = new BorderLayout(); private BorderLayout mainLayout = new BorderLayout();
@ -158,17 +158,19 @@ public class PAttributeInstance extends CDialog
// South // South
mainPanel.add(confirmPanel, BorderLayout.SOUTH); mainPanel.add(confirmPanel, BorderLayout.SOUTH);
confirmPanel.addActionListener(this); confirmPanel.addActionListener(this);
} // jbInit }
/** Table Column Layout Info */ /** Table Column Layout Info */
private static ColumnInfo[] s_layout = new ColumnInfo[] private static ColumnInfo[] s_layout = new ColumnInfo[]
{ {
new ColumnInfo(" ", "s.M_AttributeSetInstance_ID", IDColumn.class), new ColumnInfo(" ", "asi.M_AttributeSetInstance_ID", IDColumn.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "asi.Description", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "asi.Description", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Lot"), "asi.Lot", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Lot"), "asi.Lot", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "SerNo"), "asi.SerNo", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "SerNo"), "asi.SerNo", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "GuaranteeDate"), "asi.GuaranteeDate", Timestamp.class), new ColumnInfo(Msg.translate(Env.getCtx(), "GuaranteeDate"), "asi.GuaranteeDate", Timestamp.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "M_Locator_ID"), "l.Value", KeyNamePair.class, "s.M_Locator_ID"), new ColumnInfo(Msg.translate(Env.getCtx(), "M_Locator_ID"), "l.Value", KeyNamePair.class, "s.M_Locator_ID"),
// new ColumnInfo(Msg.translate(Env.getCtx(), "M_Product_ID"), "p.Value", KeyNamePair.class, "p.M_Product_ID"), // @Trifon - Not sure if this need to be shown
// new ColumnInfo(Msg.translate(Env.getCtx(), "M_AttributeSet_ID"), "st.Name", KeyNamePair.class, "st.M_AttributeSet_ID"), // @Trifon - Not sure if this need to be shown
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "s.QtyOnHand", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "s.QtyOnHand", Double.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "s.QtyReserved", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "s.QtyReserved", Double.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "s.QtyOrdered", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "s.QtyOrdered", Double.class),
@ -178,13 +180,16 @@ 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_AttributeSetInstance asi"
+ " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_AttributeSet st ON (st.M_AttributeSet_ID=asi.M_AttributeSet_ID )"
+ " INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)" + " LEFT OUTER JOIN M_Storage s ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)"
+ " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)"; + " LEFT OUTER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)"
/** Where Clause */ + " LEFT OUTER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)"
private static String s_sqlWhere = "s.M_Product_ID=? AND l.M_Warehouse_ID=?"; + " LEFT OUTER JOIN M_Product pr ON (asi.M_AttributeSet_ID = pr.M_AttributeSet_ID)"
private static String s_sqlWhereWithoutWarehouse = " s.M_Product_ID=?"; ;
/** Where Clause */
private static String s_sqlWhereWithoutWarehouse = " (pr.M_Product_ID=? OR p.M_Product_ID=?)";
private static String s_sqlWhereSameWarehouse = " AND (l.M_Warehouse_ID=? OR 0=?)";
private String m_sqlNonZero = " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)"; private String m_sqlNonZero = " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)";
private String m_sqlMinLife = ""; private String m_sqlMinLife = "";
@ -242,8 +247,7 @@ public class PAttributeInstance extends CDialog
} }
} // BPartner != 0 } // BPartner != 0
m_sql = m_table.prepareTable (s_layout, s_sqlFrom, m_sql = m_table.prepareTable (s_layout, s_sqlFrom, s_sqlWhereWithoutWarehouse, false, "asi")
m_M_Warehouse_ID == 0 ? s_sqlWhereWithoutWarehouse : s_sqlWhere, false, "s")
+ " ORDER BY asi.GuaranteeDate, s.QtyOnHand"; // oldest, smallest first + " ORDER BY asi.GuaranteeDate, s.QtyOnHand"; // oldest, smallest first
// //
m_table.setRowSelectionAllowed(true); m_table.setRowSelectionAllowed(true);
@ -252,7 +256,7 @@ public class PAttributeInstance extends CDialog
m_table.getSelectionModel().addListSelectionListener(this); m_table.getSelectionModel().addListSelectionListener(this);
// //
refresh(); refresh();
} // dynInit }
/** /**
* Refresh Query * Refresh Query
@ -264,7 +268,7 @@ public class PAttributeInstance extends CDialog
if (!showAll.isSelected()) if (!showAll.isSelected())
{ {
sql = m_sql.substring(0, pos) sql = m_sql.substring(0, pos)
+ m_sqlNonZero; + m_sqlNonZero + s_sqlWhereSameWarehouse;
if (m_sqlMinLife.length() > 0) if (m_sqlMinLife.length() > 0)
sql += m_sqlMinLife; sql += m_sqlMinLife;
sql += m_sql.substring(pos); sql += m_sql.substring(pos);
@ -277,8 +281,12 @@ public class PAttributeInstance extends CDialog
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(1, m_M_Product_ID);
if (m_M_Warehouse_ID != 0) pstmt.setInt(2, m_M_Product_ID);
pstmt.setInt(2, m_M_Warehouse_ID); if ( !showAll.isSelected() ) {
pstmt.setInt(3, m_M_Warehouse_ID);
pstmt.setInt(4, m_M_Warehouse_ID);
}
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
m_table.loadTable(rs); m_table.loadTable(rs);
} }
@ -291,7 +299,7 @@ public class PAttributeInstance extends CDialog
rs = null; pstmt = null; rs = null; pstmt = null;
} }
enableButtons(); enableButtons();
} // refresh }
/** /**
* Action Listener * Action Listener
@ -311,7 +319,7 @@ public class PAttributeInstance extends CDialog
{ {
refresh(); refresh();
} }
} // actionPerformed }
/** /**
* Table selection changed * Table selection changed
@ -322,7 +330,7 @@ public class PAttributeInstance extends CDialog
if (e.getValueIsAdjusting()) if (e.getValueIsAdjusting())
return; return;
enableButtons(); enableButtons();
} // valueChanged }
/** /**
* Enable/Set Buttons and set ID * Enable/Set Buttons and set ID
@ -354,7 +362,7 @@ public class PAttributeInstance extends CDialog
log.fine("M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID log.fine("M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID
+ " - " + m_M_AttributeSetInstanceName + " - " + m_M_AttributeSetInstanceName
+ "; M_Locator_ID=" + m_M_Locator_ID); + "; M_Locator_ID=" + m_M_Locator_ID);
} // enableButtons }
/** /**
* Mouse Clicked * Mouse Clicked
@ -368,7 +376,7 @@ public class PAttributeInstance extends CDialog
enableButtons(); enableButtons();
dispose(); dispose();
} }
} // mouseClicked }
/** /**
@ -378,7 +386,7 @@ public class PAttributeInstance extends CDialog
public int getM_AttributeSetInstance_ID() public int getM_AttributeSetInstance_ID()
{ {
return m_M_AttributeSetInstance_ID; return m_M_AttributeSetInstance_ID;
} // getM_AttributeSetInstance_ID }
/** /**
* Get Instance Name * Get Instance Name
@ -387,7 +395,7 @@ public class PAttributeInstance extends CDialog
public String getM_AttributeSetInstanceName() public String getM_AttributeSetInstanceName()
{ {
return m_M_AttributeSetInstanceName; return m_M_AttributeSetInstanceName;
} // getM_AttributeSetInstanceName }
/** /**
* Get Locator * Get Locator
@ -396,6 +404,6 @@ public class PAttributeInstance extends CDialog
public int getM_Locator_ID() public int getM_Locator_ID()
{ {
return m_M_Locator_ID; return m_M_Locator_ID;
} // getM_Locator_ID }
} // PAttributeInstance }

View File

@ -400,7 +400,7 @@ public class VPAttributeDialog extends CDialog
cmd_newEdit(); cmd_newEdit();
} }
// Attrribute Set Instance Description // Attribute Set Instance Description
CLabel label = new CLabel (Msg.translate(Env.getCtx(), "Description")); CLabel label = new CLabel (Msg.translate(Env.getCtx(), "Description"));
label.setLabelFor(fieldDescription); label.setLabelFor(fieldDescription);
fieldDescription.setText(m_masi.getDescription()); fieldDescription.setText(m_masi.getDescription());
@ -599,10 +599,9 @@ public class VPAttributeDialog extends CDialog
} }
// teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes // teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes
// Trifon - Always read Locator from Context. There are too many windows to read explicitly one by one.
int M_Locator_ID = 0; int M_Locator_ID = 0;
if (m_AD_Column_ID == 8551) { // TODO: hardcoded: M_MovementLine[324].M_AttributeSetInstance_ID[8551] M_Locator_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, X_M_MovementLine.COLUMNNAME_M_Locator_ID, true); // only window
M_Locator_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, X_M_MovementLine.COLUMNNAME_M_Locator_ID, true); // only window
}
String title = ""; String title = "";
// Get Text // Get Text
@ -618,7 +617,7 @@ public class VPAttributeDialog extends CDialog
pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID); pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next()) {
title = rs.getString(1) + " - " + rs.getString(2); title = ": " + rs.getString(1) + " - " + rs.getString(2);
M_Warehouse_ID = rs.getInt(3); // fetch the actual warehouse - teo_sarca [ 1564520 ] M_Warehouse_ID = rs.getInt(3); // fetch the actual warehouse - teo_sarca [ 1564520 ]
} }
} }