BF [ 2007837 ] VCreateFrom.save() should run in trx
https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2007837&group_id=176962
This commit is contained in:
parent
997bf660dc
commit
2e60e57aa4
|
@ -42,6 +42,7 @@ import javax.swing.event.TableModelListener;
|
|||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import org.compiere.apps.ADialog;
|
||||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.apps.AppsAction;
|
||||
import org.compiere.apps.ConfirmPanel;
|
||||
|
@ -71,6 +72,8 @@ import org.compiere.util.DisplayType;
|
|||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
import org.compiere.util.TrxRunnable;
|
||||
|
||||
/**
|
||||
* CreateFrom (Called from GridController.startProcess)
|
||||
|
@ -81,6 +84,7 @@ import org.compiere.util.Msg;
|
|||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
* <li>FR [ 1794050 ] Usability: VCreateFrom OK button always enabled
|
||||
* <li>FR [ 1974354 ] VCreateFrom.create should be more flexible
|
||||
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
|
||||
* @author Victor Perez, e-Evolucion
|
||||
* <li> RF [1811114] http://sourceforge.net/tracker/index.php?func=detail&aid=1811114&group_id=176962&atid=879335
|
||||
* @author Karsten Thiemann, Schaeffer AG
|
||||
|
@ -89,6 +93,11 @@ import org.compiere.util.Msg;
|
|||
public abstract class VCreateFrom extends CDialog
|
||||
implements ActionListener, TableModelListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 7749087067953806144L;
|
||||
|
||||
/**
|
||||
* Register custom VCreateFrom* class
|
||||
* @param ad_table_id
|
||||
|
@ -192,7 +201,7 @@ public abstract class VCreateFrom extends CDialog
|
|||
private static CLogger s_log = CLogger.getCLogger (VCreateFrom.class);
|
||||
|
||||
//
|
||||
private CPanel parameterPanel = new CPanel();
|
||||
protected CPanel parameterPanel = new CPanel();
|
||||
protected CPanel parameterBankPanel = new CPanel();
|
||||
private BorderLayout parameterLayout = new BorderLayout();
|
||||
private JLabel bankAccountLabel = new JLabel();
|
||||
|
@ -458,7 +467,7 @@ public abstract class VCreateFrom extends CDialog
|
|||
* Save & Insert Data
|
||||
* @return true if saved
|
||||
*/
|
||||
abstract boolean save();
|
||||
abstract boolean save(String trxName);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
@ -476,9 +485,24 @@ public abstract class VCreateFrom extends CDialog
|
|||
// OK - Save
|
||||
if (e.getActionCommand().equals(ConfirmPanel.A_OK))
|
||||
{
|
||||
if (save())
|
||||
try
|
||||
{
|
||||
Trx.run(new TrxRunnable()
|
||||
{
|
||||
public void run(String trxName)
|
||||
{
|
||||
if (save(trxName))
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ADialog.error(p_WindowNo, this, "Error", ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
// Cancel
|
||||
else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
|
||||
{
|
||||
|
@ -615,9 +639,9 @@ public abstract class VCreateFrom extends CDialog
|
|||
* InvoiceLine - 7
|
||||
*/
|
||||
log.config("C_Order_ID=" + C_Order_ID);
|
||||
p_order = new MOrder (Env.getCtx(), C_Order_ID, null); // save
|
||||
p_order = new MOrder (Env.getCtx(), C_Order_ID, null);
|
||||
|
||||
Vector<Vector> data = new Vector<Vector>();
|
||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||
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
|
||||
|
@ -644,11 +668,13 @@ public abstract class VCreateFrom extends CDialog
|
|||
+ "ORDER BY l.Line");
|
||||
//
|
||||
log.finer(sql.toString());
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt.setInt(1, C_Order_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
Vector<Object> line = new Vector<Object>();
|
||||
|
@ -668,13 +694,17 @@ public abstract class VCreateFrom extends CDialog
|
|||
line.add(null); // 7-Invoice
|
||||
data.add(line);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
loadTableOIS (data);
|
||||
} // LoadOrder
|
||||
|
||||
|
@ -683,7 +713,7 @@ public abstract class VCreateFrom extends CDialog
|
|||
* Load Order/Invoice/Shipment data into Table
|
||||
* @param data data
|
||||
*/
|
||||
protected void loadTableOIS (Vector data)
|
||||
protected void loadTableOIS (Vector<?> data)
|
||||
{
|
||||
// Header Info
|
||||
Vector<String> columnNames = new Vector<String>(7);
|
||||
|
@ -730,5 +760,4 @@ public abstract class VCreateFrom extends CDialog
|
|||
//
|
||||
confirmPanel.getOKButton().setEnabled(selectedRowCount > 0);
|
||||
}
|
||||
|
||||
} // VCreateFrom
|
||||
|
|
|
@ -53,9 +53,15 @@ import org.compiere.util.Msg;
|
|||
*
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
* <li>BF [ 1896947 ] Generate invoice from Order error
|
||||
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
|
||||
*/
|
||||
public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7102932507855655539L;
|
||||
|
||||
/**
|
||||
* Protected Constructor
|
||||
* @param mTab MTab
|
||||
|
@ -67,7 +73,8 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
} // VCreateFromInvoice
|
||||
|
||||
private boolean m_actionActive = false;
|
||||
private MInOut m_inout = null;
|
||||
// private MInOut m_inout = null;
|
||||
private int m_M_InOut_ID = -1;
|
||||
/** Loaded RMA */
|
||||
private MRMA m_rma = null;
|
||||
|
||||
|
@ -295,10 +302,10 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
private void loadShipment (int M_InOut_ID)
|
||||
{
|
||||
log.config("M_InOut_ID=" + M_InOut_ID);
|
||||
m_inout = new MInOut(Env.getCtx(), M_InOut_ID, null);
|
||||
MInOut inout = new MInOut(Env.getCtx(), M_InOut_ID, null);
|
||||
p_order = null;
|
||||
if (m_inout.getC_Order_ID() != 0)
|
||||
p_order = new MOrder (Env.getCtx(), m_inout.getC_Order_ID(), null);
|
||||
if (inout.getC_Order_ID() != 0)
|
||||
p_order = new MOrder (Env.getCtx(), inout.getC_Order_ID(), null);
|
||||
|
||||
//
|
||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||
|
@ -374,7 +381,7 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
|
||||
m_rma = new MRMA(Env.getCtx(), M_RMA_ID, null);
|
||||
|
||||
Vector<Vector> data = new Vector<Vector>();
|
||||
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 ");
|
||||
|
@ -409,13 +416,13 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
sqlStmt.append("AND rl.C_Charge_ID IS NOT NULL");
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sqlStmt.toString(), null);
|
||||
pstmt.setInt(1, M_RMA_ID);
|
||||
pstmt.setInt(2, M_RMA_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
|
@ -441,17 +448,8 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
}
|
||||
finally
|
||||
{
|
||||
if (pstmt != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
pstmt.close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.severe("Could not close prepared statement");
|
||||
}
|
||||
}
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
loadTableOIS(data);
|
||||
}
|
||||
|
@ -476,7 +474,7 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
* Save - Create Invoice Lines
|
||||
* @return true if saved
|
||||
*/
|
||||
protected boolean save()
|
||||
protected boolean save(String trxName)
|
||||
{
|
||||
dataTable.stopEditor(true);
|
||||
log.config("");
|
||||
|
@ -487,19 +485,25 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
|
||||
// Invoice
|
||||
int C_Invoice_ID = ((Integer)p_mTab.getValue("C_Invoice_ID")).intValue();
|
||||
MInvoice invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, null);
|
||||
MInvoice invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, trxName);
|
||||
log.config(invoice.toString());
|
||||
|
||||
if (p_order != null)
|
||||
{
|
||||
invoice.setOrder(p_order); // overwrite header values
|
||||
invoice.save();
|
||||
invoice.saveEx();
|
||||
}
|
||||
if (m_inout != null && m_inout.getM_InOut_ID() != 0
|
||||
&& m_inout.getC_Invoice_ID() == 0) // only first time
|
||||
|
||||
MInOut inout = null;
|
||||
if (m_M_InOut_ID > 0)
|
||||
{
|
||||
m_inout.setC_Invoice_ID(C_Invoice_ID);
|
||||
m_inout.save();
|
||||
inout = new MInOut(Env.getCtx(), m_M_InOut_ID, trxName);
|
||||
}
|
||||
if (inout != null && inout.getM_InOut_ID() != 0
|
||||
&& inout.getC_Invoice_ID() == 0) // only first time
|
||||
{
|
||||
inout.setC_Invoice_ID(C_Invoice_ID);
|
||||
inout.saveEx();
|
||||
}
|
||||
|
||||
|
||||
|
@ -509,7 +513,7 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||
{
|
||||
// variable values
|
||||
BigDecimal QtyEntered= (BigDecimal)model.getValueAt(i, 1);// 1-Qty
|
||||
BigDecimal QtyEntered = (BigDecimal) model.getValueAt(i, 1); // 1-Qty
|
||||
|
||||
KeyNamePair pp = (KeyNamePair)model.getValueAt(i, 2); // 2-UOM
|
||||
int C_UOM_ID = pp.getKey();
|
||||
|
@ -518,7 +522,6 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
int M_Product_ID = 0;
|
||||
if (pp != null)
|
||||
M_Product_ID = pp.getKey();
|
||||
int C_Charge_ID = 0;
|
||||
//
|
||||
int C_OrderLine_ID = 0;
|
||||
pp = (KeyNamePair)model.getValueAt(i, 5); // 5-OrderLine
|
||||
|
@ -549,22 +552,22 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
// Info
|
||||
MOrderLine orderLine = null;
|
||||
if (C_OrderLine_ID != 0)
|
||||
orderLine = new MOrderLine (Env.getCtx(), C_OrderLine_ID, null);
|
||||
orderLine = new MOrderLine (Env.getCtx(), C_OrderLine_ID, trxName);
|
||||
MInOutLine inoutLine = null;
|
||||
if (M_InOutLine_ID != 0)
|
||||
{
|
||||
inoutLine = new MInOutLine (Env.getCtx(), M_InOutLine_ID, null);
|
||||
inoutLine = new MInOutLine (Env.getCtx(), M_InOutLine_ID, trxName);
|
||||
if (orderLine == null && inoutLine.getC_OrderLine_ID() != 0)
|
||||
{
|
||||
C_OrderLine_ID = inoutLine.getC_OrderLine_ID();
|
||||
orderLine = new MOrderLine (Env.getCtx(), C_OrderLine_ID, null);
|
||||
orderLine = new MOrderLine (Env.getCtx(), C_OrderLine_ID, trxName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String whereClause = "EXISTS (SELECT 1 FROM M_InOut io WHERE io.M_InOut_ID=M_InOutLine.M_InOut_ID AND io.DocStatus IN ('CO','CL'))";
|
||||
MInOutLine[] lines = MInOutLine.getOfOrderLine(Env.getCtx(),
|
||||
C_OrderLine_ID, whereClause, null);
|
||||
C_OrderLine_ID, whereClause, trxName);
|
||||
log.fine ("Receipt Lines with OrderLine = #" + lines.length);
|
||||
if (lines.length > 0)
|
||||
{
|
||||
|
@ -613,8 +616,7 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
invoiceLine.setTax();
|
||||
}
|
||||
}
|
||||
if (!invoiceLine.save())
|
||||
log.log(Level.SEVERE, "Line NOT created #" + i);
|
||||
invoiceLine.saveEx();
|
||||
} // if selected
|
||||
} // for all rows
|
||||
|
||||
|
@ -622,7 +624,8 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
} // saveInvoice
|
||||
|
||||
@Override
|
||||
protected void loadTableOIS(Vector data) {
|
||||
protected void loadTableOIS(Vector<?> data)
|
||||
{
|
||||
// Header Info
|
||||
Vector<String> columnNames = new Vector<String>(7);
|
||||
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
||||
|
|
|
@ -32,10 +32,18 @@ import org.compiere.util.KeyNamePair;
|
|||
import org.compiere.util.Msg;
|
||||
|
||||
/**
|
||||
* Create Transactions for RMA
|
||||
* @author ashley
|
||||
* @author Teo Sarca, www.arhipac.ro
|
||||
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
|
||||
*/
|
||||
public class VCreateFromRMA extends VCreateFrom
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8621409442057992906L;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mTab
|
||||
|
@ -81,11 +89,8 @@ public class VCreateFromRMA extends VCreateFrom
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Order/Invoice/Shipment data into Table
|
||||
* @param data data
|
||||
*/
|
||||
protected void loadTableOIS (Vector data)
|
||||
@Override
|
||||
protected void loadTableOIS (Vector<?> data)
|
||||
{
|
||||
// Header Info
|
||||
Vector<String> columnNames = new Vector<String>(7);
|
||||
|
@ -191,7 +196,7 @@ public class VCreateFromRMA extends VCreateFrom
|
|||
|
||||
}
|
||||
|
||||
protected boolean save()
|
||||
protected boolean save(String trxName)
|
||||
{
|
||||
log.config("");
|
||||
int m_rma_id = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "M_RMA_ID");
|
||||
|
@ -203,7 +208,7 @@ public class VCreateFromRMA extends VCreateFrom
|
|||
}
|
||||
|
||||
// Integer bpId = (Integer)bPartnerField.getValue();
|
||||
MRMA rma = new MRMA(Env.getCtx(), m_rma_id, null);
|
||||
MRMA rma = new MRMA(Env.getCtx(), m_rma_id, trxName);
|
||||
//update BP
|
||||
// rma.setC_BPartner_ID(bpId);
|
||||
|
||||
|
@ -216,7 +221,7 @@ public class VCreateFromRMA extends VCreateFrom
|
|||
|
||||
int inOutLineId = pp.getKey();
|
||||
|
||||
MRMALine rmaLine = new MRMALine(Env.getCtx(), 0, null);
|
||||
MRMALine rmaLine = new MRMALine(rma.getCtx(), 0, rma.get_TrxName());
|
||||
rmaLine.setM_RMA_ID(m_rma_id);
|
||||
rmaLine.setM_InOutLine_ID(inOutLineId);
|
||||
rmaLine.setQty(d);
|
||||
|
@ -227,12 +232,7 @@ public class VCreateFromRMA extends VCreateFrom
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!rma.save())
|
||||
{
|
||||
throw new IllegalStateException("Could not update RMA");
|
||||
}
|
||||
|
||||
rma.saveEx();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,10 +66,16 @@ import org.compiere.util.Msg;
|
|||
* <li> BF 2530254 It is wrong locator in material receipt for outsourced PO's
|
||||
* @see http://sourceforge.net/tracker2/?func=detail&atid=879332&aid=2530254&group_id=176962
|
||||
* @version $Id: VCreateFromShipment.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $
|
||||
*
|
||||
* @author Teo Sarca, www.arhipac.ro
|
||||
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
|
||||
*/
|
||||
public class VCreateFromShipment extends VCreateFrom implements VetoableChangeListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6317997004973385619L;
|
||||
|
||||
/**
|
||||
* Cell editor specific for the MLocator in this form's table.
|
||||
|
@ -194,7 +200,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
* @param data data
|
||||
*/
|
||||
@Override
|
||||
protected void loadTableOIS (Vector data)
|
||||
protected void loadTableOIS (Vector<?> data)
|
||||
{
|
||||
// Header Info
|
||||
Vector<String> columnNames = new Vector<String>(colNames.length);
|
||||
|
@ -291,24 +297,29 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
+ " OR mi.C_InvoiceLine_ID IS NULL) "
|
||||
+ "ORDER BY i.DateInvoiced");
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt.setInt(1, C_BPartner_ID);
|
||||
pstmt.setInt(2, C_BPartner_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||
invoiceField.addItem(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
invoiceField.setSelectedIndex(0);
|
||||
invoiceField.addActionListener(this);
|
||||
upcField.addActionListener(this);
|
||||
|
@ -334,17 +345,17 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
+ "AND rl.M_InOutLine_ID IS NOT NULL)";
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sqlStmt, null);
|
||||
pstmt.setInt(1, C_BPartner_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||
rmaField.addItem(pp);
|
||||
}
|
||||
rs.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
|
@ -352,17 +363,8 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
}
|
||||
finally
|
||||
{
|
||||
if (pstmt != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
pstmt.close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.severe("Could not close prepared statement");
|
||||
}
|
||||
}
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
rmaField.setSelectedIndex(0);
|
||||
rmaField.addActionListener(this);
|
||||
|
@ -794,7 +796,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
*
|
||||
* @return true if saved
|
||||
*/
|
||||
protected boolean save()
|
||||
protected boolean save(String trxName)
|
||||
{
|
||||
dataTable.stopEditor(true);
|
||||
log.config("");
|
||||
|
@ -811,7 +813,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
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);
|
||||
MInOut inout = new MInOut(Env.getCtx(), M_InOut_ID, trxName);
|
||||
log.config(inout + ", C_Locator_ID=" + M_Locator_ID);
|
||||
|
||||
// Lines
|
||||
|
@ -843,7 +845,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
if (pp != null)
|
||||
C_InvoiceLine_ID = pp.getKey();
|
||||
if (C_InvoiceLine_ID != 0)
|
||||
il = new MInvoiceLine (Env.getCtx(), C_InvoiceLine_ID, null);
|
||||
il = new MInvoiceLine (Env.getCtx(), C_InvoiceLine_ID, trxName);
|
||||
//boolean isInvoiced = (C_InvoiceLine_ID != 0);
|
||||
// Precision of Qty UOM
|
||||
int precision = 2;
|
||||
|
@ -872,7 +874,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
if (C_OrderLine_ID != 0)
|
||||
{
|
||||
iol.setC_OrderLine_ID(C_OrderLine_ID);
|
||||
ol = new MOrderLine (Env.getCtx(), C_OrderLine_ID, null);
|
||||
ol = new MOrderLine (Env.getCtx(), C_OrderLine_ID, trxName);
|
||||
if (ol.getQtyEntered().compareTo(ol.getQtyOrdered()) != 0)
|
||||
{
|
||||
iol.setMovementQty(QtyEntered
|
||||
|
@ -913,7 +915,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
}
|
||||
else if (M_RMALine_ID != 0)
|
||||
{
|
||||
rmal = new MRMALine(Env.getCtx(), M_RMALine_ID, null);
|
||||
rmal = new MRMALine(Env.getCtx(), M_RMALine_ID, trxName);
|
||||
iol.setM_RMALine_ID(M_RMALine_ID);
|
||||
iol.setQtyEntered(QtyEntered);
|
||||
iol.setDescription(rmal.getDescription());
|
||||
|
@ -945,7 +947,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
else if (il != null)
|
||||
{
|
||||
il.setM_InOutLine_ID(iol.getM_InOutLine_ID());
|
||||
il.save();
|
||||
il.saveEx();
|
||||
}
|
||||
} // if selected
|
||||
} // for all rows
|
||||
|
@ -1000,7 +1002,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
inout.setUser1_ID(originalIO.getUser1_ID());
|
||||
inout.setUser2_ID(originalIO.getUser2_ID());
|
||||
}
|
||||
inout.save();
|
||||
inout.saveEx();
|
||||
return true;
|
||||
} // save
|
||||
|
||||
|
|
|
@ -58,9 +58,15 @@ import org.compiere.util.Msg;
|
|||
* @version $Id: VCreateFromStatement.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
* @author Victor Perez, e-Evolucion
|
||||
* <li> RF [1811114] http://sourceforge.net/tracker/index.php?func=detail&aid=1811114&group_id=176962&atid=879335
|
||||
* @author Teo Sarca, www.arhipac.ro
|
||||
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
|
||||
*/
|
||||
public class VCreateFromStatement extends VCreateFrom implements ActionListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5544131841459717303L;
|
||||
private MBankAccount bankAccount;
|
||||
|
||||
/**
|
||||
|
@ -298,13 +304,13 @@ public class VCreateFromStatement extends VCreateFrom implements ActionListener
|
|||
|
||||
sql = sql + getSQLWhere() + " ORDER BY p.DateTrx";
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
|
||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
setParameters( pstmt, false);
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
Vector<Object> line = new Vector<Object>(6);
|
||||
|
@ -319,13 +325,16 @@ public class VCreateFromStatement extends VCreateFrom implements ActionListener
|
|||
line.add(rs.getString(8)); // 6-BParner
|
||||
data.add(line);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
// Header Info
|
||||
Vector<String> columnNames = new Vector<String>(6);
|
||||
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
||||
|
@ -380,7 +389,7 @@ public class VCreateFromStatement extends VCreateFrom implements ActionListener
|
|||
* Save Statement - Insert Data
|
||||
* @return true if saved
|
||||
*/
|
||||
protected boolean save()
|
||||
protected boolean save(String trxName)
|
||||
{
|
||||
log.config("");
|
||||
TableModel model = dataTable.getModel();
|
||||
|
@ -390,7 +399,7 @@ public class VCreateFromStatement extends VCreateFrom implements ActionListener
|
|||
|
||||
// fixed values
|
||||
int C_BankStatement_ID = ((Integer)p_mTab.getValue("C_BankStatement_ID")).intValue();
|
||||
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, null);
|
||||
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, trxName);
|
||||
log.config(bs.toString());
|
||||
|
||||
// Lines
|
||||
|
@ -410,7 +419,7 @@ public class VCreateFromStatement extends VCreateFrom implements ActionListener
|
|||
//
|
||||
MBankStatementLine bsl = new MBankStatementLine (bs);
|
||||
bsl.setStatementLineDate(trxDate);
|
||||
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
|
||||
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, trxName));
|
||||
|
||||
bsl.setTrxAmt(TrxAmt);
|
||||
bsl.setStmtAmt(TrxAmt);
|
||||
|
@ -430,15 +439,18 @@ public class VCreateFromStatement extends VCreateFrom implements ActionListener
|
|||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
log.config("Action=" + e.getActionCommand());
|
||||
Object source = e.getSource();
|
||||
if ( e.getActionCommand().equals(confirmPanel.A_REFRESH) ) {
|
||||
// Object source = e.getSource();
|
||||
if ( e.getActionCommand().equals(ConfirmPanel.A_REFRESH) )
|
||||
{
|
||||
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
|
||||
loadBankAccount();
|
||||
tableChanged(null);
|
||||
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
super.actionPerformed(e);
|
||||
}
|
||||
}
|
||||
|
||||
} // VCreateFromStatement
|
||||
|
|
Loading…
Reference in New Issue