* merge revision 6147-6148 changes from branches/adempiere341

This commit is contained in:
Heng Sin Low 2008-08-19 02:08:08 +00:00
parent 7980165ed9
commit a378b8c11c
28 changed files with 2680 additions and 1666 deletions

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Product: Adempiere ERP & CRM Smart Business Solution *
* 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 *
@ -14,104 +14,102 @@
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/**
* 2007, Modified by Posterita Ltd.
*/
package org.adempiere.webui.apps.form;
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 java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.ListModelTable;
import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.event.WTableModelListener;
import org.compiere.model.GridTab;
import org.compiere.model.MInOut;
import org.compiere.model.MInOutLine;
import org.compiere.model.MInvoice;
import org.compiere.model.MInvoiceLine;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MProduct;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.compiere.model.*;
import org.compiere.util.*;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
/**
* Create From Invoice : Based on VCreateFromInvoice
*
* @author Niraj Sohun
* @date Jul 16, 2007
* Create Invoice Transactions from PO Orders or Receipt
*
* @author Jorg Janke
* @version $Id: VCreateFromInvoice.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $
*/
public class WCreateFromInvoice extends WCreateFrom implements EventListener, ValueChangeListener, WTableModelListener
public class WCreateFromInvoice extends WCreateFrom implements ValueChangeListener
{
private static final long serialVersionUID = 1L;
private MInOut m_inout = null;
private boolean m_actionActive;
/**
* Protected Constructor
* @param mTab MTab
*/
public WCreateFromInvoice(GridTab mTab)
WCreateFromInvoice(GridTab mTab)
{
super (mTab);
log.info(mTab.toString());
}
} // VCreateFromInvoice
@Override
protected boolean dynInit() throws Exception
private boolean m_actionActive = false;
private MInOut m_inout = null;
/** Loaded RMA */
private MRMA m_rma = null;
/**
* Dynamic Init
* @throws Exception if Lookups cannot be initialized
* @return true if initialized
*/
protected boolean dynInit() throws Exception
{
log.config("");
setTitle(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
parameterBankPanel.setVisible(false);
parameterShipmentPanel.setVisible(false);
invoiceLabel.setVisible(false);
invoiceField.setVisible(false);
locatorLabel.setVisible(false);
locatorField.setVisible(false);
sameWarehouseCb.setVisible(false);
// RMA Selection option should only be available for AP Credit Memo
Integer docTypeId = (Integer)p_mTab.getValue("C_DocTypeTarget_ID");
MDocType docType = MDocType.get(Env.getCtx(), docTypeId);
if (!MDocType.DOCBASETYPE_APCreditMemo.equals(docType.getDocBaseType()))
{
rmaLabel.setVisible(false);
rmaField.setVisible(false);
}
initBPartner(true);
bPartnerField.addValueChangeListner(this);
return true;
}
} // dynInit
/**
* Init Details - load receipts not invoiced
* @param C_BPartner_ID BPartner
*/
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);
// Load Shipments (Receipts) - Completed, Closed
shipmentField.removeEventListener(Events.ON_SELECT, this);
shipmentField.getChildren().clear();
// None
// load Shipments (Receipts) - Completed, Closed
shipmentField.removeActionListener(this);
shipmentField.removeAllItems();
// None
KeyNamePair pp = new KeyNamePair(0,"");
shipmentField.appendItem(pp.getName(), pp);
shipmentField.addItem(pp);
// Display
StringBuffer display = new StringBuffer("s.DocumentNo||' - '||")
.append(DB.TO_CHAR("s.MovementDate", DisplayType.Date, Env.getAD_Language(Env.getCtx())));
//
StringBuffer sql = new StringBuffer("SELECT s.M_InOut_ID,").append(display)
.append(" FROM M_InOut s "
+ "WHERE s.C_BPartner_ID=? AND s.IsSOTrx='N' AND s.DocStatus IN ('CL','CO')"
@ -122,17 +120,15 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
+ "HAVING (sl.MovementQty<>SUM(mi.Qty) AND mi.M_InOutLine_ID IS NOT NULL)"
+ " OR mi.M_InOutLine_ID IS NULL) "
+ "ORDER BY s.MovementDate");
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
shipmentField.appendItem(pp.getName(), pp);
shipmentField.addItem(pp);
}
rs.close();
pstmt.close();
@ -141,96 +137,156 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
{
log.log(Level.SEVERE, sql.toString(), e);
}
shipmentField.setSelectedIndex(0);
shipmentField.addEventListener(Events.ON_SELECT, this);
shipmentField.addActionListener(this);
}
/**
* 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
* @param e event
* @throws Exception
*/
public void onEvent(Event e) throws Exception
{
super.onEvent(e);
if (m_actionActive)
return;
m_actionActive = true;
log.config("Action=" + e.getTarget());
// Order
if (e.getTarget() == orderField)
log.config("Action=" + e.getTarget().getId());
// Order
if (e.getTarget().equals(orderField))
{
ListItem listitem = orderField.getSelectedItem();
KeyNamePair pp = (KeyNamePair)listitem.getValue();
KeyNamePair pp = orderField.getSelectedItem().toKeyNamePair();
int C_Order_ID = 0;
if (pp != null)
C_Order_ID = pp.getKey();
// Set Invoice and Shipment to Null
// set Invoice, RMA and Shipment to Null
invoiceField.setSelectedIndex(-1);
rmaField.setSelectedIndex(-1);
shipmentField.setSelectedIndex(-1);
loadOrder(C_Order_ID, true);
}
// Shipment
else if (e.getTarget() == shipmentField)
else if (e.getTarget().equals(shipmentField))
{
ListItem listitem = shipmentField.getSelectedItem();
KeyNamePair pp = (KeyNamePair)listitem.getValue();
KeyNamePair pp = shipmentField.getSelectedItem().toKeyNamePair();
int M_InOut_ID = 0;
if (pp != null)
M_InOut_ID = pp.getKey();
// Set Order and Invoice to Null
// set Order, RMA and Invoice to Null
orderField.setSelectedIndex(-1);
rmaField.setSelectedIndex(-1);
invoiceField.setSelectedIndex(-1);
loadShipment(M_InOut_ID);
}
m_actionActive = false;
}
public void valueChange(ValueChangeEvent evt)
{
log.config(evt.getPropertyName() + "=" + evt.getNewValue());
if (evt == null)
return;
if (evt.getSource() instanceof WEditor)
// RMA
else if (e.getTarget().equals(rmaField))
{
if (evt.getPropertyName().equals("C_BPartner_ID"))
{
int C_BPartner_ID = ((Integer)evt.getNewValue()).intValue();
initBPartnerOIS (C_BPartner_ID, true);
}
tableChanged(null);
KeyNamePair pp = rmaField.getSelectedItem().toKeyNamePair();
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);
}
}
private void loadShipment(int M_InOut_ID)
m_actionActive = false;
} // actionPerformed
/**
* Change Listener
* @param e event
*/
public void valueChange (ValueChangeEvent e)
{
log.config(e.getPropertyName() + "=" + e.getNewValue());
// BPartner - load Order/Invoice/Shipment
if (e.getPropertyName().equals("C_BPartner_ID"))
{
int C_BPartner_ID = ((Integer)e.getNewValue()).intValue();
initBPartnerOIS (C_BPartner_ID, true);
}
tableChanged(null);
} // vetoableChange
/**
* Load Data - Shipment not invoiced
* @param M_InOut_ID InOut
*/
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);
p_order = null;
if (m_inout.getC_Order_ID() != 0)
p_order = new MOrder (Env.getCtx(), m_inout.getC_Order_ID(), null);
//
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
StringBuffer sql = new StringBuffer("SELECT " // QtyEntered
StringBuffer sql = new StringBuffer("SELECT " // QtyEntered
+ "l.MovementQty-SUM(NVL(mi.Qty, 0)), l.QtyEntered/l.MovementQty,"
+ " l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name)," // 3..4
+ " l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line," // 5..9
+ " l.C_OrderLine_ID " // 10
+ " l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name)," // 3..4
+ " l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line," // 5..9
+ " l.C_OrderLine_ID " // 10
+ " FROM M_InOutLine l "
);
);
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)");
else
@ -253,35 +309,27 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, M_InOut_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
Vector<Object> line = new Vector<Object>(7);
//line.add(new Boolean(false)); // 0-Selection
line.add(new Boolean(false)); // 0-Selection
BigDecimal qtyMovement = rs.getBigDecimal(1);
BigDecimal multiplier = rs.getBigDecimal(2);
BigDecimal qtyEntered = qtyMovement.multiply(multiplier);
line.add(new Double(qtyEntered.doubleValue())); // 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);
if (rs.wasNull())
line.add(null); // 5-Order
else
line.add(new KeyNamePair(C_OrderLine_ID,"."));
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
line.add(pp); // 6-Ship
line.add(null); // 7-Invoice
line.add(null); // 7-RMA
data.add(line);
}
rs.close();
@ -291,25 +339,116 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
{
log.log(Level.SEVERE, sql.toString(), e);
}
loadTableOIS(data);
loadTableOIS (data);
} // 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);
}
@Override
/**
* List number of rows selected
*/
protected void info()
{
ListModelTable model = dataTable.getModel();
int rows = model.size();
int rows = model.getSize();
int count = 0;
for (int i = 0; i < rows; i++)
{
if (dataTable.getItemAtIndex(i).isSelected())//(((Boolean)model.getDataAt(i, 0)).booleanValue())
if (dataTable.getItemAtIndex(i).isSelected())
count++;
}
}
setStatusLine(count, null);
} // infoInvoice
/**
* Save - Create Invoice Lines
@ -319,99 +458,79 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
{
log.config("");
ListModelTable model = dataTable.getModel();
int rows = model.size();
int rows = model.getSize();
if (rows == 0)
return false;
// Invoice
Object obj = p_mTab.getValue("C_Invoice_ID");
if (obj == null)
throw new IllegalStateException("Company Agent or Business Partner has not been selected");
int C_Invoice_ID = ((Integer)p_mTab.getValue("C_Invoice_ID")).intValue();
MInvoice invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, null);
log.config(invoice.toString());
if (p_order != null)
{
invoice.setOrder(p_order); // Overwrite header values
invoice.setOrder(p_order); // overwrite header values
invoice.save();
}
// Only first time
if (m_inout != null && m_inout.getM_InOut_ID() != 0 && m_inout.getC_Invoice_ID() == 0)
if (m_inout != null && m_inout.getM_InOut_ID() != 0
&& m_inout.getC_Invoice_ID() == 0) // only first time
{
m_inout.setC_Invoice_ID(C_Invoice_ID);
m_inout.save();
}
// Lines
for (int i = 0; i < rows; i++)
{
if (dataTable.getItemAtIndex(i).isSelected())//(((Boolean)model.getDataAt(i, 0)).booleanValue())
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
{
// Variable values
Double d = (Double)model.getDataAt(i, 0); // 1-Qty
// variable values
Double d = (Double)model.getValueAt(i, 1); // 1-Qty
BigDecimal QtyEntered = new BigDecimal(d.doubleValue());
KeyNamePair pp = (KeyNamePair)model.getDataAt(i, 1); // 2-UOM
KeyNamePair pp = (KeyNamePair)model.getValueAt(i, 2); // 2-UOM
int C_UOM_ID = pp.getKey();
pp = (KeyNamePair)model.getDataAt(i, 2); // 3-Product
//
pp = (KeyNamePair)model.getValueAt(i, 3); // 3-Product
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.getDataAt(i, 4); // 5-OrderLine
pp = (KeyNamePair)model.getValueAt(i, 5); // 5-OrderLine
if (pp != null)
C_OrderLine_ID = pp.getKey();
int M_InOutLine_ID = 0;
pp = (KeyNamePair)model.getDataAt(i, 5); // 6-Shipment
pp = (KeyNamePair)model.getValueAt(i, 6); // 6-Shipment
if (pp != null)
M_InOutLine_ID = pp.getKey();
// Precision of Qty UOM
int precision = 2;
if (M_Product_ID != 0)
{
MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
precision = product.getUOMPrecision();
}
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_DOWN);
//
log.fine("Line QtyEntered=" + QtyEntered
+ ", Product_ID=" + M_Product_ID
+ ", OrderLine_ID=" + C_OrderLine_ID + ", InOutLine_ID=" + M_InOutLine_ID);
// Create new Invoice Line
// Create new Invoice Line
MInvoiceLine invoiceLine = new MInvoiceLine (invoice);
invoiceLine.setM_Product_ID(M_Product_ID, C_UOM_ID); // Line UOM
invoiceLine.setQty(QtyEntered); // Invoiced/Entered
// Info
// Info
MOrderLine orderLine = null;
if (C_OrderLine_ID != 0)
orderLine = new MOrderLine (Env.getCtx(), C_OrderLine_ID, null);
MInOutLine inoutLine = null;
if (M_InOutLine_ID != 0)
{
inoutLine = new MInOutLine (Env.getCtx(), M_InOutLine_ID, null);
if (orderLine == null && inoutLine.getC_OrderLine_ID() != 0)
{
C_OrderLine_ID = inoutLine.getC_OrderLine_ID();
@ -421,10 +540,8 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
else
{
MInOutLine[] lines = MInOutLine.getOfOrderLine(Env.getCtx(),
C_OrderLine_ID, null, null);
C_OrderLine_ID, null, null);
log.fine ("Receipt Lines with OrderLine = #" + lines.length);
if (lines.length > 0)
{
for (int j = 0; j < lines.length; j++)
@ -439,32 +556,28 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
}
if (inoutLine == null)
{
inoutLine = lines[0]; // First as default
inoutLine = lines[0]; // first as default
M_InOutLine_ID = inoutLine.getM_InOutLine_ID();
}
}
} // Get Ship info
} // get Ship info
// Shipment Info
if (inoutLine != null)
{
invoiceLine.setShipLine(inoutLine); // Overwrites
invoiceLine.setShipLine(inoutLine); // overwrites
if (inoutLine.getQtyEntered().compareTo(inoutLine.getMovementQty()) != 0)
invoiceLine.setQtyInvoiced(QtyEntered
.multiply(inoutLine.getMovementQty())
.divide(inoutLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
.multiply(inoutLine.getMovementQty())
.divide(inoutLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
}
else
log.fine("No Receipt Line");
// Order Info
if (orderLine != null)
{
invoiceLine.setOrderLine(orderLine); // Overwrites
invoiceLine.setOrderLine(orderLine); // overwrites
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
invoiceLine.setQtyInvoiced(QtyEntered
.multiply(orderLine.getQtyOrdered())
@ -476,12 +589,45 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
invoiceLine.setPrice();
invoiceLine.setTax();
}
if (!invoiceLine.save())
log.log(Level.SEVERE, "Line NOT created #" + i);
} // if selected
} // for all rows
} // if selected
} // for all rows
return true;
} // 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
ListModelTable model = new ListModelTable(data);
model.addTableModelListener(this);
dataTable.setData(model, columnNames);
//
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

View File

@ -0,0 +1,237 @@
/******************************************************************************
* 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.adempiere.webui.apps.form;
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 org.adempiere.webui.component.ListModelTable;
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 WCreateFromRMA extends WCreateFrom
{
/**
*
* @param mTab
*/
WCreateFromRMA(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);
sameWarehouseCb.setVisible(false);
rmaLabel.setVisible(false);
rmaField.setVisible(false);
initBPartner(true);
bPartnerField.setReadWrite(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
ListModelTable model = new ListModelTable(data);
model.addTableModelListener(this);
dataTable.setData(model, columnNames);
//
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");
ListModelTable model = dataTable.getModel();
int rows = model.getSize();
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;
}
}

View File

@ -1,314 +1,311 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* 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 *
*****************************************************************************/
/**
* 2007, Modified by Posterita Ltd.
*/
package org.adempiere.webui.apps.form;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.Vector;
import java.util.logging.Level;
import org.adempiere.webui.component.ListModelTable;
import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WSearchEditor;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.event.WTableModelListener;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.GridTab;
import org.compiere.model.MBankStatement;
import org.compiere.model.MBankStatementLine;
import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory;
import org.compiere.model.MPayment;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.EventListener;
/**
* Create From Statement : Based on VCreateFromStatement
*
* @author Niraj Sohun
* @date Jul 20, 2007
*/
public class WCreateFromStatement extends WCreateFrom implements EventListener, ValueChangeListener, WTableModelListener
{
private static final long serialVersionUID = 1L;
/**
* Protected Constructor
* @param mTab MTab
*/
WCreateFromStatement(GridTab mTab)
{
super(mTab);
//log.info("");
}
/**
* Dynamic Init
* @throws Exception if Lookups cannot be initialized
* @return true if initialized
*/
protected boolean dynInit() throws Exception
{
if (p_mTab.getValue("C_BankStatement_ID") == null)
{
FDialog.error(0, this, "SaveErrorRowNotFound");
return false;
}
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
parameterShipmentPanel.setVisible(false);
parameterInvoicePanel.setVisible(false);
hboxCommon.setVisible(false);
int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
bankAccountField = new WSearchEditor(lookup, "label","desc", true, false, true);
bankAccountField.addValueChangeListner(this);
// Set Default
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
bankAccountField.setValue(new Integer(C_BankAccount_ID));
// Initial Loading
loadBankAccount(C_BankAccount_ID);
return true;
}
/**
* Init Details (never called)
* @param C_BPartner_ID BPartner
*/
protected void initBPDetails(int C_BPartner_ID)
{
}
public void valueChange(ValueChangeEvent evt)
{
log.config(evt.getPropertyName() + "=" + evt.getNewValue());
if (evt == null)
return;
if (evt.getSource() instanceof WEditor)
{
// BankAccount
if (evt.getPropertyName().equals("C_BankAccount_ID"))
{
int C_BankAccount_ID = ((Integer)evt.getNewValue()).intValue();
loadBankAccount(C_BankAccount_ID);
}
tableChanged(null);
}
}
/**
* Load Data - Bank Account
* @param C_BankAccount_ID Bank Account
*/
private void loadBankAccount (int C_BankAccount_ID)
{
log.config ("C_BankAccount_ID=" + C_BankAccount_ID);
/**
* Selected - -
* Date - 1
* C_Payment_ID - 2
* C_Currenncy - 3
* Amt - 4
*/
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
String sql = "SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,"
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,?,null,p.AD_Client_ID,p.AD_Org_ID)," // #1
+ " bp.Name "
+ "FROM C_BankAccount ba"
+ " INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)"
+ " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)"
+ " LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) "
+ "WHERE p.Processed='Y' AND p.IsReconciled='N'"
+ " AND p.DocStatus IN ('CO','CL','RE','VO') AND p.PayAmt<>0" // Bug 1564453 Added Voided payment to bank statement payement selection
+ " AND p.C_BankAccount_ID=?" // #2
+ " AND NOT EXISTS (SELECT * FROM C_BankStatementLine l "
// Voided Bank Statements have 0 StmtAmt
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)";
// Get StatementDate
Timestamp ts = (Timestamp)p_mTab.getValue("StatementDate");
if (ts == null)
ts = new Timestamp(System.currentTimeMillis());
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setTimestamp(1, ts);
pstmt.setInt(2, C_BankAccount_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
Vector<Object> line = new Vector<Object>(6);
//line.add(new Boolean(false)); // 0-Selection
line.add(rs.getTimestamp(1)); // 1-DateTrx
KeyNamePair pp = new KeyNamePair(rs.getInt(2), rs.getString(3));
line.add(pp); // 2-C_Payment_ID
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
line.add(pp); // 3-Currency
line.add(rs.getBigDecimal(6)); // 4-PayAmt
line.add(rs.getBigDecimal(7)); // 5-Conv Amt
line.add(rs.getString(8)); // 6-BParner
data.add(line);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
if (data.size() == 0)
return;
// Header Info
Vector<String> columnNames = new Vector<String>(6);
//columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
columnNames.add(Msg.getElement(Env.getCtx(), "C_Payment_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "Amount"));
columnNames.add(Msg.translate(Env.getCtx(), "ConvertedAmount"));
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
// Remove previous listeners
//dataTable.getModel().removeListDataListener(this);
// Set Model
ListModelTable model = new ListModelTable(data);
model.addTableModelListener(this);
dataTable.setData(model, columnNames);
//dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
dataTable.setColumnClass(0, Timestamp.class, true); // 1-TrxDate
dataTable.setColumnClass(1, String.class, true); // 2-Payment
dataTable.setColumnClass(2, String.class, true); // 3-Currency
dataTable.setColumnClass(3, BigDecimal.class, true); // 4-Amount
dataTable.setColumnClass(4, BigDecimal.class, true); // 5-ConvAmount
dataTable.setColumnClass(5, String.class, true); // 6-BPartner
// Table UI
//dataTable.autoSize();
} // loadBankAccount
/**
* List total amount
*/
protected void info()
{
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
ListModelTable model = dataTable.getModel();
BigDecimal total = new BigDecimal(0.0);
int rows = model.size();
int count = 0;
for (int i = 0; i < rows; i++)
{
if (dataTable.getItemAtIndex(i).isSelected())//(((Boolean)model.getDataAt(i, 0)).booleanValue())
{
total = total.add((BigDecimal)model.getDataAt(i, 4));
count++;
}
}
lblStatus.setValue(String.valueOf(count) + " - " + Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
} // infoStatement
/**
* Save Statement - Insert Data
* @return true if saved
*/
protected boolean save()
{
log.config("");
ListModelTable model = dataTable.getModel();
int rows = model.size();
if (rows == 0)
return false;
// Fixed values
int C_BankStatement_ID = ((Integer)p_mTab.getValue("C_BankStatement_ID")).intValue();
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, null);
log.config(bs.toString());
// Lines
for (int i = 0; i < rows; i++)
{
if (dataTable.getItemAtIndex(i).isSelected())//(((Boolean)model.getDataAt(i, 0)).booleanValue())
{
Timestamp trxDate = (Timestamp)model.getDataAt(i, 0); // 1-DateTrx
KeyNamePair pp = (KeyNamePair)model.getDataAt(i, 1); // 2-C_Payment_ID
int C_Payment_ID = pp.getKey();
pp = (KeyNamePair)model.getDataAt(i, 2); // 3-Currency
int C_Currency_ID = pp.getKey();
BigDecimal TrxAmt = (BigDecimal)model.getDataAt(i, 3); // 4-PayAmt
// BigDecimal StmtAmt = (BigDecimal)model.getValueAt(i, 5);// 5-Conv Amt
log.fine("Line Date=" + trxDate
+ ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
MBankStatementLine bsl = new MBankStatementLine (bs);
bsl.setStatementLineDate(trxDate);
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
if (!bsl.save())
log.log(Level.SEVERE, "Line not created #" + i);
} // if selected
} // for all rows
return true;
} // save
}
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* 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.adempiere.webui.apps.form;
import java.math.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import java.util.logging.*;
import org.adempiere.webui.component.ListModelTable;
import org.adempiere.webui.editor.WStringEditor;
import org.adempiere.webui.editor.WTableDirEditor;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.*;
import org.compiere.util.*;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.Events;
/**
* Create Transactions for Bank Statements
*
* @author Jorg Janke
* @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
*/
public class WCreateFromStatement extends WCreateFrom implements ValueChangeListener
{
/**
* Protected Constructor
* @param mTab MTab
*/
WCreateFromStatement(GridTab mTab)
{
super (mTab);
log.info("");
} // VCreateFromStatement
/**
* Dynamic Init
* @throws Exception if Lookups cannot be initialized
* @return true if initialized
*/
protected boolean dynInit() throws Exception
{
if (p_mTab.getValue("C_BankStatement_ID") == null)
{
FDialog.error(0, this, "SaveErrorRowNotFound");
return false;
}
// Do not display RMA selection
rmaLabel.setVisible(false);
rmaField.setVisible(false);
sameWarehouseCb.setVisible(false);
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
parameterStdPanel.setVisible(false);
int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
WTableDirEditor editor = new WTableDirEditor ("C_BankAccount_ID", true, false, true, lookup);
bankAccountField = editor.getComponent();
editor.addValueChangeListner(this);
// Set Default
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
bankAccountField.setValue(new Integer(C_BankAccount_ID));
// initial Loading
//RF [1811114]
String R_AuthCode="";
authorizationField = new WStringEditor ("authorization", false, false, true, 10, 30, null, null);
authorizationField.getComponent().addEventListener(Events.ON_CHANGE, this);
loadBankAccount(C_BankAccount_ID, R_AuthCode);
return true;
} // dynInit
/**
* Init Details (never called)
* @param C_BPartner_ID BPartner
*/
protected void initBPDetails(int C_BPartner_ID)
{
} // initDetails
/**
* Change Listener
* @param e event
*/
public void valueChange (ValueChangeEvent e)
{
log.config(e.getPropertyName() + "=" + e.getNewValue());
int C_BankAccount_ID=0;
//RF [1811114]
String R_AuthCode = (authorizationField.getValue().toString());
// BankAccount
if (e.getPropertyName().equals("C_BankAccount_ID"))
{
//RF [1811114]
C_BankAccount_ID = ((Integer)e.getNewValue()).intValue();
if (authorizationField.getValue().toString().equals(""))
loadBankAccount(C_BankAccount_ID, null);
else
loadBankAccount(C_BankAccount_ID, R_AuthCode);
}
tableChanged(null);
} // vetoableChange
/**
* Load Data - Bank Account
* @param C_BankAccount_ID Bank Account
* @param Autorization Code
*/
//RF [1811114]
private void loadBankAccount (int C_BankAccount_ID, String R_AuthCode)
{
log.config ("C_BankAccount_ID=" + C_BankAccount_ID);
/**
* Selected - 0
* Date - 1
* C_Payment_ID - 2
* C_Currenncy - 3
* Amt - 4
*/
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
String sql = "SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,"
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,?,null,p.AD_Client_ID,p.AD_Org_ID)," // #1
+ " bp.Name "
+ "FROM C_BankAccount ba"
+ " INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)"
+ " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)"
+ " LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) "
+ "WHERE p.Processed='Y' AND p.IsReconciled='N'"
+ " AND p.DocStatus IN ('CO','CL','RE','VO') AND p.PayAmt<>0" // Bug 1564453 Added Voided payment to bank statement payement selection
+ " AND p.C_BankAccount_ID=?"; // #2
//RF [1811114]
if (R_AuthCode!= "" && R_AuthCode!= null)
sql = sql + " AND p.R_AuthCode LIKE ?";
sql = sql + " AND NOT EXISTS (SELECT * FROM C_BankStatementLine l "
// Voided Bank Statements have 0 StmtAmt
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)";
// Get StatementDate
Timestamp ts = (Timestamp)p_mTab.getValue("StatementDate");
if (ts == null)
ts = new Timestamp(System.currentTimeMillis());
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setTimestamp(1, ts);
pstmt.setInt(2, C_BankAccount_ID);
//RF [1811114]
if (R_AuthCode!= "" && R_AuthCode!= null){
pstmt.setString(3, R_AuthCode);}
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
Vector<Object> line = new Vector<Object>(6);
line.add(new Boolean(false)); // 0-Selection
line.add(rs.getTimestamp(1)); // 1-DateTrx
KeyNamePair pp = new KeyNamePair(rs.getInt(2), rs.getString(3));
line.add(pp); // 2-C_Payment_ID
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
line.add(pp); // 3-Currency
line.add(rs.getBigDecimal(6)); // 4-PayAmt
line.add(rs.getBigDecimal(7)); // 5-Conv Amt
line.add(rs.getString(8)); // 6-BParner
data.add(line);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
// Header Info
Vector<String> columnNames = new Vector<String>(6);
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
columnNames.add(Msg.getElement(Env.getCtx(), "C_Payment_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "Amount"));
columnNames.add(Msg.translate(Env.getCtx(), "ConvertedAmount"));
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
// Remove previous listeners
dataTable.getModel().removeTableModelListener(this);
// Set Model
ListModelTable model = new ListModelTable(data);
model.addTableModelListener(this);
dataTable.setData(model, columnNames);
//
dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
dataTable.setColumnClass(1, Timestamp.class, true); // 1-TrxDate
dataTable.setColumnClass(2, String.class, true); // 2-Payment
dataTable.setColumnClass(3, String.class, true); // 3-Currency
dataTable.setColumnClass(4, BigDecimal.class, true); // 4-Amount
dataTable.setColumnClass(5, BigDecimal.class, true); // 5-ConvAmount
dataTable.setColumnClass(6, String.class, true); // 6-BPartner
// Table UI
dataTable.autoSize();
} // loadBankAccount
/**
* List total amount
*/
protected void info()
{
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
ListModelTable model = dataTable.getModel();
BigDecimal total = new BigDecimal(0.0);
int rows = model.getRowCount();
int count = 0;
for (int i = 0; i < rows; i++)
{
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
{
total = total.add((BigDecimal)model.getValueAt(i, 4));
count++;
}
}
setStatusLine(count, Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
} // infoStatement
/**
* Save Statement - Insert Data
* @return true if saved
*/
protected boolean save()
{
log.config("");
ListModelTable model = dataTable.getModel();
int rows = model.getRowCount();
if (rows == 0)
return false;
// fixed values
int C_BankStatement_ID = ((Integer)p_mTab.getValue("C_BankStatement_ID")).intValue();
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, null);
log.config(bs.toString());
// Lines
for (int i = 0; i < rows; i++)
{
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
{
Timestamp trxDate = (Timestamp)model.getValueAt(i, 1); // 1-DateTrx
KeyNamePair pp = (KeyNamePair)model.getValueAt(i, 2); // 2-C_Payment_ID
int C_Payment_ID = pp.getKey();
pp = (KeyNamePair)model.getValueAt(i, 3); // 3-Currency
int C_Currency_ID = pp.getKey();
BigDecimal TrxAmt = (BigDecimal)model.getValueAt(i, 4); // 4-PayAmt
// BigDecimal StmtAmt = (BigDecimal)model.getValueAt(i, 5);// 5-Conv Amt
//
log.fine("Line Date=" + trxDate
+ ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
//
MBankStatementLine bsl = new MBankStatementLine (bs);
bsl.setStatementLineDate(trxDate);
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
if (!bsl.save())
log.log(Level.SEVERE, "Line not created #" + i);
} // if selected
} // for all rows
return true;
} // save
/*
* Action Listener
* @param e event*/
//RF [1811114]
public void onEvent(Event e) throws Exception
{
super.onEvent(e);
log.config("Action=" + e.getTarget().getId());
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
if (e.getTarget().equals(authorizationField.getComponent()))
{
String R_AuthCode = (authorizationField.getValue().toString());
if (authorizationField.getValue().toString().equals(""))
{
loadBankAccount(C_BankAccount_ID, null);
}
else
loadBankAccount(C_BankAccount_ID, R_AuthCode);
}
}
} // VCreateFromStatement

View File

@ -257,7 +257,7 @@ public class WTrxMaterial extends ADForm implements EventListener, ValueChangeLi
// Locator
MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo);
locatorField = new WLocatorEditor ("M_Locator_ID", false, false, true, locatorLookup);
locatorField = new WLocatorEditor ("M_Locator_ID", false, false, true, locatorLookup, m_windowNo);
locatorField.addValueChangeListner(this);
// Product

View File

@ -17,6 +17,10 @@
package org.adempiere.webui.component;
import org.adempiere.webui.apps.form.WCreateFrom;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
/**
*
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
@ -58,4 +62,12 @@ public class Button extends org.zkoss.zul.Button
{
return !super.isDisabled();
}
/**
* shortcut for addEventListener(Events.ON_CLICK, listener) to ease porting of swing form
* @param listener
*/
public void addActionListener(EventListener listener) {
addEventListener(Events.ON_CLICK, listener);
}
}

View File

@ -0,0 +1,22 @@
package org.adempiere.webui.component;
import org.compiere.util.Env;
import org.compiere.util.Msg;
public class ButtonFactory {
public static Button createButton(String action, String label) {
Button button = new Button();
button.setId(action);
button.setImage("images/" + action + "16.gif");
if (label == null) {
label = Msg.getMsg(Env.getCtx(), action);
if (label != null && !label.equals(action)) {
label = label.replaceAll("[&]", "");
button.setLabel(label);
}
}
return button;
}
}

View File

@ -17,6 +17,9 @@
package org.adempiere.webui.component;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
/**
*
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
@ -36,4 +39,38 @@ public class Checkbox extends org.zkoss.zul.Checkbox
{
return !this.isDisabled();
}
/**
* alias for setLabel, added to ease porting of swing form
* @param label
*/
public void setText(String label) {
if (label != null)
label = label.replaceAll("[&]", "");
setLabel(label);
}
/**
* alias for isChecked, to ease porting of swing form
* @return
*/
public boolean isSelected() {
return isChecked();
}
/**
* alias for setChecked, to ease porting of swing form
* @param checked
*/
public void setSelected(boolean checked) {
setChecked(checked);
}
/**
* alias for addEventListener(Events.ON_CHECK, listener), to ease porting of swing form
* @param listener
*/
public void addActionListener(EventListener listener) {
addEventListener(Events.ON_CHECK, listener);
}
}

View File

@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Messagebox;
/**
@ -35,6 +36,10 @@ public final class ConfirmPanel extends Hbox
{
private static final long serialVersionUID = 1L;
public static final String A_OK = "Ok";
public static final String A_CANCEL = "Cancel";
private Map<String, Button> buttonMap = new HashMap<String, Button>();
@ -353,5 +358,29 @@ public final class ConfirmPanel extends Hbox
button.addEventListener(event, listener);
}
}
/**
* added to ease porting of swing form
* @param listener
*/
public void addActionListener(EventListener listener) {
addActionListener(Events.ON_CLICK, listener);
}
/**
* alias for addComponentsLeft for ease of porting swing form
* @param selectAllButton
*/
public void addButton(Button button) {
addComponentsLeft(button);
}
/**
* alias for getButton("Ok"), to ease porting of swing form
* @return Button
*/
public Button getOKButton() {
return getButton("Ok");
}
} // ConfirmPanel

View File

@ -31,4 +31,13 @@ public class Grid extends org.zkoss.zul.Grid
setSclass("grid-no-striped");
setOddRowSclass("even");
}
public Rows newRows() {
Rows rows = new Rows();
appendChild(rows);
return rows;
}
}

View File

@ -0,0 +1,10 @@
package org.adempiere.webui.component;
public class GridFactory {
public static Grid newGridLayout() {
Grid grid = new Grid();
grid.makeNoStrip();
return grid;
}
}

View File

@ -17,6 +17,7 @@
package org.adempiere.webui.component;
import org.adempiere.webui.LayoutUtils;
import org.zkoss.zk.ui.Component;
/**
@ -82,4 +83,18 @@ public class Label extends org.zkoss.zul.Label
} else if (decorator != null)
decorator.setVisible(false);
}
/**
* alias for setValue, added to ease porting of swing form
* @param translate
*/
public void setText(String translate) {
if (translate != null)
translate = translate.replaceAll("[&]", "");
this.setValue(translate);
}
public Component rightAlign() {
return LayoutUtils.makeRightAlign(this);
}
}

View File

@ -19,6 +19,9 @@ package org.adempiere.webui.component;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import org.compiere.util.KeyNamePair;
import org.compiere.util.ValueNamePair;
/**
*
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
@ -44,4 +47,13 @@ public class ListItem extends org.zkoss.zul.Listitem
{
m_propertyChangeListeners.addPropertyChangeListener(l);
}
public KeyNamePair toKeyNamePair()
{
return new KeyNamePair((Integer)getValue(), getLabel());
}
public ValueNamePair toValueNamePair() {
return new ValueNamePair((String)getValue(), getLabel());
}
}

View File

@ -331,4 +331,32 @@ public class ListModelTable extends ListModelList implements ListModelExt
return;
}
/**
* alias for getDataAt, to ease porting of swing form
* @param rowIndex
* @param columnIndex
* @return column value
*/
public Object getValueAt(int rowIndex, int columnIndex) {
return getDataAt(rowIndex, columnIndex);
}
/**
* alias for setDataAt, to ease porting of swing form
* @param value
* @param row
* @param col
*/
public void setValueAt(Object value, int row, int col) {
setDataAt(value, row, col);
}
/**
* alias for getSize, to ease porting of swing form
* @return size
*/
public int getRowCount() {
return getSize();
}
}

View File

@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.adempiere.webui.apps.form.WCreateFrom;
import org.compiere.util.KeyNamePair;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
@ -204,5 +205,36 @@ public class Listbox extends org.zkoss.zul.Listbox implements EventListener
listener.onEvent(event);
}
}
}
/**
* shortcut for appendItem(pp.getName(), pp.getKey()), to ease porting of swing form
* @param pp
*/
public void addItem(KeyNamePair pp) {
appendItem(pp.getName(), pp.getKey());
}
/**
* remove all items, to ease porting of swing form
*/
public void removeAllItems() {
getItems().clear();
}
/**
* alias for removeEventListener(Events.ON_SELECT, listener), to ease porting of swing form
* @param listener
*/
public void removeActionListener(EventListener listener) {
removeEventListener(Events.ON_SELECT, listener);
}
/**
* alias for addEventListener(Events.ON_SELECT, listener), to ease porting of swing form
* @param listener
*/
public void addActionListener(EventListener listener) {
addEventListener(Events.ON_SELECT, listener);
}
}

View File

@ -0,0 +1,20 @@
package org.adempiere.webui.component;
public class ListboxFactory {
public static Listbox newDropdownListbox() {
Listbox listbox = new Listbox();
listbox.setMold("select");
return listbox;
}
public static WListbox newDataTable() {
WListbox dataTable = new WListbox();
dataTable.setWidth("100%");
dataTable.setHeight("100%");
dataTable.setFixedLayout(true);
dataTable.setVflex(true);
return dataTable;
}
}

View File

@ -26,5 +26,11 @@ package org.adempiere.webui.component;
public class Rows extends org.zkoss.zul.Rows
{
private static final long serialVersionUID = 1L;
public Row newRow() {
Row row = new Row();
appendChild(row);
return row;
}
}

View File

@ -17,7 +17,14 @@
package org.adempiere.webui.component;
import java.awt.Color;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.model.Obscure;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
/**
*
@ -25,23 +32,90 @@ import org.zkoss.zk.ui.WrongValueException;
* @date Feb 25, 2007
* @version $Revision: 0.10 $
*/
public class Textbox extends org.zkoss.zul.Textbox
public class Textbox extends org.zkoss.zul.Textbox implements EventListener
{
private static final long serialVersionUID = 1L;
private Obscure m_obscure = null;
private boolean m_infocus;
public Textbox()
{
super();
addFocusListener(this);
}
public Textbox(String value) throws WrongValueException
{
super(value);
addFocusListener(this);
}
public void setEnabled(boolean enabled)
{
this.setDisabled(!enabled);
}
public void setObscureType(String obscureType)
{
if (obscureType != null && obscureType.length() > 0)
{
m_obscure = new Obscure ("", obscureType);
}
else
{
m_obscure = null;
}
setValue(getValue());
}
/**
* method to ease porting of swing form
* @param listener
*/
public void addFocusListener(EventListener listener) {
addEventListener(Events.ON_FOCUS, listener);
addEventListener(Events.ON_BLUR, listener);
}
@Override
public String getValue() throws WrongValueException {
String value = super.getValue();
if (m_obscure != null && value != null && value.length() > 0)
{
if (value.equals(m_obscure.getObscuredValue()))
value = m_obscure.getClearValue();
}
return value;
}
@Override
public void setValue(String value) throws WrongValueException {
if (m_obscure != null && !m_infocus)
{
super.setValue(m_obscure.getObscuredValue(value));
}
else
{
super.setValue(value);
}
}
public void onEvent(Event event) throws Exception {
if (Events.ON_FOCUS.equals(event.getName()))
{
m_infocus = true;
if (m_obscure != null)
setValue(getValue());
}
else if (Events.ON_BLUR.equals(event.getName()))
{
m_infocus = false;
if (m_obscure != null)
setValue(getValue());
}
}
}

View File

@ -999,4 +999,11 @@ public class WListbox extends Listbox implements TableValueChangeListener, WTabl
return;
}
/**
* no op, to ease porting of swing form
*/
public void autoSize() {
//no op
}
}

View File

@ -39,4 +39,12 @@ public class Window extends org.zkoss.zul.Window
{
super();
}
/**
* alias for detach, to ease porting of swing form
*/
public void dispose()
{
detach();
}
}

View File

@ -124,6 +124,34 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
init();
}
/**
* Constructor for use if a grid field is unavailable
*
* @param comp The editor's component
* @param label column name (not displayed)
* @param description description of component
* @param mandatory whether a selection must be made
* @param readonly whether or not the editor is read only
* @param updateable whether the editor contents can be changed
*/
public WEditor(Component comp, String columnName, String label, String description, boolean mandatory, boolean readonly, boolean updateable)
{
if (comp == null)
{
throw new IllegalArgumentException("Component cannot be null");
}
this.setComponent(comp);
this.setMandatory(mandatory);
this.readOnly = readonly;
this.description = description;
this.updateable = updateable;
this.strLabel = label;
this.columnName = columnName;
init();
}
/**
* Set the editor component.
* @param comp the editor component
@ -160,11 +188,19 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
}
}
/**
*
* @return grid field for this editor ( can be null )
*/
public GridField getGridField()
{
return gridField;
}
/**
*
* @return columnNames
*/
public String getColumnName()
{
return columnName;
@ -201,6 +237,10 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
this.columnName = cleanColumnName;
}
/**
*
* @return Component
*/
public Component getComponent()
{
return component;

View File

@ -63,7 +63,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
public WLocatorEditor()
{
this("M_Locator_ID", false, false, true, null);
this("M_Locator_ID", false, false, true, null, 0);
}
/**
@ -78,7 +78,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
*/
public WLocatorEditor( String columnName, boolean mandatory, boolean isReadOnly,
boolean isUpdateable, MLocatorLookup mLocator)
boolean isUpdateable, MLocatorLookup mLocator, int windowNo)
{
super(new EditorBox(), "Locator", "", mandatory, isReadOnly, isUpdateable);
@ -87,6 +87,8 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
getComponent().setButtonImage("/images/Locator10.gif");
setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ]
m_WindowNo = windowNo;
}
public void setValue(Object value)

View File

@ -119,6 +119,23 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
init();
}
public WSearchEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
Lookup lookup)
{
super(new Searchbox(), null, null, mandatory, readonly, updateable);
if (lookup == null)
{
throw new IllegalArgumentException("Lookup cannot be null");
}
this.lookup = lookup;
this.columnName = columnName;
super.setColumnName(columnName);
init();
}
/**
* initialise editor
* @param columnName columnName

View File

@ -18,6 +18,7 @@
package org.adempiere.webui.editor;
import org.adempiere.webui.ValuePreference;
import org.adempiere.webui.apps.form.WCreateFromStatement;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.event.ContextMenuEvent;
import org.adempiere.webui.event.ContextMenuListener;
@ -26,6 +27,7 @@ import org.compiere.model.GridField;
import org.compiere.model.MRole;
import org.compiere.util.DisplayType;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
/**
@ -42,12 +44,38 @@ public class WStringEditor extends WEditor implements ContextMenuListener
private WEditorPopupMenu popupMenu;
/**
* to ease porting of swing form
*/
public WStringEditor()
{
this("String", false, false, true, 30, 30, "", null);
}
public WStringEditor(GridField gridField)
{
super(new Textbox(), gridField);
init();
init(gridField.getObscureType());
}
/**
* to ease porting of swing form
* @param columnName
* @param mandatory
* @param isReadOnly
* @param isUpdateable
* @param displayLength
* @param fieldLength
* @param vFormat
* @param obscureType
*/
public WStringEditor(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable,
int displayLength, int fieldLength, String vFormat, String obscureType)
{
super(new Textbox(), columnName, null, null, mandatory, isReadOnly,isUpdateable);
init(obscureType);
}
@Override
@ -65,41 +93,49 @@ public class WStringEditor extends WEditor implements ContextMenuListener
getComponent().setReadonly(!readWrite);
}
private void init()
private void init(String obscureType)
{
getComponent().setMaxlength(gridField.getFieldLength());
int displayLength = gridField.getDisplayLength();
if (displayLength <= 0 || displayLength > MAX_DISPLAY_LENGTH)
{
displayLength = MAX_DISPLAY_LENGTH;
}
getComponent().setCols(displayLength);
if (gridField.getDisplayType() == DisplayType.Text)
{
getComponent().setMultiline(true);
getComponent().setRows(3);
}
else if (gridField.getDisplayType() == DisplayType.TextLong)
{
getComponent().setMultiline(true);
getComponent().setRows(5);
}
else if (gridField.getDisplayType() == DisplayType.Memo)
{
getComponent().setMultiline(true);
getComponent().setRows(8);
}
popupMenu = new WEditorPopupMenu(false, false, true);
if (gridField != null)
{
getComponent().setMaxlength(gridField.getFieldLength());
int displayLength = gridField.getDisplayLength();
if (displayLength <= 0 || displayLength > MAX_DISPLAY_LENGTH)
{
displayLength = MAX_DISPLAY_LENGTH;
}
getComponent().setCols(displayLength);
if (gridField.getDisplayType() == DisplayType.Text)
{
getComponent().setMultiline(true);
getComponent().setRows(3);
}
else if (gridField.getDisplayType() == DisplayType.TextLong)
{
getComponent().setMultiline(true);
getComponent().setRows(5);
}
else if (gridField.getDisplayType() == DisplayType.Memo)
{
getComponent().setMultiline(true);
getComponent().setRows(8);
}
getComponent().setObscureType(obscureType);
popupMenu = new WEditorPopupMenu(false, false, true);
}
}
public void onEvent(Event event)
{
String newText = getComponent().getValue();
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldText, newText);
super.fireValueChange(changeEvent);
oldText = newText;
if (Events.ON_CHANGE.equals(event.getName()))
{
String newText = getComponent().getValue();
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldText, newText);
super.fireValueChange(changeEvent);
oldText = newText;
}
}
@Override

View File

@ -94,6 +94,26 @@ ContextMenuListener, IZoomableEditor
init();
}
/**
* For ease of porting swing form
* @param columnName
* @param mandatory
* @param isReadOnly
* @param isUpdateable
* @param lookup
*/
public WTableDirEditor(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable,
Lookup lookup)
{
super(new Listbox(), columnName, null, null, mandatory, isReadOnly, isUpdateable);
if (lookup == null)
{
throw new IllegalArgumentException("Lookup cannot be null");
}
this.lookup = lookup;
init();
}
private void init()
{
getComponent().setRows(0);
@ -119,8 +139,11 @@ ContextMenuListener, IZoomableEditor
refreshList();
}
popupMenu = new WEditorPopupMenu(zoom, true, true);
getComponent().setContext(popupMenu.getId());
if (gridField != null)
{
popupMenu = new WEditorPopupMenu(zoom, true, true);
getComponent().setContext(popupMenu.getId());
}
}
@Override

View File

@ -57,8 +57,7 @@ public class WebEditorFactory
WEditor editor = null;
int displayType = gridField.getDisplayType();
int WindowNo = gridField.getWindowNo();
/** Not a Field */
if (gridField.isHeading())
{
@ -144,7 +143,7 @@ public class WebEditorFactory
{
editor = new WLocatorEditor(gridField.getColumnName(), gridField.isMandatory(false),
gridField.isReadOnly(), gridField.isUpdateable(),
(MLocatorLookup)gridField.getLookup());
(MLocatorLookup)gridField.getLookup(), gridField.getWindowNo());
}
else if (displayType == DisplayType.Account)
{

View File

@ -53,7 +53,6 @@ import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WNumberEditor;
import org.adempiere.webui.editor.WSearchEditor;
import org.adempiere.webui.editor.WStringEditor;
import org.adempiere.webui.editor.WTableDirEditor;
import org.adempiere.webui.editor.WebEditorFactory;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
@ -1286,7 +1285,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
} // cmd_ok_Simple
private void dispose()
public void dispose()
{
log.config("");
@ -1305,7 +1304,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
m_targetFields.clear();
m_targetFields = null;
//
this.detach();
super.dispose();
} // dispose
/**