* merge revision 6147-6148 changes from branches/adempiere341
This commit is contained in:
parent
7980165ed9
commit
a378b8c11c
File diff suppressed because it is too large
Load Diff
|
@ -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. *
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* 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 *
|
* 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 *
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/**
|
|
||||||
* 2007, Modified by Posterita Ltd.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.adempiere.webui.apps.form;
|
package org.adempiere.webui.apps.form;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.*;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.*;
|
||||||
import java.sql.ResultSet;
|
import java.util.*;
|
||||||
import java.sql.SQLException;
|
import java.util.logging.*;
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.adempiere.webui.component.ListItem;
|
|
||||||
import org.adempiere.webui.component.ListModelTable;
|
import org.adempiere.webui.component.ListModelTable;
|
||||||
import org.adempiere.webui.editor.WEditor;
|
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.event.ValueChangeListener;
|
import org.adempiere.webui.event.ValueChangeListener;
|
||||||
import org.adempiere.webui.event.WTableModelListener;
|
import org.compiere.model.*;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.util.*;
|
||||||
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.zkoss.zk.ui.event.Event;
|
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
|
* Create Invoice Transactions from PO Orders or Receipt
|
||||||
*
|
*
|
||||||
* @author Niraj Sohun
|
* @author Jorg Janke
|
||||||
* @date Jul 16, 2007
|
* @version $Id: VCreateFromInvoice.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
|
public class WCreateFromInvoice extends WCreateFrom implements ValueChangeListener
|
||||||
public class WCreateFromInvoice extends WCreateFrom implements EventListener, ValueChangeListener, WTableModelListener
|
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private MInOut m_inout = null;
|
|
||||||
|
|
||||||
private boolean m_actionActive;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected Constructor
|
* Protected Constructor
|
||||||
* @param mTab MTab
|
* @param mTab MTab
|
||||||
*/
|
*/
|
||||||
|
WCreateFromInvoice(GridTab mTab)
|
||||||
public WCreateFromInvoice(GridTab mTab)
|
|
||||||
{
|
{
|
||||||
super (mTab);
|
super (mTab);
|
||||||
log.info(mTab.toString());
|
log.info(mTab.toString());
|
||||||
}
|
} // VCreateFromInvoice
|
||||||
|
|
||||||
@Override
|
private boolean m_actionActive = false;
|
||||||
protected boolean dynInit() throws Exception
|
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("");
|
log.config("");
|
||||||
|
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
|
||||||
parameterBankPanel.setVisible(false);
|
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);
|
initBPartner(true);
|
||||||
bPartnerField.addValueChangeListner(this);
|
bPartnerField.addValueChangeListner(this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} // dynInit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init Details - load receipts not invoiced
|
||||||
|
* @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);
|
||||||
|
|
||||||
// Load Shipments (Receipts) - Completed, Closed
|
// load Shipments (Receipts) - Completed, Closed
|
||||||
|
shipmentField.removeActionListener(this);
|
||||||
shipmentField.removeEventListener(Events.ON_SELECT, this);
|
shipmentField.removeAllItems();
|
||||||
shipmentField.getChildren().clear();
|
// None
|
||||||
|
|
||||||
// None
|
|
||||||
|
|
||||||
KeyNamePair pp = new KeyNamePair(0,"");
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
shipmentField.appendItem(pp.getName(), pp);
|
shipmentField.addItem(pp);
|
||||||
|
|
||||||
// Display
|
// Display
|
||||||
|
|
||||||
StringBuffer display = new StringBuffer("s.DocumentNo||' - '||")
|
StringBuffer display = new StringBuffer("s.DocumentNo||' - '||")
|
||||||
.append(DB.TO_CHAR("s.MovementDate", DisplayType.Date, Env.getAD_Language(Env.getCtx())));
|
.append(DB.TO_CHAR("s.MovementDate", DisplayType.Date, Env.getAD_Language(Env.getCtx())));
|
||||||
|
//
|
||||||
StringBuffer sql = new StringBuffer("SELECT s.M_InOut_ID,").append(display)
|
StringBuffer sql = new StringBuffer("SELECT s.M_InOut_ID,").append(display)
|
||||||
.append(" FROM M_InOut s "
|
.append(" FROM M_InOut s "
|
||||||
+ "WHERE s.C_BPartner_ID=? AND s.IsSOTrx='N' AND s.DocStatus IN ('CL','CO')"
|
+ "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)"
|
+ "HAVING (sl.MovementQty<>SUM(mi.Qty) AND mi.M_InOutLine_ID IS NOT NULL)"
|
||||||
+ " OR mi.M_InOutLine_ID IS NULL) "
|
+ " OR mi.M_InOutLine_ID IS NULL) "
|
||||||
+ "ORDER BY s.MovementDate");
|
+ "ORDER BY s.MovementDate");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, C_BPartner_ID);
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||||
shipmentField.appendItem(pp.getName(), pp);
|
shipmentField.addItem(pp);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
|
@ -141,96 +137,156 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
shipmentField.setSelectedIndex(0);
|
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
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
super.onEvent(e);
|
super.onEvent(e);
|
||||||
|
|
||||||
if (m_actionActive)
|
if (m_actionActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_actionActive = true;
|
m_actionActive = true;
|
||||||
log.config("Action=" + e.getTarget());
|
log.config("Action=" + e.getTarget().getId());
|
||||||
|
// Order
|
||||||
// Order
|
if (e.getTarget().equals(orderField))
|
||||||
|
|
||||||
if (e.getTarget() == orderField)
|
|
||||||
{
|
{
|
||||||
ListItem listitem = orderField.getSelectedItem();
|
KeyNamePair pp = orderField.getSelectedItem().toKeyNamePair();
|
||||||
KeyNamePair pp = (KeyNamePair)listitem.getValue();
|
|
||||||
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, RMA and Shipment to Null
|
||||||
// Set Invoice 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);
|
||||||
}
|
}
|
||||||
// Shipment
|
// Shipment
|
||||||
else if (e.getTarget() == shipmentField)
|
else if (e.getTarget().equals(shipmentField))
|
||||||
{
|
{
|
||||||
ListItem listitem = shipmentField.getSelectedItem();
|
KeyNamePair pp = shipmentField.getSelectedItem().toKeyNamePair();
|
||||||
KeyNamePair pp = (KeyNamePair)listitem.getValue();
|
|
||||||
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, RMA and Invoice to Null
|
||||||
// Set Order 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);
|
||||||
}
|
}
|
||||||
m_actionActive = false;
|
// RMA
|
||||||
}
|
else if (e.getTarget().equals(rmaField))
|
||||||
|
|
||||||
public void valueChange(ValueChangeEvent evt)
|
|
||||||
{
|
|
||||||
log.config(evt.getPropertyName() + "=" + evt.getNewValue());
|
|
||||||
|
|
||||||
if (evt == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (evt.getSource() instanceof WEditor)
|
|
||||||
{
|
{
|
||||||
if (evt.getPropertyName().equals("C_BPartner_ID"))
|
KeyNamePair pp = rmaField.getSelectedItem().toKeyNamePair();
|
||||||
{
|
int M_RMA_ID = 0;
|
||||||
int C_BPartner_ID = ((Integer)evt.getNewValue()).intValue();
|
if (pp != null)
|
||||||
initBPartnerOIS (C_BPartner_ID, true);
|
M_RMA_ID = pp.getKey();
|
||||||
}
|
// set Order and Invoice to Null
|
||||||
tableChanged(null);
|
orderField.setSelectedIndex(-1);
|
||||||
|
invoiceField.setSelectedIndex(-1);
|
||||||
|
shipmentField.setSelectedIndex(-1);
|
||||||
|
loadRMA(M_RMA_ID);
|
||||||
}
|
}
|
||||||
}
|
m_actionActive = false;
|
||||||
|
} // actionPerformed
|
||||||
private void loadShipment(int M_InOut_ID)
|
|
||||||
|
/**
|
||||||
|
* 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);
|
log.config("M_InOut_ID=" + M_InOut_ID);
|
||||||
|
|
||||||
m_inout = new MInOut(Env.getCtx(), M_InOut_ID, null);
|
m_inout = new MInOut(Env.getCtx(), M_InOut_ID, null);
|
||||||
p_order = null;
|
p_order = null;
|
||||||
|
|
||||||
if (m_inout.getC_Order_ID() != 0)
|
if (m_inout.getC_Order_ID() != 0)
|
||||||
p_order = new MOrder (Env.getCtx(), m_inout.getC_Order_ID(), null);
|
p_order = new MOrder (Env.getCtx(), m_inout.getC_Order_ID(), null);
|
||||||
|
|
||||||
|
//
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
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.MovementQty-SUM(NVL(mi.Qty, 0)), l.QtyEntered/l.MovementQty,"
|
||||||
+ " l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name)," // 3..4
|
+ " 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.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line," // 5..9
|
||||||
+ " l.C_OrderLine_ID " // 10
|
+ " l.C_OrderLine_ID " // 10
|
||||||
+ " FROM M_InOutLine l "
|
+ " FROM M_InOutLine l "
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
|
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
|
||||||
sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)");
|
sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)");
|
||||||
else
|
else
|
||||||
|
@ -253,35 +309,27 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, M_InOut_ID);
|
pstmt.setInt(1, M_InOut_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
Vector<Object> line = new Vector<Object>(7);
|
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 qtyMovement = rs.getBigDecimal(1);
|
||||||
BigDecimal multiplier = rs.getBigDecimal(2);
|
BigDecimal multiplier = rs.getBigDecimal(2);
|
||||||
BigDecimal qtyEntered = qtyMovement.multiply(multiplier);
|
BigDecimal qtyEntered = qtyMovement.multiply(multiplier);
|
||||||
line.add(new Double(qtyEntered.doubleValue())); // 1-Qty
|
line.add(new Double(qtyEntered.doubleValue())); // 1-Qty
|
||||||
|
|
||||||
KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(4).trim());
|
KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(4).trim());
|
||||||
line.add(pp); // 2-UOM
|
line.add(pp); // 2-UOM
|
||||||
|
|
||||||
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
|
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
|
||||||
line.add(pp); // 3-Product
|
line.add(pp); // 3-Product
|
||||||
line.add(rs.getString(7)); // 4-VendorProductNo
|
line.add(rs.getString(7)); // 4-VendorProductNo
|
||||||
|
|
||||||
int C_OrderLine_ID = rs.getInt(10);
|
int C_OrderLine_ID = rs.getInt(10);
|
||||||
|
|
||||||
if (rs.wasNull())
|
if (rs.wasNull())
|
||||||
line.add(null); // 5-Order
|
line.add(null); // 5-Order
|
||||||
else
|
else
|
||||||
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();
|
||||||
|
@ -291,25 +339,116 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
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
|
* List number of rows selected
|
||||||
*/
|
*/
|
||||||
protected void info()
|
protected void info()
|
||||||
{
|
{
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
int rows = model.size();
|
int rows = model.getSize();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < rows; i++)
|
for (int i = 0; i < rows; i++)
|
||||||
{
|
{
|
||||||
if (dataTable.getItemAtIndex(i).isSelected())//(((Boolean)model.getDataAt(i, 0)).booleanValue())
|
if (dataTable.getItemAtIndex(i).isSelected())
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
setStatusLine(count, null);
|
||||||
|
} // infoInvoice
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save - Create Invoice Lines
|
* Save - Create Invoice Lines
|
||||||
|
@ -319,99 +458,79 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
int rows = model.size();
|
int rows = model.getSize();
|
||||||
|
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Invoice
|
// 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();
|
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, null);
|
||||||
log.config(invoice.toString());
|
log.config(invoice.toString());
|
||||||
|
|
||||||
if (p_order != null)
|
if (p_order != null)
|
||||||
{
|
{
|
||||||
invoice.setOrder(p_order); // Overwrite header values
|
invoice.setOrder(p_order); // overwrite header values
|
||||||
invoice.save();
|
invoice.save();
|
||||||
}
|
}
|
||||||
|
if (m_inout != null && m_inout.getM_InOut_ID() != 0
|
||||||
// Only first time
|
&& m_inout.getC_Invoice_ID() == 0) // only first time
|
||||||
if (m_inout != null && m_inout.getM_InOut_ID() != 0 && m_inout.getC_Invoice_ID() == 0)
|
|
||||||
{
|
{
|
||||||
m_inout.setC_Invoice_ID(C_Invoice_ID);
|
m_inout.setC_Invoice_ID(C_Invoice_ID);
|
||||||
m_inout.save();
|
m_inout.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Lines
|
// Lines
|
||||||
|
|
||||||
for (int i = 0; i < rows; i++)
|
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
|
// variable values
|
||||||
|
Double d = (Double)model.getValueAt(i, 1); // 1-Qty
|
||||||
Double d = (Double)model.getDataAt(i, 0); // 1-Qty
|
|
||||||
BigDecimal QtyEntered = new BigDecimal(d.doubleValue());
|
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();
|
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;
|
int M_Product_ID = 0;
|
||||||
|
|
||||||
if (pp != null)
|
if (pp != null)
|
||||||
M_Product_ID = pp.getKey();
|
M_Product_ID = pp.getKey();
|
||||||
|
|
||||||
int C_Charge_ID = 0;
|
int C_Charge_ID = 0;
|
||||||
|
//
|
||||||
int C_OrderLine_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)
|
if (pp != null)
|
||||||
C_OrderLine_ID = pp.getKey();
|
C_OrderLine_ID = pp.getKey();
|
||||||
|
|
||||||
int M_InOutLine_ID = 0;
|
int M_InOutLine_ID = 0;
|
||||||
pp = (KeyNamePair)model.getDataAt(i, 5); // 6-Shipment
|
pp = (KeyNamePair)model.getValueAt(i, 6); // 6-Shipment
|
||||||
|
|
||||||
if (pp != null)
|
if (pp != null)
|
||||||
M_InOutLine_ID = pp.getKey();
|
M_InOutLine_ID = pp.getKey();
|
||||||
|
|
||||||
// Precision of Qty UOM
|
// Precision of Qty UOM
|
||||||
int precision = 2;
|
int precision = 2;
|
||||||
|
|
||||||
if (M_Product_ID != 0)
|
if (M_Product_ID != 0)
|
||||||
{
|
{
|
||||||
MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
|
MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
|
||||||
precision = product.getUOMPrecision();
|
precision = product.getUOMPrecision();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_DOWN);
|
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_DOWN);
|
||||||
|
//
|
||||||
log.fine("Line QtyEntered=" + QtyEntered
|
log.fine("Line QtyEntered=" + QtyEntered
|
||||||
+ ", Product_ID=" + M_Product_ID
|
+ ", Product_ID=" + M_Product_ID
|
||||||
+ ", OrderLine_ID=" + C_OrderLine_ID + ", InOutLine_ID=" + M_InOutLine_ID);
|
+ ", OrderLine_ID=" + C_OrderLine_ID + ", InOutLine_ID=" + M_InOutLine_ID);
|
||||||
|
|
||||||
// Create new Invoice Line
|
// Create new Invoice Line
|
||||||
|
|
||||||
MInvoiceLine invoiceLine = new MInvoiceLine (invoice);
|
MInvoiceLine invoiceLine = new MInvoiceLine (invoice);
|
||||||
invoiceLine.setM_Product_ID(M_Product_ID, C_UOM_ID); // Line UOM
|
invoiceLine.setM_Product_ID(M_Product_ID, C_UOM_ID); // Line UOM
|
||||||
invoiceLine.setQty(QtyEntered); // Invoiced/Entered
|
invoiceLine.setQty(QtyEntered); // Invoiced/Entered
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
|
|
||||||
MOrderLine orderLine = null;
|
MOrderLine orderLine = null;
|
||||||
|
|
||||||
if (C_OrderLine_ID != 0)
|
if (C_OrderLine_ID != 0)
|
||||||
orderLine = new MOrderLine (Env.getCtx(), C_OrderLine_ID, null);
|
orderLine = new MOrderLine (Env.getCtx(), C_OrderLine_ID, null);
|
||||||
|
|
||||||
MInOutLine inoutLine = null;
|
MInOutLine inoutLine = null;
|
||||||
|
|
||||||
if (M_InOutLine_ID != 0)
|
if (M_InOutLine_ID != 0)
|
||||||
{
|
{
|
||||||
inoutLine = new MInOutLine (Env.getCtx(), M_InOutLine_ID, null);
|
inoutLine = new MInOutLine (Env.getCtx(), M_InOutLine_ID, null);
|
||||||
|
|
||||||
if (orderLine == null && inoutLine.getC_OrderLine_ID() != 0)
|
if (orderLine == null && inoutLine.getC_OrderLine_ID() != 0)
|
||||||
{
|
{
|
||||||
C_OrderLine_ID = inoutLine.getC_OrderLine_ID();
|
C_OrderLine_ID = inoutLine.getC_OrderLine_ID();
|
||||||
|
@ -421,10 +540,8 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MInOutLine[] lines = MInOutLine.getOfOrderLine(Env.getCtx(),
|
MInOutLine[] lines = MInOutLine.getOfOrderLine(Env.getCtx(),
|
||||||
C_OrderLine_ID, null, null);
|
C_OrderLine_ID, null, null);
|
||||||
|
|
||||||
log.fine ("Receipt Lines with OrderLine = #" + lines.length);
|
log.fine ("Receipt Lines with OrderLine = #" + lines.length);
|
||||||
|
|
||||||
if (lines.length > 0)
|
if (lines.length > 0)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < lines.length; j++)
|
for (int j = 0; j < lines.length; j++)
|
||||||
|
@ -439,32 +556,28 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
|
||||||
}
|
}
|
||||||
if (inoutLine == null)
|
if (inoutLine == null)
|
||||||
{
|
{
|
||||||
inoutLine = lines[0]; // First as default
|
inoutLine = lines[0]; // first as default
|
||||||
M_InOutLine_ID = inoutLine.getM_InOutLine_ID();
|
M_InOutLine_ID = inoutLine.getM_InOutLine_ID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // Get Ship info
|
} // get Ship info
|
||||||
|
|
||||||
// Shipment Info
|
// Shipment Info
|
||||||
|
|
||||||
if (inoutLine != null)
|
if (inoutLine != null)
|
||||||
{
|
{
|
||||||
invoiceLine.setShipLine(inoutLine); // Overwrites
|
invoiceLine.setShipLine(inoutLine); // overwrites
|
||||||
|
|
||||||
if (inoutLine.getQtyEntered().compareTo(inoutLine.getMovementQty()) != 0)
|
if (inoutLine.getQtyEntered().compareTo(inoutLine.getMovementQty()) != 0)
|
||||||
invoiceLine.setQtyInvoiced(QtyEntered
|
invoiceLine.setQtyInvoiced(QtyEntered
|
||||||
.multiply(inoutLine.getMovementQty())
|
.multiply(inoutLine.getMovementQty())
|
||||||
.divide(inoutLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
.divide(inoutLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log.fine("No Receipt Line");
|
log.fine("No Receipt Line");
|
||||||
|
|
||||||
// Order Info
|
// Order Info
|
||||||
|
|
||||||
if (orderLine != null)
|
if (orderLine != null)
|
||||||
{
|
{
|
||||||
invoiceLine.setOrderLine(orderLine); // Overwrites
|
invoiceLine.setOrderLine(orderLine); // overwrites
|
||||||
|
|
||||||
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
|
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
|
||||||
invoiceLine.setQtyInvoiced(QtyEntered
|
invoiceLine.setQtyInvoiced(QtyEntered
|
||||||
.multiply(orderLine.getQtyOrdered())
|
.multiply(orderLine.getQtyOrdered())
|
||||||
|
@ -476,12 +589,45 @@ public class WCreateFromInvoice extends WCreateFrom implements EventListener, Va
|
||||||
invoiceLine.setPrice();
|
invoiceLine.setPrice();
|
||||||
invoiceLine.setTax();
|
invoiceLine.setTax();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!invoiceLine.save())
|
if (!invoiceLine.save())
|
||||||
log.log(Level.SEVERE, "Line NOT created #" + i);
|
log.log(Level.SEVERE, "Line NOT created #" + i);
|
||||||
} // if selected
|
} // if selected
|
||||||
} // for all rows
|
} // for all rows
|
||||||
|
|
||||||
return true;
|
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
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,314 +1,311 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* 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 *
|
* 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 *
|
* 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 *
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
* See the GNU General Public License for more details. *
|
* See the GNU General Public License for more details. *
|
||||||
* You should have received a copy of the GNU General Public License along *
|
* 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., *
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* 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 *
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
package org.adempiere.webui.apps.form;
|
||||||
/**
|
|
||||||
* 2007, Modified by Posterita Ltd.
|
import java.math.*;
|
||||||
*/
|
import java.sql.*;
|
||||||
|
import java.text.*;
|
||||||
package org.adempiere.webui.apps.form;
|
import java.util.*;
|
||||||
|
import java.util.logging.*;
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.sql.PreparedStatement;
|
import org.adempiere.webui.component.ListModelTable;
|
||||||
import java.sql.ResultSet;
|
import org.adempiere.webui.editor.WStringEditor;
|
||||||
import java.sql.SQLException;
|
import org.adempiere.webui.editor.WTableDirEditor;
|
||||||
import java.sql.Timestamp;
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import java.text.DecimalFormat;
|
import org.adempiere.webui.event.ValueChangeListener;
|
||||||
import java.util.Vector;
|
import org.adempiere.webui.window.FDialog;
|
||||||
import java.util.logging.Level;
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
import org.adempiere.webui.component.ListModelTable;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.adempiere.webui.editor.WEditor;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
import org.adempiere.webui.editor.WSearchEditor;
|
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
/**
|
||||||
import org.adempiere.webui.event.ValueChangeListener;
|
* Create Transactions for Bank Statements
|
||||||
import org.adempiere.webui.event.WTableModelListener;
|
*
|
||||||
import org.adempiere.webui.window.FDialog;
|
* @author Jorg Janke
|
||||||
import org.compiere.model.GridTab;
|
* @version $Id: VCreateFromStatement.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||||
import org.compiere.model.MBankStatement;
|
* @author Victor Perez, e-Evolucion
|
||||||
import org.compiere.model.MBankStatementLine;
|
* <li> RF [1811114] http://sourceforge.net/tracker/index.php?func=detail&aid=1811114&group_id=176962&atid=879335
|
||||||
import org.compiere.model.MLookup;
|
*/
|
||||||
import org.compiere.model.MLookupFactory;
|
public class WCreateFromStatement extends WCreateFrom implements ValueChangeListener
|
||||||
import org.compiere.model.MPayment;
|
{
|
||||||
import org.compiere.util.DB;
|
/**
|
||||||
import org.compiere.util.DisplayType;
|
* Protected Constructor
|
||||||
import org.compiere.util.Env;
|
* @param mTab MTab
|
||||||
import org.compiere.util.KeyNamePair;
|
*/
|
||||||
import org.compiere.util.Msg;
|
WCreateFromStatement(GridTab mTab)
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
{
|
||||||
|
super (mTab);
|
||||||
/**
|
log.info("");
|
||||||
* Create From Statement : Based on VCreateFromStatement
|
} // VCreateFromStatement
|
||||||
*
|
|
||||||
* @author Niraj Sohun
|
/**
|
||||||
* @date Jul 20, 2007
|
* Dynamic Init
|
||||||
*/
|
* @throws Exception if Lookups cannot be initialized
|
||||||
|
* @return true if initialized
|
||||||
public class WCreateFromStatement extends WCreateFrom implements EventListener, ValueChangeListener, WTableModelListener
|
*/
|
||||||
{
|
protected boolean dynInit() throws Exception
|
||||||
private static final long serialVersionUID = 1L;
|
{
|
||||||
|
if (p_mTab.getValue("C_BankStatement_ID") == null)
|
||||||
/**
|
{
|
||||||
* Protected Constructor
|
FDialog.error(0, this, "SaveErrorRowNotFound");
|
||||||
* @param mTab MTab
|
return false;
|
||||||
*/
|
}
|
||||||
|
// Do not display RMA selection
|
||||||
WCreateFromStatement(GridTab mTab)
|
rmaLabel.setVisible(false);
|
||||||
{
|
rmaField.setVisible(false);
|
||||||
super(mTab);
|
|
||||||
//log.info("");
|
sameWarehouseCb.setVisible(false);
|
||||||
}
|
|
||||||
|
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
/**
|
parameterStdPanel.setVisible(false);
|
||||||
* Dynamic Init
|
|
||||||
* @throws Exception if Lookups cannot be initialized
|
int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID
|
||||||
* @return true if initialized
|
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();
|
||||||
protected boolean dynInit() throws Exception
|
editor.addValueChangeListner(this);
|
||||||
{
|
// Set Default
|
||||||
if (p_mTab.getValue("C_BankStatement_ID") == null)
|
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
||||||
{
|
bankAccountField.setValue(new Integer(C_BankAccount_ID));
|
||||||
FDialog.error(0, this, "SaveErrorRowNotFound");
|
// initial Loading
|
||||||
return false;
|
//RF [1811114]
|
||||||
}
|
String R_AuthCode="";
|
||||||
|
authorizationField = new WStringEditor ("authorization", false, false, true, 10, 30, null, null);
|
||||||
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
authorizationField.getComponent().addEventListener(Events.ON_CHANGE, this);
|
||||||
|
loadBankAccount(C_BankAccount_ID, R_AuthCode);
|
||||||
parameterShipmentPanel.setVisible(false);
|
|
||||||
parameterInvoicePanel.setVisible(false);
|
return true;
|
||||||
hboxCommon.setVisible(false);
|
} // dynInit
|
||||||
|
|
||||||
int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID
|
/**
|
||||||
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
* Init Details (never called)
|
||||||
bankAccountField = new WSearchEditor(lookup, "label","desc", true, false, true);
|
* @param C_BPartner_ID BPartner
|
||||||
bankAccountField.addValueChangeListner(this);
|
*/
|
||||||
|
protected void initBPDetails(int C_BPartner_ID)
|
||||||
// Set Default
|
{
|
||||||
|
} // initDetails
|
||||||
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
|
||||||
bankAccountField.setValue(new Integer(C_BankAccount_ID));
|
/**
|
||||||
|
* Change Listener
|
||||||
// Initial Loading
|
* @param e event
|
||||||
loadBankAccount(C_BankAccount_ID);
|
*/
|
||||||
|
public void valueChange (ValueChangeEvent e)
|
||||||
return true;
|
{
|
||||||
}
|
log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||||
|
int C_BankAccount_ID=0;
|
||||||
/**
|
//RF [1811114]
|
||||||
* Init Details (never called)
|
String R_AuthCode = (authorizationField.getValue().toString());
|
||||||
* @param C_BPartner_ID BPartner
|
|
||||||
*/
|
// BankAccount
|
||||||
|
if (e.getPropertyName().equals("C_BankAccount_ID"))
|
||||||
protected void initBPDetails(int C_BPartner_ID)
|
{
|
||||||
{
|
//RF [1811114]
|
||||||
}
|
C_BankAccount_ID = ((Integer)e.getNewValue()).intValue();
|
||||||
|
if (authorizationField.getValue().toString().equals(""))
|
||||||
public void valueChange(ValueChangeEvent evt)
|
loadBankAccount(C_BankAccount_ID, null);
|
||||||
{
|
else
|
||||||
log.config(evt.getPropertyName() + "=" + evt.getNewValue());
|
loadBankAccount(C_BankAccount_ID, R_AuthCode);
|
||||||
|
}
|
||||||
if (evt == null)
|
tableChanged(null);
|
||||||
return;
|
} // vetoableChange
|
||||||
|
|
||||||
if (evt.getSource() instanceof WEditor)
|
/**
|
||||||
{
|
* Load Data - Bank Account
|
||||||
// BankAccount
|
* @param C_BankAccount_ID Bank Account
|
||||||
|
* @param Autorization Code
|
||||||
if (evt.getPropertyName().equals("C_BankAccount_ID"))
|
*/
|
||||||
{
|
//RF [1811114]
|
||||||
int C_BankAccount_ID = ((Integer)evt.getNewValue()).intValue();
|
private void loadBankAccount (int C_BankAccount_ID, String R_AuthCode)
|
||||||
loadBankAccount(C_BankAccount_ID);
|
{
|
||||||
}
|
log.config ("C_BankAccount_ID=" + C_BankAccount_ID);
|
||||||
tableChanged(null);
|
/**
|
||||||
}
|
* Selected - 0
|
||||||
}
|
* Date - 1
|
||||||
|
* C_Payment_ID - 2
|
||||||
/**
|
* C_Currenncy - 3
|
||||||
* Load Data - Bank Account
|
* Amt - 4
|
||||||
* @param C_BankAccount_ID Bank Account
|
*/
|
||||||
*/
|
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,"
|
||||||
private void loadBankAccount (int C_BankAccount_ID)
|
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,?,null,p.AD_Client_ID,p.AD_Org_ID)," // #1
|
||||||
{
|
+ " bp.Name "
|
||||||
log.config ("C_BankAccount_ID=" + C_BankAccount_ID);
|
+ "FROM C_BankAccount ba"
|
||||||
/**
|
+ " INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)"
|
||||||
* Selected - -
|
+ " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)"
|
||||||
* Date - 1
|
+ " LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) "
|
||||||
* C_Payment_ID - 2
|
+ "WHERE p.Processed='Y' AND p.IsReconciled='N'"
|
||||||
* C_Currenncy - 3
|
+ " AND p.DocStatus IN ('CO','CL','RE','VO') AND p.PayAmt<>0" // Bug 1564453 Added Voided payment to bank statement payement selection
|
||||||
* Amt - 4
|
+ " AND p.C_BankAccount_ID=?"; // #2
|
||||||
*/
|
//RF [1811114]
|
||||||
|
if (R_AuthCode!= "" && R_AuthCode!= null)
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
sql = sql + " AND p.R_AuthCode LIKE ?";
|
||||||
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
|
sql = sql + " AND NOT EXISTS (SELECT * FROM C_BankStatementLine l "
|
||||||
+ " bp.Name "
|
// Voided Bank Statements have 0 StmtAmt
|
||||||
+ "FROM C_BankAccount ba"
|
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)";
|
||||||
+ " 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)"
|
// Get StatementDate
|
||||||
+ " LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) "
|
Timestamp ts = (Timestamp)p_mTab.getValue("StatementDate");
|
||||||
+ "WHERE p.Processed='Y' AND p.IsReconciled='N'"
|
if (ts == null)
|
||||||
+ " AND p.DocStatus IN ('CO','CL','RE','VO') AND p.PayAmt<>0" // Bug 1564453 Added Voided payment to bank statement payement selection
|
ts = new Timestamp(System.currentTimeMillis());
|
||||||
+ " AND p.C_BankAccount_ID=?" // #2
|
|
||||||
+ " AND NOT EXISTS (SELECT * FROM C_BankStatementLine l "
|
try
|
||||||
// Voided Bank Statements have 0 StmtAmt
|
{
|
||||||
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)";
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
|
pstmt.setTimestamp(1, ts);
|
||||||
// Get StatementDate
|
pstmt.setInt(2, C_BankAccount_ID);
|
||||||
|
//RF [1811114]
|
||||||
Timestamp ts = (Timestamp)p_mTab.getValue("StatementDate");
|
if (R_AuthCode!= "" && R_AuthCode!= null){
|
||||||
|
pstmt.setString(3, R_AuthCode);}
|
||||||
if (ts == null)
|
ResultSet rs = pstmt.executeQuery();
|
||||||
ts = new Timestamp(System.currentTimeMillis());
|
while (rs.next())
|
||||||
|
{
|
||||||
try
|
Vector<Object> line = new Vector<Object>(6);
|
||||||
{
|
line.add(new Boolean(false)); // 0-Selection
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
line.add(rs.getTimestamp(1)); // 1-DateTrx
|
||||||
pstmt.setTimestamp(1, ts);
|
KeyNamePair pp = new KeyNamePair(rs.getInt(2), rs.getString(3));
|
||||||
pstmt.setInt(2, C_BankAccount_ID);
|
line.add(pp); // 2-C_Payment_ID
|
||||||
ResultSet rs = pstmt.executeQuery();
|
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
|
||||||
|
line.add(pp); // 3-Currency
|
||||||
while (rs.next())
|
line.add(rs.getBigDecimal(6)); // 4-PayAmt
|
||||||
{
|
line.add(rs.getBigDecimal(7)); // 5-Conv Amt
|
||||||
Vector<Object> line = new Vector<Object>(6);
|
line.add(rs.getString(8)); // 6-BParner
|
||||||
//line.add(new Boolean(false)); // 0-Selection
|
data.add(line);
|
||||||
line.add(rs.getTimestamp(1)); // 1-DateTrx
|
}
|
||||||
|
rs.close();
|
||||||
KeyNamePair pp = new KeyNamePair(rs.getInt(2), rs.getString(3));
|
pstmt.close();
|
||||||
line.add(pp); // 2-C_Payment_ID
|
}
|
||||||
|
catch (SQLException e)
|
||||||
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
|
{
|
||||||
line.add(pp); // 3-Currency
|
log.log(Level.SEVERE, sql, e);
|
||||||
line.add(rs.getBigDecimal(6)); // 4-PayAmt
|
}
|
||||||
line.add(rs.getBigDecimal(7)); // 5-Conv Amt
|
// Header Info
|
||||||
line.add(rs.getString(8)); // 6-BParner
|
Vector<String> columnNames = new Vector<String>(6);
|
||||||
data.add(line);
|
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
||||||
}
|
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
|
||||||
rs.close();
|
columnNames.add(Msg.getElement(Env.getCtx(), "C_Payment_ID"));
|
||||||
pstmt.close();
|
columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
||||||
}
|
columnNames.add(Msg.translate(Env.getCtx(), "Amount"));
|
||||||
catch (SQLException e)
|
columnNames.add(Msg.translate(Env.getCtx(), "ConvertedAmount"));
|
||||||
{
|
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
|
||||||
log.log(Level.SEVERE, sql, e);
|
|
||||||
}
|
// Remove previous listeners
|
||||||
|
dataTable.getModel().removeTableModelListener(this);
|
||||||
if (data.size() == 0)
|
// Set Model
|
||||||
return;
|
ListModelTable model = new ListModelTable(data);
|
||||||
|
model.addTableModelListener(this);
|
||||||
// Header Info
|
dataTable.setData(model, columnNames);
|
||||||
|
//
|
||||||
Vector<String> columnNames = new Vector<String>(6);
|
dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
//columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
dataTable.setColumnClass(1, Timestamp.class, true); // 1-TrxDate
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
|
dataTable.setColumnClass(2, String.class, true); // 2-Payment
|
||||||
columnNames.add(Msg.getElement(Env.getCtx(), "C_Payment_ID"));
|
dataTable.setColumnClass(3, String.class, true); // 3-Currency
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
dataTable.setColumnClass(4, BigDecimal.class, true); // 4-Amount
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "Amount"));
|
dataTable.setColumnClass(5, BigDecimal.class, true); // 5-ConvAmount
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "ConvertedAmount"));
|
dataTable.setColumnClass(6, String.class, true); // 6-BPartner
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
|
// Table UI
|
||||||
|
dataTable.autoSize();
|
||||||
// Remove previous listeners
|
} // loadBankAccount
|
||||||
//dataTable.getModel().removeListDataListener(this);
|
|
||||||
|
/**
|
||||||
// Set Model
|
* List total amount
|
||||||
ListModelTable model = new ListModelTable(data);
|
*/
|
||||||
model.addTableModelListener(this);
|
protected void info()
|
||||||
dataTable.setData(model, columnNames);
|
{
|
||||||
|
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||||
//dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
|
||||||
dataTable.setColumnClass(0, Timestamp.class, true); // 1-TrxDate
|
ListModelTable model = dataTable.getModel();
|
||||||
dataTable.setColumnClass(1, String.class, true); // 2-Payment
|
BigDecimal total = new BigDecimal(0.0);
|
||||||
dataTable.setColumnClass(2, String.class, true); // 3-Currency
|
int rows = model.getRowCount();
|
||||||
dataTable.setColumnClass(3, BigDecimal.class, true); // 4-Amount
|
int count = 0;
|
||||||
dataTable.setColumnClass(4, BigDecimal.class, true); // 5-ConvAmount
|
for (int i = 0; i < rows; i++)
|
||||||
dataTable.setColumnClass(5, String.class, true); // 6-BPartner
|
{
|
||||||
|
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||||
// Table UI
|
{
|
||||||
//dataTable.autoSize();
|
total = total.add((BigDecimal)model.getValueAt(i, 4));
|
||||||
} // loadBankAccount
|
count++;
|
||||||
|
}
|
||||||
/**
|
}
|
||||||
* List total amount
|
setStatusLine(count, Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
|
||||||
*/
|
} // infoStatement
|
||||||
|
|
||||||
protected void info()
|
/**
|
||||||
{
|
* Save Statement - Insert Data
|
||||||
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
* @return true if saved
|
||||||
|
*/
|
||||||
ListModelTable model = dataTable.getModel();
|
protected boolean save()
|
||||||
BigDecimal total = new BigDecimal(0.0);
|
{
|
||||||
int rows = model.size();
|
log.config("");
|
||||||
int count = 0;
|
ListModelTable model = dataTable.getModel();
|
||||||
|
int rows = model.getRowCount();
|
||||||
for (int i = 0; i < rows; i++)
|
if (rows == 0)
|
||||||
{
|
return false;
|
||||||
if (dataTable.getItemAtIndex(i).isSelected())//(((Boolean)model.getDataAt(i, 0)).booleanValue())
|
|
||||||
{
|
// fixed values
|
||||||
total = total.add((BigDecimal)model.getDataAt(i, 4));
|
int C_BankStatement_ID = ((Integer)p_mTab.getValue("C_BankStatement_ID")).intValue();
|
||||||
count++;
|
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, null);
|
||||||
}
|
log.config(bs.toString());
|
||||||
}
|
|
||||||
lblStatus.setValue(String.valueOf(count) + " - " + Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
|
// Lines
|
||||||
} // infoStatement
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
/**
|
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||||
* Save Statement - Insert Data
|
{
|
||||||
* @return true if saved
|
Timestamp trxDate = (Timestamp)model.getValueAt(i, 1); // 1-DateTrx
|
||||||
*/
|
KeyNamePair pp = (KeyNamePair)model.getValueAt(i, 2); // 2-C_Payment_ID
|
||||||
protected boolean save()
|
int C_Payment_ID = pp.getKey();
|
||||||
{
|
pp = (KeyNamePair)model.getValueAt(i, 3); // 3-Currency
|
||||||
log.config("");
|
int C_Currency_ID = pp.getKey();
|
||||||
|
BigDecimal TrxAmt = (BigDecimal)model.getValueAt(i, 4); // 4-PayAmt
|
||||||
ListModelTable model = dataTable.getModel();
|
// BigDecimal StmtAmt = (BigDecimal)model.getValueAt(i, 5);// 5-Conv Amt
|
||||||
int rows = model.size();
|
//
|
||||||
|
log.fine("Line Date=" + trxDate
|
||||||
if (rows == 0)
|
+ ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
|
||||||
return false;
|
//
|
||||||
|
MBankStatementLine bsl = new MBankStatementLine (bs);
|
||||||
// Fixed values
|
bsl.setStatementLineDate(trxDate);
|
||||||
|
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
|
||||||
int C_BankStatement_ID = ((Integer)p_mTab.getValue("C_BankStatement_ID")).intValue();
|
if (!bsl.save())
|
||||||
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, null);
|
log.log(Level.SEVERE, "Line not created #" + i);
|
||||||
log.config(bs.toString());
|
} // if selected
|
||||||
|
} // for all rows
|
||||||
// Lines
|
return true;
|
||||||
|
} // save
|
||||||
for (int i = 0; i < rows; i++)
|
|
||||||
{
|
/*
|
||||||
if (dataTable.getItemAtIndex(i).isSelected())//(((Boolean)model.getDataAt(i, 0)).booleanValue())
|
* Action Listener
|
||||||
{
|
* @param e event*/
|
||||||
Timestamp trxDate = (Timestamp)model.getDataAt(i, 0); // 1-DateTrx
|
//RF [1811114]
|
||||||
KeyNamePair pp = (KeyNamePair)model.getDataAt(i, 1); // 2-C_Payment_ID
|
public void onEvent(Event e) throws Exception
|
||||||
int C_Payment_ID = pp.getKey();
|
{
|
||||||
pp = (KeyNamePair)model.getDataAt(i, 2); // 3-Currency
|
super.onEvent(e);
|
||||||
int C_Currency_ID = pp.getKey();
|
log.config("Action=" + e.getTarget().getId());
|
||||||
BigDecimal TrxAmt = (BigDecimal)model.getDataAt(i, 3); // 4-PayAmt
|
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
||||||
// BigDecimal StmtAmt = (BigDecimal)model.getValueAt(i, 5);// 5-Conv Amt
|
if (e.getTarget().equals(authorizationField.getComponent()))
|
||||||
|
{
|
||||||
log.fine("Line Date=" + trxDate
|
String R_AuthCode = (authorizationField.getValue().toString());
|
||||||
+ ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
|
if (authorizationField.getValue().toString().equals(""))
|
||||||
|
{
|
||||||
MBankStatementLine bsl = new MBankStatementLine (bs);
|
loadBankAccount(C_BankAccount_ID, null);
|
||||||
bsl.setStatementLineDate(trxDate);
|
}
|
||||||
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
|
else
|
||||||
|
loadBankAccount(C_BankAccount_ID, R_AuthCode);
|
||||||
if (!bsl.save())
|
}
|
||||||
log.log(Level.SEVERE, "Line not created #" + i);
|
}
|
||||||
} // if selected
|
|
||||||
} // for all rows
|
} // VCreateFromStatement
|
||||||
return true;
|
|
||||||
} // save
|
|
||||||
}
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ public class WTrxMaterial extends ADForm implements EventListener, ValueChangeLi
|
||||||
|
|
||||||
// Locator
|
// Locator
|
||||||
MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo);
|
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);
|
locatorField.addValueChangeListner(this);
|
||||||
|
|
||||||
// Product
|
// Product
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
|
|
||||||
package org.adempiere.webui.component;
|
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>
|
* @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();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,9 @@
|
||||||
|
|
||||||
package org.adempiere.webui.component;
|
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>
|
* @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();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zul.Hbox;
|
import org.zkoss.zul.Hbox;
|
||||||
import org.zkoss.zul.Messagebox;
|
import org.zkoss.zul.Messagebox;
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +36,10 @@ public final class ConfirmPanel extends Hbox
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
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>();
|
private Map<String, Button> buttonMap = new HashMap<String, Button>();
|
||||||
|
|
||||||
|
@ -353,5 +358,29 @@ public final class ConfirmPanel extends Hbox
|
||||||
button.addEventListener(event, listener);
|
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
|
} // ConfirmPanel
|
||||||
|
|
|
@ -31,4 +31,13 @@ public class Grid extends org.zkoss.zul.Grid
|
||||||
setSclass("grid-no-striped");
|
setSclass("grid-no-striped");
|
||||||
setOddRowSclass("even");
|
setOddRowSclass("even");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Rows newRows() {
|
||||||
|
Rows rows = new Rows();
|
||||||
|
appendChild(rows);
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.adempiere.webui.component;
|
||||||
|
|
||||||
|
public class GridFactory {
|
||||||
|
|
||||||
|
public static Grid newGridLayout() {
|
||||||
|
Grid grid = new Grid();
|
||||||
|
grid.makeNoStrip();
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.adempiere.webui.component;
|
package org.adempiere.webui.component;
|
||||||
|
|
||||||
|
import org.adempiere.webui.LayoutUtils;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,4 +83,18 @@ public class Label extends org.zkoss.zul.Label
|
||||||
} else if (decorator != null)
|
} else if (decorator != null)
|
||||||
decorator.setVisible(false);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@ package org.adempiere.webui.component;
|
||||||
|
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.beans.PropertyChangeSupport;
|
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>
|
* @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);
|
m_propertyChangeListeners.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KeyNamePair toKeyNamePair()
|
||||||
|
{
|
||||||
|
return new KeyNamePair((Integer)getValue(), getLabel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValueNamePair toValueNamePair() {
|
||||||
|
return new ValueNamePair((String)getValue(), getLabel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,4 +331,32 @@ public class ListModelTable extends ListModelList implements ListModelExt
|
||||||
|
|
||||||
return;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.adempiere.webui.apps.form.WCreateFrom;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
@ -204,5 +205,36 @@ public class Listbox extends org.zkoss.zul.Listbox implements EventListener
|
||||||
listener.onEvent(event);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,5 +26,11 @@ package org.adempiere.webui.component;
|
||||||
public class Rows extends org.zkoss.zul.Rows
|
public class Rows extends org.zkoss.zul.Rows
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public Row newRow() {
|
||||||
|
Row row = new Row();
|
||||||
|
appendChild(row);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,14 @@
|
||||||
|
|
||||||
package org.adempiere.webui.component;
|
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.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
|
* @date Feb 25, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @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 static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Obscure m_obscure = null;
|
||||||
|
|
||||||
|
private boolean m_infocus;
|
||||||
|
|
||||||
|
|
||||||
public Textbox()
|
public Textbox()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
addFocusListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Textbox(String value) throws WrongValueException
|
public Textbox(String value) throws WrongValueException
|
||||||
{
|
{
|
||||||
super(value);
|
super(value);
|
||||||
|
addFocusListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled)
|
public void setEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
this.setDisabled(!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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -999,4 +999,11 @@ public class WListbox extends Listbox implements TableValueChangeListener, WTabl
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no op, to ease porting of swing form
|
||||||
|
*/
|
||||||
|
public void autoSize() {
|
||||||
|
//no op
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,4 +39,12 @@ public class Window extends org.zkoss.zul.Window
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* alias for detach, to ease porting of swing form
|
||||||
|
*/
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,34 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
|
||||||
init();
|
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.
|
* Set the editor component.
|
||||||
* @param comp 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()
|
public GridField getGridField()
|
||||||
{
|
{
|
||||||
return gridField;
|
return gridField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return columnNames
|
||||||
|
*/
|
||||||
public String getColumnName()
|
public String getColumnName()
|
||||||
{
|
{
|
||||||
return columnName;
|
return columnName;
|
||||||
|
@ -201,6 +237,10 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
|
||||||
this.columnName = cleanColumnName;
|
this.columnName = cleanColumnName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Component
|
||||||
|
*/
|
||||||
public Component getComponent()
|
public Component getComponent()
|
||||||
{
|
{
|
||||||
return component;
|
return component;
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
|
||||||
|
|
||||||
public WLocatorEditor()
|
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,
|
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);
|
super(new EditorBox(), "Locator", "", mandatory, isReadOnly, isUpdateable);
|
||||||
|
|
||||||
|
@ -87,6 +87,8 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
|
||||||
getComponent().setButtonImage("/images/Locator10.gif");
|
getComponent().setButtonImage("/images/Locator10.gif");
|
||||||
|
|
||||||
setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ]
|
setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ]
|
||||||
|
|
||||||
|
m_WindowNo = windowNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(Object value)
|
public void setValue(Object value)
|
||||||
|
|
|
@ -119,6 +119,23 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
init();
|
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
|
* initialise editor
|
||||||
* @param columnName columnName
|
* @param columnName columnName
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import org.adempiere.webui.ValuePreference;
|
import org.adempiere.webui.ValuePreference;
|
||||||
|
import org.adempiere.webui.apps.form.WCreateFromStatement;
|
||||||
import org.adempiere.webui.component.Textbox;
|
import org.adempiere.webui.component.Textbox;
|
||||||
import org.adempiere.webui.event.ContextMenuEvent;
|
import org.adempiere.webui.event.ContextMenuEvent;
|
||||||
import org.adempiere.webui.event.ContextMenuListener;
|
import org.adempiere.webui.event.ContextMenuListener;
|
||||||
|
@ -26,6 +27,7 @@ import org.compiere.model.GridField;
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,12 +44,38 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
|
|
||||||
private WEditorPopupMenu popupMenu;
|
private WEditorPopupMenu popupMenu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* to ease porting of swing form
|
||||||
|
*/
|
||||||
|
public WStringEditor()
|
||||||
|
{
|
||||||
|
this("String", false, false, true, 30, 30, "", null);
|
||||||
|
}
|
||||||
|
|
||||||
public WStringEditor(GridField gridField)
|
public WStringEditor(GridField gridField)
|
||||||
{
|
{
|
||||||
super(new Textbox(), 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
|
@Override
|
||||||
|
@ -65,41 +93,49 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
getComponent().setReadonly(!readWrite);
|
getComponent().setReadonly(!readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private void init(String obscureType)
|
||||||
{
|
{
|
||||||
getComponent().setMaxlength(gridField.getFieldLength());
|
if (gridField != null)
|
||||||
int displayLength = gridField.getDisplayLength();
|
{
|
||||||
if (displayLength <= 0 || displayLength > MAX_DISPLAY_LENGTH)
|
getComponent().setMaxlength(gridField.getFieldLength());
|
||||||
{
|
int displayLength = gridField.getDisplayLength();
|
||||||
displayLength = MAX_DISPLAY_LENGTH;
|
if (displayLength <= 0 || displayLength > MAX_DISPLAY_LENGTH)
|
||||||
}
|
{
|
||||||
getComponent().setCols(displayLength);
|
displayLength = MAX_DISPLAY_LENGTH;
|
||||||
|
}
|
||||||
if (gridField.getDisplayType() == DisplayType.Text)
|
getComponent().setCols(displayLength);
|
||||||
{
|
|
||||||
getComponent().setMultiline(true);
|
if (gridField.getDisplayType() == DisplayType.Text)
|
||||||
getComponent().setRows(3);
|
{
|
||||||
}
|
getComponent().setMultiline(true);
|
||||||
else if (gridField.getDisplayType() == DisplayType.TextLong)
|
getComponent().setRows(3);
|
||||||
{
|
}
|
||||||
getComponent().setMultiline(true);
|
else if (gridField.getDisplayType() == DisplayType.TextLong)
|
||||||
getComponent().setRows(5);
|
{
|
||||||
}
|
getComponent().setMultiline(true);
|
||||||
else if (gridField.getDisplayType() == DisplayType.Memo)
|
getComponent().setRows(5);
|
||||||
{
|
}
|
||||||
getComponent().setMultiline(true);
|
else if (gridField.getDisplayType() == DisplayType.Memo)
|
||||||
getComponent().setRows(8);
|
{
|
||||||
}
|
getComponent().setMultiline(true);
|
||||||
|
getComponent().setRows(8);
|
||||||
popupMenu = new WEditorPopupMenu(false, false, true);
|
}
|
||||||
|
|
||||||
|
getComponent().setObscureType(obscureType);
|
||||||
|
|
||||||
|
popupMenu = new WEditorPopupMenu(false, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
String newText = getComponent().getValue();
|
if (Events.ON_CHANGE.equals(event.getName()))
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldText, newText);
|
{
|
||||||
super.fireValueChange(changeEvent);
|
String newText = getComponent().getValue();
|
||||||
oldText = newText;
|
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldText, newText);
|
||||||
|
super.fireValueChange(changeEvent);
|
||||||
|
oldText = newText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -94,6 +94,26 @@ ContextMenuListener, IZoomableEditor
|
||||||
init();
|
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()
|
private void init()
|
||||||
{
|
{
|
||||||
getComponent().setRows(0);
|
getComponent().setRows(0);
|
||||||
|
@ -119,8 +139,11 @@ ContextMenuListener, IZoomableEditor
|
||||||
refreshList();
|
refreshList();
|
||||||
}
|
}
|
||||||
|
|
||||||
popupMenu = new WEditorPopupMenu(zoom, true, true);
|
if (gridField != null)
|
||||||
getComponent().setContext(popupMenu.getId());
|
{
|
||||||
|
popupMenu = new WEditorPopupMenu(zoom, true, true);
|
||||||
|
getComponent().setContext(popupMenu.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -57,8 +57,7 @@ public class WebEditorFactory
|
||||||
|
|
||||||
WEditor editor = null;
|
WEditor editor = null;
|
||||||
int displayType = gridField.getDisplayType();
|
int displayType = gridField.getDisplayType();
|
||||||
int WindowNo = gridField.getWindowNo();
|
|
||||||
|
|
||||||
/** Not a Field */
|
/** Not a Field */
|
||||||
if (gridField.isHeading())
|
if (gridField.isHeading())
|
||||||
{
|
{
|
||||||
|
@ -144,7 +143,7 @@ public class WebEditorFactory
|
||||||
{
|
{
|
||||||
editor = new WLocatorEditor(gridField.getColumnName(), gridField.isMandatory(false),
|
editor = new WLocatorEditor(gridField.getColumnName(), gridField.isMandatory(false),
|
||||||
gridField.isReadOnly(), gridField.isUpdateable(),
|
gridField.isReadOnly(), gridField.isUpdateable(),
|
||||||
(MLocatorLookup)gridField.getLookup());
|
(MLocatorLookup)gridField.getLookup(), gridField.getWindowNo());
|
||||||
}
|
}
|
||||||
else if (displayType == DisplayType.Account)
|
else if (displayType == DisplayType.Account)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,6 @@ import org.adempiere.webui.editor.WEditor;
|
||||||
import org.adempiere.webui.editor.WNumberEditor;
|
import org.adempiere.webui.editor.WNumberEditor;
|
||||||
import org.adempiere.webui.editor.WSearchEditor;
|
import org.adempiere.webui.editor.WSearchEditor;
|
||||||
import org.adempiere.webui.editor.WStringEditor;
|
import org.adempiere.webui.editor.WStringEditor;
|
||||||
import org.adempiere.webui.editor.WTableDirEditor;
|
|
||||||
import org.adempiere.webui.editor.WebEditorFactory;
|
import org.adempiere.webui.editor.WebEditorFactory;
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.event.ValueChangeListener;
|
import org.adempiere.webui.event.ValueChangeListener;
|
||||||
|
@ -1286,7 +1285,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
||||||
|
|
||||||
} // cmd_ok_Simple
|
} // cmd_ok_Simple
|
||||||
|
|
||||||
private void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
|
|
||||||
|
@ -1305,7 +1304,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
||||||
m_targetFields.clear();
|
m_targetFields.clear();
|
||||||
m_targetFields = null;
|
m_targetFields = null;
|
||||||
//
|
//
|
||||||
this.detach();
|
super.dispose();
|
||||||
} // dispose
|
} // dispose
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue