patch [ 1659688 ] Material Receipt: "Copy from" button

https://sourceforge.net/tracker/index.php?func=detail&aid=1659688&group_id=176962&atid=879334
This commit is contained in:
kthiemann 2007-02-22 12:41:39 +00:00
parent d98492adc9
commit 9faf8748bc
3 changed files with 104 additions and 117 deletions

View File

@ -396,9 +396,10 @@ public abstract class VCreateFrom extends CDialog
* Qty - 1
* C_UOM_ID - 2
* M_Product_ID - 3
* OrderLine - 4
* ShipmentLine - 5
* InvoiceLine - 6
* VendorProductNo - 4
* OrderLine - 5
* ShipmentLine - 6
* InvoiceLine - 7
*/
log.config("C_Order_ID=" + C_Order_ID);
p_order = new MOrder (Env.getCtx(), C_Order_ID, null); // save
@ -408,9 +409,10 @@ public abstract class VCreateFrom extends CDialog
+ "l.QtyOrdered-SUM(COALESCE(m.Qty,0))," // 1
+ "CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END," // 2
+ " l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name)," // 3..4
+ " COALESCE(l.M_Product_ID,0),COALESCE(p.Name,c.Name)," // 5..6
+ " l.C_OrderLine_ID,l.Line " // 7..8
+ " COALESCE(l.M_Product_ID,0),COALESCE(p.Name,c.Name),po.VendorProductNo," // 5..7
+ " l.C_OrderLine_ID,l.Line " // 8..9
+ "FROM C_OrderLine l"
+ " LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND l.C_BPartner_ID = po.C_BPartner_ID) "
+ " LEFT OUTER JOIN M_MatchPO m ON (l.C_OrderLine_ID=m.C_OrderLine_ID AND ");
sql.append(forInvoice ? "m.C_InvoiceLine_ID" : "m.M_InOutLine_ID");
sql.append(" IS NOT NULL)")
@ -424,7 +426,7 @@ public abstract class VCreateFrom extends CDialog
//
sql.append(" WHERE l.C_Order_ID=? " // #1
+ "GROUP BY l.QtyOrdered,CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END, "
+ "l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name), "
+ "l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name),po.VendorProductNo, "
+ "l.M_Product_ID,COALESCE(p.Name,c.Name), l.Line,l.C_OrderLine_ID "
+ "ORDER BY l.Line");
//
@ -446,10 +448,11 @@ public abstract class VCreateFrom extends CDialog
line.add(pp); // 2-UOM
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
line.add(pp); // 3-Product
pp = new KeyNamePair(rs.getInt(7), rs.getString(8));
line.add(pp); // 4-OrderLine
line.add(null); // 5-Ship
line.add(null); // 6-Invoice
line.add(rs.getString(7)); // 4-VendorProductNo
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
line.add(pp); // 5-OrderLine
line.add(null); // 6-Ship
line.add(null); // 7-Invoice
data.add(line);
}
rs.close();
@ -475,6 +478,7 @@ public abstract class VCreateFrom extends CDialog
columnNames.add(Msg.translate(Env.getCtx(), "Quantity"));
columnNames.add(Msg.translate(Env.getCtx(), "C_UOM_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "M_Product_ID"));
columnNames.add(Msg.getElement(Env.getCtx(), "VendorProductNo", false));
columnNames.add(Msg.getElement(Env.getCtx(), "C_Order_ID", false));
columnNames.add(Msg.getElement(Env.getCtx(), "M_InOut_ID", false));
columnNames.add(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false));
@ -490,9 +494,10 @@ public abstract class VCreateFrom extends CDialog
dataTable.setColumnClass(1, Double.class, true); // 1-Qty
dataTable.setColumnClass(2, String.class, true); // 2-UOM
dataTable.setColumnClass(3, String.class, true); // 3-Product
dataTable.setColumnClass(4, String.class, true); // 4-Order
dataTable.setColumnClass(5, String.class, true); // 5-Ship
dataTable.setColumnClass(6, String.class, true); // 6-Invoice
dataTable.setColumnClass(4, String.class, true); // 4-VendorProductNo
dataTable.setColumnClass(5, String.class, true); // 5-Order
dataTable.setColumnClass(6, String.class, true); // 6-Ship
dataTable.setColumnClass(7, String.class, true); // 7-Invoice
// Table UI
dataTable.autoSize();
} // loadOrder

View File

@ -190,24 +190,25 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
StringBuffer sql = new StringBuffer("SELECT " // QtyEntered
+ "l.MovementQty-SUM(NVL(mi.Qty, 0)), l.QtyEntered/l.MovementQty,"
+ " l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name)," // 3..4
+ " l.M_Product_ID, p.Name, l.M_InOutLine_ID, l.Line," // 5..8
+ " l.C_OrderLine_ID "); // 9
+ " l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line," // 5..9
+ " l.C_OrderLine_ID " // 10
+ " FROM M_InOutLine l "
);
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
{
sql.append("FROM C_UOM uom, M_InOutLine l, M_Product p, M_MatchInv mi ");
sql.append("WHERE l.C_UOM_ID=uom.C_UOM_ID");
}
sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)");
else
{
sql.append("FROM C_UOM_Trl uom, M_InOutLine l, M_Product p, M_MatchInv mi ");
sql.append("WHERE l.C_UOM_ID=uom.C_UOM_ID AND uom.AD_Language='").append(Env.getAD_Language(Env.getCtx())).append("'");
}
sql.append(" AND l.M_Product_ID=p.M_Product_ID")
.append(" AND l.M_InOutLine_ID=mi.M_InOutLine_ID(+)")
.append(" AND l.M_InOut_ID=? ") // #1
sql.append(" LEFT OUTER JOIN C_UOM_Trl uom ON (l.C_UOM_ID=uom.C_UOM_ID AND uom.AD_Language='")
.append(Env.getAD_Language(Env.getCtx())).append("')");
sql.append(" LEFT OUTER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID)")
.append(" INNER JOIN M_InOut io ON (l.M_InOut_ID=io.M_InOut_ID)")
.append(" LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND io.C_BPartner_ID = po.C_BPartner_ID)")
.append(" LEFT OUTER JOIN M_MatchInv mi ON (l.M_InOutLine_ID=mi.M_InOutLine_ID)")
.append(" WHERE l.M_InOut_ID=? ")
.append("GROUP BY l.MovementQty, l.QtyEntered/l.MovementQty, "
+ "l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name), "
+ "l.M_Product_ID, p.Name, l.M_InOutLine_ID, l.Line, l.C_OrderLine_ID ")
+ "l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line, l.C_OrderLine_ID ")
.append("ORDER BY l.Line");
try
@ -227,14 +228,15 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
line.add(pp); // 2-UOM
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
line.add(pp); // 3-Product
int C_OrderLine_ID = rs.getInt(9);
line.add(rs.getString(7)); // 4-VendorProductNo
int C_OrderLine_ID = rs.getInt(10);
if (rs.wasNull())
line.add(null); // 4-Order
line.add(null); // 5-Order
else
line.add(new KeyNamePair(C_OrderLine_ID,"."));
pp = new KeyNamePair(rs.getInt(7), rs.getString(8));
line.add(pp); // 5-Ship
line.add(null); // 6-Invoice
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
line.add(pp); // 6-Ship
line.add(null); // 7-Invoice
data.add(line);
}
rs.close();
@ -311,11 +313,11 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
int C_Charge_ID = 0;
//
int C_OrderLine_ID = 0;
pp = (KeyNamePair)model.getValueAt(i, 4); // 4-OrderLine
pp = (KeyNamePair)model.getValueAt(i, 5); // 5-OrderLine
if (pp != null)
C_OrderLine_ID = pp.getKey();
int M_InOutLine_ID = 0;
pp = (KeyNamePair)model.getValueAt(i, 5); // 5-Shipment
pp = (KeyNamePair)model.getValueAt(i, 6); // 6-Shipment
if (pp != null)
M_InOutLine_ID = pp.getKey();
// Precision of Qty UOM

View File

@ -192,8 +192,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
* Load Data - Invoice
* @param C_Invoice_ID Invoice
*/
private void loadInvoice (int C_Invoice_ID)
{
private void loadInvoice(int C_Invoice_ID) {
log.config("C_Invoice_ID=" + C_Invoice_ID);
m_invoice = new MInvoice(Env.getCtx(), C_Invoice_ID, null); // save
p_order = null;
@ -202,32 +201,31 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
StringBuffer sql = new StringBuffer("SELECT " // Entered UOM
+ "l.QtyInvoiced-SUM(NVL(mi.Qty,0)),l.QtyEntered/l.QtyInvoiced,"
+ " l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name)," // 3..4
+ " l.M_Product_ID,p.Name, l.C_InvoiceLine_ID,l.Line," // 5..8
+ " l.C_OrderLine_ID "); // 9
+ " l.M_Product_ID,p.Name, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line," // 5..9
+ " l.C_OrderLine_ID "
+ " FROM C_InvoiceLine l "); // 10
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
{
sql.append("FROM C_UOM uom, C_InvoiceLine l, M_Product p, M_MatchInv mi ");
sql.append("WHERE l.C_UOM_ID=uom.C_UOM_ID");
}
sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)");
else
{
sql.append("FROM C_UOM_Trl uom, C_InvoiceLine_v l, M_Product p, M_MatchInv mi ");
sql.append("WHERE l.C_UOM_ID=uom.C_UOM_ID AND uom.AD_Language='").append(Env.getAD_Language(Env.getCtx())).append("'");
}
sql.append(" AND l.M_Product_ID=p.M_Product_ID"
+ " AND l.C_InvoiceLine_ID=mi.C_InvoiceLine_ID(+)"
+ " AND l.C_Invoice_ID=? " // #1
+ "GROUP BY l.QtyInvoiced,l.QtyEntered/l.QtyInvoiced,"
sql.append(" LEFT OUTER JOIN C_UOM_Trl uom ON (l.C_UOM_ID=uom.C_UOM_ID AND uom.AD_Language='")
.append(Env.getAD_Language(Env.getCtx())).append("')");
sql.append(" LEFT OUTER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID)")
.append(" INNER JOIN C_Invoice inv ON (l.C_Invoice_ID=inv.C_Invoice_ID)")
.append(" LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND inv.C_BPartner_ID = po.C_BPartner_ID)")
.append(" LEFT OUTER JOIN M_MatchInv mi ON (l.C_InvoiceLine_ID=mi.C_InvoiceLine_ID)")
.append(" WHERE l.C_Invoice_ID=? ")
.append("GROUP BY l.QtyInvoiced,l.QtyEntered/l.QtyInvoiced,"
+ "l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name),"
+ "l.M_Product_ID,p.Name, l.C_InvoiceLine_ID,l.Line,l.C_OrderLine_ID "
+ "ORDER BY l.Line");
try
{
+ "l.M_Product_ID,p.Name, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line,l.C_OrderLine_ID ")
.append("ORDER BY l.Line");
try {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_Invoice_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
while (rs.next()) {
Vector<Object> line = new Vector<Object>(7);
line.add(new Boolean(false)); // 0-Selection
BigDecimal qtyInvoiced = rs.getBigDecimal(1);
@ -238,50 +236,45 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
line.add(pp); // 2-UOM
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
line.add(pp); // 3-Product
int C_OrderLine_ID = rs.getInt(9);
line.add(rs.getString(7)); // 4-VendorProductNo
int C_OrderLine_ID = rs.getInt(10);
if (rs.wasNull())
line.add(null); // 4-Order
line.add(null); // 5-Order
else
line.add(new KeyNamePair(C_OrderLine_ID, "."));
line.add(null); // 5-Ship
pp = new KeyNamePair(rs.getInt(7), rs.getString(8));
line.add(pp); // 6-Invoice
line.add(null); // 6-Ship
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
line.add(pp); // 7-Invoice
data.add(line);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
} catch (SQLException e) {
log.log(Level.SEVERE, sql.toString(), e);
}
loadTableOIS(data);
} // loadInvoice
/**
* List number of rows selected
*/
protected void info()
{
protected void info() {
TableModel model = dataTable.getModel();
int rows = model.getRowCount();
int count = 0;
for (int i = 0; i < rows; i++)
{
for (int i = 0; i < rows; i++) {
if (((Boolean) model.getValueAt(i, 0)).booleanValue())
count++;
}
statusBar.setStatusLine(String.valueOf(count));
} // info
/**
* Save - create Shipments
*
* @return true if saved
*/
protected boolean save()
{
protected boolean save() {
log.config("");
TableModel model = dataTable.getModel();
int rows = model.getRowCount();
@ -289,8 +282,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
return false;
//
Integer loc = (Integer) locatorField.getValue();
if (loc == null || loc.intValue() == 0)
{
if (loc == null || loc.intValue() == 0) {
locatorField.setBackground(AdempierePLAF.getFieldBackground_Error());
return false;
}
@ -300,21 +292,9 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
MInOut inout = new MInOut(Env.getCtx(), M_InOut_ID, null);
log.config(inout + ", C_Locator_ID=" + M_Locator_ID);
/**
* Selected - 0
* QtyEntered - 1
* C_UOM_ID - 2
* M_Product_ID - 3
* OrderLine - 4
* ShipmentLine - 5
* InvoiceLine - 6
*/
// Lines
for (int i = 0; i < rows; i++)
{
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
{
for (int i = 0; i < rows; i++) {
if (((Boolean) model.getValueAt(i, 0)).booleanValue()) {
// variable values
Double d = (Double) model.getValueAt(i, 1); // 1-Qty
BigDecimal QtyEntered = new BigDecimal(d.doubleValue());
@ -323,12 +303,12 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
pp = (KeyNamePair) model.getValueAt(i, 3); // 3-Product
int M_Product_ID = pp.getKey();
int C_OrderLine_ID = 0;
pp = (KeyNamePair)model.getValueAt(i, 4); // 4-OrderLine
pp = (KeyNamePair) model.getValueAt(i, 5); // 5-OrderLine
if (pp != null)
C_OrderLine_ID = pp.getKey();
int C_InvoiceLine_ID = 0;
MInvoiceLine il = null;
pp = (KeyNamePair)model.getValueAt(i, 6); // 6-InvoiceLine
pp = (KeyNamePair) model.getValueAt(i, 7); // 7-InvoiceLine
if (pp != null)
C_InvoiceLine_ID = pp.getKey();
if (C_InvoiceLine_ID != 0)