* merge revision 6147-6148 changes from branches/adempiere341
This commit is contained in:
parent
7980165ed9
commit
a378b8c11c
|
@ -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,262 +14,106 @@
|
||||||
* 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.sql.*;
|
||||||
import java.sql.PreparedStatement;
|
import java.util.*;
|
||||||
import java.sql.ResultSet;
|
import java.util.logging.*;
|
||||||
import java.sql.SQLException;
|
import java.math.*;
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.adempiere.webui.apps.AEnv;
|
import org.adempiere.webui.apps.AEnv;
|
||||||
import org.adempiere.webui.component.Button;
|
import org.adempiere.webui.component.Button;
|
||||||
|
import org.adempiere.webui.component.ButtonFactory;
|
||||||
|
import org.adempiere.webui.component.Checkbox;
|
||||||
|
import org.adempiere.webui.component.ConfirmPanel;
|
||||||
|
import org.adempiere.webui.component.Grid;
|
||||||
|
import org.adempiere.webui.component.GridFactory;
|
||||||
import org.adempiere.webui.component.Label;
|
import org.adempiere.webui.component.Label;
|
||||||
import org.adempiere.webui.component.ListModelTable;
|
import org.adempiere.webui.component.ListModelTable;
|
||||||
import org.adempiere.webui.component.Listbox;
|
import org.adempiere.webui.component.Listbox;
|
||||||
|
import org.adempiere.webui.component.ListboxFactory;
|
||||||
|
import org.adempiere.webui.component.Panel;
|
||||||
|
import org.adempiere.webui.component.Row;
|
||||||
|
import org.adempiere.webui.component.Rows;
|
||||||
import org.adempiere.webui.component.WListbox;
|
import org.adempiere.webui.component.WListbox;
|
||||||
|
import org.adempiere.webui.component.WStatusBar;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
import org.adempiere.webui.editor.WEditor;
|
import org.adempiere.webui.editor.WEditor;
|
||||||
|
import org.adempiere.webui.editor.WLocatorEditor;
|
||||||
import org.adempiere.webui.editor.WSearchEditor;
|
import org.adempiere.webui.editor.WSearchEditor;
|
||||||
import org.adempiere.webui.event.ValueChangeListener;
|
import org.adempiere.webui.editor.WStringEditor;
|
||||||
|
import org.adempiere.webui.editor.WTableDirEditor;
|
||||||
import org.adempiere.webui.event.WTableModelEvent;
|
import org.adempiere.webui.event.WTableModelEvent;
|
||||||
import org.adempiere.webui.event.WTableModelListener;
|
import org.adempiere.webui.event.WTableModelListener;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.*;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.util.*;
|
||||||
import org.compiere.model.MLookupFactory;
|
|
||||||
import org.compiere.model.MOrder;
|
|
||||||
import org.compiere.util.CLogger;
|
|
||||||
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.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zkex.zul.Borderlayout;
|
||||||
import org.zkoss.zul.Hbox;
|
import org.zkoss.zkex.zul.Center;
|
||||||
|
import org.zkoss.zkex.zul.North;
|
||||||
|
import org.zkoss.zkex.zul.South;
|
||||||
import org.zkoss.zul.Separator;
|
import org.zkoss.zul.Separator;
|
||||||
import org.zkoss.zul.Vbox;
|
import org.zkoss.zul.Space;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create From (Base Class) : Based on VCreateFrom
|
* CreateFrom (Called from GridController.startProcess)
|
||||||
*
|
*
|
||||||
* @author Niraj Sohun
|
* @author Jorg Janke
|
||||||
* @date Jul 16, 2007
|
* @version $Id: VCreateFrom.java,v 1.4 2006/10/11 09:52:23 comdivision Exp $
|
||||||
|
*
|
||||||
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
|
* <li>FR [ 1794050 ] Usability: VCreateFrom OK button always enabled
|
||||||
|
* @author Victor Perez, e-Evolucion
|
||||||
|
* <li> RF [1811114] http://sourceforge.net/tracker/index.php?func=detail&aid=1811114&group_id=176962&atid=879335
|
||||||
|
* @author Karsten Thiemann, Schaeffer AG
|
||||||
|
* <li>Bug [ 1759431 ] Problems with VCreateFrom
|
||||||
*/
|
*/
|
||||||
|
public abstract class WCreateFrom extends Window
|
||||||
public abstract class WCreateFrom extends Window implements EventListener, WTableModelListener, ValueChangeListener
|
implements EventListener, WTableModelListener
|
||||||
{
|
{
|
||||||
private static CLogger s_log = CLogger.getCLogger (WCreateFrom.class);
|
/**
|
||||||
protected CLogger log = CLogger.getCLogger(getClass());
|
* Factory - called from APanel
|
||||||
|
* @param mTab Model Tab for the trx
|
||||||
protected Hbox hboxCommon = new Hbox();
|
* @return JDialog
|
||||||
protected Vbox parameterShipmentPanel = new Vbox();
|
*/
|
||||||
protected Hbox parameterBankPanel = new Hbox();
|
public static WCreateFrom create (GridTab mTab)
|
||||||
protected Vbox parameterInvoicePanel = new Vbox();
|
|
||||||
private Vbox bottomPanel = new Vbox();
|
|
||||||
|
|
||||||
protected Listbox shipmentField = new Listbox();
|
|
||||||
protected Listbox orderField = new Listbox();
|
|
||||||
protected Listbox invoiceField = new Listbox();
|
|
||||||
|
|
||||||
protected WEditor bankAccountField;
|
|
||||||
protected WEditor bPartnerField;
|
|
||||||
protected WEditor locatorField;
|
|
||||||
|
|
||||||
protected Button btnCancel = new Button();
|
|
||||||
protected Button btnOk = new Button();
|
|
||||||
protected Button btnSelectAll = new Button();
|
|
||||||
|
|
||||||
protected Label bankAccountLabel = new Label();
|
|
||||||
protected Label bPartnerLabel = new Label();
|
|
||||||
protected Label shipmentLabel = new Label();
|
|
||||||
protected Label orderLabel = new Label();
|
|
||||||
protected Label invoiceLabel = new Label();
|
|
||||||
protected Label locatorLabel = new Label();
|
|
||||||
protected Label lblStatus = new Label();
|
|
||||||
|
|
||||||
protected WListbox dataTable = new WListbox();
|
|
||||||
|
|
||||||
protected int p_WindowNo;
|
|
||||||
protected GridTab p_mTab;
|
|
||||||
private boolean p_initOK;
|
|
||||||
|
|
||||||
protected MOrder p_order = null;
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
{
|
||||||
// Common - BP and Purchase Order
|
// dynamic init preparation
|
||||||
|
|
||||||
bPartnerLabel.setValue(Msg.getElement(Env.getCtx(), "C_BPartner_ID"));
|
|
||||||
|
|
||||||
orderLabel.setValue(Msg.getElement(Env.getCtx(), "C_Order_ID", false));
|
|
||||||
|
|
||||||
orderField.setRows(0);
|
|
||||||
orderField.setMold("select");
|
|
||||||
orderField.addEventListener(Events.ON_SELECT, this);
|
|
||||||
|
|
||||||
hboxCommon.setWidth("700px");
|
|
||||||
hboxCommon.setWidths("13%, 30%, 12%, 25%");
|
|
||||||
|
|
||||||
hboxCommon.appendChild(bPartnerLabel);
|
|
||||||
|
|
||||||
if (bPartnerField != null)
|
|
||||||
hboxCommon.appendChild(bPartnerField.getComponent());
|
|
||||||
|
|
||||||
hboxCommon.appendChild(orderLabel);
|
|
||||||
hboxCommon.appendChild(orderField);
|
|
||||||
|
|
||||||
//End Common
|
|
||||||
|
|
||||||
// WCreateFromShipment
|
|
||||||
|
|
||||||
invoiceLabel.setValue(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false));
|
|
||||||
|
|
||||||
locatorLabel.setValue(Msg.translate(Env.getCtx(), "M_Locator_ID"));
|
|
||||||
|
|
||||||
invoiceField.setRows(0);
|
|
||||||
invoiceField.setMold("select");
|
|
||||||
invoiceField.addEventListener(Events.ON_SELECT, this);
|
|
||||||
|
|
||||||
Hbox boxShipment = new Hbox();
|
|
||||||
boxShipment.setWidth("100%");
|
|
||||||
boxShipment.setWidths("13%, 30%, 12%, 25%");
|
|
||||||
|
|
||||||
boxShipment.appendChild(locatorLabel);
|
|
||||||
|
|
||||||
if (locatorField != null)
|
|
||||||
boxShipment.appendChild(locatorField.getComponent());
|
|
||||||
|
|
||||||
boxShipment.appendChild(invoiceLabel);
|
|
||||||
boxShipment.appendChild(invoiceField);
|
|
||||||
|
|
||||||
parameterShipmentPanel.setWidth("700px");
|
|
||||||
parameterShipmentPanel.appendChild(boxShipment);
|
|
||||||
|
|
||||||
// WCreateFromInvoice
|
|
||||||
|
|
||||||
shipmentLabel.setValue(Msg.getElement(Env.getCtx(), "M_InOut_ID", false));
|
|
||||||
|
|
||||||
shipmentField.setRows(0);
|
|
||||||
shipmentField.setMold("select");
|
|
||||||
shipmentField.addEventListener(Events.ON_SELECT, this);
|
|
||||||
|
|
||||||
Hbox boxInvoice = new Hbox();
|
|
||||||
boxInvoice.setWidth("100%");
|
|
||||||
boxInvoice.setWidths("13%, 30%, 12%, 25%");
|
|
||||||
|
|
||||||
boxInvoice.appendChild(new Label());
|
|
||||||
boxInvoice.appendChild(new Label());
|
|
||||||
boxInvoice.appendChild(shipmentLabel);
|
|
||||||
boxInvoice.appendChild(shipmentField);
|
|
||||||
//boxInvoice.setStyle("text-align:right");
|
|
||||||
|
|
||||||
parameterInvoicePanel.setWidth("700px");
|
|
||||||
parameterInvoicePanel.appendChild(boxInvoice);
|
|
||||||
|
|
||||||
// End WCreateFromInvoice
|
|
||||||
|
|
||||||
// WCreateFromStatement
|
|
||||||
|
|
||||||
bankAccountLabel.setValue(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
|
|
||||||
|
|
||||||
Hbox boxStatement = new Hbox();
|
|
||||||
boxStatement.appendChild(bankAccountLabel);
|
|
||||||
|
|
||||||
if (bankAccountField != null)
|
|
||||||
boxStatement.appendChild(bankAccountField.getComponent());
|
|
||||||
|
|
||||||
boxStatement.setStyle("text-align:center");
|
|
||||||
|
|
||||||
parameterBankPanel.setWidth("700px");
|
|
||||||
parameterBankPanel.appendChild(boxStatement);
|
|
||||||
|
|
||||||
// End WCreateFromStatement
|
|
||||||
|
|
||||||
// Listbox
|
|
||||||
|
|
||||||
dataTable.setCheckmark(true);
|
|
||||||
dataTable.setMultiSelection(true);
|
|
||||||
|
|
||||||
|
|
||||||
// Buttons & Status
|
|
||||||
|
|
||||||
Hbox boxButtons = new Hbox();
|
|
||||||
boxButtons.setWidth("100%");
|
|
||||||
boxButtons.setWidths("90%, 5%, 5%" );
|
|
||||||
boxButtons.setStyle("text-align:left");
|
|
||||||
|
|
||||||
btnCancel.addEventListener(Events.ON_CLICK, this);
|
|
||||||
btnCancel.setImage("/images/Cancel24.gif");
|
|
||||||
|
|
||||||
btnOk.addEventListener(Events.ON_CLICK, this);
|
|
||||||
btnOk.setImage("/images/Ok24.gif");
|
|
||||||
|
|
||||||
btnSelectAll.addEventListener(Events.ON_CLICK, this);
|
|
||||||
btnSelectAll.setLabel("Select All");
|
|
||||||
|
|
||||||
boxButtons.appendChild(btnSelectAll);
|
|
||||||
boxButtons.appendChild(btnCancel);
|
|
||||||
boxButtons.appendChild(btnOk);
|
|
||||||
|
|
||||||
bottomPanel.setWidth("700px");
|
|
||||||
bottomPanel.appendChild(boxButtons);
|
|
||||||
bottomPanel.appendChild(lblStatus);
|
|
||||||
|
|
||||||
// End Buttons & Status
|
|
||||||
|
|
||||||
// Window
|
|
||||||
|
|
||||||
// this.setWidth("700px");
|
|
||||||
this.setClosable(true);
|
|
||||||
this.setBorder("normal");
|
|
||||||
|
|
||||||
this.appendChild(hboxCommon);
|
|
||||||
this.appendChild(new Separator());
|
|
||||||
this.appendChild(parameterInvoicePanel);
|
|
||||||
this.appendChild(parameterBankPanel);
|
|
||||||
this.appendChild(parameterShipmentPanel);
|
|
||||||
this.appendChild(new Separator());
|
|
||||||
this.appendChild(dataTable);
|
|
||||||
this.appendChild(new Separator());
|
|
||||||
this.appendChild(bottomPanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WCreateFrom create(GridTab mTab)
|
|
||||||
{
|
|
||||||
// Dynamic init preparation
|
|
||||||
|
|
||||||
int AD_Table_ID = Env.getContextAsInt(Env.getCtx(), mTab.getWindowNo(), "BaseTable_ID");
|
int AD_Table_ID = Env.getContextAsInt(Env.getCtx(), mTab.getWindowNo(), "BaseTable_ID");
|
||||||
|
|
||||||
WCreateFrom retValue = null;
|
WCreateFrom retValue = null;
|
||||||
|
if (AD_Table_ID == 392) // C_BankStatement
|
||||||
if (AD_Table_ID == 392) // C_BankStatement
|
retValue = new WCreateFromStatement (mTab);
|
||||||
retValue = new WCreateFromStatement(mTab);
|
else if (AD_Table_ID == 318) // C_Invoice
|
||||||
else if (AD_Table_ID == 318) // C_Invoice
|
retValue = new WCreateFromInvoice (mTab);
|
||||||
retValue = new WCreateFromInvoice(mTab);
|
else if (AD_Table_ID == 319) // M_InOut
|
||||||
else if (AD_Table_ID == 319) // M_InOut
|
retValue = new WCreateFromShipment (mTab);
|
||||||
retValue = new WCreateFromShipment(mTab);
|
else if (AD_Table_ID == 426) // C_PaySelection
|
||||||
else if (AD_Table_ID == 426) // C_PaySelection
|
return null; // ignore - will call process C_PaySelection_CreateFrom
|
||||||
return null; // Ignore - will call process C_PaySelection_CreateFrom
|
/**
|
||||||
else // Not supported CreateFrom
|
* Modification to support create Lines from for RMA
|
||||||
|
* @author ashley
|
||||||
|
*/
|
||||||
|
else if (AD_Table_ID == 661)
|
||||||
|
retValue = new WCreateFromRMA(mTab); // RMA
|
||||||
|
else // Not supported CreateFrom
|
||||||
{
|
{
|
||||||
s_log.info("Unsupported AD_Table_ID=" + AD_Table_ID);
|
s_log.info("Unsupported AD_Table_ID=" + AD_Table_ID);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
} // create
|
||||||
|
|
||||||
public WCreateFrom (GridTab mTab)
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Protected super class Constructor
|
||||||
|
* @param mTab MTab
|
||||||
|
*/
|
||||||
|
WCreateFrom (GridTab mTab)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
this.setAttribute("mode", "modal");
|
||||||
log.info(mTab.toString());
|
log.info(mTab.toString());
|
||||||
p_WindowNo = mTab.getWindowNo();
|
p_WindowNo = mTab.getWindowNo();
|
||||||
p_mTab = mTab;
|
p_mTab = mTab;
|
||||||
|
@ -278,14 +122,10 @@ public abstract class WCreateFrom extends Window implements EventListener, WTabl
|
||||||
{
|
{
|
||||||
if (!dynInit())
|
if (!dynInit())
|
||||||
return;
|
return;
|
||||||
|
zkInit();
|
||||||
init();
|
confirmPanel.addActionListener(this);
|
||||||
|
|
||||||
//confirmPanel.addActionListener(this);
|
|
||||||
|
|
||||||
// Set status
|
// Set status
|
||||||
|
statusBar.setStatusDB("");
|
||||||
//statusBar.setStatusDB("");
|
|
||||||
tableChanged(null);
|
tableChanged(null);
|
||||||
p_initOK = true;
|
p_initOK = true;
|
||||||
}
|
}
|
||||||
|
@ -295,167 +135,336 @@ public abstract class WCreateFrom extends Window implements EventListener, WTabl
|
||||||
p_initOK = false;
|
p_initOK = false;
|
||||||
}
|
}
|
||||||
AEnv.showWindow(this);
|
AEnv.showWindow(this);
|
||||||
}
|
} // VCreateFrom
|
||||||
|
|
||||||
|
/** Window No */
|
||||||
|
protected int p_WindowNo;
|
||||||
|
/** Model Tab */
|
||||||
|
protected GridTab p_mTab;
|
||||||
|
|
||||||
|
private boolean p_initOK = false;
|
||||||
|
|
||||||
|
/** Loaded Order */
|
||||||
|
protected MOrder p_order = null;
|
||||||
|
/** Logger */
|
||||||
|
protected CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
/** Static Logger */
|
||||||
|
private static CLogger s_log = CLogger.getCLogger (WCreateFrom.class);
|
||||||
|
|
||||||
|
//
|
||||||
|
private Borderlayout contentPane = new Borderlayout();
|
||||||
|
private Panel parameterPanel = new Panel();
|
||||||
|
protected Panel parameterBankPanel = new Panel();
|
||||||
|
private Borderlayout parameterLayout = new Borderlayout();
|
||||||
|
private Label bankAccountLabel = new Label();
|
||||||
|
protected Panel parameterStdPanel = new Panel();
|
||||||
|
private Label bPartnerLabel = new Label();
|
||||||
|
protected Listbox bankAccountField;
|
||||||
|
//RF [1811114]
|
||||||
|
private Label authorizationLabel = new Label();
|
||||||
|
protected WStringEditor authorizationField = new WStringEditor();
|
||||||
|
private Grid parameterStdLayout = GridFactory.newGridLayout();
|
||||||
|
private Grid parameterBankLayout = GridFactory.newGridLayout();
|
||||||
|
// Bug [1759431]
|
||||||
|
protected Checkbox sameWarehouseCb = new Checkbox();
|
||||||
|
protected WEditor bPartnerField;
|
||||||
|
protected Label orderLabel = new Label();
|
||||||
|
protected Listbox orderField = ListboxFactory.newDropdownListbox();
|
||||||
|
protected Label invoiceLabel = new Label();
|
||||||
|
protected Listbox invoiceField = ListboxFactory.newDropdownListbox();
|
||||||
|
protected Label shipmentLabel = new Label();
|
||||||
|
protected Listbox shipmentField = ListboxFactory.newDropdownListbox();
|
||||||
|
// private JScrollPane dataPane = new JScrollPane();
|
||||||
|
private Panel southPanel = new Panel();
|
||||||
|
// private Borderlayout southLayout = new Borderlayout();
|
||||||
|
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||||
|
private WStatusBar statusBar = new WStatusBar();
|
||||||
|
protected WListbox dataTable = ListboxFactory.newDataTable();
|
||||||
|
protected Label locatorLabel = new Label();
|
||||||
|
protected WLocatorEditor locatorField = new WLocatorEditor();
|
||||||
|
public static final String SELECT_ALL = "SelectAll";
|
||||||
|
// public static final String SELECT_ALL_TOOLTIP = "Select all records";
|
||||||
|
|
||||||
|
/** Label for the rma selection */
|
||||||
|
protected Label rmaLabel = new Label();
|
||||||
|
/** Combo box for selecting RMA document */
|
||||||
|
protected Listbox rmaField = ListboxFactory.newDropdownListbox();
|
||||||
|
/**
|
||||||
|
* Static Init.
|
||||||
|
* <pre>
|
||||||
|
* parameterPanel
|
||||||
|
* parameterBankPanel
|
||||||
|
* parameterStdPanel
|
||||||
|
* bPartner/order/invoice/shopment/licator Label/Field
|
||||||
|
* dataPane
|
||||||
|
* southPanel
|
||||||
|
* confirmPanel
|
||||||
|
* statusBar
|
||||||
|
* </pre>
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void zkInit() throws Exception
|
||||||
|
{
|
||||||
|
parameterPanel.appendChild(parameterLayout);
|
||||||
|
parameterStdPanel.appendChild(parameterStdLayout);
|
||||||
|
parameterBankPanel.appendChild(parameterBankLayout);
|
||||||
|
//
|
||||||
|
bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
|
||||||
|
//RF [1811114]
|
||||||
|
authorizationLabel.setText(Msg.translate(Env.getCtx(), "R_AuthCode"));
|
||||||
|
bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID"));
|
||||||
|
orderLabel.setText(Msg.getElement(Env.getCtx(), "C_Order_ID", false));
|
||||||
|
invoiceLabel.setText(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false));
|
||||||
|
shipmentLabel.setText(Msg.getElement(Env.getCtx(), "M_InOut_ID", false));
|
||||||
|
locatorLabel.setText(Msg.translate(Env.getCtx(), "M_Locator_ID"));
|
||||||
|
rmaLabel.setText(Msg.translate(Env.getCtx(), "M_RMA_ID"));
|
||||||
|
sameWarehouseCb.setText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", true));
|
||||||
|
sameWarehouseCb.setTooltiptext(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", false));
|
||||||
|
|
||||||
|
//
|
||||||
|
North north = new North();
|
||||||
|
this.appendChild(contentPane);
|
||||||
|
contentPane.appendChild(north);
|
||||||
|
north.appendChild(parameterPanel);
|
||||||
|
parameterPanel.appendChild(parameterLayout);
|
||||||
|
north = new North();
|
||||||
|
parameterLayout.appendChild(north);
|
||||||
|
north.appendChild(parameterBankPanel);
|
||||||
|
|
||||||
|
parameterLayout.setHeight("100px");
|
||||||
|
parameterLayout.setWidth("100%");
|
||||||
|
|
||||||
|
parameterBankPanel.appendChild(parameterBankLayout);
|
||||||
|
//RF [1811114]
|
||||||
|
Rows rows = (Rows) parameterBankLayout.newRows();
|
||||||
|
Row row = rows.newRow();
|
||||||
|
row.appendChild(bankAccountLabel.rightAlign());
|
||||||
|
if (bankAccountField != null)
|
||||||
|
row.appendChild(bankAccountField);
|
||||||
|
row.appendChild(authorizationLabel.rightAlign());
|
||||||
|
row.appendChild(authorizationField.getComponent());
|
||||||
|
|
||||||
|
Center center = new Center();
|
||||||
|
parameterLayout.appendChild(center);
|
||||||
|
center.appendChild(parameterStdPanel);
|
||||||
|
|
||||||
|
parameterStdPanel.appendChild(parameterStdLayout);
|
||||||
|
rows = (Rows) parameterStdLayout.newRows();
|
||||||
|
row = rows.newRow();
|
||||||
|
row.appendChild(bPartnerLabel.rightAlign());
|
||||||
|
if (bPartnerField != null)
|
||||||
|
row.appendChild(bPartnerField.getComponent());
|
||||||
|
row.appendChild(orderLabel.rightAlign());
|
||||||
|
row.appendChild(orderField);
|
||||||
|
|
||||||
|
row = rows.newRow();
|
||||||
|
row.appendChild(locatorLabel.rightAlign());
|
||||||
|
row.appendChild(locatorField.getComponent());
|
||||||
|
row.appendChild(invoiceLabel.rightAlign());
|
||||||
|
row.appendChild(invoiceField);
|
||||||
|
|
||||||
|
row = rows.newRow();
|
||||||
|
row.appendChild(new Space());
|
||||||
|
row.appendChild(sameWarehouseCb);
|
||||||
|
row.appendChild(shipmentLabel.rightAlign());
|
||||||
|
row.appendChild(shipmentField);
|
||||||
|
|
||||||
|
// Add RMA document selection to panel
|
||||||
|
row = rows.newRow();
|
||||||
|
row.appendChild(new Space());
|
||||||
|
row.appendChild(new Space());
|
||||||
|
row.appendChild(rmaLabel.rightAlign());
|
||||||
|
row.appendChild(rmaField);
|
||||||
|
|
||||||
|
center = new Center();
|
||||||
|
contentPane.appendChild(center);
|
||||||
|
center.appendChild(dataTable);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Trifon
|
||||||
|
// AppsAction selectAllAction = new AppsAction (SELECT_ALL, KeyStroke.getKeyStroke(KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK), null);
|
||||||
|
|
||||||
|
Button selectAllButton = ButtonFactory.createButton(SELECT_ALL, null);
|
||||||
|
confirmPanel.addComponentsLeft(selectAllButton);
|
||||||
|
selectAllButton.addActionListener(this);
|
||||||
|
// selectAllButton.setToolTipText(Msg.getMsg(Env.getCtx(), SELECT_ALL_TOOLTIP));
|
||||||
|
confirmPanel.addButton(selectAllButton);
|
||||||
|
//
|
||||||
|
South south = new South();
|
||||||
|
contentPane.appendChild(south);
|
||||||
|
south.appendChild(southPanel);
|
||||||
|
southPanel.appendChild(new Separator());
|
||||||
|
southPanel.appendChild(confirmPanel);
|
||||||
|
// Trifon End
|
||||||
|
southPanel.appendChild(new Separator());
|
||||||
|
southPanel.appendChild(statusBar);
|
||||||
|
|
||||||
|
this.setWidth("750px");
|
||||||
|
this.setHeight("550px");
|
||||||
|
this.setSizable(true);
|
||||||
|
this.setBorder("normal");
|
||||||
|
contentPane.setWidth("100%");
|
||||||
|
contentPane.setHeight("100%");
|
||||||
|
} // jbInit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init OK to be able to make changes?
|
* Init OK to be able to make changes?
|
||||||
* @return on if initialized
|
* @return on if initialized
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean isInitOK()
|
public boolean isInitOK()
|
||||||
{
|
{
|
||||||
return p_initOK;
|
return p_initOK;
|
||||||
}
|
} // isInitOK
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamic Init
|
* Dynamic Init
|
||||||
* @throws Exception if Lookups cannot be initialized
|
* @throws Exception if Lookups cannot be initialized
|
||||||
* @return true if initialized
|
* @return true if initialized
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract boolean dynInit() throws Exception;
|
abstract boolean dynInit() throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init Business Partner Details
|
* Init Business Partner Details
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract void initBPDetails(int C_BPartner_ID);
|
abstract void initBPDetails(int C_BPartner_ID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Info
|
* Add Info
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract void info();
|
abstract void info();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save & Insert Data
|
* Save & Insert Data
|
||||||
* @return true if saved
|
* @return true if saved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract boolean save();
|
abstract boolean save();
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action Listener
|
||||||
|
* @param e event
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
//log.config("Action=" + e.getActionCommand());
|
log.config("Action=" + e.getTarget().getId());
|
||||||
|
// if (m_action)
|
||||||
|
// return;
|
||||||
|
// m_action = true;
|
||||||
|
|
||||||
// OK - Save
|
// OK - Save
|
||||||
|
if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
|
||||||
if (e.getTarget() == btnOk)
|
|
||||||
{
|
{
|
||||||
if (save())
|
if (save())
|
||||||
this.detach();
|
dispose();
|
||||||
}
|
}
|
||||||
// Cancel
|
// Cancel
|
||||||
else if (e.getTarget() == btnCancel)
|
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
|
||||||
{
|
{
|
||||||
this.detach();
|
dispose();
|
||||||
}
|
}
|
||||||
// Select All
|
// Select All
|
||||||
// Trifon
|
// Trifon
|
||||||
else if (e.getTarget() == btnSelectAll)
|
else if (e.getTarget().getId().equals(SELECT_ALL)) {
|
||||||
{
|
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
int rows = model.size();
|
int rows = model.getSize();
|
||||||
|
|
||||||
for (int i = 0; i < rows; i++)
|
for (int i = 0; i < rows; i++)
|
||||||
{
|
{
|
||||||
//model.setDataAt(new Boolean(true), i, 0);
|
model.setValueAt(new Boolean(true), i, 0);
|
||||||
dataTable.addItemToSelection(dataTable.getItemAtIndex(i));
|
|
||||||
//dataTable.setSelectedIndex(i);
|
|
||||||
}
|
}
|
||||||
|
//refresh
|
||||||
|
dataTable.setModel(model);
|
||||||
info();
|
info();
|
||||||
}
|
}
|
||||||
// m_action = false;
|
// m_action = false;
|
||||||
}
|
} // actionPerformed
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table Model Listener
|
||||||
|
* @param e event
|
||||||
|
*/
|
||||||
public void tableChanged (WTableModelEvent e)
|
public void tableChanged (WTableModelEvent e)
|
||||||
{
|
{
|
||||||
int type = -1;
|
int type = -1;
|
||||||
|
|
||||||
info();
|
|
||||||
|
|
||||||
if (e != null)
|
if (e != null)
|
||||||
{
|
{
|
||||||
type = e.getType();
|
type = e.getType();
|
||||||
|
|
||||||
if (type != WTableModelEvent.CONTENTS_CHANGED)
|
if (type != WTableModelEvent.CONTENTS_CHANGED)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.config("Type=" + type);
|
log.config("Type=" + type);
|
||||||
info();
|
info();
|
||||||
}
|
} // tableChanged
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Load BPartner Field
|
||||||
|
* @param forInvoice true if Invoices are to be created, false receipts
|
||||||
|
* @throws Exception if Lookups cannot be initialized
|
||||||
|
*/
|
||||||
protected void initBPartner (boolean forInvoice) throws Exception
|
protected void initBPartner (boolean forInvoice) throws Exception
|
||||||
{
|
{
|
||||||
// Load BPartner
|
// load BPartner
|
||||||
|
|
||||||
int AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
|
int AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
|
||||||
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search);
|
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search);
|
||||||
|
bPartnerField = new WSearchEditor ("C_BPartner_ID", true, false, true, lookup);
|
||||||
bPartnerField = new WSearchEditor(lookup, Msg.translate(Env.getCtx(), "C_BPartner_ID"), "", true, false, true);
|
//
|
||||||
bPartnerField.addValueChangeListner(this);
|
|
||||||
|
|
||||||
int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID");
|
int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID");
|
||||||
bPartnerField.setValue(new Integer(C_BPartner_ID));
|
bPartnerField.setValue(new Integer(C_BPartner_ID));
|
||||||
|
|
||||||
// Initial loading
|
// initial loading
|
||||||
|
|
||||||
initBPartnerOIS(C_BPartner_ID, forInvoice);
|
initBPartnerOIS(C_BPartner_ID, forInvoice);
|
||||||
}
|
} // initBPartner
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
* Load PBartner dependent Order/Invoice/Shipment Field.
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
* @param forInvoice for invoice
|
* @param forInvoice for invoice
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void initBPartnerOIS (int C_BPartner_ID, boolean forInvoice)
|
protected void initBPartnerOIS (int C_BPartner_ID, boolean forInvoice)
|
||||||
{
|
{
|
||||||
log.config("C_BPartner_ID=" + C_BPartner_ID);
|
log.config("C_BPartner_ID=" + C_BPartner_ID);
|
||||||
KeyNamePair pp = new KeyNamePair(0,"");
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
|
boolean sameWarehouseOnly = sameWarehouseCb.isVisible() && sameWarehouseCb.isSelected();
|
||||||
// Load PO Orders - Closed, Completed
|
// load PO Orders - Closed, Completed
|
||||||
|
orderField.removeActionListener(this);
|
||||||
orderField.removeEventListener(Events.ON_SELECT, this);
|
orderField.removeAllItems();
|
||||||
orderField.getChildren().clear();
|
orderField.addItem(pp);
|
||||||
orderField.appendItem(pp.getName(), pp);
|
|
||||||
|
|
||||||
// Display
|
// Display
|
||||||
|
|
||||||
StringBuffer display = new StringBuffer("o.DocumentNo||' - ' ||")
|
StringBuffer display = new StringBuffer("o.DocumentNo||' - ' ||")
|
||||||
.append(DB.TO_CHAR("o.DateOrdered", DisplayType.Date, Env.getAD_Language(Env.getCtx())))
|
.append(DB.TO_CHAR("o.DateOrdered", DisplayType.Date, Env.getAD_Language(Env.getCtx())))
|
||||||
.append("||' - '||")
|
.append("||' - '||")
|
||||||
.append(DB.TO_CHAR("o.GrandTotal", DisplayType.Amount, Env.getAD_Language(Env.getCtx())));
|
.append(DB.TO_CHAR("o.GrandTotal", DisplayType.Amount, Env.getAD_Language(Env.getCtx())));
|
||||||
|
//
|
||||||
String column = "m.M_InOutLine_ID";
|
String column = "ol.QtyDelivered";
|
||||||
|
|
||||||
if (forInvoice)
|
if (forInvoice)
|
||||||
column = "m.C_InvoiceLine_ID";
|
column = "ol.QtyInvoiced";
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer("SELECT o.C_Order_ID,").append(display)
|
StringBuffer sql = new StringBuffer("SELECT o.C_Order_ID,").append(display)
|
||||||
.append(" FROM C_Order o "
|
.append(" FROM C_Order o "
|
||||||
+ "WHERE o.C_BPartner_ID=? AND o.IsSOTrx='N' AND o.DocStatus IN ('CL','CO')"
|
+ "WHERE o.C_BPartner_ID=? AND o.IsSOTrx='N' AND o.DocStatus IN ('CL','CO')"
|
||||||
+ " AND o.C_Order_ID IN "
|
+ " AND o.C_Order_ID IN "
|
||||||
+ "(SELECT ol.C_Order_ID FROM C_OrderLine ol"
|
+ "(SELECT ol.C_Order_ID FROM C_OrderLine ol"
|
||||||
+ " LEFT OUTER JOIN M_MatchPO m ON (ol.C_OrderLine_ID=m.C_OrderLine_ID) "
|
+ " WHERE ol.QtyOrdered - ").append(column).append(" != 0) ");
|
||||||
+ "GROUP BY ol.C_Order_ID,ol.C_OrderLine_ID, ol.QtyOrdered,").append(column)
|
if(sameWarehouseOnly) {
|
||||||
.append(" HAVING (ol.QtyOrdered <> SUM(m.Qty) AND ").append(column)
|
sql = sql.append(" AND o.M_Warehouse_ID=? ");
|
||||||
.append(" IS NOT NULL) OR ").append(column).append(" IS NULL) "
|
}
|
||||||
+ "ORDER BY o.DateOrdered");
|
sql = sql.append("ORDER BY o.DateOrdered");
|
||||||
|
|
||||||
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);
|
||||||
|
if(sameWarehouseOnly) {
|
||||||
|
//only active for material receipts
|
||||||
|
pstmt.setInt(2, Env.getContextAsInt(Env.getCtx(), p_WindowNo, "M_Warehouse_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));
|
||||||
orderField.appendItem(pp.getName(), pp);
|
orderField.addItem(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
}
|
}
|
||||||
|
@ -464,86 +473,80 @@ public abstract class WCreateFrom extends Window implements EventListener, WTabl
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
orderField.setSelectedIndex(0);
|
orderField.setSelectedIndex(0);
|
||||||
orderField.addEventListener(Events.ON_SELECT, this);
|
orderField.addActionListener(this);
|
||||||
|
|
||||||
initBPDetails(C_BPartner_ID);
|
initBPDetails(C_BPartner_ID);
|
||||||
}
|
} // initBPartnerOIS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Data - Order
|
||||||
|
* @param C_Order_ID Order
|
||||||
|
* @param forInvoice true if for invoice vs. delivery qty
|
||||||
|
*/
|
||||||
protected void loadOrder (int C_Order_ID, boolean forInvoice)
|
protected void loadOrder (int C_Order_ID, boolean forInvoice)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Selected - -
|
* Selected - 0
|
||||||
* Qty - 0
|
* Qty - 1
|
||||||
* C_UOM_ID - 1
|
* C_UOM_ID - 2
|
||||||
* M_Product_ID - 2
|
* M_Product_ID - 3
|
||||||
* VendorProductNo - 3
|
* VendorProductNo - 4
|
||||||
* OrderLine - 4
|
* OrderLine - 5
|
||||||
* ShipmentLine - 5
|
* ShipmentLine - 6
|
||||||
* InvoiceLine - 6
|
* InvoiceLine - 7
|
||||||
*/
|
*/
|
||||||
|
|
||||||
log.config("C_Order_ID=" + C_Order_ID);
|
log.config("C_Order_ID=" + C_Order_ID);
|
||||||
p_order = new MOrder (Env.getCtx(), C_Order_ID, null); // save
|
p_order = new MOrder (Env.getCtx(), C_Order_ID, null); // save
|
||||||
|
|
||||||
Vector<Vector> data = new Vector<Vector>();
|
Vector<Vector> data = new Vector<Vector>();
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer("SELECT "
|
StringBuffer sql = new StringBuffer("SELECT "
|
||||||
+ "l.QtyOrdered-SUM(COALESCE(m.Qty,0))," // 1
|
+ "l.QtyOrdered-SUM(COALESCE(m.Qty,0))," // 1
|
||||||
+ "CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END," // 2
|
+ "CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END," // 2
|
||||||
+ " l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name)," // 3..4
|
+ " l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name)," // 3..4
|
||||||
+ " COALESCE(l.M_Product_ID,0),COALESCE(p.Name,c.Name),po.VendorProductNo," // 5..7
|
+ " COALESCE(l.M_Product_ID,0),COALESCE(p.Name,c.Name),po.VendorProductNo," // 5..7
|
||||||
+ " l.C_OrderLine_ID,l.Line " // 8..9
|
+ " l.C_OrderLine_ID,l.Line " // 8..9
|
||||||
+ "FROM C_OrderLine l"
|
+ "FROM C_OrderLine l"
|
||||||
+ " LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND l.C_BPartner_ID = po.C_BPartner_ID) "
|
+ " LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND l.C_BPartner_ID = po.C_BPartner_ID) "
|
||||||
+ " LEFT OUTER JOIN M_MatchPO m ON (l.C_OrderLine_ID=m.C_OrderLine_ID AND ");
|
+ " LEFT OUTER JOIN M_MatchPO m ON (l.C_OrderLine_ID=m.C_OrderLine_ID AND ");
|
||||||
|
|
||||||
sql.append(forInvoice ? "m.C_InvoiceLine_ID" : "m.M_InOutLine_ID");
|
sql.append(forInvoice ? "m.C_InvoiceLine_ID" : "m.M_InOutLine_ID");
|
||||||
sql.append(" IS NOT NULL)")
|
sql.append(" IS NOT NULL)")
|
||||||
.append(" LEFT OUTER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID)"
|
.append(" LEFT OUTER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID)"
|
||||||
+ " LEFT OUTER JOIN C_Charge c ON (l.C_Charge_ID=c.C_Charge_ID)");
|
+ " LEFT OUTER JOIN C_Charge c ON (l.C_Charge_ID=c.C_Charge_ID)");
|
||||||
|
|
||||||
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
|
||||||
sql.append(" LEFT OUTER JOIN C_UOM_Trl uom ON (l.C_UOM_ID=uom.C_UOM_ID AND uom.AD_Language='")
|
sql.append(" LEFT OUTER JOIN C_UOM_Trl uom ON (l.C_UOM_ID=uom.C_UOM_ID AND uom.AD_Language='")
|
||||||
.append(Env.getAD_Language(Env.getCtx())).append("')");
|
.append(Env.getAD_Language(Env.getCtx())).append("')");
|
||||||
|
//
|
||||||
sql.append(" WHERE l.C_Order_ID=? " // #1
|
sql.append(" WHERE l.C_Order_ID=? " // #1
|
||||||
+ "GROUP BY l.QtyOrdered,CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END, "
|
+ "GROUP BY l.QtyOrdered,CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END, "
|
||||||
+ "l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name),po.VendorProductNo, "
|
+ "l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name),po.VendorProductNo, "
|
||||||
+ "l.M_Product_ID,COALESCE(p.Name,c.Name), l.Line,l.C_OrderLine_ID "
|
+ "l.M_Product_ID,COALESCE(p.Name,c.Name), l.Line,l.C_OrderLine_ID "
|
||||||
+ "ORDER BY l.Line");
|
+ "ORDER BY l.Line");
|
||||||
|
//
|
||||||
log.finer(sql.toString());
|
log.finer(sql.toString());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, C_Order_ID);
|
pstmt.setInt(1, C_Order_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
Vector<Object> line = new Vector<Object>();
|
Vector<Object> line = new Vector<Object>();
|
||||||
//line.add(new Boolean(false)); // 0-Selection
|
line.add(new Boolean(false)); // 0-Selection
|
||||||
|
|
||||||
BigDecimal qtyOrdered = rs.getBigDecimal(1);
|
BigDecimal qtyOrdered = rs.getBigDecimal(1);
|
||||||
BigDecimal multiplier = rs.getBigDecimal(2);
|
BigDecimal multiplier = rs.getBigDecimal(2);
|
||||||
BigDecimal qtyEntered = qtyOrdered.multiply(multiplier);
|
BigDecimal qtyEntered = qtyOrdered.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
|
||||||
|
|
||||||
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
|
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
|
||||||
line.add(pp); // 5-OrderLine
|
line.add(pp); // 5-OrderLine
|
||||||
line.add(null); // 6-Ship
|
line.add(null); // 6-Ship
|
||||||
line.add(null); // 7-Invoice
|
line.add(null); // 7-Invoice
|
||||||
|
|
||||||
data.add(line);
|
data.add(line);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
|
@ -553,20 +556,19 @@ public abstract class WCreateFrom extends Window implements EventListener, WTabl
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadTableOIS (data);
|
loadTableOIS (data);
|
||||||
}
|
} // LoadOrder
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Order/Invoice/Shipment data into Table
|
* Load Order/Invoice/Shipment data into Table
|
||||||
* @param data data
|
* @param data data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void loadTableOIS (Vector data)
|
protected void loadTableOIS (Vector data)
|
||||||
{
|
{
|
||||||
// Header Info
|
// Header Info
|
||||||
Vector<String> columnNames = new Vector<String>(6);
|
Vector<String> columnNames = new Vector<String>(7);
|
||||||
//columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "Quantity"));
|
columnNames.add(Msg.translate(Env.getCtx(), "Quantity"));
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "C_UOM_ID"));
|
columnNames.add(Msg.translate(Env.getCtx(), "C_UOM_ID"));
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "M_Product_ID"));
|
columnNames.add(Msg.translate(Env.getCtx(), "M_Product_ID"));
|
||||||
|
@ -576,25 +578,38 @@ public abstract class WCreateFrom extends Window implements EventListener, WTabl
|
||||||
columnNames.add(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false));
|
columnNames.add(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false));
|
||||||
|
|
||||||
// Remove previous listeners
|
// Remove previous listeners
|
||||||
//dataTable.getModel().removeTableModelListener(this);
|
dataTable.getModel().removeTableModelListener(this);
|
||||||
|
|
||||||
// Set Model
|
// Set Model
|
||||||
ListModelTable model = new ListModelTable(data);
|
ListModelTable model = new ListModelTable(data);
|
||||||
//DefaultTableModel model = new DefaultTableModel(data, columnNames);
|
|
||||||
|
|
||||||
model.addTableModelListener(this);
|
model.addTableModelListener(this);
|
||||||
dataTable.setData(model, columnNames);
|
dataTable.setData(model, columnNames);
|
||||||
|
//
|
||||||
//dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
dataTable.setColumnClass(0, Double.class, true); // 1-Qty
|
dataTable.setColumnClass(1, Double.class, true); // 1-Qty
|
||||||
dataTable.setColumnClass(1, String.class, true); // 2-UOM
|
dataTable.setColumnClass(2, String.class, true); // 2-UOM
|
||||||
dataTable.setColumnClass(2, String.class, true); // 3-Product
|
dataTable.setColumnClass(3, String.class, true); // 3-Product
|
||||||
dataTable.setColumnClass(3, String.class, true); // 4-VendorProductNo
|
dataTable.setColumnClass(4, String.class, true); // 4-VendorProductNo
|
||||||
dataTable.setColumnClass(4, String.class, true); // 5-Order
|
dataTable.setColumnClass(5, String.class, true); // 5-Order
|
||||||
dataTable.setColumnClass(5, String.class, true); // 6-Ship
|
dataTable.setColumnClass(6, String.class, true); // 6-Ship
|
||||||
dataTable.setColumnClass(6, String.class, true); // 7-Invoice
|
dataTable.setColumnClass(7, String.class, true); // 7-Invoice
|
||||||
|
|
||||||
// Table UI
|
// Table UI
|
||||||
//dataTable.autoSize();
|
dataTable.autoSize();
|
||||||
|
} // loadOrder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set form status line.
|
||||||
|
* Please note, will enable/disable the OK button if the selectedRowCount > 0.
|
||||||
|
* @param selectedRowCount number of selected lines
|
||||||
|
* @param text additional text
|
||||||
|
*/
|
||||||
|
protected void setStatusLine(int selectedRowCount, String text) {
|
||||||
|
StringBuffer sb = new StringBuffer(String.valueOf(selectedRowCount));
|
||||||
|
if (text != null && text.trim().length() > 0) {
|
||||||
|
sb.append(" - ").append(text);
|
||||||
|
}
|
||||||
|
statusBar.setStatusLine(sb.toString());
|
||||||
|
//
|
||||||
|
confirmPanel.getOKButton().setEnabled(selectedRowCount > 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // VCreateFrom
|
||||||
|
|
|
@ -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;
|
||||||
|
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
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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,235 +14,330 @@
|
||||||
* 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.plaf.AdempierePLAF;
|
||||||
|
import org.adempiere.webui.component.Label;
|
||||||
import org.adempiere.webui.component.ListModelTable;
|
import org.adempiere.webui.component.ListModelTable;
|
||||||
import org.adempiere.webui.editor.WEditor;
|
|
||||||
import org.adempiere.webui.editor.WLocatorEditor;
|
import org.adempiere.webui.editor.WLocatorEditor;
|
||||||
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.adempiere.webui.window.FDialog;
|
import org.adempiere.webui.window.FDialog;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.*;
|
||||||
import org.compiere.model.MInOut;
|
import org.compiere.util.*;
|
||||||
import org.compiere.model.MInOutLine;
|
|
||||||
import org.compiere.model.MInvoice;
|
|
||||||
import org.compiere.model.MInvoiceLine;
|
|
||||||
import org.compiere.model.MLocator;
|
|
||||||
import org.compiere.model.MLocatorLookup;
|
|
||||||
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.zul.Popup;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create From Shipment : Based on VCreateFromShipment
|
* Create Shipments Transactions - from PO Orders or AP Invoices
|
||||||
*
|
*
|
||||||
* @author Niraj Sohun
|
* @author Jorg Janke
|
||||||
* @date Jul 18, 2007
|
* @version $Id: VCreateFromShipment.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
|
public class WCreateFromShipment extends WCreateFrom implements ValueChangeListener
|
||||||
public class WCreateFromShipment extends WCreateFrom implements EventListener, ValueChangeListener, WTableModelListener
|
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** Loaded Invoice */
|
|
||||||
private MInvoice m_invoice = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected Constructor
|
* Protected Constructor
|
||||||
* @param mTab MTab
|
* @param mTab MTab
|
||||||
*/
|
*/
|
||||||
|
|
||||||
WCreateFromShipment(GridTab mTab)
|
WCreateFromShipment(GridTab mTab)
|
||||||
{
|
{
|
||||||
super (mTab);
|
super (mTab);
|
||||||
}
|
// log.info( "VCreateFromShipment");
|
||||||
|
} // VCreateFromShipment
|
||||||
|
|
||||||
|
/** Loaded Invoice */
|
||||||
|
private MInvoice m_invoice = null;
|
||||||
|
/** Loaded RMA */
|
||||||
|
private MRMA m_rma = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Order/Invoice/RMA 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(Msg.translate(Env.getCtx(), "Quantity"));
|
||||||
|
columnNames.add(Msg.translate(Env.getCtx(), "C_UOM_ID"));
|
||||||
|
columnNames.add(Msg.translate(Env.getCtx(), "M_Product_ID"));
|
||||||
|
columnNames.add(Msg.getElement(Env.getCtx(), "VendorProductNo", false));
|
||||||
|
columnNames.add(Msg.getElement(Env.getCtx(), "C_Order_ID", false));
|
||||||
|
columnNames.add(Msg.getElement(Env.getCtx(), "M_RMA_ID", false));
|
||||||
|
columnNames.add(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false));
|
||||||
|
|
||||||
|
// 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-RMA
|
||||||
|
dataTable.setColumnClass(7, String.class, true); // 7-Invoice
|
||||||
|
// Table UI
|
||||||
|
dataTable.autoSize();
|
||||||
|
} // loadOrder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamic Init
|
||||||
|
* @throws Exception if Lookups cannot be initialized
|
||||||
|
* @return true if initialized
|
||||||
|
*/
|
||||||
protected boolean dynInit() throws Exception
|
protected boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "M_InOut_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.getElement(Env.getCtx(), "M_InOut_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
|
||||||
parameterBankPanel.setVisible(false);
|
parameterBankPanel.setVisible(false);
|
||||||
parameterInvoicePanel.setVisible(false);
|
shipmentLabel.setVisible(false);
|
||||||
|
shipmentField.setVisible(false);
|
||||||
|
sameWarehouseCb.setSelected(true);
|
||||||
|
sameWarehouseCb.addActionListener(this);
|
||||||
|
|
||||||
//shipmentLabel.setVisible(false);
|
// load Locator
|
||||||
//shipmentField.setVisible(false);
|
|
||||||
|
|
||||||
// Load Locator
|
|
||||||
int AD_Column_ID = 3537; // M_InOut.M_Locator_ID
|
int AD_Column_ID = 3537; // M_InOut.M_Locator_ID
|
||||||
MLocatorLookup locator = new MLocatorLookup(Env.getCtx(), p_WindowNo);
|
MLocatorLookup locator = new MLocatorLookup(Env.getCtx(), p_WindowNo);
|
||||||
locatorField = new WLocatorEditor ("M_Locator_ID", true, false, true, locator);
|
locatorField = new WLocatorEditor ("M_Locator_ID", true, false, true, locator, p_WindowNo);
|
||||||
locatorField.addValueChangeListner(this);
|
|
||||||
|
|
||||||
initBPartner(false);
|
initBPartner(false);
|
||||||
bPartnerField.addValueChangeListner(this);
|
bPartnerField.addValueChangeListner(this);
|
||||||
|
|
||||||
locatorLabel.setMandatory(true);
|
locatorLabel.setMandatory(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} // dynInit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init Details - load invoices not shipped and RMA candidates for Shipment
|
||||||
|
* @param C_BPartner_ID BPartner
|
||||||
|
*/
|
||||||
protected void initBPDetails(int C_BPartner_ID)
|
protected void initBPDetails(int C_BPartner_ID)
|
||||||
{
|
{
|
||||||
log.config("C_BPartner_ID=" + C_BPartner_ID);
|
log.config("C_BPartner_ID=" + C_BPartner_ID);
|
||||||
|
|
||||||
// Load AP Invoice closed or complete
|
initBPInvoiceDetails(C_BPartner_ID);
|
||||||
|
initBPRMADetails(C_BPartner_ID);
|
||||||
|
} // initBPDetails
|
||||||
|
|
||||||
invoiceField.removeEventListener(Events.ON_SELECT, this);
|
/**
|
||||||
invoiceField.getChildren().clear();
|
* Init Details - load invoices not shipped
|
||||||
|
* @param C_BPartner_ID BPartner
|
||||||
|
*/
|
||||||
|
private void initBPInvoiceDetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
// load AP Invoice closed or complete
|
||||||
|
invoiceField.removeActionListener(this);
|
||||||
|
invoiceField.removeAllItems();
|
||||||
|
// None
|
||||||
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
|
invoiceField.addItem(pp);
|
||||||
|
StringBuffer display = new StringBuffer("i.DocumentNo||' - '||")
|
||||||
|
.append(DB.TO_CHAR("DateInvoiced", DisplayType.Date, Env.getAD_Language(Env.getCtx())))
|
||||||
|
.append("|| ' - ' ||")
|
||||||
|
.append(DB.TO_CHAR("GrandTotal", DisplayType.Amount, Env.getAD_Language(Env.getCtx())));
|
||||||
|
//
|
||||||
|
StringBuffer sql = new StringBuffer("SELECT i.C_Invoice_ID,").append(display)
|
||||||
|
.append(" FROM C_Invoice i "
|
||||||
|
+ "WHERE i.C_BPartner_ID=? AND i.IsSOTrx='N' AND i.DocStatus IN ('CL','CO')"
|
||||||
|
+ " AND i.C_Invoice_ID IN "
|
||||||
|
+ "(SELECT il.C_Invoice_ID FROM C_InvoiceLine il"
|
||||||
|
+ " LEFT OUTER JOIN M_MatchInv mi ON (il.C_InvoiceLine_ID=mi.C_InvoiceLine_ID) "
|
||||||
|
+ "GROUP BY il.C_Invoice_ID,mi.C_InvoiceLine_ID,il.QtyInvoiced "
|
||||||
|
+ "HAVING (il.QtyInvoiced<>SUM(mi.Qty) AND mi.C_InvoiceLine_ID IS NOT NULL)"
|
||||||
|
+ " OR mi.C_InvoiceLine_ID IS NULL) "
|
||||||
|
+ "ORDER BY i.DateInvoiced");
|
||||||
|
|
||||||
// None
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
|
{
|
||||||
|
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||||
|
invoiceField.addItem(pp);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
|
}
|
||||||
|
invoiceField.setSelectedIndex(0);
|
||||||
|
invoiceField.addActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
KeyNamePair pp = new KeyNamePair(0,"");
|
/**
|
||||||
invoiceField.appendItem(pp.getName(), pp);
|
* 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);
|
||||||
|
|
||||||
StringBuffer display = new StringBuffer("i.DocumentNo||' - '||")
|
String sqlStmt = "SELECT r.M_RMA_ID, r.DocumentNo || '-' || r.Amt from M_RMA r "
|
||||||
.append(DB.TO_CHAR("DateInvoiced", DisplayType.Date, Env.getAD_Language(Env.getCtx())))
|
+ "WHERE ISSOTRX='Y' AND r.DocStatus in ('CO', 'CL') "
|
||||||
.append("|| ' - ' ||")
|
+ "AND r.C_BPartner_ID=? "
|
||||||
.append(DB.TO_CHAR("GrandTotal", DisplayType.Amount, Env.getAD_Language(Env.getCtx())));
|
+ "AND r.M_RMA_ID in (SELECT rl.M_RMA_ID FROM M_RMALine rl "
|
||||||
|
+ "WHERE rl.M_RMA_ID=r.M_RMA_ID AND rl.QtyDelivered < rl.Qty "
|
||||||
|
+ "AND rl.M_InOutLine_ID IS NOT NULL)";
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer("SELECT i.C_Invoice_ID,").append(display)
|
PreparedStatement pstmt = null;
|
||||||
.append(" FROM C_Invoice i "
|
try
|
||||||
+ "WHERE i.C_BPartner_ID=? AND i.IsSOTrx='N' AND i.DocStatus IN ('CL','CO')"
|
{
|
||||||
+ " AND i.C_Invoice_ID IN "
|
pstmt = DB.prepareStatement(sqlStmt, null);
|
||||||
+ "(SELECT il.C_Invoice_ID FROM C_InvoiceLine il"
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
+ " LEFT OUTER JOIN M_MatchInv mi ON (il.C_InvoiceLine_ID=mi.C_InvoiceLine_ID) "
|
ResultSet rs = pstmt.executeQuery();
|
||||||
+ "GROUP BY il.C_Invoice_ID,mi.C_InvoiceLine_ID,il.QtyInvoiced "
|
while (rs.next())
|
||||||
+ "HAVING (il.QtyInvoiced<>SUM(mi.Qty) AND mi.C_InvoiceLine_ID IS NOT NULL)"
|
{
|
||||||
+ " OR mi.C_InvoiceLine_ID IS NULL) "
|
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||||
+ "ORDER BY i.DateInvoiced");
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
|
||||||
pstmt.setInt(1, C_BPartner_ID);
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
|
||||||
invoiceField.appendItem(pp.getName(), pp);
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
invoiceField.setSelectedIndex(0);
|
|
||||||
invoiceField.addEventListener(Events.ON_SELECT, 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);
|
||||||
|
log.config("Action=" + e.getTarget().getId());
|
||||||
log.config("Action=" + e.getTarget());
|
|
||||||
|
|
||||||
// Order
|
// Order
|
||||||
if (e.getTarget() == orderField)
|
if (e.getTarget().equals(orderField))
|
||||||
{
|
{
|
||||||
ListItem listitem = orderField.getSelectedItem();
|
KeyNamePair pp = orderField.getSelectedItem().toKeyNamePair();
|
||||||
KeyNamePair pp = (KeyNamePair)listitem.getValue();
|
|
||||||
|
|
||||||
if (pp == null || pp.getKey() == 0)
|
if (pp == null || pp.getKey() == 0)
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int C_Order_ID = pp.getKey();
|
int C_Order_ID = pp.getKey();
|
||||||
|
// set Invoice and Shipment to Null
|
||||||
// Set Invoice and Shipment to Null
|
invoiceField.setSelectedIndex(-1);
|
||||||
invoiceField.setSelectedIndex(0);
|
shipmentField.setSelectedIndex(-1);
|
||||||
if (shipmentField.getItemCount() > 0)
|
rmaField.setSelectedIndex(-1);
|
||||||
shipmentField.setSelectedIndex(0);
|
|
||||||
loadOrder(C_Order_ID, false);
|
loadOrder(C_Order_ID, false);
|
||||||
m_invoice = null;
|
m_invoice = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Invoice
|
// Invoice
|
||||||
else if (e.getTarget() == invoiceField)
|
else if (e.getTarget().equals(invoiceField))
|
||||||
{
|
{
|
||||||
ListItem listitem = invoiceField.getSelectedItem();
|
KeyNamePair pp = invoiceField.getSelectedItem().toKeyNamePair();
|
||||||
KeyNamePair pp = (KeyNamePair)listitem.getValue();
|
|
||||||
|
|
||||||
if (pp == null || pp.getKey() == 0)
|
if (pp == null || pp.getKey() == 0)
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int C_Invoice_ID = pp.getKey();
|
int C_Invoice_ID = pp.getKey();
|
||||||
|
|
||||||
// set Order and Shipment to Null
|
// set Order and Shipment to Null
|
||||||
orderField.setSelectedIndex(0);
|
orderField.setSelectedIndex(-1);
|
||||||
if (shipmentField.getItemCount() > 0)
|
shipmentField.setSelectedIndex(-1);
|
||||||
shipmentField.setSelectedIndex(0);
|
rmaField.setSelectedIndex(-1);
|
||||||
loadInvoice(C_Invoice_ID);
|
loadInvoice(C_Invoice_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// RMA
|
||||||
|
else if (e.getTarget().equals(rmaField))
|
||||||
|
{
|
||||||
|
KeyNamePair pp = rmaField.getSelectedItem().toKeyNamePair();
|
||||||
|
if (pp == null || pp.getKey() == 0)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int M_RMA_ID = pp.getKey();
|
||||||
|
// set Order and Shipment to Null
|
||||||
|
orderField.setSelectedIndex(-1);
|
||||||
|
shipmentField.setSelectedIndex(-1);
|
||||||
|
invoiceField.setSelectedIndex(-1);
|
||||||
|
loadRMA(M_RMA_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//sameWarehouseCb
|
||||||
|
else if (e.getTarget().equals(sameWarehouseCb))
|
||||||
|
{
|
||||||
|
initBPartnerOIS(((Integer)bPartnerField.getValue()).intValue(), false);
|
||||||
|
}
|
||||||
|
} // actionPerformed
|
||||||
|
|
||||||
public void valueChange(ValueChangeEvent evt)
|
|
||||||
|
/**
|
||||||
|
* Change Listener
|
||||||
|
* @param e event
|
||||||
|
*/
|
||||||
|
public void valueChange (ValueChangeEvent e)
|
||||||
{
|
{
|
||||||
log.config(evt.getPropertyName() + "=" + evt.getNewValue());
|
log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||||
|
|
||||||
if (evt == null)
|
// BPartner - load Order/Invoice/Shipment
|
||||||
return;
|
if (e.getPropertyName().equals("C_BPartner_ID"))
|
||||||
|
|
||||||
if (evt.getSource() instanceof WEditor)
|
|
||||||
{
|
{
|
||||||
// BPartner - load Order/Invoice/Shipment
|
int C_BPartner_ID = ((Integer)e.getNewValue()).intValue();
|
||||||
|
initBPartnerOIS (C_BPartner_ID, false);
|
||||||
if (evt.getPropertyName().equals("C_BPartner_ID"))
|
|
||||||
{
|
|
||||||
int C_BPartner_ID = ((Integer)evt.getNewValue()).intValue();
|
|
||||||
initBPartnerOIS (C_BPartner_ID, false);
|
|
||||||
}
|
|
||||||
tableChanged(null);
|
|
||||||
}
|
}
|
||||||
}
|
tableChanged(null);
|
||||||
|
} // vetoableChange
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Data - Invoice
|
* Load Data - Invoice
|
||||||
* @param C_Invoice_ID Invoice
|
* @param C_Invoice_ID Invoice
|
||||||
*/
|
*/
|
||||||
|
private void loadInvoice(int C_Invoice_ID) {
|
||||||
private void loadInvoice(int C_Invoice_ID)
|
|
||||||
{
|
|
||||||
log.config("C_Invoice_ID=" + C_Invoice_ID);
|
log.config("C_Invoice_ID=" + C_Invoice_ID);
|
||||||
m_invoice = new MInvoice(Env.getCtx(), C_Invoice_ID, null); // save
|
m_invoice = new MInvoice(Env.getCtx(), C_Invoice_ID, null); // save
|
||||||
p_order = null;
|
p_order = null;
|
||||||
|
m_rma = null;
|
||||||
|
|
||||||
Vector<Vector> data = new Vector<Vector>();
|
Vector<Vector> data = new Vector<Vector>();
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer("SELECT " // Entered UOM
|
StringBuffer sql = new StringBuffer("SELECT " // Entered UOM
|
||||||
+ "l.QtyInvoiced-SUM(NVL(mi.Qty,0)),l.QtyEntered/l.QtyInvoiced,"
|
+ "l.QtyInvoiced-SUM(NVL(mi.Qty,0)),l.QtyEntered/l.QtyInvoiced,"
|
||||||
+ " 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.C_InvoiceLine_ID,l.Line," // 5..9
|
+ " l.M_Product_ID,p.Name, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line," // 5..9
|
||||||
+ " l.C_OrderLine_ID "
|
+ " l.C_OrderLine_ID "
|
||||||
+ " FROM C_InvoiceLine l "); // 10
|
+ " FROM C_InvoiceLine l "); // 10
|
||||||
|
|
||||||
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
|
||||||
|
@ -260,69 +355,145 @@ public class WCreateFromShipment extends WCreateFrom implements EventListener, V
|
||||||
+ "l.M_Product_ID,p.Name, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line,l.C_OrderLine_ID ")
|
+ "l.M_Product_ID,p.Name, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line,l.C_OrderLine_ID ")
|
||||||
.append("ORDER BY l.Line");
|
.append("ORDER BY l.Line");
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, C_Invoice_ID);
|
pstmt.setInt(1, C_Invoice_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 qtyInvoiced = rs.getBigDecimal(1);
|
BigDecimal qtyInvoiced = rs.getBigDecimal(1);
|
||||||
BigDecimal multiplier = rs.getBigDecimal(2);
|
BigDecimal multiplier = rs.getBigDecimal(2);
|
||||||
BigDecimal qtyEntered = qtyInvoiced.multiply(multiplier);
|
BigDecimal qtyEntered = qtyInvoiced.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, "."));
|
||||||
|
|
||||||
line.add(null); // 6-Ship
|
line.add(null); // 6-Ship
|
||||||
|
|
||||||
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
|
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
|
||||||
line.add(pp); // 7-Invoice
|
line.add(pp); // 7-Invoice
|
||||||
data.add(line);
|
data.add(line);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
}
|
} catch (SQLException e) {
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadTableOIS(data);
|
loadTableOIS(data);
|
||||||
} // loadInvoice
|
} // loadInvoice
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load RMA details
|
||||||
|
* @param M_RMA_ID RMA
|
||||||
|
*/
|
||||||
|
private void loadRMA(int M_RMA_ID)
|
||||||
|
{
|
||||||
|
m_invoice = null;
|
||||||
|
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(pp); //6-RMA
|
||||||
|
line.add(null); //7-invoice
|
||||||
|
data.add(line);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sqlStmt.toString(), ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.severe("Could not close prepared statement");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadTableOIS(data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List number of rows selected
|
* List number of rows selected
|
||||||
*/
|
*/
|
||||||
|
protected void info() {
|
||||||
protected void info()
|
|
||||||
{
|
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
int rows = model.size();
|
int rows = model.getRowCount();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
for (int i = 0; i < rows; i++) {
|
||||||
for (int i = 0; i < rows; i++)
|
if (((Boolean) model.getValueAt(i, 0)).booleanValue())
|
||||||
{
|
|
||||||
if (dataTable.getItemAtIndex(i).isSelected())//(((Boolean) model.getDataAt(i, 0)).booleanValue())
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
lblStatus.setValue(String.valueOf(count));
|
setStatusLine(count, null);
|
||||||
} // info
|
} // info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -330,99 +501,83 @@ public class WCreateFromShipment extends WCreateFrom implements EventListener, V
|
||||||
*
|
*
|
||||||
* @return true if saved
|
* @return true if saved
|
||||||
*/
|
*/
|
||||||
|
protected boolean save() {
|
||||||
protected boolean save()
|
|
||||||
{
|
|
||||||
log.config("");
|
log.config("");
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
int rows = model.size();
|
int rows = model.getRowCount();
|
||||||
|
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
return false;
|
return false;
|
||||||
|
//
|
||||||
MLocator mlocator = (MLocator)locatorField.getValue();
|
Integer loc = locatorField.getM_Locator_ID();
|
||||||
|
if (loc == null || loc.intValue() == 0) {
|
||||||
//Integer loc = (Integer) locatorField.getValue();
|
Popup popup = new Popup();
|
||||||
|
Label label = new Label(Msg.getMsg(Env.getCtx(), "FillMandatory") + locatorLabel.getValue());
|
||||||
if (mlocator == null || mlocator.getM_Locator_ID()/*.intValue()*/ == 0)
|
popup.appendChild(label);
|
||||||
{
|
popup.setPage(locatorField.getComponent().getPage());
|
||||||
FDialog.error(p_WindowNo, Msg.getMsg(Env.getCtx(), "FillMandatory", new Object[]{locatorField.getLabel().getValue()}));
|
popup.open(locatorField.getComponent());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int M_Locator_ID = loc.intValue();
|
||||||
int M_Locator_ID = mlocator.getM_Locator_ID();
|
|
||||||
|
|
||||||
// Get Shipment
|
// Get Shipment
|
||||||
|
|
||||||
int M_InOut_ID = ((Integer) p_mTab.getValue("M_InOut_ID")).intValue();
|
int M_InOut_ID = ((Integer) p_mTab.getValue("M_InOut_ID")).intValue();
|
||||||
MInOut inout = new MInOut(Env.getCtx(), M_InOut_ID, null);
|
MInOut inout = new MInOut(Env.getCtx(), M_InOut_ID, null);
|
||||||
log.config(inout + ", C_Locator_ID=" + M_Locator_ID);
|
log.config(inout + ", C_Locator_ID=" + M_Locator_ID);
|
||||||
|
|
||||||
// Lines
|
// Lines
|
||||||
|
for (int i = 0; i < rows; i++) {
|
||||||
for (int i = 0; i < rows; i++)
|
if (((Boolean) model.getValueAt(i, 0)).booleanValue()) {
|
||||||
{
|
// variable values
|
||||||
if (dataTable.getItemAtIndex(i).isSelected())//(((Boolean) model.getDataAt(i, 0)).booleanValue())
|
Double d = (Double) model.getValueAt(i, 1); // 1-Qty
|
||||||
{
|
|
||||||
// Variable values
|
|
||||||
|
|
||||||
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-Product
|
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 = pp.getKey();
|
int M_Product_ID = pp.getKey();
|
||||||
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_RMALine_ID = 0;
|
||||||
|
pp = (KeyNamePair) model.getValueAt(i, 6); // 6-RMA
|
||||||
|
if (pp != null)
|
||||||
|
M_RMALine_ID = pp.getKey();
|
||||||
int C_InvoiceLine_ID = 0;
|
int C_InvoiceLine_ID = 0;
|
||||||
MInvoiceLine il = null;
|
MInvoiceLine il = null;
|
||||||
pp = (KeyNamePair) model.getDataAt(i, 6); // 7-InvoiceLine
|
pp = (KeyNamePair) model.getValueAt(i, 7); // 7-InvoiceLine
|
||||||
|
|
||||||
if (pp != null)
|
if (pp != null)
|
||||||
C_InvoiceLine_ID = pp.getKey();
|
C_InvoiceLine_ID = pp.getKey();
|
||||||
|
|
||||||
if (C_InvoiceLine_ID != 0)
|
if (C_InvoiceLine_ID != 0)
|
||||||
il = new MInvoiceLine (Env.getCtx(), C_InvoiceLine_ID, null);
|
il = new MInvoiceLine (Env.getCtx(), C_InvoiceLine_ID, null);
|
||||||
|
|
||||||
boolean isInvoiced = (C_InvoiceLine_ID != 0);
|
boolean isInvoiced = (C_InvoiceLine_ID != 0);
|
||||||
|
|
||||||
// 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=" + M_Product_ID
|
+ ", Product=" + M_Product_ID
|
||||||
+ ", OrderLine=" + C_OrderLine_ID + ", InvoiceLine=" + C_InvoiceLine_ID);
|
+ ", OrderLine=" + C_OrderLine_ID + ", InvoiceLine=" + C_InvoiceLine_ID);
|
||||||
|
|
||||||
// Credit Memo - negative Qty
|
// Credit Memo - negative Qty
|
||||||
|
if (m_invoice != null && m_invoice.isCreditMemo() )
|
||||||
if (m_invoice != null && m_invoice.isCreditMemo())
|
|
||||||
QtyEntered = QtyEntered.negate();
|
QtyEntered = QtyEntered.negate();
|
||||||
|
|
||||||
// Create new InOut Line
|
// Create new InOut Line
|
||||||
MInOutLine iol = new MInOutLine (inout);
|
MInOutLine iol = new MInOutLine (inout);
|
||||||
|
|
||||||
iol.setM_Product_ID(M_Product_ID, C_UOM_ID); // Line UOM
|
iol.setM_Product_ID(M_Product_ID, C_UOM_ID); // Line UOM
|
||||||
iol.setQty(QtyEntered); // Movement/Entered
|
iol.setQty(QtyEntered); // Movement/Entered
|
||||||
|
//
|
||||||
MOrderLine ol = null;
|
MOrderLine ol = null;
|
||||||
|
MRMALine rmal = null;
|
||||||
if (C_OrderLine_ID != 0)
|
if (C_OrderLine_ID != 0)
|
||||||
{
|
{
|
||||||
iol.setC_OrderLine_ID(C_OrderLine_ID);
|
iol.setC_OrderLine_ID(C_OrderLine_ID);
|
||||||
ol = new MOrderLine (Env.getCtx(), C_OrderLine_ID, null);
|
ol = new MOrderLine (Env.getCtx(), C_OrderLine_ID, null);
|
||||||
|
// iol.setOrderLine(ol, M_Locator_ID, QtyEntered);
|
||||||
if (ol.getQtyEntered().compareTo(ol.getQtyOrdered()) != 0)
|
if (ol.getQtyEntered().compareTo(ol.getQtyOrdered()) != 0)
|
||||||
{
|
{
|
||||||
iol.setMovementQty(QtyEntered
|
iol.setMovementQty(QtyEntered
|
||||||
|
@ -430,10 +585,9 @@ public class WCreateFromShipment extends WCreateFrom implements EventListener, V
|
||||||
.divide(ol.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
.divide(ol.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
||||||
iol.setC_UOM_ID(ol.getC_UOM_ID());
|
iol.setC_UOM_ID(ol.getC_UOM_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
iol.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
|
iol.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
|
||||||
iol.setDescription(ol.getDescription());
|
iol.setDescription(ol.getDescription());
|
||||||
|
//
|
||||||
iol.setC_Project_ID(ol.getC_Project_ID());
|
iol.setC_Project_ID(ol.getC_Project_ID());
|
||||||
iol.setC_ProjectPhase_ID(ol.getC_ProjectPhase_ID());
|
iol.setC_ProjectPhase_ID(ol.getC_ProjectPhase_ID());
|
||||||
iol.setC_ProjectTask_ID(ol.getC_ProjectTask_ID());
|
iol.setC_ProjectTask_ID(ol.getC_ProjectTask_ID());
|
||||||
|
@ -445,6 +599,7 @@ public class WCreateFromShipment extends WCreateFrom implements EventListener, V
|
||||||
}
|
}
|
||||||
else if (il != null)
|
else if (il != null)
|
||||||
{
|
{
|
||||||
|
// iol.setInvoiceLine(il, M_Locator_ID, QtyEntered);
|
||||||
if (il.getQtyEntered().compareTo(il.getQtyInvoiced()) != 0)
|
if (il.getQtyEntered().compareTo(il.getQtyInvoiced()) != 0)
|
||||||
{
|
{
|
||||||
iol.setQtyEntered(QtyEntered
|
iol.setQtyEntered(QtyEntered
|
||||||
|
@ -452,7 +607,6 @@ public class WCreateFromShipment extends WCreateFrom implements EventListener, V
|
||||||
.divide(il.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
.divide(il.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
||||||
iol.setC_UOM_ID(il.getC_UOM_ID());
|
iol.setC_UOM_ID(il.getC_UOM_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
iol.setDescription(il.getDescription());
|
iol.setDescription(il.getDescription());
|
||||||
iol.setC_Project_ID(il.getC_Project_ID());
|
iol.setC_Project_ID(il.getC_Project_ID());
|
||||||
iol.setC_ProjectPhase_ID(il.getC_ProjectPhase_ID());
|
iol.setC_ProjectPhase_ID(il.getC_ProjectPhase_ID());
|
||||||
|
@ -463,36 +617,50 @@ public class WCreateFromShipment extends WCreateFrom implements EventListener, V
|
||||||
iol.setUser1_ID(il.getUser1_ID());
|
iol.setUser1_ID(il.getUser1_ID());
|
||||||
iol.setUser2_ID(il.getUser2_ID());
|
iol.setUser2_ID(il.getUser2_ID());
|
||||||
}
|
}
|
||||||
|
else if (M_RMALine_ID != 0)
|
||||||
|
{
|
||||||
|
rmal = new MRMALine(Env.getCtx(), M_RMALine_ID, null);
|
||||||
|
iol.setM_RMALine_ID(M_RMALine_ID);
|
||||||
|
iol.setQtyEntered(QtyEntered);
|
||||||
|
iol.setDescription(rmal.getDescription());
|
||||||
|
iol.setM_AttributeSetInstance_ID(rmal.getM_AttributeSetInstance_ID());
|
||||||
|
iol.setC_Project_ID(rmal.getC_Project_ID());
|
||||||
|
iol.setC_ProjectPhase_ID(rmal.getC_ProjectPhase_ID());
|
||||||
|
iol.setC_ProjectTask_ID(rmal.getC_ProjectTask_ID());
|
||||||
|
iol.setC_Activity_ID(rmal.getC_Activity_ID());
|
||||||
|
iol.setAD_OrgTrx_ID(rmal.getAD_OrgTrx_ID());
|
||||||
|
iol.setUser1_ID(rmal.getUser1_ID());
|
||||||
|
iol.setUser2_ID(rmal.getUser2_ID());
|
||||||
|
}
|
||||||
|
|
||||||
// Charge
|
// Charge
|
||||||
|
|
||||||
if (M_Product_ID == 0)
|
if (M_Product_ID == 0)
|
||||||
{
|
{
|
||||||
if (ol != null && ol.getC_Charge_ID() != 0) // from order
|
if (ol != null && ol.getC_Charge_ID() != 0) // from order
|
||||||
iol.setC_Charge_ID(ol.getC_Charge_ID());
|
iol.setC_Charge_ID(ol.getC_Charge_ID());
|
||||||
else if (il != null && il.getC_Charge_ID() != 0) // from invoice
|
else if (il != null && il.getC_Charge_ID() != 0) // from invoice
|
||||||
iol.setC_Charge_ID(il.getC_Charge_ID());
|
iol.setC_Charge_ID(il.getC_Charge_ID());
|
||||||
|
else if (rmal != null && rmal.getC_Charge_ID() != 0) // from rma
|
||||||
|
iol.setC_Charge_ID(rmal.getC_Charge_ID());
|
||||||
}
|
}
|
||||||
|
//
|
||||||
iol.setM_Locator_ID(M_Locator_ID);
|
iol.setM_Locator_ID(M_Locator_ID);
|
||||||
|
|
||||||
if (!iol.save())
|
if (!iol.save())
|
||||||
log.log(Level.SEVERE, "Line NOT created #" + i);
|
log.log(Level.SEVERE, "Line NOT created #" + i);
|
||||||
// Create Invoice Line Link
|
// Create Invoice Line Link
|
||||||
else if (il != null)
|
else if (il != null)
|
||||||
{
|
{
|
||||||
il.setM_InOutLine_ID(iol.getM_InOutLine_ID());
|
il.setM_InOutLine_ID(iol.getM_InOutLine_ID());
|
||||||
il.save();
|
il.save();
|
||||||
}
|
}
|
||||||
} // if selected
|
} // if selected
|
||||||
} // for all rows
|
} // for all rows
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Header
|
* Update Header
|
||||||
* - if linked to another order/invoice - remove link
|
* - if linked to another order/invoice/rma - remove link
|
||||||
* - if no link set it
|
* - if no link set it
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (p_order != null && p_order.getC_Order_ID() != 0)
|
if (p_order != null && p_order.getC_Order_ID() != 0)
|
||||||
{
|
{
|
||||||
inout.setC_Order_ID (p_order.getC_Order_ID());
|
inout.setC_Order_ID (p_order.getC_Order_ID());
|
||||||
|
@ -503,7 +671,6 @@ public class WCreateFromShipment extends WCreateFrom implements EventListener, V
|
||||||
inout.setUser1_ID(p_order.getUser1_ID());
|
inout.setUser1_ID(p_order.getUser1_ID());
|
||||||
inout.setUser2_ID(p_order.getUser2_ID());
|
inout.setUser2_ID(p_order.getUser2_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_invoice != null && m_invoice.getC_Invoice_ID() != 0)
|
if (m_invoice != null && m_invoice.getC_Invoice_ID() != 0)
|
||||||
{
|
{
|
||||||
if (inout.getC_Order_ID() == 0)
|
if (inout.getC_Order_ID() == 0)
|
||||||
|
@ -516,7 +683,22 @@ public class WCreateFromShipment extends WCreateFrom implements EventListener, V
|
||||||
inout.setUser1_ID(m_invoice.getUser1_ID());
|
inout.setUser1_ID(m_invoice.getUser1_ID());
|
||||||
inout.setUser2_ID(m_invoice.getUser2_ID());
|
inout.setUser2_ID(m_invoice.getUser2_ID());
|
||||||
}
|
}
|
||||||
|
if (m_rma != null && m_rma.getM_RMA_ID() != 0)
|
||||||
|
{
|
||||||
|
MInOut originalIO = m_rma.getShipment();
|
||||||
|
inout.setIsSOTrx(m_rma.isSOTrx());
|
||||||
|
inout.setC_Order_ID(0);
|
||||||
|
inout.setC_Invoice_ID(0);
|
||||||
|
inout.setM_RMA_ID(m_rma.getM_RMA_ID());
|
||||||
|
inout.setAD_OrgTrx_ID(originalIO.getAD_OrgTrx_ID());
|
||||||
|
inout.setC_Project_ID(originalIO.getC_Project_ID());
|
||||||
|
inout.setC_Campaign_ID(originalIO.getC_Campaign_ID());
|
||||||
|
inout.setC_Activity_ID(originalIO.getC_Activity_ID());
|
||||||
|
inout.setUser1_ID(originalIO.getUser1_ID());
|
||||||
|
inout.setUser2_ID(originalIO.getUser2_ID());
|
||||||
|
}
|
||||||
inout.save();
|
inout.save();
|
||||||
return true;
|
return true;
|
||||||
} // save
|
} // save
|
||||||
}
|
|
||||||
|
} // VCreateFromShipment
|
||||||
|
|
|
@ -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,70 +14,50 @@
|
||||||
* 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.text.*;
|
||||||
import java.sql.SQLException;
|
import java.util.*;
|
||||||
import java.sql.Timestamp;
|
import java.util.logging.*;
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.adempiere.webui.component.ListModelTable;
|
import org.adempiere.webui.component.ListModelTable;
|
||||||
import org.adempiere.webui.editor.WEditor;
|
import org.adempiere.webui.editor.WStringEditor;
|
||||||
import org.adempiere.webui.editor.WSearchEditor;
|
import org.adempiere.webui.editor.WTableDirEditor;
|
||||||
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.adempiere.webui.window.FDialog;
|
import org.adempiere.webui.window.FDialog;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.*;
|
||||||
import org.compiere.model.MBankStatement;
|
import org.compiere.util.*;
|
||||||
import org.compiere.model.MBankStatementLine;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.compiere.model.MLookup;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
import org.compiere.model.MLookupFactory;
|
|
||||||
import org.compiere.model.MPayment;
|
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.DisplayType;
|
|
||||||
import org.compiere.util.Env;
|
|
||||||
import org.compiere.util.KeyNamePair;
|
|
||||||
import org.compiere.util.Msg;
|
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create From Statement : Based on VCreateFromStatement
|
* Create Transactions for Bank Statements
|
||||||
*
|
*
|
||||||
* @author Niraj Sohun
|
* @author Jorg Janke
|
||||||
* @date Jul 20, 2007
|
* @version $Id: VCreateFromStatement.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||||
|
* @author Victor Perez, e-Evolucion
|
||||||
|
* <li> RF [1811114] http://sourceforge.net/tracker/index.php?func=detail&aid=1811114&group_id=176962&atid=879335
|
||||||
*/
|
*/
|
||||||
|
public class WCreateFromStatement extends WCreateFrom implements ValueChangeListener
|
||||||
public class WCreateFromStatement extends WCreateFrom implements EventListener, ValueChangeListener, WTableModelListener
|
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected Constructor
|
* Protected Constructor
|
||||||
* @param mTab MTab
|
* @param mTab MTab
|
||||||
*/
|
*/
|
||||||
|
|
||||||
WCreateFromStatement(GridTab mTab)
|
WCreateFromStatement(GridTab mTab)
|
||||||
{
|
{
|
||||||
super(mTab);
|
super (mTab);
|
||||||
//log.info("");
|
log.info("");
|
||||||
}
|
} // VCreateFromStatement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamic Init
|
* Dynamic Init
|
||||||
* @throws Exception if Lookups cannot be initialized
|
* @throws Exception if Lookups cannot be initialized
|
||||||
* @return true if initialized
|
* @return true if initialized
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected boolean dynInit() throws Exception
|
protected boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
if (p_mTab.getValue("C_BankStatement_ID") == null)
|
if (p_mTab.getValue("C_BankStatement_ID") == null)
|
||||||
|
@ -85,74 +65,81 @@ public class WCreateFromStatement extends WCreateFrom implements EventListener,
|
||||||
FDialog.error(0, this, "SaveErrorRowNotFound");
|
FDialog.error(0, this, "SaveErrorRowNotFound");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Do not display RMA selection
|
||||||
|
rmaLabel.setVisible(false);
|
||||||
|
rmaField.setVisible(false);
|
||||||
|
|
||||||
|
sameWarehouseCb.setVisible(false);
|
||||||
|
|
||||||
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
parameterStdPanel.setVisible(false);
|
||||||
parameterShipmentPanel.setVisible(false);
|
|
||||||
parameterInvoicePanel.setVisible(false);
|
|
||||||
hboxCommon.setVisible(false);
|
|
||||||
|
|
||||||
int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID
|
int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID
|
||||||
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
||||||
bankAccountField = new WSearchEditor(lookup, "label","desc", true, false, true);
|
WTableDirEditor editor = new WTableDirEditor ("C_BankAccount_ID", true, false, true, lookup);
|
||||||
bankAccountField.addValueChangeListner(this);
|
bankAccountField = editor.getComponent();
|
||||||
|
editor.addValueChangeListner(this);
|
||||||
// Set Default
|
// Set Default
|
||||||
|
|
||||||
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
||||||
bankAccountField.setValue(new Integer(C_BankAccount_ID));
|
bankAccountField.setValue(new Integer(C_BankAccount_ID));
|
||||||
|
// initial Loading
|
||||||
// Initial Loading
|
//RF [1811114]
|
||||||
loadBankAccount(C_BankAccount_ID);
|
String R_AuthCode="";
|
||||||
|
authorizationField = new WStringEditor ("authorization", false, false, true, 10, 30, null, null);
|
||||||
|
authorizationField.getComponent().addEventListener(Events.ON_CHANGE, this);
|
||||||
|
loadBankAccount(C_BankAccount_ID, R_AuthCode);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} // dynInit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init Details (never called)
|
* Init Details (never called)
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void initBPDetails(int C_BPartner_ID)
|
protected void initBPDetails(int C_BPartner_ID)
|
||||||
{
|
{
|
||||||
}
|
} // initDetails
|
||||||
|
|
||||||
public void valueChange(ValueChangeEvent evt)
|
/**
|
||||||
|
* Change Listener
|
||||||
|
* @param e event
|
||||||
|
*/
|
||||||
|
public void valueChange (ValueChangeEvent e)
|
||||||
{
|
{
|
||||||
log.config(evt.getPropertyName() + "=" + evt.getNewValue());
|
log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||||
|
int C_BankAccount_ID=0;
|
||||||
|
//RF [1811114]
|
||||||
|
String R_AuthCode = (authorizationField.getValue().toString());
|
||||||
|
|
||||||
if (evt == null)
|
// BankAccount
|
||||||
return;
|
if (e.getPropertyName().equals("C_BankAccount_ID"))
|
||||||
|
|
||||||
if (evt.getSource() instanceof WEditor)
|
|
||||||
{
|
{
|
||||||
// BankAccount
|
//RF [1811114]
|
||||||
|
C_BankAccount_ID = ((Integer)e.getNewValue()).intValue();
|
||||||
if (evt.getPropertyName().equals("C_BankAccount_ID"))
|
if (authorizationField.getValue().toString().equals(""))
|
||||||
{
|
loadBankAccount(C_BankAccount_ID, null);
|
||||||
int C_BankAccount_ID = ((Integer)evt.getNewValue()).intValue();
|
else
|
||||||
loadBankAccount(C_BankAccount_ID);
|
loadBankAccount(C_BankAccount_ID, R_AuthCode);
|
||||||
}
|
|
||||||
tableChanged(null);
|
|
||||||
}
|
}
|
||||||
}
|
tableChanged(null);
|
||||||
|
} // vetoableChange
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Data - Bank Account
|
* Load Data - Bank Account
|
||||||
* @param C_BankAccount_ID Bank Account
|
* @param C_BankAccount_ID Bank Account
|
||||||
|
* @param Autorization Code
|
||||||
*/
|
*/
|
||||||
|
//RF [1811114]
|
||||||
private void loadBankAccount (int C_BankAccount_ID)
|
private void loadBankAccount (int C_BankAccount_ID, String R_AuthCode)
|
||||||
{
|
{
|
||||||
log.config ("C_BankAccount_ID=" + C_BankAccount_ID);
|
log.config ("C_BankAccount_ID=" + C_BankAccount_ID);
|
||||||
/**
|
/**
|
||||||
* Selected - -
|
* Selected - 0
|
||||||
* Date - 1
|
* Date - 1
|
||||||
* C_Payment_ID - 2
|
* C_Payment_ID - 2
|
||||||
* C_Currenncy - 3
|
* C_Currenncy - 3
|
||||||
* Amt - 4
|
* Amt - 4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
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,"
|
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
|
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,?,null,p.AD_Client_ID,p.AD_Org_ID)," // #1
|
||||||
|
@ -163,15 +150,17 @@ public class WCreateFromStatement extends WCreateFrom implements EventListener,
|
||||||
+ " LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) "
|
+ " LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) "
|
||||||
+ "WHERE p.Processed='Y' AND p.IsReconciled='N'"
|
+ "WHERE p.Processed='Y' AND p.IsReconciled='N'"
|
||||||
+ " AND p.DocStatus IN ('CO','CL','RE','VO') AND p.PayAmt<>0" // Bug 1564453 Added Voided payment to bank statement payement selection
|
+ " AND p.DocStatus IN ('CO','CL','RE','VO') AND p.PayAmt<>0" // Bug 1564453 Added Voided payment to bank statement payement selection
|
||||||
+ " AND p.C_BankAccount_ID=?" // #2
|
+ " AND p.C_BankAccount_ID=?"; // #2
|
||||||
+ " AND NOT EXISTS (SELECT * FROM C_BankStatementLine l "
|
//RF [1811114]
|
||||||
|
if (R_AuthCode!= "" && R_AuthCode!= null)
|
||||||
|
sql = sql + " AND p.R_AuthCode LIKE ?";
|
||||||
|
|
||||||
|
sql = sql + " AND NOT EXISTS (SELECT * FROM C_BankStatementLine l "
|
||||||
// Voided Bank Statements have 0 StmtAmt
|
// Voided Bank Statements have 0 StmtAmt
|
||||||
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)";
|
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)";
|
||||||
|
|
||||||
// Get StatementDate
|
// Get StatementDate
|
||||||
|
|
||||||
Timestamp ts = (Timestamp)p_mTab.getValue("StatementDate");
|
Timestamp ts = (Timestamp)p_mTab.getValue("StatementDate");
|
||||||
|
|
||||||
if (ts == null)
|
if (ts == null)
|
||||||
ts = new Timestamp(System.currentTimeMillis());
|
ts = new Timestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
|
@ -180,17 +169,17 @@ public class WCreateFromStatement extends WCreateFrom implements EventListener,
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setTimestamp(1, ts);
|
pstmt.setTimestamp(1, ts);
|
||||||
pstmt.setInt(2, C_BankAccount_ID);
|
pstmt.setInt(2, C_BankAccount_ID);
|
||||||
|
//RF [1811114]
|
||||||
|
if (R_AuthCode!= "" && R_AuthCode!= null){
|
||||||
|
pstmt.setString(3, R_AuthCode);}
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
Vector<Object> line = new Vector<Object>(6);
|
Vector<Object> line = new Vector<Object>(6);
|
||||||
//line.add(new Boolean(false)); // 0-Selection
|
line.add(new Boolean(false)); // 0-Selection
|
||||||
line.add(rs.getTimestamp(1)); // 1-DateTrx
|
line.add(rs.getTimestamp(1)); // 1-DateTrx
|
||||||
|
|
||||||
KeyNamePair pp = new KeyNamePair(rs.getInt(2), rs.getString(3));
|
KeyNamePair pp = new KeyNamePair(rs.getInt(2), rs.getString(3));
|
||||||
line.add(pp); // 2-C_Payment_ID
|
line.add(pp); // 2-C_Payment_ID
|
||||||
|
|
||||||
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
|
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
|
||||||
line.add(pp); // 3-Currency
|
line.add(pp); // 3-Currency
|
||||||
line.add(rs.getBigDecimal(6)); // 4-PayAmt
|
line.add(rs.getBigDecimal(6)); // 4-PayAmt
|
||||||
|
@ -205,14 +194,9 @@ public class WCreateFromStatement extends WCreateFrom implements EventListener,
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.size() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Header Info
|
// Header Info
|
||||||
|
|
||||||
Vector<String> columnNames = new Vector<String>(6);
|
Vector<String> columnNames = new Vector<String>(6);
|
||||||
//columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
|
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
|
||||||
columnNames.add(Msg.getElement(Env.getCtx(), "C_Payment_ID"));
|
columnNames.add(Msg.getElement(Env.getCtx(), "C_Payment_ID"));
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
||||||
|
@ -221,48 +205,44 @@ public class WCreateFromStatement extends WCreateFrom implements EventListener,
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
|
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
|
||||||
|
|
||||||
// Remove previous listeners
|
// Remove previous listeners
|
||||||
//dataTable.getModel().removeListDataListener(this);
|
dataTable.getModel().removeTableModelListener(this);
|
||||||
|
// Set Model
|
||||||
// Set Model
|
|
||||||
ListModelTable model = new ListModelTable(data);
|
ListModelTable model = new ListModelTable(data);
|
||||||
model.addTableModelListener(this);
|
model.addTableModelListener(this);
|
||||||
dataTable.setData(model, columnNames);
|
dataTable.setData(model, columnNames);
|
||||||
|
//
|
||||||
//dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
dataTable.setColumnClass(0, Timestamp.class, true); // 1-TrxDate
|
dataTable.setColumnClass(1, Timestamp.class, true); // 1-TrxDate
|
||||||
dataTable.setColumnClass(1, String.class, true); // 2-Payment
|
dataTable.setColumnClass(2, String.class, true); // 2-Payment
|
||||||
dataTable.setColumnClass(2, String.class, true); // 3-Currency
|
dataTable.setColumnClass(3, String.class, true); // 3-Currency
|
||||||
dataTable.setColumnClass(3, BigDecimal.class, true); // 4-Amount
|
dataTable.setColumnClass(4, BigDecimal.class, true); // 4-Amount
|
||||||
dataTable.setColumnClass(4, BigDecimal.class, true); // 5-ConvAmount
|
dataTable.setColumnClass(5, BigDecimal.class, true); // 5-ConvAmount
|
||||||
dataTable.setColumnClass(5, String.class, true); // 6-BPartner
|
dataTable.setColumnClass(6, String.class, true); // 6-BPartner
|
||||||
|
|
||||||
// Table UI
|
// Table UI
|
||||||
//dataTable.autoSize();
|
dataTable.autoSize();
|
||||||
} // loadBankAccount
|
} // loadBankAccount
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List total amount
|
* List total amount
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void info()
|
protected void info()
|
||||||
{
|
{
|
||||||
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||||
|
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
BigDecimal total = new BigDecimal(0.0);
|
BigDecimal total = new BigDecimal(0.0);
|
||||||
int rows = model.size();
|
int rows = model.getRowCount();
|
||||||
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 (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||||
{
|
{
|
||||||
total = total.add((BigDecimal)model.getDataAt(i, 4));
|
total = total.add((BigDecimal)model.getValueAt(i, 4));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lblStatus.setValue(String.valueOf(count) + " - " + Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
|
setStatusLine(count, Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
|
||||||
} // infoStatement
|
} // infoStatement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save Statement - Insert Data
|
* Save Statement - Insert Data
|
||||||
|
@ -271,44 +251,61 @@ public class WCreateFromStatement extends WCreateFrom implements EventListener,
|
||||||
protected boolean save()
|
protected boolean save()
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
|
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
int rows = model.size();
|
int rows = model.getRowCount();
|
||||||
|
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Fixed values
|
// fixed values
|
||||||
|
|
||||||
int C_BankStatement_ID = ((Integer)p_mTab.getValue("C_BankStatement_ID")).intValue();
|
int C_BankStatement_ID = ((Integer)p_mTab.getValue("C_BankStatement_ID")).intValue();
|
||||||
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, null);
|
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, null);
|
||||||
log.config(bs.toString());
|
log.config(bs.toString());
|
||||||
|
|
||||||
// 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())
|
||||||
{
|
{
|
||||||
Timestamp trxDate = (Timestamp)model.getDataAt(i, 0); // 1-DateTrx
|
Timestamp trxDate = (Timestamp)model.getValueAt(i, 1); // 1-DateTrx
|
||||||
KeyNamePair pp = (KeyNamePair)model.getDataAt(i, 1); // 2-C_Payment_ID
|
KeyNamePair pp = (KeyNamePair)model.getValueAt(i, 2); // 2-C_Payment_ID
|
||||||
int C_Payment_ID = pp.getKey();
|
int C_Payment_ID = pp.getKey();
|
||||||
pp = (KeyNamePair)model.getDataAt(i, 2); // 3-Currency
|
pp = (KeyNamePair)model.getValueAt(i, 3); // 3-Currency
|
||||||
int C_Currency_ID = pp.getKey();
|
int C_Currency_ID = pp.getKey();
|
||||||
BigDecimal TrxAmt = (BigDecimal)model.getDataAt(i, 3); // 4-PayAmt
|
BigDecimal TrxAmt = (BigDecimal)model.getValueAt(i, 4); // 4-PayAmt
|
||||||
// BigDecimal StmtAmt = (BigDecimal)model.getValueAt(i, 5);// 5-Conv Amt
|
// BigDecimal StmtAmt = (BigDecimal)model.getValueAt(i, 5);// 5-Conv Amt
|
||||||
|
//
|
||||||
log.fine("Line Date=" + trxDate
|
log.fine("Line Date=" + trxDate
|
||||||
+ ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
|
+ ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
|
||||||
|
//
|
||||||
MBankStatementLine bsl = new MBankStatementLine (bs);
|
MBankStatementLine bsl = new MBankStatementLine (bs);
|
||||||
bsl.setStatementLineDate(trxDate);
|
bsl.setStatementLineDate(trxDate);
|
||||||
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
|
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
|
||||||
|
|
||||||
if (!bsl.save())
|
if (!bsl.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;
|
||||||
} // save
|
} // save
|
||||||
}
|
|
||||||
|
/*
|
||||||
|
* Action Listener
|
||||||
|
* @param e event*/
|
||||||
|
//RF [1811114]
|
||||||
|
public void onEvent(Event e) throws Exception
|
||||||
|
{
|
||||||
|
super.onEvent(e);
|
||||||
|
log.config("Action=" + e.getTarget().getId());
|
||||||
|
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
||||||
|
if (e.getTarget().equals(authorizationField.getComponent()))
|
||||||
|
{
|
||||||
|
String R_AuthCode = (authorizationField.getValue().toString());
|
||||||
|
if (authorizationField.getValue().toString().equals(""))
|
||||||
|
{
|
||||||
|
loadBankAccount(C_BankAccount_ID, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
loadBankAccount(C_BankAccount_ID, R_AuthCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // VCreateFromStatement
|
||||||
|
|
|
@ -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;
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +37,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>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -354,4 +359,28 @@ public final class ConfirmPanel extends Hbox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
@ -205,4 +206,35 @@ public class Listbox extends org.zkoss.zul.Listbox implements EventListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,4 +27,10 @@ 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;
|
||||||
|
}
|
||||||
|
getComponent().setCols(displayLength);
|
||||||
|
|
||||||
if (gridField.getDisplayType() == DisplayType.Text)
|
if (gridField.getDisplayType() == DisplayType.Text)
|
||||||
{
|
{
|
||||||
getComponent().setMultiline(true);
|
getComponent().setMultiline(true);
|
||||||
getComponent().setRows(3);
|
getComponent().setRows(3);
|
||||||
}
|
}
|
||||||
else if (gridField.getDisplayType() == DisplayType.TextLong)
|
else if (gridField.getDisplayType() == DisplayType.TextLong)
|
||||||
{
|
{
|
||||||
getComponent().setMultiline(true);
|
getComponent().setMultiline(true);
|
||||||
getComponent().setRows(5);
|
getComponent().setRows(5);
|
||||||
}
|
}
|
||||||
else if (gridField.getDisplayType() == DisplayType.Memo)
|
else if (gridField.getDisplayType() == DisplayType.Memo)
|
||||||
{
|
{
|
||||||
getComponent().setMultiline(true);
|
getComponent().setMultiline(true);
|
||||||
getComponent().setRows(8);
|
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,7 +57,6 @@ 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