[ 1756793 ] RMA Feature
- Incorporate bug fix from client production site.
This commit is contained in:
parent
4d45c2eb8a
commit
811584d0ad
|
@ -45,6 +45,7 @@ public class AZoomAcross implements ActionListener
|
||||||
public AZoomAcross (JComponent invoker, String tableName, MQuery query)
|
public AZoomAcross (JComponent invoker, String tableName, MQuery query)
|
||||||
{
|
{
|
||||||
log.config("TableName=" + tableName + " - " + query);
|
log.config("TableName=" + tableName + " - " + query);
|
||||||
|
m_tableName = tableName;
|
||||||
m_query = query;
|
m_query = query;
|
||||||
|
|
||||||
// See What is there
|
// See What is there
|
||||||
|
@ -59,6 +60,8 @@ public class AZoomAcross implements ActionListener
|
||||||
private ArrayList<KeyNamePair> m_list = new ArrayList<KeyNamePair>();
|
private ArrayList<KeyNamePair> m_list = new ArrayList<KeyNamePair>();
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger log = CLogger.getCLogger(AZoomAcross.class);
|
private static CLogger log = CLogger.getCLogger(AZoomAcross.class);
|
||||||
|
/** Table Name */
|
||||||
|
private String m_tableName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Zomm Targets for the table.
|
* Get the Zomm Targets for the table.
|
||||||
|
@ -162,7 +165,19 @@ public class AZoomAcross implements ActionListener
|
||||||
+ " WHERE " + m_query.getWhereClause(false);
|
+ " WHERE " + m_query.getWhereClause(false);
|
||||||
String sqlAdd = "";
|
String sqlAdd = "";
|
||||||
if (isSO != null)
|
if (isSO != null)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
For RMA, Material Receipt window should be loaded for IsSOTrx=true
|
||||||
|
and Shipment for IsSOTrx=false
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (MRMA.Table_Name.equals(m_tableName) && (AD_Window_ID == 169
|
||||||
|
|| AD_Window_ID == 184))
|
||||||
|
{
|
||||||
|
isSO = !isSO;
|
||||||
|
}
|
||||||
sqlAdd = " AND IsSOTrx=" + (isSO.booleanValue() ? "'Y'" : "'N'");
|
sqlAdd = " AND IsSOTrx=" + (isSO.booleanValue() ? "'Y'" : "'N'");
|
||||||
|
}
|
||||||
int count = DB.getSQLValue(null, sql+sqlAdd);
|
int count = DB.getSQLValue(null, sql+sqlAdd);
|
||||||
if (count < 0 && isSO != null) // error try again w/o SO
|
if (count < 0 && isSO != null) // error try again w/o SO
|
||||||
count = DB.getSQLValue(null, sql);
|
count = DB.getSQLValue(null, sql);
|
||||||
|
|
|
@ -254,7 +254,7 @@ public class VInvoiceGen extends CPanel
|
||||||
sql.append("INNER JOIN C_BPartner bp ON rma.C_BPartner_ID=bp.C_BPartner_ID ");
|
sql.append("INNER JOIN C_BPartner bp ON rma.C_BPartner_ID=bp.C_BPartner_ID ");
|
||||||
sql.append("INNER JOIN M_InOut io ON rma.InOut_ID=io.M_InOut_ID ");
|
sql.append("INNER JOIN M_InOut io ON rma.InOut_ID=io.M_InOut_ID ");
|
||||||
sql.append("WHERE rma.DocStatus='CO' ");
|
sql.append("WHERE rma.DocStatus='CO' ");
|
||||||
sql.append("AND dt.DocBaseType = 'POO' ");
|
sql.append("AND dt.DocBaseType = 'SOO' ");
|
||||||
sql.append("AND NOT EXISTS (SELECT * FROM C_Invoice i ");
|
sql.append("AND NOT EXISTS (SELECT * FROM C_Invoice i ");
|
||||||
sql.append("WHERE i.M_RMA_ID=rma.M_RMA_ID AND i.DocStatus IN ('IP', 'CO', 'CL')) ");
|
sql.append("WHERE i.M_RMA_ID=rma.M_RMA_ID AND i.DocStatus IN ('IP', 'CO', 'CL')) ");
|
||||||
sql.append("AND EXISTS (SELECT * FROM C_InvoiceLine il INNER JOIN M_InOutLine iol ");
|
sql.append("AND EXISTS (SELECT * FROM C_InvoiceLine il INNER JOIN M_InOutLine iol ");
|
||||||
|
|
|
@ -65,6 +65,12 @@ public abstract class VCreateFrom extends CDialog
|
||||||
retValue = new VCreateFromShipment (mTab);
|
retValue = new VCreateFromShipment (mTab);
|
||||||
else if (AD_Table_ID == 426) // C_PaySelection
|
else if (AD_Table_ID == 426) // C_PaySelection
|
||||||
return null; // ignore - will call process C_PaySelection_CreateFrom
|
return null; // ignore - will call process C_PaySelection_CreateFrom
|
||||||
|
/**
|
||||||
|
* Modification to support create Lines from for RMA
|
||||||
|
* @author ashley
|
||||||
|
*/
|
||||||
|
else if (AD_Table_ID == 661)
|
||||||
|
retValue = new VCreateFromRMA(mTab); // RMA
|
||||||
else // Not supported CreateFrom
|
else // Not supported CreateFrom
|
||||||
{
|
{
|
||||||
s_log.info("Unsupported AD_Table_ID=" + AD_Table_ID);
|
s_log.info("Unsupported AD_Table_ID=" + AD_Table_ID);
|
||||||
|
@ -132,7 +138,7 @@ public abstract class VCreateFrom extends CDialog
|
||||||
private GridBagLayout parameterStdLayout = new GridBagLayout();
|
private GridBagLayout parameterStdLayout = new GridBagLayout();
|
||||||
private GridBagLayout parameterBankLayout = new GridBagLayout();
|
private GridBagLayout parameterBankLayout = new GridBagLayout();
|
||||||
protected VLookup bPartnerField;
|
protected VLookup bPartnerField;
|
||||||
private JLabel orderLabel = new JLabel();
|
protected JLabel orderLabel = new JLabel();
|
||||||
protected JComboBox orderField = new JComboBox();
|
protected JComboBox orderField = new JComboBox();
|
||||||
protected JLabel invoiceLabel = new JLabel();
|
protected JLabel invoiceLabel = new JLabel();
|
||||||
protected JComboBox invoiceField = new JComboBox();
|
protected JComboBox invoiceField = new JComboBox();
|
||||||
|
|
|
@ -46,6 +46,8 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
||||||
|
|
||||||
private boolean m_actionActive = false;
|
private boolean m_actionActive = false;
|
||||||
private MInOut m_inout = null;
|
private MInOut m_inout = null;
|
||||||
|
/** Loaded RMA */
|
||||||
|
private MRMA m_rma = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamic Init
|
* Dynamic Init
|
||||||
|
@ -63,9 +65,14 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
||||||
locatorLabel.setVisible(false);
|
locatorLabel.setVisible(false);
|
||||||
locatorField.setVisible(false);
|
locatorField.setVisible(false);
|
||||||
|
|
||||||
// Do not display RMA document selection
|
// RMA Selection option should only be available for AP Credit Memo
|
||||||
rmaLabel.setVisible(false);
|
Integer docTypeId = (Integer)p_mTab.getValue("C_DocTypeTarget_ID");
|
||||||
rmaField.setVisible(false);
|
MDocType docType = MDocType.get(Env.getCtx(), docTypeId);
|
||||||
|
if (!MDocType.DOCBASETYPE_APCreditMemo.equals(docType.getDocBaseType()))
|
||||||
|
{
|
||||||
|
rmaLabel.setVisible(false);
|
||||||
|
rmaField.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
initBPartner(true);
|
initBPartner(true);
|
||||||
bPartnerField.addVetoableChangeListener(this);
|
bPartnerField.addVetoableChangeListener(this);
|
||||||
|
@ -77,6 +84,16 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
*/
|
*/
|
||||||
protected void initBPDetails(int C_BPartner_ID)
|
protected void initBPDetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
initBPShipmentDetails(C_BPartner_ID);
|
||||||
|
initBPRMADetails(C_BPartner_ID);
|
||||||
|
} // initDetails
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param C_BPartner_ID
|
||||||
|
*/
|
||||||
|
private void initBPShipmentDetails(int C_BPartner_ID)
|
||||||
{
|
{
|
||||||
log.config("C_BPartner_ID" + C_BPartner_ID);
|
log.config("C_BPartner_ID" + C_BPartner_ID);
|
||||||
|
|
||||||
|
@ -119,8 +136,61 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
||||||
}
|
}
|
||||||
shipmentField.setSelectedIndex(0);
|
shipmentField.setSelectedIndex(0);
|
||||||
shipmentField.addActionListener(this);
|
shipmentField.addActionListener(this);
|
||||||
} // initDetails
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load RMA that are candidates for shipment
|
||||||
|
* @param C_BPartner_ID BPartner
|
||||||
|
*/
|
||||||
|
private void initBPRMADetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
rmaField.removeActionListener(this);
|
||||||
|
rmaField.removeAllItems();
|
||||||
|
// None
|
||||||
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
|
rmaField.addItem(pp);
|
||||||
|
|
||||||
|
String sqlStmt = "SELECT r.M_RMA_ID, r.DocumentNo || '-' || r.Amt from M_RMA r "
|
||||||
|
+ "WHERE ISSOTRX='N' AND r.DocStatus in ('CO', 'CL') "
|
||||||
|
+ "AND r.C_BPartner_ID=? "
|
||||||
|
+ "AND NOT EXISTS (SELECT * FROM C_Invoice inv "
|
||||||
|
+ "WHERE inv.M_RMA_ID=r.M_RMA_ID AND inv.DocStatus IN ('CO', 'CL'))";
|
||||||
|
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sqlStmt, null);
|
||||||
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
|
{
|
||||||
|
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||||
|
rmaField.addItem(pp);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sqlStmt.toString(), e);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.severe("Could not close prepared statement");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rmaField.setSelectedIndex(0);
|
||||||
|
rmaField.addActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action Listener
|
* Action Listener
|
||||||
* @param e event
|
* @param e event
|
||||||
|
@ -139,8 +209,9 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
||||||
int C_Order_ID = 0;
|
int C_Order_ID = 0;
|
||||||
if (pp != null)
|
if (pp != null)
|
||||||
C_Order_ID = pp.getKey();
|
C_Order_ID = pp.getKey();
|
||||||
// set Invoice and Shipment to Null
|
// set Invoice, RMA and Shipment to Null
|
||||||
invoiceField.setSelectedIndex(-1);
|
invoiceField.setSelectedIndex(-1);
|
||||||
|
rmaField.setSelectedIndex(-1);
|
||||||
shipmentField.setSelectedIndex(-1);
|
shipmentField.setSelectedIndex(-1);
|
||||||
loadOrder(C_Order_ID, true);
|
loadOrder(C_Order_ID, true);
|
||||||
}
|
}
|
||||||
|
@ -151,11 +222,25 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
||||||
int M_InOut_ID = 0;
|
int M_InOut_ID = 0;
|
||||||
if (pp != null)
|
if (pp != null)
|
||||||
M_InOut_ID = pp.getKey();
|
M_InOut_ID = pp.getKey();
|
||||||
// set Order and Invoice to Null
|
// set Order, RMA and Invoice to Null
|
||||||
orderField.setSelectedIndex(-1);
|
orderField.setSelectedIndex(-1);
|
||||||
|
rmaField.setSelectedIndex(-1);
|
||||||
invoiceField.setSelectedIndex(-1);
|
invoiceField.setSelectedIndex(-1);
|
||||||
loadShipment(M_InOut_ID);
|
loadShipment(M_InOut_ID);
|
||||||
}
|
}
|
||||||
|
// RMA
|
||||||
|
else if (e.getSource().equals(rmaField))
|
||||||
|
{
|
||||||
|
KeyNamePair pp = (KeyNamePair)rmaField.getSelectedItem();
|
||||||
|
int M_RMA_ID = 0;
|
||||||
|
if (pp != null)
|
||||||
|
M_RMA_ID = pp.getKey();
|
||||||
|
// set Order and Invoice to Null
|
||||||
|
orderField.setSelectedIndex(-1);
|
||||||
|
invoiceField.setSelectedIndex(-1);
|
||||||
|
shipmentField.setSelectedIndex(-1);
|
||||||
|
loadRMA(M_RMA_ID);
|
||||||
|
}
|
||||||
m_actionActive = false;
|
m_actionActive = false;
|
||||||
} // actionPerformed
|
} // actionPerformed
|
||||||
|
|
||||||
|
@ -240,7 +325,7 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
||||||
line.add(new KeyNamePair(C_OrderLine_ID,"."));
|
line.add(new KeyNamePair(C_OrderLine_ID,"."));
|
||||||
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
|
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
|
||||||
line.add(pp); // 6-Ship
|
line.add(pp); // 6-Ship
|
||||||
line.add(null); // 7-Invoice
|
line.add(null); // 7-RMA
|
||||||
data.add(line);
|
data.add(line);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
|
@ -252,6 +337,98 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
||||||
}
|
}
|
||||||
loadTableOIS (data);
|
loadTableOIS (data);
|
||||||
} // loadShipment
|
} // loadShipment
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load RMA details
|
||||||
|
* @param M_RMA_ID RMA
|
||||||
|
*/
|
||||||
|
private void loadRMA(int M_RMA_ID)
|
||||||
|
{
|
||||||
|
p_order = null;
|
||||||
|
|
||||||
|
m_rma = new MRMA(Env.getCtx(), M_RMA_ID, null);
|
||||||
|
|
||||||
|
Vector<Vector> data = new Vector<Vector>();
|
||||||
|
StringBuffer sqlStmt = new StringBuffer();
|
||||||
|
sqlStmt.append("SELECT rl.M_RMALine_ID, rl.line, rl.Qty - rl.QtyDelivered, iol.M_Product_ID, p.Name, uom.C_UOM_ID, COALESCE(uom.UOMSymbol,uom.Name) ");
|
||||||
|
sqlStmt.append("FROM M_RMALine rl INNER JOIN M_InOutLine iol ON rl.M_InOutLine_ID=iol.M_InOutLine_ID ");
|
||||||
|
|
||||||
|
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
|
||||||
|
{
|
||||||
|
sqlStmt.append("LEFT OUTER JOIN C_UOM uom ON (uom.C_UOM_ID=iol.C_UOM_ID) ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sqlStmt.append("LEFT OUTER JOIN C_UOM_Trl uom ON (uom.C_UOM_ID=iol.C_UOM_ID AND uom.AD_Language='");
|
||||||
|
sqlStmt.append(Env.getAD_Language(Env.getCtx())).append("') ");
|
||||||
|
}
|
||||||
|
sqlStmt.append("LEFT OUTER JOIN M_Product p ON p.M_Product_ID=iol.M_Product_ID ");
|
||||||
|
sqlStmt.append("WHERE rl.M_RMA_ID=? ");
|
||||||
|
sqlStmt.append("AND rl.M_INOUTLINE_ID IS NOT NULL");
|
||||||
|
|
||||||
|
sqlStmt.append(" UNION ");
|
||||||
|
|
||||||
|
sqlStmt.append("SELECT rl.M_RMALine_ID, rl.line, rl.Qty - rl.QtyDelivered, 0, c.Name, uom.C_UOM_ID, COALESCE(uom.UOMSymbol,uom.Name) ");
|
||||||
|
sqlStmt.append("FROM M_RMALine rl INNER JOIN C_Charge c ON c.C_Charge_ID = rl.C_Charge_ID ");
|
||||||
|
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
|
||||||
|
{
|
||||||
|
sqlStmt.append("LEFT OUTER JOIN C_UOM uom ON (uom.C_UOM_ID=100) ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sqlStmt.append("LEFT OUTER JOIN C_UOM_Trl uom ON (uom.C_UOM_ID=100 AND uom.AD_Language='");
|
||||||
|
sqlStmt.append(Env.getAD_Language(Env.getCtx())).append("') ");
|
||||||
|
}
|
||||||
|
sqlStmt.append("WHERE rl.M_RMA_ID=? ");
|
||||||
|
sqlStmt.append("AND rl.C_Charge_ID IS NOT NULL");
|
||||||
|
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sqlStmt.toString(), null);
|
||||||
|
pstmt.setInt(1, M_RMA_ID);
|
||||||
|
pstmt.setInt(2, M_RMA_ID);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next())
|
||||||
|
{
|
||||||
|
Vector<Object> line = new Vector<Object>(7);
|
||||||
|
line.add(new Boolean(false)); // 0-Selection
|
||||||
|
line.add(rs.getBigDecimal(3).doubleValue()); // 1-Qty
|
||||||
|
KeyNamePair pp = new KeyNamePair(rs.getInt(6), rs.getString(7));
|
||||||
|
line.add(pp); // 2-UOM
|
||||||
|
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
|
||||||
|
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||||
|
line.add(null); //6-Ship
|
||||||
|
line.add(pp); //7-RMA
|
||||||
|
data.add(line);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sqlStmt.toString(), ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.severe("Could not close prepared statement");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadTableOIS(data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List number of rows selected
|
* List number of rows selected
|
||||||
|
@ -416,5 +593,37 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
||||||
return true;
|
return true;
|
||||||
} // saveInvoice
|
} // saveInvoice
|
||||||
|
|
||||||
|
@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_InOut_ID", false));
|
||||||
|
columnNames.add(Msg.getElement(Env.getCtx(), "M_RMA_ID", false));
|
||||||
|
|
||||||
|
// Remove previous listeners
|
||||||
|
dataTable.getModel().removeTableModelListener(this);
|
||||||
|
// Set Model
|
||||||
|
DefaultTableModel model = new DefaultTableModel(data, columnNames);
|
||||||
|
model.addTableModelListener(this);
|
||||||
|
dataTable.setModel(model);
|
||||||
|
//
|
||||||
|
dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
|
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-VendorProductNo
|
||||||
|
dataTable.setColumnClass(5, String.class, true); // 5-Order
|
||||||
|
dataTable.setColumnClass(6, String.class, true); // 6-Ship
|
||||||
|
dataTable.setColumnClass(7, String.class, true); // 7-RMA
|
||||||
|
// Table UI
|
||||||
|
dataTable.autoSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // VCreateFromInvoice
|
} // VCreateFromInvoice
|
||||||
|
|
|
@ -0,0 +1,238 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 2007 Adempiere, 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. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.grid;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.MRMA;
|
||||||
|
import org.compiere.model.MRMALine;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ashley
|
||||||
|
*/
|
||||||
|
public class VCreateFromRMA extends VCreateFrom
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mTab
|
||||||
|
*/
|
||||||
|
VCreateFromRMA(GridTab mTab)
|
||||||
|
{
|
||||||
|
super(mTab);
|
||||||
|
log.info(mTab.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean dynInit() throws Exception
|
||||||
|
{
|
||||||
|
log.config("");
|
||||||
|
setTitle("Customer RMA - Create Lines From");
|
||||||
|
|
||||||
|
parameterBankPanel.setVisible(false);
|
||||||
|
|
||||||
|
invoiceLabel.setVisible(false);
|
||||||
|
invoiceField.setVisible(false);
|
||||||
|
|
||||||
|
locatorLabel.setVisible(false);
|
||||||
|
locatorField.setVisible(false);
|
||||||
|
|
||||||
|
orderLabel.setVisible(false);
|
||||||
|
orderField.setVisible(false);
|
||||||
|
|
||||||
|
shipmentLabel.setVisible(false);
|
||||||
|
shipmentField.setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
|
rmaLabel.setVisible(false);
|
||||||
|
rmaField.setVisible(false);
|
||||||
|
|
||||||
|
initBPartner(true);
|
||||||
|
|
||||||
|
bPartnerField.setEnabled(false);
|
||||||
|
|
||||||
|
int inOutId = Env.getContextAsInt(Env.getCtx(), p_mTab.getWindowNo(), "InOut_ID");
|
||||||
|
|
||||||
|
loadShipment(inOutId);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Order/Invoice/Shipment data into Table
|
||||||
|
* @param data data
|
||||||
|
*/
|
||||||
|
protected void loadTableOIS (Vector data)
|
||||||
|
{
|
||||||
|
// Header Info
|
||||||
|
Vector<String> columnNames = new Vector<String>(7);
|
||||||
|
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
||||||
|
columnNames.add("Line");
|
||||||
|
columnNames.add(Msg.translate(Env.getCtx(), "M_Product_ID"));
|
||||||
|
columnNames.add("ASI");
|
||||||
|
columnNames.add(Msg.translate(Env.getCtx(), "Quantity"));
|
||||||
|
columnNames.add(Msg.getElement(Env.getCtx(), "QtyDelivered", false));
|
||||||
|
|
||||||
|
|
||||||
|
// Remove previous listeners
|
||||||
|
dataTable.getModel().removeTableModelListener(this);
|
||||||
|
// Set Model
|
||||||
|
DefaultTableModel model = new DefaultTableModel(data, columnNames);
|
||||||
|
model.addTableModelListener(this);
|
||||||
|
dataTable.setModel(model);
|
||||||
|
//
|
||||||
|
dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
|
dataTable.setColumnClass(1, String.class, true); // 1-Line
|
||||||
|
dataTable.setColumnClass(2, String.class, true); // 2-Product
|
||||||
|
dataTable.setColumnClass(3, String.class, true); // 3-ASI
|
||||||
|
dataTable.setColumnClass(4, Double.class, true); // 4-Qty
|
||||||
|
dataTable.setColumnClass(5, Double.class, true); // 5-Delivered Qty
|
||||||
|
|
||||||
|
// Table UI
|
||||||
|
dataTable.autoSize();
|
||||||
|
} // loadOrder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Data - Shipment not invoiced
|
||||||
|
* @param M_InOut_ID InOut
|
||||||
|
*/
|
||||||
|
private void loadShipment (int M_InOut_ID)
|
||||||
|
{
|
||||||
|
int m_rma_id = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "M_RMA_ID");
|
||||||
|
log.config("M_InOut_ID=" + M_InOut_ID);
|
||||||
|
log.config("M_RMA_ID=" + m_rma_id);
|
||||||
|
//
|
||||||
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1 M_InOutLine_ID
|
||||||
|
* 2 Line
|
||||||
|
* 3 Product Name
|
||||||
|
* 4 Qty Entered
|
||||||
|
* 5 Movement Qty
|
||||||
|
* 6 ASI
|
||||||
|
*/
|
||||||
|
StringBuffer sqlStmt = new StringBuffer();
|
||||||
|
|
||||||
|
sqlStmt.append("SELECT iol.M_InOutLine_ID, iol.Line, ");
|
||||||
|
sqlStmt.append("CASE WHEN iol.M_Product_ID IS NOT NULL THEN (Select p.Name from M_Product p where p.M_Product_ID = iol.M_Product_ID) END as ProductName, ");
|
||||||
|
sqlStmt.append("iol.QtyEntered, ");
|
||||||
|
sqlStmt.append("iol.movementQty, ");
|
||||||
|
sqlStmt.append("CASE WHEN iol.M_AttributeSetInstance_ID IS NOT NULL THEN (SELECT SerNo FROM M_AttributeSetInstance asi where asi.M_AttributeSetInstance_ID=iol.M_AttributeSetInstance_ID) END as ASI ");
|
||||||
|
sqlStmt.append("from M_InOutLine iol where M_InOut_ID=? ");
|
||||||
|
sqlStmt.append("and iol.M_InOutLine_ID not in (select rmal.M_InOutLine_ID from M_RMALine rmal where rmal.M_RMA_ID=?)");
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sqlStmt.toString(), null);
|
||||||
|
pstmt.setInt(1, M_InOut_ID);
|
||||||
|
pstmt.setInt(2, m_rma_id);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
|
{
|
||||||
|
Vector<Object> line = new Vector<Object>(7);
|
||||||
|
line.add(new Boolean(false)); // 0-Selection
|
||||||
|
|
||||||
|
KeyNamePair lineKNPair = new KeyNamePair(rs.getInt(1), rs.getString(2)); // 1-Line
|
||||||
|
line.add(lineKNPair);
|
||||||
|
line.add(rs.getString(3)); //2-Product
|
||||||
|
line.add(rs.getString(6)); //3-ASI
|
||||||
|
|
||||||
|
BigDecimal qtyEntered = rs.getBigDecimal(4);
|
||||||
|
BigDecimal movementQty = rs.getBigDecimal(5);
|
||||||
|
|
||||||
|
line.add(qtyEntered.doubleValue()); //4-Qty
|
||||||
|
line.add(movementQty.doubleValue()); //5-Movement Qty
|
||||||
|
|
||||||
|
|
||||||
|
data.add(line);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sqlStmt.toString(), e);
|
||||||
|
}
|
||||||
|
loadTableOIS (data);
|
||||||
|
} // loadShipment
|
||||||
|
|
||||||
|
protected void initBPDetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void info()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean save()
|
||||||
|
{
|
||||||
|
log.config("");
|
||||||
|
int m_rma_id = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "M_RMA_ID");
|
||||||
|
TableModel model = dataTable.getModel();
|
||||||
|
int rows = model.getRowCount();
|
||||||
|
if (rows == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Integer bpId = (Integer)bPartnerField.getValue();
|
||||||
|
MRMA rma = new MRMA(Env.getCtx(), m_rma_id, null);
|
||||||
|
//update BP
|
||||||
|
// rma.setC_BPartner_ID(bpId);
|
||||||
|
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||||
|
{
|
||||||
|
Double d = (Double)model.getValueAt(i, 5); // 5-Movement Qty
|
||||||
|
KeyNamePair pp = (KeyNamePair)model.getValueAt(i, 1); // 1-Line
|
||||||
|
|
||||||
|
int inOutLineId = pp.getKey();
|
||||||
|
|
||||||
|
MRMALine rmaLine = new MRMALine(Env.getCtx(), 0, null);
|
||||||
|
rmaLine.setM_RMA_ID(m_rma_id);
|
||||||
|
rmaLine.setM_InOutLine_ID(inOutLineId);
|
||||||
|
rmaLine.setQty(new BigDecimal(d));
|
||||||
|
rmaLine.setAD_Org_ID(rma.getAD_Org_ID());
|
||||||
|
if (!rmaLine.save())
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("Could not create RMA Line");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rma.save())
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("Could not update RMA");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -668,7 +668,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
||||||
if (m_rma != null && m_rma.getM_RMA_ID() != 0)
|
if (m_rma != null && m_rma.getM_RMA_ID() != 0)
|
||||||
{
|
{
|
||||||
MInOut originalIO = m_rma.getShipment();
|
MInOut originalIO = m_rma.getShipment();
|
||||||
inout.setIsSOTrx(!m_rma.isSOTrx());
|
inout.setIsSOTrx(m_rma.isSOTrx());
|
||||||
inout.setC_Order_ID(0);
|
inout.setC_Order_ID(0);
|
||||||
inout.setC_Invoice_ID(0);
|
inout.setC_Invoice_ID(0);
|
||||||
inout.setM_RMA_ID(m_rma.getM_RMA_ID());
|
inout.setM_RMA_ID(m_rma.getM_RMA_ID());
|
||||||
|
|
Loading…
Reference in New Issue