FEATURE: [ 2306161 ] Locator on line level when creating lines from.

GUI: Added field for using barcode scanner when checking received goods.
This commit is contained in:
usrdno 2008-12-08 14:49:12 +00:00
parent 230a2c9396
commit 34f8c8ba7c
3 changed files with 759 additions and 494 deletions

View File

@ -3,321 +3,320 @@
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;
import java.io.Serializable;
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Level;
import org.compiere.util.DB;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.KeyNamePair;
import org.compiere.util.NamePair;
/**
* Warehouse Locator Lookup Model.
* (Lookup Model is model.Lookup.java)
*
* @author Jorg Janke
* @version $Id: MLocatorLookup.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $
/**
* Warehouse Locator Lookup Model.
* (Lookup Model is model.Lookup.java)
*
* @author Jorg Janke
* @version $Id: MLocatorLookup.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $
*
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>BF [ 1892920 ] Locators fieldshould be ordered by Warehouse/Value
*/
public final class MLocatorLookup extends Lookup implements Serializable
{
/**
* Constructor
* @param ctx context
* @param WindowNo window no
*/
public MLocatorLookup(Properties ctx, int WindowNo)
{
super (DisplayType.TableDir, WindowNo);
m_ctx = ctx;
//
m_loader = new Loader();
m_loader.start();
} // MLocator
/** Context */
private Properties m_ctx;
protected int C_Locator_ID;
private Loader m_loader;
/** Only Warehouse */
private int m_only_Warehouse_ID = 0;
/** Only Product */
private int m_only_Product_ID = 0;
/** Storage of data MLookups */
private volatile LinkedHashMap<Integer,MLocator> m_lookup = new LinkedHashMap<Integer,MLocator>();
/** Max Locators per Lookup */
private static int s_maxRows = 200; // how many rows to read
/**
* Dispose
*/
public void dispose()
{
log.fine("C_Locator_ID=" + C_Locator_ID);
if (m_loader != null)
{
while (m_loader.isAlive())
m_loader.interrupt();
}
m_loader = null;
if (m_lookup != null)
m_lookup.clear();
m_lookup = null;
//
super.dispose();
} // dispose
/**
* Set Warehouse restriction
* @param only_Warehouse_ID warehouse
*/
public void setOnly_Warehouse_ID (int only_Warehouse_ID)
{
m_only_Warehouse_ID = only_Warehouse_ID;
} // setOnly_Warehouse_ID
/**
* Get Only Wahrehouse
* @return warehouse
*/
public int getOnly_Warehouse_ID()
{
return m_only_Warehouse_ID;
} // getOnly_Warehouse_ID
/**
* Set Product restriction
* @param only_Product_ID Product
*/
public void setOnly_Product_ID (int only_Product_ID)
{
m_only_Product_ID = only_Product_ID;
} // setOnly_Product_ID
/**
* Get Only Product
* @return Product
*/
public int getOnly_Product_ID()
{
return m_only_Product_ID;
} // getOnly_Product_ID
/**
* Wait until async Load Complete
*/
public void loadComplete()
{
if (m_loader != null)
{
try
{
m_loader.join();
}
catch (InterruptedException ie)
{
log.log(Level.SEVERE, "Join interrupted", ie);
}
}
} // loadComplete
/**
* Get value
* @param key key
* @return value value
*/
public NamePair get (Object key)
{
if (key == null)
return null;
// try cache
MLocator loc = (MLocator) m_lookup.get(key);
if (loc != null)
return new KeyNamePair (loc.getM_Locator_ID(), loc.toString());
// Not found and waiting for loader
if (m_loader.isAlive())
{
log.fine("Waiting for Loader");
loadComplete();
// is most current
loc = (MLocator) m_lookup.get(key);
}
if (loc != null)
return new KeyNamePair (loc.getM_Locator_ID(), loc.toString());
// Try to get it directly
return getDirect(key, true, null);
} // get
/**
* Get Display value
* @param value value
* @return String to display
*/
public String getDisplay (Object value)
{
if (value == null)
return "";
//
NamePair display = get (value);
if (display == null)
return "<" + value.toString() + ">";
return display.toString();
} // getDisplay
/**
* The Lookup contains the key
* @param key key
* @return true, if lookup contains key
*/
public boolean containsKey (Object key)
{
return m_lookup.containsKey(key);
} // containsKey
/**
* Get Data Direct from Table
* @param keyValue integer key value
* @param saveInCache save in cache
* @param trxName transaction
* @return Object directly loaded
*/
public NamePair getDirect (Object keyValue, boolean saveInCache, String trxName)
{
MLocator loc = getMLocator (keyValue, trxName);
if (loc == null)
return null;
//
int key = loc.getM_Locator_ID();
if (saveInCache)
m_lookup.put(new Integer(key), loc);
NamePair retValue = new KeyNamePair(key, loc.toString());
return retValue;
} // getDirect
/**
* Get Data Direct from Table
* @param keyValue integer key value
* @param trxName transaction
* @return Object directly loaded
*/
public MLocator getMLocator (Object keyValue, String trxName)
{
// log.fine( "MLocatorLookup.getDirect " + keyValue.getClass() + "=" + keyValue);
int M_Locator_ID = -1;
try
{
M_Locator_ID = Integer.parseInt(keyValue.toString());
}
catch (Exception e)
{}
if (M_Locator_ID == -1)
{
log.log(Level.SEVERE, "Invalid key=" + keyValue);
return null;
}
//
return new MLocator (m_ctx, M_Locator_ID, trxName);
} // getMLocator
/**
* @return a string representation of the object.
*/
public String toString()
{
return "MLocatorLookup[Size=" + m_lookup.size() + "]";
} // toString
/**
* Is Locator with key valid (Warehouse)
* @param key key
* @return true if valid
*/
public boolean isValid (Object key)
{
if (key == null)
return true;
// try cache
MLocator loc = (MLocator) m_lookup.get(key);
if (loc == null)
loc = getMLocator(key, null);
return isValid(loc);
} // isValid
/**
* Is Locator with key valid (Warehouse)
* @param locator locator
* @return true if valid
*/
public boolean isValid (MLocator locator)
{
if (locator == null || getOnly_Warehouse_ID() == 0)
return true;
// Warehouse OK - Product check
if (getOnly_Warehouse_ID() == locator.getM_Warehouse_ID())
return locator.isCanStoreProduct(getOnly_Product_ID());
return false;
} // isValid
/**************************************************************************
* Loader
*/
class Loader extends Thread implements Serializable
{
* <li>FR [ 2306161 ] Removed limit of 200 on max number of locators.
*/
public final class MLocatorLookup extends Lookup implements Serializable
{
/**
* Constructor
* @param ctx context
* @param WindowNo window no
*/
public MLocatorLookup(Properties ctx, int WindowNo)
{
super (DisplayType.TableDir, WindowNo);
m_ctx = ctx;
//
m_loader = new Loader();
m_loader.start();
} // MLocator
/** Context */
private Properties m_ctx;
protected int C_Locator_ID;
private Loader m_loader;
/** Only Warehouse */
private int m_only_Warehouse_ID = 0;
/** Only Product */
private int m_only_Product_ID = 0;
/** Storage of data MLookups */
private volatile LinkedHashMap<Integer,MLocator> m_lookup = new LinkedHashMap<Integer,MLocator>();
/**
* Dispose
*/
public void dispose()
{
log.fine("C_Locator_ID=" + C_Locator_ID);
if (m_loader != null)
{
while (m_loader.isAlive())
m_loader.interrupt();
}
m_loader = null;
if (m_lookup != null)
m_lookup.clear();
m_lookup = null;
//
super.dispose();
} // dispose
/**
* Set Warehouse restriction
* @param only_Warehouse_ID warehouse
*/
public void setOnly_Warehouse_ID (int only_Warehouse_ID)
{
m_only_Warehouse_ID = only_Warehouse_ID;
} // setOnly_Warehouse_ID
/**
* Get Only Wahrehouse
* @return warehouse
*/
public int getOnly_Warehouse_ID()
{
return m_only_Warehouse_ID;
} // getOnly_Warehouse_ID
/**
* Set Product restriction
* @param only_Product_ID Product
*/
public void setOnly_Product_ID (int only_Product_ID)
{
m_only_Product_ID = only_Product_ID;
} // setOnly_Product_ID
/**
* Get Only Product
* @return Product
*/
public int getOnly_Product_ID()
{
return m_only_Product_ID;
} // getOnly_Product_ID
/**
* Wait until async Load Complete
*/
public void loadComplete()
{
if (m_loader != null)
{
try
{
m_loader.join();
}
catch (InterruptedException ie)
{
log.log(Level.SEVERE, "Join interrupted", ie);
}
}
} // loadComplete
/**
* Get value
* @param key key
* @return value value
*/
public NamePair get (Object key)
{
if (key == null)
return null;
// try cache
MLocator loc = (MLocator) m_lookup.get(key);
if (loc != null)
return new KeyNamePair (loc.getM_Locator_ID(), loc.toString());
// Not found and waiting for loader
if (m_loader.isAlive())
{
log.fine("Waiting for Loader");
loadComplete();
// is most current
loc = (MLocator) m_lookup.get(key);
}
if (loc != null)
return new KeyNamePair (loc.getM_Locator_ID(), loc.toString());
// Try to get it directly
return getDirect(key, true, null);
} // get
/**
* Get Display value
* @param value value
* @return String to display
*/
public String getDisplay (Object value)
{
if (value == null)
return "";
//
NamePair display = get (value);
if (display == null)
return "<" + value.toString() + ">";
return display.toString();
} // getDisplay
/**
* The Lookup contains the key
* @param key key
* @return true, if lookup contains key
*/
public boolean containsKey (Object key)
{
return m_lookup.containsKey(key);
} // containsKey
/**
* Get Data Direct from Table
* @param keyValue integer key value
* @param saveInCache save in cache
* @param trxName transaction
* @return Object directly loaded
*/
public NamePair getDirect (Object keyValue, boolean saveInCache, String trxName)
{
MLocator loc = getMLocator (keyValue, trxName);
if (loc == null)
return null;
//
int key = loc.getM_Locator_ID();
if (saveInCache)
m_lookup.put(new Integer(key), loc);
NamePair retValue = new KeyNamePair(key, loc.toString());
return retValue;
} // getDirect
/**
* Get Data Direct from Table
* @param keyValue integer key value
* @param trxName transaction
* @return Object directly loaded
*/
public MLocator getMLocator (Object keyValue, String trxName)
{
// log.fine( "MLocatorLookup.getDirect " + keyValue.getClass() + "=" + keyValue);
int M_Locator_ID = -1;
try
{
M_Locator_ID = Integer.parseInt(keyValue.toString());
}
catch (Exception e)
{}
if (M_Locator_ID == -1)
{
log.log(Level.SEVERE, "Invalid key=" + keyValue);
return null;
}
//
return new MLocator (m_ctx, M_Locator_ID, trxName);
} // getMLocator
/**
* @return a string representation of the object.
*/
public String toString()
{
return "MLocatorLookup[Size=" + m_lookup.size() + "]";
} // toString
/**
* Is Locator with key valid (Warehouse)
* @param key key
* @return true if valid
*/
public boolean isValid (Object key)
{
if (key == null)
return true;
// try cache
MLocator loc = (MLocator) m_lookup.get(key);
if (loc == null)
loc = getMLocator(key, null);
return isValid(loc);
} // isValid
/**
* Is Locator with key valid (Warehouse)
* @param locator locator
* @return true if valid
*/
public boolean isValid (MLocator locator)
{
if (locator == null || getOnly_Warehouse_ID() == 0)
return true;
// Warehouse OK - Product check
if (getOnly_Warehouse_ID() == locator.getM_Warehouse_ID())
return locator.isCanStoreProduct(getOnly_Product_ID());
return false;
} // isValid
/**************************************************************************
* Loader
*/
class Loader extends Thread implements Serializable
{
private static final long serialVersionUID = 1L;
/**
* Loader
*/
public Loader()
{
super("MLocatorLookup");
} // Loader
/**
* Load Lookup
*/
public void run()
{
// log.config("MLocatorLookup Loader.run " + m_AD_Column_ID);
// Set Info - see VLocator.actionText
/**
* Loader
*/
public Loader()
{
super("MLocatorLookup");
} // Loader
/**
* Load Lookup
*/
public void run()
{
// log.config("MLocatorLookup Loader.run " + m_AD_Column_ID);
// Set Info - see VLocator.actionText
int local_only_warehouse_id = getOnly_Warehouse_ID(); // [ 1674891 ] MLocatorLookup - weird error
int local_only_product_id = getOnly_Product_ID();
StringBuffer sql = new StringBuffer("SELECT * FROM M_Locator ")
StringBuffer sql = new StringBuffer("SELECT * FROM M_Locator ")
.append(" WHERE IsActive='Y'");
if (local_only_warehouse_id != 0)
sql.append(" AND M_Warehouse_ID=?");
if (local_only_warehouse_id != 0)
sql.append(" AND M_Warehouse_ID=?");
if (local_only_product_id != 0)
sql.append(" AND (IsDefault='Y' ") // Default Locator
.append("OR EXISTS (SELECT * FROM M_Product p ") // Product Locator
@ -329,138 +328,132 @@ public final class MLocatorLookup extends Lookup implements Serializable
sql.append("(SELECT wh.Name FROM M_Warehouse wh WHERE wh.M_Warehouse_ID=M_Locator.M_Warehouse_ID),");
sql.append("M_Locator.Value");
String finalSql = MRole.getDefault(m_ctx, false).addAccessSQL(
sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
if (isInterrupted())
{
log.log(Level.SEVERE, "Interrupted");
return;
}
// Reset
m_lookup.clear();
int rows = 0;
sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
if (isInterrupted())
{
log.log(Level.SEVERE, "Interrupted");
return;
}
// Reset
m_lookup.clear();
int rows = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(finalSql, null);
int index = 1;
if (local_only_warehouse_id != 0)
pstmt.setInt(index++, getOnly_Warehouse_ID());
if (local_only_product_id != 0)
{
pstmt.setInt(index++, getOnly_Product_ID());
pstmt.setInt(index++, getOnly_Product_ID());
}
rs = pstmt.executeQuery();
//
while (rs.next())
{
// Max out
if (rows++ > s_maxRows)
{
log.warning("Over Max Rows - " + rows);
break;
}
MLocator loc = new MLocator(m_ctx, rs, null);
int M_Locator_ID = loc.getM_Locator_ID();
m_lookup.put(new Integer(M_Locator_ID), loc);
}
}
catch (SQLException e)
{
log.log(Level.SEVERE, finalSql, e);
try
{
pstmt = DB.prepareStatement(finalSql, null);
int index = 1;
if (local_only_warehouse_id != 0)
pstmt.setInt(index++, getOnly_Warehouse_ID());
if (local_only_product_id != 0)
{
pstmt.setInt(index++, getOnly_Product_ID());
pstmt.setInt(index++, getOnly_Product_ID());
}
rs = pstmt.executeQuery();
//
while (rs.next())
{
MLocator loc = new MLocator(m_ctx, rs, null);
int M_Locator_ID = loc.getM_Locator_ID();
m_lookup.put(new Integer(M_Locator_ID), loc);
}
}
catch (SQLException e)
{
log.log(Level.SEVERE, finalSql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
log.fine("Complete #" + m_lookup.size());
if (m_lookup.size() == 0)
log.finer(finalSql);
} // run
} // Loader
/**
* Return info as ArrayList containing Locator, waits for the loader to finish
* @return Collection of lookup values
*/
public Collection<MLocator> getData ()
{
if (m_loader.isAlive())
{
log.fine("Waiting for Loader");
try
{
m_loader.join();
}
catch (InterruptedException ie)
{
log.severe ("Join interrupted - " + ie.getMessage());
}
}
return m_lookup.values();
} // getData
/**
* Return data as sorted ArrayList
* @param mandatory mandatory
* @param onlyValidated only validated
* @param onlyActive only active
* @param temporary force load for temporary display
* @return ArrayList of lookup values
*/
public ArrayList<Object> getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary)
{
// create list
Collection<MLocator> collection = getData();
ArrayList<Object> list = new ArrayList<Object>(collection.size());
Iterator<MLocator> it = collection.iterator();
while (it.hasNext())
{
MLocator loc = it.next();
if (isValid(loc)) // only valid warehouses
list.add(loc);
}
/** Sort Data
MLocator l = new MLocator (m_ctx, 0);
if (!mandatory)
list.add (l);
Collections.sort (list, l);
**/
return list;
} // getArray
/**
* Refresh Values
* @return new size of lookup
*/
public int refresh()
{
log.fine("start");
m_loader = new Loader();
m_loader.start();
try
{
m_loader.join();
}
catch (InterruptedException ie)
{
}
log.info("#" + m_lookup.size());
return m_lookup.size();
} // refresh
/**
* Get underlying fully qualified Table.Column Name
* @return Table.ColumnName
*/
public String getColumnName()
{
return "M_Locator.M_Locator_ID";
} // getColumnName
} // MLocatorLookup
}
log.fine("Complete #" + m_lookup.size());
if (m_lookup.size() == 0)
log.finer(finalSql);
} // run
} // Loader
/**
* Return info as ArrayList containing Locator, waits for the loader to finish
* @return Collection of lookup values
*/
public Collection<MLocator> getData ()
{
if (m_loader.isAlive())
{
log.fine("Waiting for Loader");
try
{
m_loader.join();
}
catch (InterruptedException ie)
{
log.severe ("Join interrupted - " + ie.getMessage());
}
}
return m_lookup.values();
} // getData
/**
* Return data as sorted ArrayList
* @param mandatory mandatory
* @param onlyValidated only validated
* @param onlyActive only active
* @param temporary force load for temporary display
* @return ArrayList of lookup values
*/
public ArrayList<Object> getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary)
{
// create list
Collection<MLocator> collection = getData();
ArrayList<Object> list = new ArrayList<Object>(collection.size());
Iterator<MLocator> it = collection.iterator();
while (it.hasNext())
{
MLocator loc = it.next();
if (isValid(loc)) // only valid warehouses
list.add(loc);
}
/** Sort Data
MLocator l = new MLocator (m_ctx, 0);
if (!mandatory)
list.add (l);
Collections.sort (list, l);
**/
return list;
} // getArray
/**
* Refresh Values
* @return new size of lookup
*/
public int refresh()
{
log.fine("start");
m_loader = new Loader();
m_loader.start();
try
{
m_loader.join();
}
catch (InterruptedException ie)
{
}
log.info("#" + m_lookup.size());
return m_lookup.size();
} // refresh
/**
* Get underlying fully qualified Table.Column Name
* @return Table.ColumnName
*/
public String getColumnName()
{
return "M_Locator.M_Locator_ID";
} // getColumnName
} // MLocatorLookup

View File

@ -34,6 +34,7 @@ import java.util.logging.Level;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
import javax.swing.event.TableModelEvent;
@ -217,6 +218,8 @@ public abstract class VCreateFrom extends CDialog
protected JComboBox invoiceField = new JComboBox();
protected JLabel shipmentLabel = new JLabel();
protected JComboBox shipmentField = new JComboBox();
protected JLabel upcLabel = new JLabel();
protected JTextField upcField = new JTextField();
private JScrollPane dataPane = new JScrollPane();
private CPanel southPanel = new CPanel();
private BorderLayout southLayout = new BorderLayout();
@ -276,6 +279,7 @@ public abstract class VCreateFrom extends CDialog
rmaLabel.setText(Msg.translate(Env.getCtx(), "M_RMA_ID"));
sameWarehouseCb.setText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", true));
sameWarehouseCb.setToolTipText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", false));
upcLabel.setText(Msg.getElement(Env.getCtx(), "UPC", false));
documentTypeLabel.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
tenderTypeLabel.setText(Msg.translate(Env.getCtx(), "TenderType"));
@ -384,6 +388,13 @@ public abstract class VCreateFrom extends CDialog
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
parameterStdPanel.add(sameWarehouseCb, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
if (this instanceof VCreateFromShipment) {
parameterStdPanel.add(upcLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
parameterStdPanel.add(upcField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
}
// Add RMA document selection to panel
parameterStdPanel.add(rmaLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
@ -648,7 +659,7 @@ public abstract class VCreateFrom extends CDialog
line.add(qtyEntered); // 1-Qty
KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(4).trim());
line.add(pp); // 2-UOM
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
line.add(pp); // 3-Product
line.add(rs.getString(7)); // 4-VendorProductNo
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));

View File

@ -22,8 +22,10 @@ import java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.table.*;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.grid.ed.*;
import org.compiere.model.*;
@ -37,6 +39,82 @@ import org.compiere.util.*;
*/
public class VCreateFromShipment extends VCreateFrom implements VetoableChangeListener
{
/**
* Cell editor specific for the MLocator in this form's table.
*
*/
public class InnerLocatorTableCellEditor extends AbstractCellEditor implements TableCellEditor, CellEditorListener {
private KeyNamePair m_locatorKey;
private VLocator v_loc;
private JTable m_table;
private int m_row;
private int m_column;
public InnerLocatorTableCellEditor() {
addCellEditorListener(this);
}
public Object getCellEditorValue() {
return(m_locatorKey);
}
/**
*
* @param table
* @param value The current value in the cell. In this case, a KeyName pair of the locator
* @param isSelected
* @param row
* @param column
* @return
*/
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
m_table = table;
m_row = row;
m_column = column;
m_locatorKey = (KeyNamePair)value;
MLocatorLookup mLocatorLookup = new MLocatorLookup(Env.getCtx(), 0);
v_loc = new VLocator("M_Locator_ID", true, false, true, mLocatorLookup, 0);
v_loc.setValue(m_locatorKey.getKey());
return(v_loc);
}
/**
* When editing stops (editing done), save the value in the table model
* and update the product's default locator.
*
* @param e
*/
public void editingStopped(ChangeEvent e) {
// Editing ends, save value
if (v_loc.getValue()!=null) {
int key = ((Integer)v_loc.getValue()).intValue();
MLocator locator = new MLocator(Env.getCtx(), key, null);
m_locatorKey = new KeyNamePair(key, locator.getValue());
m_table.getModel().setValueAt(m_locatorKey, m_row, m_column);
// Get product and save new locator
KeyNamePair prodKey = (KeyNamePair)m_table.getModel().getValueAt(m_row, m_column + 1);
MProduct prod = new MProduct(Env.getCtx(), prodKey.getKey(), null);
prod.setM_Locator_ID(key);
prod.save();
}
}
/**
* When editing stops, do nothing.
* @param e
*/
public void editingCanceled(ChangeEvent e) {
}
}
// == END OF INNER CLASS InnerLocatorTableCellEditor
/**
* Protected Constructor
* @param mTab MTab
@ -49,25 +127,48 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
/** Loaded Invoice */
private MInvoice m_invoice = null;
/** Loaded RMA */
private MRMA m_rma = null;
/** Loaded RMA */
private MRMA m_rma = null;
private static int COL_SELECT = 0;
private static int COL_QTY = 1;
private static int COL_UOM = 2;
private static int COL_LOCATOR_ID = 3;
private static int COL_PRODUCT_ID = 4;
private static int COL_VENDORPRODNO = 5;
private static int COL_ORDER_ID = 6;
private static int COL_RMA_ID = 7;
private static int COL_INVOICE_ID = 8;
/**
* Column names
* Override names from parent class since it differs on COL_RMA_ID.
*/
protected String[] colNames = new String[] {
Msg.getMsg(Env.getCtx(), "Select"),
Msg.translate(Env.getCtx(), "Quantity"),
Msg.translate(Env.getCtx(), "C_UOM_ID"),
Msg.translate((Env.getCtx()), "M_Locator_ID"),
Msg.translate(Env.getCtx(), "M_Product_ID"),
Msg.getElement(Env.getCtx(), "VendorProductNo", false),
Msg.getElement(Env.getCtx(), "C_Order_ID", false),
Msg.getElement(Env.getCtx(), "M_RMA_ID", false),
Msg.getElement(Env.getCtx(), "C_Invoice_ID", false)
};
/**
* Load Order/Invoice/RMA data into Table
* @param data data
*/
@Override
protected void loadTableOIS (Vector data)
{
// Header Info
Vector<String> columnNames = new Vector<String>(7);
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
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_RMA_ID", false));
columnNames.add(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false));
Vector<String> columnNames = new Vector<String>(colNames.length);
for (int i=0; i<colNames.length; i++) {
columnNames.add(colNames[i]);
}
// Remove previous listeners
dataTable.getModel().removeTableModelListener(this);
@ -76,14 +177,17 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
model.addTableModelListener(this);
dataTable.setModel(model);
//
dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
dataTable.setColumnClass(1, BigDecimal.class, false); // 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-VendorProductNo
dataTable.setColumnClass(5, String.class, true); // 5-Order
dataTable.setColumnClass(6, String.class, true); // 6-RMA
dataTable.setColumnClass(7, String.class, true); // 7-Invoice
dataTable.setColumnClass(COL_SELECT, Boolean.class, false); // Selection
dataTable.setColumnClass(COL_QTY, BigDecimal.class, false); // Qty
dataTable.setColumnClass(COL_UOM, String.class, true); // UOM
dataTable.setColumnClass(COL_LOCATOR_ID, String.class, false); // Locator
TableColumn col = dataTable.getColumnModel().getColumn(COL_LOCATOR_ID);
col.setCellEditor(new InnerLocatorTableCellEditor());
dataTable.setColumnClass(COL_PRODUCT_ID, String.class, true); // Product
dataTable.setColumnClass(COL_VENDORPRODNO, String.class, true); // VendorProductNo
dataTable.setColumnClass(COL_ORDER_ID, String.class, true); // Order
dataTable.setColumnClass(COL_RMA_ID, String.class, true); // Ship
dataTable.setColumnClass(COL_INVOICE_ID, String.class, true); // Invoice
// Table UI
dataTable.autoSize();
} // loadOrder
@ -105,7 +209,6 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
sameWarehouseCb.addActionListener(this);
// load Locator
int AD_Column_ID = 3537; // M_InOut.M_Locator_ID
MLocatorLookup locator = new MLocatorLookup(Env.getCtx(), p_WindowNo);
locatorField = new VLocator ("M_Locator_ID", true, false, true, locator, p_WindowNo);
@ -176,6 +279,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
}
invoiceField.setSelectedIndex(0);
invoiceField.addActionListener(this);
upcField.addActionListener(this);
}
/**
@ -295,10 +399,58 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
else if (e.getSource().equals(sameWarehouseCb))
{
initBPartnerOIS(((Integer)bPartnerField.getValue()).intValue(), false);
} else if (e.getSource().equals(upcField)) {
checkProductUsingUpc();
}
} // actionPerformed
/**
* Checks the UPC value and checks if the UPC matches any of the products in the
* list.
*/
private void checkProductUsingUpc() {
String upc = upcField.getText();
DefaultTableModel model = (DefaultTableModel)dataTable.getModel();
// Lookup UPC
java.util.List<MProduct> products = MProduct.getByUPC(Env.getCtx(), upc, null);
MProduct product;
int row;
BigDecimal qty;
for (Iterator<MProduct> it = products.iterator(); it.hasNext();) {
product = it.next();
row = findProductRow(product.get_ID());
if (row>=0) {
qty = (BigDecimal)model.getValueAt(row, COL_QTY);
model.setValueAt(qty, row, COL_QTY);
model.setValueAt(Boolean.TRUE, row, COL_SELECT);
model.fireTableRowsUpdated(row, row);
}
}
upcField.setText("");
upcField.requestFocusInWindow();
}
/**
* Finds the row where a given product is. If the product is not found
* in the table -1 is returned.
* @param M_Product_ID
* @return Row of the product or -1 if non existing.
*
*/
private int findProductRow(int M_Product_ID) {
DefaultTableModel model = (DefaultTableModel)dataTable.getModel();
KeyNamePair kp;
for (int i=0; i<model.getRowCount(); i++) {
kp = (KeyNamePair)model.getValueAt(i, COL_PRODUCT_ID);
if (kp.getKey()==M_Product_ID) {
return(i);
}
}
return(-1);
}
/**
* Change Listener
* @param e event
@ -316,10 +468,108 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
tableChanged(null);
} // vetoableChange
/**
* Load Data - Order
* @param C_Order_ID Order
* @param forInvoice true if for invoice vs. delivery qty
*/
protected void loadOrder (int C_Order_ID, boolean forInvoice)
{
/**
* Selected - 0
* Qty - 1
* C_UOM_ID - 2
* M_Locator_ID - 3
* M_Product_ID - 4
* VendorProductNo - 5
* OrderLine - 6
* ShipmentLine - 7
* InvoiceLine - 8
*/
log.config("C_Order_ID=" + C_Order_ID);
p_order = new MOrder (Env.getCtx(), C_Order_ID, null); // save
Vector<Vector> data = new Vector<Vector>();
StringBuffer sql = new StringBuffer("SELECT "
+ "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
+ " p.M_Locator_ID, COALESCE(loc.value,''), " // 5..6
+ " COALESCE(l.M_Product_ID,0),COALESCE(p.Name,c.Name), " // 7..8
+ " po.VendorProductNo, " // 9
+ " l.C_OrderLine_ID,l.Line " // 10..11
+ "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)")
.append(" LEFT OUTER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID)"
+ " LEFT OUTER JOIN M_Locator loc on (p.M_Locator_ID=loc.M_Locator_ID)"
+ " LEFT OUTER JOIN C_Charge c ON (l.C_Charge_ID=c.C_Charge_ID)");
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)");
else
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(" 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), p.m_locator_id, COALESCE(loc.value,''), po.VendorProductNo, "
+ "l.M_Product_ID,COALESCE(p.Name,c.Name), l.Line,l.C_OrderLine_ID "
+ "ORDER BY l.Line");
//
log.finer(sql.toString());
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_Order_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
Vector<Object> line = new Vector<Object>();
line.add(new Boolean(false)); // 0-Selection
BigDecimal qtyOrdered = rs.getBigDecimal(1);
BigDecimal multiplier = rs.getBigDecimal(2);
BigDecimal qtyEntered = qtyOrdered.multiply(multiplier);
line.add(qtyEntered); // 1-Qty
KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(4).trim());
line.add(pp); // 2-UOM
// Add locator
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
line.add(pp); // 3-Locator
// Add product
pp = new KeyNamePair(rs.getInt(7), rs.getString(8));
line.add(pp); // 4-Product
line.add(rs.getString(9)); // 5-VendorProductNo
pp = new KeyNamePair(rs.getInt(10), rs.getString(11));
line.add(pp); // 6-OrderLine
line.add(null); // 7-Ship
line.add(null); // 8-Invoice
data.add(line);
}
rs.close();
pstmt.close();
}
catch (Exception e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
loadTableOIS (data);
} // LoadOrder
/**
* Load Data - Invoice
* @param C_Invoice_ID Invoice
*
* Selected - 0
* Qty - 1
* C_UOM_ID - 2
* M_Locator_ID - 3
* M_Product_ID - 4
* VendorProductNo - 5
* OrderLine - 6
* ShipmentLine - 7
* InvoiceLine - 8
*/
private void loadInvoice(int C_Invoice_ID) {
log.config("C_Invoice_ID=" + C_Invoice_ID);
@ -331,9 +581,10 @@ 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, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line," // 5..9
+ " l.C_OrderLine_ID "
+ " FROM C_InvoiceLine l "); // 10
+ " p.M_Locator_ID, COALESCE(loc.value,''), " // 5..6
+ " l.M_Product_ID,p.Name, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line," // 7..11
+ " l.C_OrderLine_ID " // 12
+ " FROM C_InvoiceLine l ");
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)");
else
@ -341,6 +592,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
.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(" LEFT OUTER JOIN M_Locator loc on (p.M_Locator_ID=loc.M_Locator_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)")
@ -348,6 +600,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
.append(" WHERE l.C_Invoice_ID=? AND l.QtyInvoiced<>0 ")
.append("GROUP BY l.QtyInvoiced,l.QtyEntered/l.QtyInvoiced,"
+ "l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name),"
+ "p.M_Locator_ID, COALESCE(loc.value,''), "
+ "l.M_Product_ID,p.Name, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line,l.C_OrderLine_ID ")
.append("ORDER BY l.Line");
@ -364,17 +617,21 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
line.add(qtyEntered); // 1-Qty
KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(4).trim());
line.add(pp); // 2-UOM
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
line.add(pp); // 3-Product
line.add(rs.getString(7)); // 4-VendorProductNo
int C_OrderLine_ID = rs.getInt(10);
// Add locator
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
line.add(pp); // 3-Locator
pp = new KeyNamePair(rs.getInt(7), rs.getString(8));
line.add(pp); // 4-Product
line.add(rs.getString(9)); // 5-VendorProductNo
int C_OrderLine_ID = rs.getInt(12);
if (rs.wasNull())
line.add(null); // 5-Order
line.add(null); // 6-Order
else
line.add(new KeyNamePair(C_OrderLine_ID, "."));
line.add(null); // 6-Ship
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
line.add(pp); // 7-Invoice
line.add(null); // 7-Ship
pp = new KeyNamePair(rs.getInt(10), rs.getString(11));
line.add(pp); // 8-Invoice
data.add(line);
}
rs.close();
@ -446,13 +703,14 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
line.add(rs.getBigDecimal(3)); // 1-Qty
KeyNamePair pp = new KeyNamePair(rs.getInt(6), rs.getString(7));
line.add(pp); // 2-UOM
line.add(null); // 3-Locator - TODO: Not implemented since RMA is in alpha and can't be tested.
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
line.add(pp); // 3-Product
line.add(null); //4-Vendor Product No
line.add(null); //5-Order
line.add(pp); // 4-Product
line.add(null); //5-Vendor Product No
line.add(null); //6-Order
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
line.add(pp); //6-RMA
line.add(null); //7-invoice
line.add(pp); //7-RMA
line.add(null); //8-invoice
data.add(line);
}
rs.close();
@ -506,12 +764,12 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
if (rows == 0)
return false;
//
Integer loc = (Integer) locatorField.getValue();
if (loc == null || loc.intValue() == 0) {
Integer defaultLoc = (Integer) locatorField.getValue();
if (defaultLoc == null || defaultLoc.intValue() == 0) {
locatorField.setBackground(AdempierePLAF.getFieldBackground_Error());
return false;
}
int M_Locator_ID = loc.intValue();
int M_Locator_ID = defaultLoc.intValue();
// Get Shipment
int M_InOut_ID = ((Integer) p_mTab.getValue("M_InOut_ID")).intValue();
MInOut inout = new MInOut(Env.getCtx(), M_InOut_ID, null);
@ -521,22 +779,27 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
for (int i = 0; i < rows; i++) {
if (((Boolean) model.getValueAt(i, 0)).booleanValue()) {
// variable values
BigDecimal QtyEntered = (BigDecimal) model.getValueAt(i, 1); // 1-Qty
KeyNamePair pp = (KeyNamePair) model.getValueAt(i, 2); // 2-UOM
BigDecimal QtyEntered = (BigDecimal) model.getValueAt(i, COL_QTY); // Qty
KeyNamePair pp = (KeyNamePair) model.getValueAt(i, COL_UOM); // UOM
int C_UOM_ID = pp.getKey();
pp = (KeyNamePair) model.getValueAt(i, 3); // 3-Product
pp = (KeyNamePair) model.getValueAt(i, COL_LOCATOR_ID); // Locator
// If a locator is specified on the product, choose that otherwise default locator
M_Locator_ID = pp!=null ? pp.getKey() : defaultLoc.intValue();
pp = (KeyNamePair) model.getValueAt(i, COL_PRODUCT_ID); // Product
int M_Product_ID = pp.getKey();
int C_OrderLine_ID = 0;
pp = (KeyNamePair) model.getValueAt(i, 5); // 5-OrderLine
pp = (KeyNamePair) model.getValueAt(i, COL_ORDER_ID); // OrderLine
if (pp != null)
C_OrderLine_ID = pp.getKey();
int M_RMALine_ID = 0;
pp = (KeyNamePair) model.getValueAt(i, 6); // 6-RMA
if (pp != null)
M_RMALine_ID = pp.getKey();
int M_RMALine_ID = 0;
pp = (KeyNamePair) model.getValueAt(i, COL_RMA_ID); // RMA
// If we have RMA
if (pp != null)
M_RMALine_ID = pp.getKey();
int C_InvoiceLine_ID = 0;
MInvoiceLine il = null;
pp = (KeyNamePair) model.getValueAt(i, 7); // 7-InvoiceLine
pp = (KeyNamePair) model.getValueAt(i, COL_INVOICE_ID); // InvoiceLine
if (pp != null)
C_InvoiceLine_ID = pp.getKey();
if (C_InvoiceLine_ID != 0)
@ -570,7 +833,6 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
{
iol.setC_OrderLine_ID(C_OrderLine_ID);
ol = new MOrderLine (Env.getCtx(), C_OrderLine_ID, null);
// iol.setOrderLine(ol, M_Locator_ID, QtyEntered);
if (ol.getQtyEntered().compareTo(ol.getQtyOrdered()) != 0)
{
iol.setMovementQty(QtyEntered
@ -592,7 +854,6 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
}
else if (il != null)
{
// iol.setInvoiceLine(il, M_Locator_ID, QtyEntered);
if (il.getQtyEntered().compareTo(il.getQtyInvoiced()) != 0)
{
iol.setQtyEntered(QtyEntered
@ -610,21 +871,21 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
iol.setUser1_ID(il.getUser1_ID());
iol.setUser2_ID(il.getUser2_ID());
}
else if (M_RMALine_ID != 0)
{
rmal = new MRMALine(Env.getCtx(), M_RMALine_ID, null);
iol.setM_RMALine_ID(M_RMALine_ID);
iol.setQtyEntered(QtyEntered);
iol.setDescription(rmal.getDescription());
iol.setM_AttributeSetInstance_ID(rmal.getM_AttributeSetInstance_ID());
iol.setC_Project_ID(rmal.getC_Project_ID());
iol.setC_ProjectPhase_ID(rmal.getC_ProjectPhase_ID());
iol.setC_ProjectTask_ID(rmal.getC_ProjectTask_ID());
iol.setC_Activity_ID(rmal.getC_Activity_ID());
iol.setAD_OrgTrx_ID(rmal.getAD_OrgTrx_ID());
iol.setUser1_ID(rmal.getUser1_ID());
iol.setUser2_ID(rmal.getUser2_ID());
}
else if (M_RMALine_ID != 0)
{
rmal = new MRMALine(Env.getCtx(), M_RMALine_ID, null);
iol.setM_RMALine_ID(M_RMALine_ID);
iol.setQtyEntered(QtyEntered);
iol.setDescription(rmal.getDescription());
iol.setM_AttributeSetInstance_ID(rmal.getM_AttributeSetInstance_ID());
iol.setC_Project_ID(rmal.getC_Project_ID());
iol.setC_ProjectPhase_ID(rmal.getC_ProjectPhase_ID());
iol.setC_ProjectTask_ID(rmal.getC_ProjectTask_ID());
iol.setC_Activity_ID(rmal.getC_Activity_ID());
iol.setAD_OrgTrx_ID(rmal.getAD_OrgTrx_ID());
iol.setUser1_ID(rmal.getUser1_ID());
iol.setUser2_ID(rmal.getUser2_ID());
}
// Charge
if (M_Product_ID == 0)
@ -636,7 +897,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
else if (rmal != null && rmal.getC_Charge_ID() != 0) // from rma
iol.setC_Charge_ID(rmal.getC_Charge_ID());
}
//
// Set locator
iol.setM_Locator_ID(M_Locator_ID);
if (!iol.save())
log.log(Level.SEVERE, "Line NOT created #" + i);
@ -663,15 +924,15 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
inout.setC_Activity_ID(p_order.getC_Activity_ID());
inout.setUser1_ID(p_order.getUser1_ID());
inout.setUser2_ID(p_order.getUser2_ID());
if ( p_order.isDropShip() )
if ( p_order.isDropShip() )
{
inout.setM_Warehouse_ID( p_order.getM_Warehouse_ID() );
inout.setIsDropShip(p_order.isDropShip());
inout.setDropShip_BPartner_ID(p_order.getDropShip_BPartner_ID());
inout.setDropShip_Location_ID(p_order.getDropShip_Location_ID());
inout.setDropShip_User_ID(p_order.getDropShip_User_ID());
}
}
}
if (m_invoice != null && m_invoice.getC_Invoice_ID() != 0)
{