Ticket #1001569: Move receipts into batch from QS to Idempiere - adjustment to the 'Create From Batch' code design
This commit is contained in:
parent
7d24e083c3
commit
145c0005cc
|
@ -0,0 +1,42 @@
|
||||||
|
-- Jan 30, 2013 3:35:24 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
INSERT INTO AD_Form (Name,AccessLevel,Classname,AD_Form_ID,IsBetaFunctionality,EntityType,AD_Form_UU,AD_Org_ID,UpdatedBy,CreatedBy,Updated,Created,AD_Client_ID,IsActive) VALUES ('VCreateFromBatchStatementUI','3','org.compiere.apps.form.VCreateFromBatchStatementUI',200006,'N','D','f7ea6003-2e6b-4873-9e0b-a8c18ec2ee6d',0,100,100,TO_DATE('2013-01-30 15:35:23','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-01-30 15:35:23','YYYY-MM-DD HH24:MI:SS'),0,'Y')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:35:24 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
INSERT INTO AD_Form_Trl (AD_Language,AD_Form_ID, Name,Help,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Form_Trl_UU ) SELECT l.AD_Language,t.AD_Form_ID, t.Name,t.Help,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Form t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Form_ID=200006 AND NOT EXISTS (SELECT * FROM AD_Form_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Form_ID=t.AD_Form_ID)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:36:19 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
UPDATE AD_Form SET Name='Bank Statement Create From Batch',Updated=TO_DATE('2013-01-30 15:36:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Form_ID=200006
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:36:19 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
UPDATE AD_Form_Trl SET IsTranslated='N' WHERE AD_Form_ID=200006
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:37:04 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
INSERT INTO AD_Process (CopyFromProcess,AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,EntityType,AD_Form_ID,Name,Value,AD_Org_ID,AD_Client_ID,Created,Updated,UpdatedBy,IsActive,CreatedBy) VALUES ('N',200032,'N','N','986e4432-909a-4ca4-a838-0868f7d022a7','3','N','N',0,0,'Y','D',200006,'Bank Statement Create From Batch','C_BankStatement X_CreateFromBatch',0,0,TO_DATE('2013-01-30 15:37:04','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-01-30 15:37:04','YYYY-MM-DD HH24:MI:SS'),100,'Y',100)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:37:04 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
INSERT INTO AD_Process_Trl (AD_Language,AD_Process_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Trl_UU ) SELECT l.AD_Language,t.AD_Process_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_ID=200032 AND NOT EXISTS (SELECT * FROM AD_Process_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_ID=t.AD_Process_ID)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:37:34 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
UPDATE AD_Column SET AD_Process_ID=200032,Updated=TO_DATE('2013-01-30 15:37:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208442
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:59:04 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
UPDATE AD_Form SET Classname='org.compiere.apps.form.VStatementCreateFromBatch',Updated=TO_DATE('2013-01-30 15:59:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Form_ID=200006
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201301311640_TICKET-1001569.sql') FROM dual
|
||||||
|
;
|
|
@ -0,0 +1,42 @@
|
||||||
|
-- Jan 30, 2013 3:35:24 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
INSERT INTO AD_Form (Name,AccessLevel,Classname,AD_Form_ID,IsBetaFunctionality,EntityType,AD_Form_UU,AD_Org_ID,UpdatedBy,CreatedBy,Updated,Created,AD_Client_ID,IsActive) VALUES ('VCreateFromBatchStatementUI','3','org.compiere.apps.form.VCreateFromBatchStatementUI',200006,'N','D','f7ea6003-2e6b-4873-9e0b-a8c18ec2ee6d',0,100,100,TO_TIMESTAMP('2013-01-30 15:35:23','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-01-30 15:35:23','YYYY-MM-DD HH24:MI:SS'),0,'Y')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:35:24 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
INSERT INTO AD_Form_Trl (AD_Language,AD_Form_ID, Name,Help,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Form_Trl_UU ) SELECT l.AD_Language,t.AD_Form_ID, t.Name,t.Help,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Form t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Form_ID=200006 AND NOT EXISTS (SELECT * FROM AD_Form_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Form_ID=t.AD_Form_ID)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:36:19 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
UPDATE AD_Form SET Name='Bank Statement Create From Batch',Updated=TO_TIMESTAMP('2013-01-30 15:36:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Form_ID=200006
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:36:19 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
UPDATE AD_Form_Trl SET IsTranslated='N' WHERE AD_Form_ID=200006
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:37:04 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
INSERT INTO AD_Process (CopyFromProcess,AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,EntityType,AD_Form_ID,Name,Value,AD_Org_ID,AD_Client_ID,Created,Updated,UpdatedBy,IsActive,CreatedBy) VALUES ('N',200032,'N','N','986e4432-909a-4ca4-a838-0868f7d022a7','3','N','N',0,0,'Y','D',200006,'Bank Statement Create From Batch','C_BankStatement X_CreateFromBatch',0,0,TO_TIMESTAMP('2013-01-30 15:37:04','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-01-30 15:37:04','YYYY-MM-DD HH24:MI:SS'),100,'Y',100)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:37:04 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
INSERT INTO AD_Process_Trl (AD_Language,AD_Process_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Trl_UU ) SELECT l.AD_Language,t.AD_Process_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_ID=200032 AND NOT EXISTS (SELECT * FROM AD_Process_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_ID=t.AD_Process_ID)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:37:34 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
UPDATE AD_Column SET AD_Process_ID=200032,Updated=TO_TIMESTAMP('2013-01-30 15:37:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208442
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 30, 2013 3:59:04 PM SGT
|
||||||
|
-- Ticket #1001569: Move receipts into batch from QS to Idempiere
|
||||||
|
UPDATE AD_Form SET Classname='org.compiere.apps.form.VStatementCreateFromBatch',Updated=TO_TIMESTAMP('2013-01-30 15:59:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Form_ID=200006
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201301311640_TICKET-1001569.sql') FROM dual
|
||||||
|
;
|
|
@ -2549,12 +2549,12 @@ public final class APanel extends CPanel
|
||||||
} // DocAction
|
} // DocAction
|
||||||
|
|
||||||
// Pop up Create From
|
// Pop up Create From
|
||||||
else if (col.equals("CreateFrom") || col.equals("X_CreateFromBatch"))
|
else if (col.equals("CreateFrom"))
|
||||||
{
|
{
|
||||||
// Run form only if the button has no process defined - teo_sarca [ 1974354 ]
|
// Run form only if the button has no process defined - teo_sarca [ 1974354 ]
|
||||||
if (vButton.getProcess_ID() <= 0)
|
if (vButton.getProcess_ID() <= 0)
|
||||||
{
|
{
|
||||||
ICreateFrom cf = VCreateFromFactory.create(m_curTab, col);
|
ICreateFrom cf = VCreateFromFactory.create(m_curTab);
|
||||||
if(cf != null)
|
if(cf != null)
|
||||||
{
|
{
|
||||||
if(cf.isInitOK())
|
if(cf.isInitOK())
|
||||||
|
@ -2660,7 +2660,7 @@ public final class APanel extends CPanel
|
||||||
pi.setAD_User_ID (Env.getAD_User_ID(m_ctx));
|
pi.setAD_User_ID (Env.getAD_User_ID(m_ctx));
|
||||||
pi.setAD_Client_ID (Env.getAD_Client_ID(m_ctx));
|
pi.setAD_Client_ID (Env.getAD_Client_ID(m_ctx));
|
||||||
ff.setProcessInfo(pi);
|
ff.setProcessInfo(pi);
|
||||||
ff.openForm(form_ID);
|
ff.openForm(form_ID, m_curTab);
|
||||||
ff.pack();
|
ff.pack();
|
||||||
AEnv.showCenterScreen(ff);
|
AEnv.showCenterScreen(ff);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.compiere.apps.AGlassPane;
|
||||||
import org.compiere.apps.AMenu;
|
import org.compiere.apps.AMenu;
|
||||||
import org.compiere.apps.Help;
|
import org.compiere.apps.Help;
|
||||||
import org.compiere.apps.WindowMenu;
|
import org.compiere.apps.WindowMenu;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.model.MUser;
|
import org.compiere.model.MUser;
|
||||||
import org.compiere.process.ProcessInfo;
|
import org.compiere.process.ProcessInfo;
|
||||||
|
@ -251,6 +252,11 @@ public class FormFrame extends CFrame
|
||||||
* @return true if form opened
|
* @return true if form opened
|
||||||
*/
|
*/
|
||||||
public boolean openForm (int AD_Form_ID)
|
public boolean openForm (int AD_Form_ID)
|
||||||
|
{
|
||||||
|
return openForm(AD_Form_ID, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean openForm (int AD_Form_ID, GridTab gridTab)
|
||||||
{
|
{
|
||||||
Properties ctx = Env.getCtx();
|
Properties ctx = Env.getCtx();
|
||||||
//
|
//
|
||||||
|
@ -296,7 +302,7 @@ public class FormFrame extends CFrame
|
||||||
if (className == null)
|
if (className == null)
|
||||||
return false;
|
return false;
|
||||||
//
|
//
|
||||||
return openForm(AD_Form_ID, className, name);
|
return openForm(AD_Form_ID, className, name, gridTab);
|
||||||
} // openForm
|
} // openForm
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -307,11 +313,17 @@ public class FormFrame extends CFrame
|
||||||
* @return true if started
|
* @return true if started
|
||||||
*/
|
*/
|
||||||
protected boolean openForm (int AD_Form_ID, String className, String name)
|
protected boolean openForm (int AD_Form_ID, String className, String name)
|
||||||
|
{
|
||||||
|
return openForm(AD_Form_ID, className, name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean openForm (int AD_Form_ID, String className, String name, GridTab gridTab)
|
||||||
{
|
{
|
||||||
log.info("AD_Form_ID=" + AD_Form_ID + " - Class=" + className);
|
log.info("AD_Form_ID=" + AD_Form_ID + " - Class=" + className);
|
||||||
Properties ctx = Env.getCtx();
|
Properties ctx = Env.getCtx();
|
||||||
Env.setContext(ctx, m_WindowNo, "WindowName", name);
|
Env.setContext(ctx, m_WindowNo, "WindowName", name);
|
||||||
setTitle(Env.getHeader(ctx, m_WindowNo));
|
setTitle(Env.getHeader(ctx, m_WindowNo));
|
||||||
|
this.gridTab = gridTab;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -481,5 +493,11 @@ public class FormFrame extends CFrame
|
||||||
{
|
{
|
||||||
return menuBar;
|
return menuBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GridTab gridTab;
|
||||||
|
|
||||||
|
public GridTab getGridTab()
|
||||||
|
{
|
||||||
|
return gridTab;
|
||||||
|
}
|
||||||
} // FormFrame
|
} // FormFrame
|
||||||
|
|
|
@ -0,0 +1,237 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2013 Elaine Tan *
|
||||||
|
* Copyright (C) 2013 Trek Global
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.apps.form;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.event.TableModelEvent;
|
||||||
|
import javax.swing.event.TableModelListener;
|
||||||
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
|
import org.compiere.apps.ADialog;
|
||||||
|
import org.compiere.apps.AppsAction;
|
||||||
|
import org.compiere.apps.ConfirmPanel;
|
||||||
|
import org.compiere.apps.StatusBar;
|
||||||
|
import org.compiere.minigrid.MiniTable;
|
||||||
|
import org.compiere.swing.CPanel;
|
||||||
|
import org.compiere.swing.CToggleButton;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
import org.compiere.util.Trx;
|
||||||
|
import org.compiere.util.TrxRunnable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Elaine
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class VCreateFromForm extends CPanel implements ActionListener, TableModelListener
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -8242250391030501785L;
|
||||||
|
private CreateFromForm form;
|
||||||
|
private int windowNo;
|
||||||
|
/** FormFrame */
|
||||||
|
private FormFrame m_frame;
|
||||||
|
|
||||||
|
private CPanel parameterPanel = new CPanel();
|
||||||
|
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||||
|
private StatusBar statusBar = new StatusBar();
|
||||||
|
private MiniTable dataTable = new MiniTable();
|
||||||
|
|
||||||
|
private static final String SELECT_DESELECT_ALL = "SelectAll";
|
||||||
|
protected AppsAction selectDeselectAllAction = new AppsAction (SELECT_DESELECT_ALL, null, Msg.getMsg(Env.getCtx(), SELECT_DESELECT_ALL), true);
|
||||||
|
|
||||||
|
public VCreateFromForm(CreateFromForm createFrom, FormFrame frame)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.form = createFrom;
|
||||||
|
this.m_frame = frame;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jbInit();
|
||||||
|
confirmPanel.addActionListener(this);
|
||||||
|
|
||||||
|
statusBar.setStatusDB("");
|
||||||
|
tableChanged(null);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void jbInit() throws Exception
|
||||||
|
{
|
||||||
|
m_frame.getContentPane().add(parameterPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
JScrollPane dataPane = new JScrollPane();
|
||||||
|
m_frame.getContentPane().add(dataPane, BorderLayout.CENTER);
|
||||||
|
dataPane.getViewport().add(dataTable, null);
|
||||||
|
|
||||||
|
CToggleButton selectAllButton = (CToggleButton)selectDeselectAllAction.getButton();
|
||||||
|
selectAllButton.setMargin(ConfirmPanel.s_insets);
|
||||||
|
selectAllButton.addActionListener(this);
|
||||||
|
confirmPanel.addComponent(selectAllButton);
|
||||||
|
|
||||||
|
CPanel southPanel = new CPanel();
|
||||||
|
m_frame.getContentPane().add(southPanel, BorderLayout.SOUTH);
|
||||||
|
BorderLayout southLayout = new BorderLayout();
|
||||||
|
southPanel.setLayout(southLayout);
|
||||||
|
southPanel.add(confirmPanel, BorderLayout.CENTER);
|
||||||
|
southPanel.add(statusBar, BorderLayout.SOUTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
if (e.getActionCommand().equals(ConfirmPanel.A_OK))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Trx.run(new TrxRunnable()
|
||||||
|
{
|
||||||
|
public void run(String trxName)
|
||||||
|
{
|
||||||
|
if (save(trxName))
|
||||||
|
{
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ADialog.error(windowNo, this, "Error", ex.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Cancel
|
||||||
|
else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
|
||||||
|
{
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
// Select All
|
||||||
|
// Trifon
|
||||||
|
else if (e.getActionCommand().equals(SELECT_DESELECT_ALL))
|
||||||
|
{
|
||||||
|
TableModel model = dataTable.getModel();
|
||||||
|
model.removeTableModelListener(this);
|
||||||
|
|
||||||
|
// select or deselect all as required
|
||||||
|
int rows = model.getRowCount();
|
||||||
|
Boolean selectAll = selectDeselectAllAction.isPressed() ? Boolean.FALSE : Boolean.TRUE;
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
model.setValueAt(selectAll, i, 0);
|
||||||
|
|
||||||
|
model.addTableModelListener(this);
|
||||||
|
|
||||||
|
info();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean save(String trxName)
|
||||||
|
{
|
||||||
|
dataTable.stopEditor(true);
|
||||||
|
|
||||||
|
TableModel model = dataTable.getModel();
|
||||||
|
int rows = model.getRowCount();
|
||||||
|
if (rows == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return form.save(dataTable, trxName, m_frame.getGridTab());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tableChanged (TableModelEvent e)
|
||||||
|
{
|
||||||
|
int type = -1;
|
||||||
|
if (e != null)
|
||||||
|
{
|
||||||
|
type = e.getType();
|
||||||
|
if (type != TableModelEvent.UPDATE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (e.getColumn() == 0)
|
||||||
|
{
|
||||||
|
TableModel model = dataTable.getModel();
|
||||||
|
Boolean isPressed = (Boolean)model.getValueAt(0, 0);
|
||||||
|
int rows = model.getRowCount();
|
||||||
|
boolean equals = true;
|
||||||
|
for (int i = 1; equals && i < rows; i++)
|
||||||
|
{
|
||||||
|
equals = isPressed.equals(model.getValueAt(i, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equals) {
|
||||||
|
selectDeselectAllAction.setPressed(isPressed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info();
|
||||||
|
dataTable.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info()
|
||||||
|
{
|
||||||
|
TableModel model = dataTable.getModel();
|
||||||
|
int rows = model.getRowCount();
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
setStatusLine(count, null);
|
||||||
|
|
||||||
|
form.info(dataTable, statusBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatusLine(int selectedRowCount, String text)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder(String.valueOf(selectedRowCount));
|
||||||
|
if (text != null && text.trim().length() > 0) {
|
||||||
|
sb.append(" - ").append(text);
|
||||||
|
}
|
||||||
|
statusBar.setStatusLine(sb.toString());
|
||||||
|
//
|
||||||
|
confirmPanel.getOKButton().setEnabled(selectedRowCount > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MiniTable getMiniTable()
|
||||||
|
{
|
||||||
|
return dataTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CPanel getParameterPanel()
|
||||||
|
{
|
||||||
|
return parameterPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfirmPanel getConfirmPanel()
|
||||||
|
{
|
||||||
|
return confirmPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
if (m_frame != null)
|
||||||
|
m_frame.dispose();
|
||||||
|
m_frame = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,7 @@
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.grid;
|
package org.compiere.apps.form;
|
||||||
|
|
||||||
import static org.compiere.model.SystemIDs.COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID;
|
import static org.compiere.model.SystemIDs.COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID;
|
||||||
|
|
||||||
|
@ -30,13 +30,11 @@ import javax.swing.JLabel;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
import org.compiere.apps.ADialog;
|
import org.compiere.apps.ADialog;
|
||||||
import org.compiere.apps.AEnv;
|
|
||||||
import org.compiere.apps.ConfirmPanel;
|
import org.compiere.apps.ConfirmPanel;
|
||||||
import org.compiere.grid.ed.VDate;
|
import org.compiere.grid.ed.VDate;
|
||||||
import org.compiere.grid.ed.VLookup;
|
import org.compiere.grid.ed.VLookup;
|
||||||
import org.compiere.grid.ed.VNumber;
|
import org.compiere.grid.ed.VNumber;
|
||||||
import org.compiere.grid.ed.VString;
|
import org.compiere.grid.ed.VString;
|
||||||
import org.compiere.model.GridTab;
|
|
||||||
import org.compiere.model.MBankStatement;
|
import org.compiere.model.MBankStatement;
|
||||||
import org.compiere.model.MColumn;
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
|
@ -56,41 +54,40 @@ import org.compiere.util.Msg;
|
||||||
* @author Elaine
|
* @author Elaine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class VCreateFromStatementBatchUI extends CreateFromStatementBatch implements ActionListener
|
public class VStatementCreateFromBatch extends StatementCreateFromBatch implements ActionListener, FormPanel
|
||||||
{
|
{
|
||||||
private VCreateFromDialog dialog;
|
private VCreateFromForm form;
|
||||||
|
private FormFrame m_frame;
|
||||||
public VCreateFromStatementBatchUI(GridTab mTab)
|
|
||||||
|
public void init (int WindowNo, FormFrame frame)
|
||||||
{
|
{
|
||||||
super(mTab);
|
form = new VCreateFromForm(this, frame);
|
||||||
log.info(getGridTab().toString());
|
p_WindowNo = WindowNo;
|
||||||
|
m_frame = frame;
|
||||||
dialog = new VCreateFromDialog(this, getGridTab().getWindowNo(), true);
|
initForm();
|
||||||
|
}
|
||||||
p_WindowNo = getGridTab().getWindowNo();
|
|
||||||
|
@Override
|
||||||
|
public void initForm()
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!dynInit())
|
if (!dynInit())
|
||||||
return;
|
return;
|
||||||
jbInit();
|
jbInit();
|
||||||
|
|
||||||
setInitOK(true);
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "", e);
|
log.log(Level.SEVERE, "init", e);
|
||||||
setInitOK(false);
|
|
||||||
}
|
}
|
||||||
AEnv.positionCenterWindow(AEnv.getWindow(p_WindowNo), dialog);
|
}
|
||||||
} // VCreateFrom
|
|
||||||
|
|
||||||
/** Window No */
|
/** Window No */
|
||||||
private int p_WindowNo;
|
private int p_WindowNo;
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private CLogger log = CLogger.getCLogger(getClass());
|
private CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
|
||||||
private JLabel bankAccountLabel = new JLabel();
|
private JLabel bankAccountLabel = new JLabel();
|
||||||
protected VLookup bankAccountField;
|
protected VLookup bankAccountField;
|
||||||
|
|
||||||
|
@ -127,25 +124,25 @@ public class VCreateFromStatementBatchUI extends CreateFromStatementBatch implem
|
||||||
*/
|
*/
|
||||||
public boolean dynInit() throws Exception
|
public boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
|
||||||
|
|
||||||
super.dynInit();
|
super.dynInit();
|
||||||
|
|
||||||
|
log.config("");
|
||||||
|
|
||||||
//Refresh button
|
//Refresh button
|
||||||
CButton refreshButton = ConfirmPanel.createRefreshButton(false);
|
CButton refreshButton = ConfirmPanel.createRefreshButton(false);
|
||||||
refreshButton.setMargin(new Insets (1, 10, 0, 10));
|
refreshButton.setMargin(new Insets (1, 10, 0, 10));
|
||||||
refreshButton.setDefaultCapable(true);
|
refreshButton.setDefaultCapable(true);
|
||||||
refreshButton.addActionListener(this);
|
refreshButton.addActionListener(this);
|
||||||
dialog.getConfirmPanel().addButton(refreshButton);
|
form.getConfirmPanel().addButton(refreshButton);
|
||||||
dialog.getRootPane().setDefaultButton(refreshButton);
|
// form.getRootPane().setDefaultButton(refreshButton);
|
||||||
|
|
||||||
if (getGridTab().getValue("C_BankStatement_ID") == null)
|
if (m_frame.getGridTab() != null && m_frame.getGridTab().getValue("C_BankStatement_ID") == null)
|
||||||
{
|
{
|
||||||
ADialog.error(0, dialog, "SaveErrorRowNotFound");
|
ADialog.error(0, form, "SaveErrorRowNotFound");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.setTitle(getTitle());
|
m_frame.setTitle(getTitle());
|
||||||
|
|
||||||
int AD_Column_ID = COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; // C_BankStatement.C_BankAccount_ID
|
int AD_Column_ID = COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; // 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);
|
||||||
|
@ -180,7 +177,7 @@ public class VCreateFromStatementBatchUI extends CreateFromStatementBatch implem
|
||||||
amtFromField.addActionListener(this);
|
amtFromField.addActionListener(this);
|
||||||
amtToField.addActionListener(this);
|
amtToField.addActionListener(this);
|
||||||
|
|
||||||
loadBankAccount();
|
executeQuery();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // dynInit
|
} // dynInit
|
||||||
|
@ -217,7 +214,7 @@ public class VCreateFromStatementBatchUI extends CreateFromStatementBatch implem
|
||||||
amtToLabel.setLabelFor(amtToField);
|
amtToLabel.setLabelFor(amtToField);
|
||||||
amtToField.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo"));
|
amtToField.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo"));
|
||||||
|
|
||||||
CPanel parameterPanel = dialog.getParameterPanel();
|
CPanel parameterPanel = form.getParameterPanel();
|
||||||
parameterPanel.setLayout(new BorderLayout());
|
parameterPanel.setLayout(new BorderLayout());
|
||||||
|
|
||||||
CPanel parameterBankPanel = new CPanel();
|
CPanel parameterBankPanel = new CPanel();
|
||||||
|
@ -290,46 +287,38 @@ public class VCreateFromStatementBatchUI extends CreateFromStatementBatch implem
|
||||||
if(e.getActionCommand().equals(ConfirmPanel.A_REFRESH))
|
if(e.getActionCommand().equals(ConfirmPanel.A_REFRESH))
|
||||||
{
|
{
|
||||||
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
|
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
|
||||||
loadBankAccount();
|
executeQuery();
|
||||||
dialog.tableChanged(null);
|
form.tableChanged(null);
|
||||||
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
||||||
}
|
}
|
||||||
} // actionPerformed
|
} // actionPerformed
|
||||||
|
|
||||||
protected void loadBankAccount()
|
public void executeQuery()
|
||||||
{
|
{
|
||||||
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
||||||
documentNoField.getText(), dateFromField.getValue(), dateToField.getValue(),
|
documentNoField.getText(), dateFromField.getValue(), dateToField.getValue(),
|
||||||
amtFromField.getValue(), amtToField.getValue(),
|
amtFromField.getValue(), amtToField.getValue(),
|
||||||
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getText()));
|
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getText(),
|
||||||
|
m_frame.getGridTab()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
{
|
{
|
||||||
// Remove previous listeners
|
// Remove previous listeners
|
||||||
dialog.getMiniTable().getModel().removeTableModelListener(dialog);
|
form.getMiniTable().getModel().removeTableModelListener(form);
|
||||||
// Set Model
|
// Set Model
|
||||||
DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames());
|
DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames());
|
||||||
model.addTableModelListener(dialog);
|
model.addTableModelListener(form);
|
||||||
dialog.getMiniTable().setModel(model);
|
form.getMiniTable().setModel(model);
|
||||||
//
|
//
|
||||||
|
|
||||||
configureMiniTable(dialog.getMiniTable());
|
configureMiniTable(form.getMiniTable());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showWindow()
|
public void dispose()
|
||||||
{
|
{
|
||||||
dialog.setVisible(true);
|
if (m_frame != null)
|
||||||
}
|
m_frame.dispose();
|
||||||
|
m_frame = null;
|
||||||
public void closeWindow()
|
|
||||||
{
|
|
||||||
dialog.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getWindow()
|
|
||||||
{
|
|
||||||
return dialog;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -30,30 +30,21 @@ public class DefaultCreateFromFactory implements ICreateFromFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICreateFrom create(GridTab mTab, String columnName)
|
public ICreateFrom create(GridTab mTab)
|
||||||
{
|
{
|
||||||
String tableName = mTab.getTableName();
|
String tableName = mTab.getTableName();
|
||||||
if (columnName.equals("CreateFrom"))
|
if (tableName.equals(I_C_Invoice.Table_Name))
|
||||||
{
|
return new VCreateFromInvoiceUI(mTab);
|
||||||
if (tableName.equals(I_C_Invoice.Table_Name))
|
else if (tableName.equals(I_C_BankStatement.Table_Name))
|
||||||
return new VCreateFromInvoiceUI(mTab);
|
return new VCreateFromStatementUI(mTab);
|
||||||
else if (tableName.equals(I_C_BankStatement.Table_Name))
|
else if (tableName.equals(I_M_InOut.Table_Name))
|
||||||
// return new VCreateFromStatementUI(mTab);
|
return new VCreateFromShipmentUI(mTab);
|
||||||
return new VCreateFromStatementBatchUI(mTab);
|
else if (tableName.equals(I_M_RMA.Table_Name))
|
||||||
else if (tableName.equals(I_M_InOut.Table_Name))
|
return new VCreateFromRMAUI(mTab);
|
||||||
return new VCreateFromShipmentUI(mTab);
|
else if (tableName.equals(I_M_PackageMPS.Table_Name))
|
||||||
else if (tableName.equals(I_M_RMA.Table_Name))
|
return new VCreateFromPackageShipmentUI(mTab);
|
||||||
return new VCreateFromRMAUI(mTab);
|
else if (tableName.equals(I_X_DepositBatch.Table_Name))
|
||||||
else if (tableName.equals(I_M_PackageMPS.Table_Name))
|
return new VCreateFromDepositBatchUI(mTab);
|
||||||
return new VCreateFromPackageShipmentUI(mTab);
|
|
||||||
else if (tableName.equals(I_X_DepositBatch.Table_Name))
|
|
||||||
return new VCreateFromDepositBatchUI(mTab);
|
|
||||||
}
|
|
||||||
else if (columnName.equalsIgnoreCase("X_CreateFromBatch"))
|
|
||||||
{
|
|
||||||
if (tableName.equals(I_C_BankStatement.Table_Name))
|
|
||||||
return new VCreateFromBatchStatementUI(mTab);
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,335 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2013 Elaine Tan *
|
|
||||||
* Copyright (C) 2013 Trek Global
|
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
|
||||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
||||||
* See the GNU General Public License for more details. *
|
|
||||||
* You should have received a copy of the GNU General Public License along *
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
|
||||||
*****************************************************************************/
|
|
||||||
package org.compiere.grid;
|
|
||||||
|
|
||||||
import static org.compiere.model.SystemIDs.COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Cursor;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.table.DefaultTableModel;
|
|
||||||
|
|
||||||
import org.compiere.apps.ADialog;
|
|
||||||
import org.compiere.apps.AEnv;
|
|
||||||
import org.compiere.apps.ConfirmPanel;
|
|
||||||
import org.compiere.grid.ed.VDate;
|
|
||||||
import org.compiere.grid.ed.VLookup;
|
|
||||||
import org.compiere.grid.ed.VNumber;
|
|
||||||
import org.compiere.grid.ed.VString;
|
|
||||||
import org.compiere.model.GridTab;
|
|
||||||
import org.compiere.model.MBankStatement;
|
|
||||||
import org.compiere.model.MColumn;
|
|
||||||
import org.compiere.model.MLookup;
|
|
||||||
import org.compiere.model.MLookupFactory;
|
|
||||||
import org.compiere.model.MPayment;
|
|
||||||
import org.compiere.swing.CButton;
|
|
||||||
import org.compiere.swing.CLabel;
|
|
||||||
import org.compiere.swing.CPanel;
|
|
||||||
import org.compiere.swing.CTextField;
|
|
||||||
import org.compiere.util.CLogger;
|
|
||||||
import org.compiere.util.DisplayType;
|
|
||||||
import org.compiere.util.Env;
|
|
||||||
import org.compiere.util.Msg;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Elaine
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class VCreateFromBatchStatementUI extends CreateFromBatchStatement implements ActionListener
|
|
||||||
{
|
|
||||||
private VCreateFromDialog dialog;
|
|
||||||
|
|
||||||
public VCreateFromBatchStatementUI(GridTab mTab)
|
|
||||||
{
|
|
||||||
super(mTab);
|
|
||||||
log.info(getGridTab().toString());
|
|
||||||
|
|
||||||
dialog = new VCreateFromDialog(this, getGridTab().getWindowNo(), true);
|
|
||||||
|
|
||||||
p_WindowNo = getGridTab().getWindowNo();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!dynInit())
|
|
||||||
return;
|
|
||||||
jbInit();
|
|
||||||
|
|
||||||
setInitOK(true);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "", e);
|
|
||||||
setInitOK(false);
|
|
||||||
}
|
|
||||||
AEnv.positionCenterWindow(AEnv.getWindow(p_WindowNo), dialog);
|
|
||||||
} // VCreateFrom
|
|
||||||
|
|
||||||
/** Window No */
|
|
||||||
private int p_WindowNo;
|
|
||||||
|
|
||||||
/** Logger */
|
|
||||||
private CLogger log = CLogger.getCLogger(getClass());
|
|
||||||
|
|
||||||
private JLabel bankAccountLabel = new JLabel();
|
|
||||||
protected VLookup bankAccountField;
|
|
||||||
|
|
||||||
private CLabel documentNoLabel = new CLabel(Msg.translate(Env.getCtx(), "DocumentNo"));
|
|
||||||
protected CTextField documentNoField = new CTextField(10);
|
|
||||||
|
|
||||||
private JLabel documentTypeLabel = new JLabel();
|
|
||||||
protected VLookup documentTypeField;
|
|
||||||
|
|
||||||
private JLabel authorizationLabel = new JLabel();
|
|
||||||
protected VString authorizationField = new VString();
|
|
||||||
|
|
||||||
private JLabel tenderTypeLabel = new JLabel();
|
|
||||||
protected VLookup tenderTypeField;
|
|
||||||
|
|
||||||
private CLabel amtFromLabel = new CLabel(Msg.translate(Env.getCtx(), "PayAmt"));
|
|
||||||
protected VNumber amtFromField = new VNumber("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom"));
|
|
||||||
private CLabel amtToLabel = new CLabel("-");
|
|
||||||
protected VNumber amtToField = new VNumber("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo"));
|
|
||||||
|
|
||||||
protected CLabel BPartner_idLabel = new CLabel(Msg.translate(Env.getCtx(), "BPartner"));
|
|
||||||
protected VLookup bPartnerLookup;
|
|
||||||
|
|
||||||
private CLabel dateFromLabel = new CLabel(Msg.translate(Env.getCtx(), "DateTrx"));
|
|
||||||
protected VDate dateFromField = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom"));
|
|
||||||
private CLabel dateToLabel = new CLabel("-");
|
|
||||||
protected VDate dateToField = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo"));
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dynamic Init
|
|
||||||
* @throws Exception if Lookups cannot be initialized
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
|
||||||
log.config("");
|
|
||||||
|
|
||||||
super.dynInit();
|
|
||||||
|
|
||||||
//Refresh button
|
|
||||||
CButton refreshButton = ConfirmPanel.createRefreshButton(false);
|
|
||||||
refreshButton.setMargin(new Insets (1, 10, 0, 10));
|
|
||||||
refreshButton.setDefaultCapable(true);
|
|
||||||
refreshButton.addActionListener(this);
|
|
||||||
dialog.getConfirmPanel().addButton(refreshButton);
|
|
||||||
dialog.getRootPane().setDefaultButton(refreshButton);
|
|
||||||
|
|
||||||
if (getGridTab().getValue("C_BankStatement_ID") == null)
|
|
||||||
{
|
|
||||||
ADialog.error(0, dialog, "SaveErrorRowNotFound");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.setTitle(getTitle());
|
|
||||||
|
|
||||||
int AD_Column_ID = COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; // C_BankStatement.C_BankAccount_ID
|
|
||||||
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
|
||||||
bankAccountField = new VLookup ("C_BankAccount_ID", true, true, true, lookup);
|
|
||||||
// Set Default
|
|
||||||
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
|
||||||
bankAccountField.setValue(new Integer(C_BankAccount_ID));
|
|
||||||
bankAccountField.addActionListener(this);
|
|
||||||
// initial Loading
|
|
||||||
authorizationField = new VString ("authorization", false, false, true, 10, 30, null, null);
|
|
||||||
authorizationField.addActionListener(this);
|
|
||||||
|
|
||||||
MLookup lookupDocument = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_C_DocType_ID), DisplayType.TableDir);
|
|
||||||
documentTypeField = new VLookup (MPayment.COLUMNNAME_C_DocType_ID,false,false,true,lookupDocument);
|
|
||||||
documentTypeField.addActionListener(this);
|
|
||||||
|
|
||||||
MLookup lookupTender = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_TenderType), DisplayType.List);
|
|
||||||
tenderTypeField = new VLookup (MPayment.COLUMNNAME_TenderType,false,false,true,lookupTender);
|
|
||||||
tenderTypeField.addActionListener(this);
|
|
||||||
|
|
||||||
bPartnerLookup = new VLookup("C_BPartner_ID", false, false, true,
|
|
||||||
MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search));
|
|
||||||
BPartner_idLabel.setLabelFor(bPartnerLookup);
|
|
||||||
bPartnerLookup.addActionListener(this);
|
|
||||||
|
|
||||||
Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate);
|
|
||||||
dateToField.setValue(date);
|
|
||||||
|
|
||||||
documentNoField.addActionListener(this);
|
|
||||||
dateFromField.addActionListener(this);
|
|
||||||
dateToField.addActionListener(this);
|
|
||||||
amtFromField.addActionListener(this);
|
|
||||||
amtToField.addActionListener(this);
|
|
||||||
|
|
||||||
loadBankAccount();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} // dynInit
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static Init.
|
|
||||||
* <pre>
|
|
||||||
* parameterPanel
|
|
||||||
* parameterBankPanel
|
|
||||||
* parameterStdPanel
|
|
||||||
* bPartner/order/invoice/shopment/licator Label/Field
|
|
||||||
* dataPane
|
|
||||||
* southPanel
|
|
||||||
* confirmPanel
|
|
||||||
* statusBar
|
|
||||||
* </pre>
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
private void jbInit() throws Exception
|
|
||||||
{
|
|
||||||
bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
|
|
||||||
authorizationLabel.setText(Msg.translate(Env.getCtx(), "R_AuthCode"));
|
|
||||||
|
|
||||||
documentTypeLabel.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
|
|
||||||
tenderTypeLabel.setText(Msg.translate(Env.getCtx(), "TenderType"));
|
|
||||||
|
|
||||||
documentNoLabel.setLabelFor(documentNoField);
|
|
||||||
dateFromLabel.setLabelFor(dateFromField);
|
|
||||||
dateFromField.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom"));
|
|
||||||
dateToLabel.setLabelFor(dateToField);
|
|
||||||
dateToField.setToolTipText(Msg.translate(Env.getCtx(), "DateTo"));
|
|
||||||
amtFromLabel.setLabelFor(amtFromField);
|
|
||||||
amtFromField.setToolTipText(Msg.translate(Env.getCtx(), "AmtFrom"));
|
|
||||||
amtToLabel.setLabelFor(amtToField);
|
|
||||||
amtToField.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo"));
|
|
||||||
|
|
||||||
CPanel parameterPanel = dialog.getParameterPanel();
|
|
||||||
parameterPanel.setLayout(new BorderLayout());
|
|
||||||
|
|
||||||
CPanel parameterBankPanel = new CPanel();
|
|
||||||
parameterBankPanel.setLayout(new GridBagLayout());
|
|
||||||
parameterPanel.add(parameterBankPanel, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
parameterBankPanel.add(bankAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
if (bankAccountField != null)
|
|
||||||
parameterBankPanel.add(bankAccountField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
|
|
||||||
parameterBankPanel.add(documentTypeLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
if(documentTypeField!= null)
|
|
||||||
parameterBankPanel.add(documentTypeField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
|
|
||||||
parameterBankPanel.add(tenderTypeLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
if(tenderTypeField!=null)
|
|
||||||
parameterBankPanel.add(tenderTypeField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
|
|
||||||
parameterBankPanel.add(BPartner_idLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
parameterBankPanel.add(bPartnerLookup, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
|
|
||||||
parameterBankPanel.add(documentNoLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
parameterBankPanel.add(documentNoField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
|
|
||||||
parameterBankPanel.add(authorizationLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
parameterBankPanel.add(authorizationField, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
|
|
||||||
parameterBankPanel.add(amtFromLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
parameterBankPanel.add(amtFromField, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
parameterBankPanel.add(amtToLabel, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
parameterBankPanel.add(amtToField, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
|
|
||||||
parameterBankPanel.add(dateFromLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
parameterBankPanel.add(dateFromField, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
parameterBankPanel.add(dateToLabel, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
|
||||||
parameterBankPanel.add(dateToField, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0
|
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
|
||||||
|
|
||||||
} // jbInit
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action Listener
|
|
||||||
* @param e event
|
|
||||||
*/
|
|
||||||
public void actionPerformed(ActionEvent e)
|
|
||||||
{
|
|
||||||
log.config("Action=" + e.getActionCommand());
|
|
||||||
// Object source = e.getSource();
|
|
||||||
if(e.getActionCommand().equals(ConfirmPanel.A_REFRESH))
|
|
||||||
{
|
|
||||||
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
|
|
||||||
loadBankAccount();
|
|
||||||
dialog.tableChanged(null);
|
|
||||||
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
|
||||||
}
|
|
||||||
} // actionPerformed
|
|
||||||
|
|
||||||
protected void loadBankAccount()
|
|
||||||
{
|
|
||||||
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
|
||||||
documentNoField.getText(), dateFromField.getValue(), dateToField.getValue(),
|
|
||||||
amtFromField.getValue(), amtToField.getValue(),
|
|
||||||
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getText()));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void loadTableOIS (Vector<?> data)
|
|
||||||
{
|
|
||||||
// Remove previous listeners
|
|
||||||
dialog.getMiniTable().getModel().removeTableModelListener(dialog);
|
|
||||||
// Set Model
|
|
||||||
DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames());
|
|
||||||
model.addTableModelListener(dialog);
|
|
||||||
dialog.getMiniTable().setModel(model);
|
|
||||||
//
|
|
||||||
|
|
||||||
configureMiniTable(dialog.getMiniTable());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showWindow()
|
|
||||||
{
|
|
||||||
dialog.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeWindow()
|
|
||||||
{
|
|
||||||
dialog.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getWindow()
|
|
||||||
{
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,13 +20,13 @@ import org.compiere.model.GridTab;
|
||||||
|
|
||||||
public class VCreateFromFactory
|
public class VCreateFromFactory
|
||||||
{
|
{
|
||||||
public static ICreateFrom create (GridTab mTab, String columnName)
|
public static ICreateFrom create (GridTab mTab)
|
||||||
{
|
{
|
||||||
ICreateFrom createFrom = null;
|
ICreateFrom createFrom = null;
|
||||||
List<ICreateFromFactory> factories = Service.locator().list(ICreateFromFactory.class).getServices();
|
List<ICreateFromFactory> factories = Service.locator().list(ICreateFromFactory.class).getServices();
|
||||||
for (ICreateFromFactory factory : factories)
|
for (ICreateFromFactory factory : factories)
|
||||||
{
|
{
|
||||||
createFrom = factory.create(mTab, columnName);
|
createFrom = factory.create(mTab);
|
||||||
if (createFrom != null)
|
if (createFrom != null)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright (C) 2009 Low Heng Sin *
|
* Copyright (C) 2013 Elaine Tan *
|
||||||
* Copyright (C) 2009 Idalica Corporation *
|
* Copyright (C) 2013 Trek Global
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
@ -37,7 +37,6 @@ import org.compiere.grid.ed.VLookup;
|
||||||
import org.compiere.grid.ed.VNumber;
|
import org.compiere.grid.ed.VNumber;
|
||||||
import org.compiere.grid.ed.VString;
|
import org.compiere.grid.ed.VString;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.MBankAccount;
|
|
||||||
import org.compiere.model.MBankStatement;
|
import org.compiere.model.MBankStatement;
|
||||||
import org.compiere.model.MColumn;
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
|
@ -52,6 +51,11 @@ import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Elaine
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class VCreateFromStatementUI extends CreateFromStatement implements ActionListener
|
public class VCreateFromStatementUI extends CreateFromStatement implements ActionListener
|
||||||
{
|
{
|
||||||
private VCreateFromDialog dialog;
|
private VCreateFromDialog dialog;
|
||||||
|
@ -149,6 +153,7 @@ public class VCreateFromStatementUI extends CreateFromStatement implements Actio
|
||||||
// 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));
|
||||||
|
bankAccountField.addActionListener(this);
|
||||||
// initial Loading
|
// initial Loading
|
||||||
authorizationField = new VString ("authorization", false, false, true, 10, 30, null, null);
|
authorizationField = new VString ("authorization", false, false, true, 10, 30, null, null);
|
||||||
authorizationField.addActionListener(this);
|
authorizationField.addActionListener(this);
|
||||||
|
@ -164,11 +169,16 @@ public class VCreateFromStatementUI extends CreateFromStatement implements Actio
|
||||||
bPartnerLookup = new VLookup("C_BPartner_ID", false, false, true,
|
bPartnerLookup = new VLookup("C_BPartner_ID", false, false, true,
|
||||||
MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search));
|
MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search));
|
||||||
BPartner_idLabel.setLabelFor(bPartnerLookup);
|
BPartner_idLabel.setLabelFor(bPartnerLookup);
|
||||||
|
bPartnerLookup.addActionListener(this);
|
||||||
|
|
||||||
Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate);
|
Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate);
|
||||||
dateToField.setValue(date);
|
dateToField.setValue(date);
|
||||||
|
|
||||||
bankAccount = new MBankAccount(Env.getCtx(), C_BankAccount_ID, null);
|
documentNoField.addActionListener(this);
|
||||||
|
dateFromField.addActionListener(this);
|
||||||
|
dateToField.addActionListener(this);
|
||||||
|
amtFromField.addActionListener(this);
|
||||||
|
amtToField.addActionListener(this);
|
||||||
|
|
||||||
loadBankAccount();
|
loadBankAccount();
|
||||||
|
|
||||||
|
@ -277,7 +287,7 @@ public class VCreateFromStatementUI extends CreateFromStatement implements Actio
|
||||||
{
|
{
|
||||||
log.config("Action=" + e.getActionCommand());
|
log.config("Action=" + e.getActionCommand());
|
||||||
// Object source = e.getSource();
|
// Object source = e.getSource();
|
||||||
if ( e.getActionCommand().equals(ConfirmPanel.A_REFRESH) )
|
if(e.getActionCommand().equals(ConfirmPanel.A_REFRESH))
|
||||||
{
|
{
|
||||||
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
|
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
|
||||||
loadBankAccount();
|
loadBankAccount();
|
||||||
|
@ -288,9 +298,10 @@ public class VCreateFromStatementUI extends CreateFromStatement implements Actio
|
||||||
|
|
||||||
protected void loadBankAccount()
|
protected void loadBankAccount()
|
||||||
{
|
{
|
||||||
loadTableOIS(getBankData(documentNoField.getText(), bPartnerLookup.getValue(), dateFromField.getValue(), dateToField.getValue(),
|
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
||||||
amtFromField.getValue(), amtToField.getValue(), documentTypeField.getValue(), tenderTypeField.getValue(),
|
documentNoField.getText(), dateFromField.getValue(), dateToField.getValue(),
|
||||||
authorizationField.getText()));
|
amtFromField.getValue(), amtToField.getValue(),
|
||||||
|
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getText()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
|
@ -317,7 +328,8 @@ public class VCreateFromStatementUI extends CreateFromStatement implements Actio
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getWindow() {
|
public Object getWindow()
|
||||||
|
{
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -2411,9 +2411,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
} // DocAction
|
} // DocAction
|
||||||
|
|
||||||
// Pop up Create From
|
// Pop up Create From
|
||||||
else if (col.equals("CreateFrom") || col.equals("X_CreateFromBatch"))
|
else if (col.equals("CreateFrom"))
|
||||||
{
|
{
|
||||||
ICreateFrom cf = WCreateFromFactory.create(adtabPanel.getGridTab(), col);
|
ICreateFrom cf = WCreateFromFactory.create(adtabPanel.getGridTab());
|
||||||
|
|
||||||
if(cf != null)
|
if(cf != null)
|
||||||
{
|
{
|
||||||
|
@ -2584,15 +2584,20 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
{
|
{
|
||||||
String title = wButton.getDescription();
|
String title = wButton.getDescription();
|
||||||
if (title == null || title.length() == 0)
|
if (title == null || title.length() == 0)
|
||||||
title = wButton.getDisplay();
|
title = wButton.getDisplay();
|
||||||
ProcessInfo pi = new ProcessInfo (title, wButton.getProcess_ID(), table_ID, record_ID);
|
ProcessInfo pi = new ProcessInfo (title, wButton.getProcess_ID(), table_ID, record_ID);
|
||||||
pi.setAD_User_ID (Env.getAD_User_ID(ctx));
|
pi.setAD_User_ID (Env.getAD_User_ID(ctx));
|
||||||
pi.setAD_Client_ID (Env.getAD_Client_ID(ctx));
|
pi.setAD_Client_ID (Env.getAD_Client_ID(ctx));
|
||||||
ADForm form = ADForm.openForm(adFormID);
|
final IADTabpanel adtabPanel = findADTabpanel(wButton);
|
||||||
|
GridTab gridTab = null;
|
||||||
|
if (adtabPanel != null)
|
||||||
|
gridTab = adtabPanel.getGridTab();
|
||||||
|
ADForm form = ADForm.openForm(adFormID, gridTab);
|
||||||
form.setProcessInfo(pi);
|
form.setProcessInfo(pi);
|
||||||
Mode mode = form.getWindowMode();
|
Mode mode = form.getWindowMode();
|
||||||
form.setAttribute(Window.MODE_KEY, form.getWindowMode());
|
form.setAttribute(Window.MODE_KEY, form.getWindowMode());
|
||||||
form.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
|
form.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
|
||||||
|
|
||||||
if (mode == Mode.HIGHLIGHTED || mode == Mode.MODAL) {
|
if (mode == Mode.HIGHLIGHTED || mode == Mode.MODAL) {
|
||||||
form.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
form.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,30 +32,21 @@ public class DefaultCreateFromFactory implements ICreateFromFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICreateFrom create(GridTab mTab, String columnName)
|
public ICreateFrom create(GridTab mTab)
|
||||||
{
|
{
|
||||||
String tableName = mTab.getTableName();
|
String tableName = mTab.getTableName();
|
||||||
if (columnName.equals("CreateFrom"))
|
if (tableName.equals(I_C_Invoice.Table_Name))
|
||||||
{
|
return new WCreateFromInvoiceUI(mTab);
|
||||||
if (tableName.equals(I_C_Invoice.Table_Name))
|
else if (tableName.equals(I_C_BankStatement.Table_Name))
|
||||||
return new WCreateFromInvoiceUI(mTab);
|
return new WCreateFromStatementUI(mTab);
|
||||||
else if (tableName.equals(I_C_BankStatement.Table_Name))
|
else if (tableName.equals(I_M_InOut.Table_Name))
|
||||||
// return new WCreateFromStatementUI(mTab);
|
return new WCreateFromShipmentUI(mTab);
|
||||||
return new WCreateFromStatementBatchUI(mTab);
|
else if (tableName.equals(I_M_RMA.Table_Name))
|
||||||
else if (tableName.equals(I_M_InOut.Table_Name))
|
return new WCreateFromRMAUI(mTab);
|
||||||
return new WCreateFromShipmentUI(mTab);
|
else if (tableName.equals(I_M_PackageMPS.Table_Name))
|
||||||
else if (tableName.equals(I_M_RMA.Table_Name))
|
return new WCreateFromPackageShipmentUI(mTab);
|
||||||
return new WCreateFromRMAUI(mTab);
|
else if (tableName.equals(I_X_DepositBatch.Table_Name))
|
||||||
else if (tableName.equals(I_M_PackageMPS.Table_Name))
|
return new WCreateFromDepositBatchUI(mTab);
|
||||||
return new WCreateFromPackageShipmentUI(mTab);
|
|
||||||
else if (tableName.equals(I_X_DepositBatch.Table_Name))
|
|
||||||
return new WCreateFromDepositBatchUI(mTab);
|
|
||||||
}
|
|
||||||
else if (columnName.equalsIgnoreCase("X_CreateFromBatch"))
|
|
||||||
{
|
|
||||||
if (tableName.equals(I_C_BankStatement.Table_Name))
|
|
||||||
return new WCreateFromBatchStatementUI(mTab);
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,13 @@ import org.compiere.model.GridTab;
|
||||||
|
|
||||||
public class WCreateFromFactory
|
public class WCreateFromFactory
|
||||||
{
|
{
|
||||||
public static ICreateFrom create (GridTab mTab, String columnName)
|
public static ICreateFrom create (GridTab mTab)
|
||||||
{
|
{
|
||||||
ICreateFrom createFrom = null;
|
ICreateFrom createFrom = null;
|
||||||
List<ICreateFromFactory> factories = Service.locator().list(ICreateFromFactory.class).getServices();
|
List<ICreateFromFactory> factories = Service.locator().list(ICreateFromFactory.class).getServices();
|
||||||
for (ICreateFromFactory factory : factories)
|
for (ICreateFromFactory factory : factories)
|
||||||
{
|
{
|
||||||
createFrom = factory.create(mTab, columnName);
|
createFrom = factory.create(mTab);
|
||||||
if (createFrom != null)
|
if (createFrom != null)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,269 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2013 Elaine Tan *
|
||||||
|
* Copyright (C) 2013 Trek Global
|
||||||
|
* 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 org.adempiere.webui.component.Button;
|
||||||
|
import org.adempiere.webui.component.ConfirmPanel;
|
||||||
|
import org.adempiere.webui.component.ListModelTable;
|
||||||
|
import org.adempiere.webui.component.ListboxFactory;
|
||||||
|
import org.adempiere.webui.component.Panel;
|
||||||
|
import org.adempiere.webui.component.WAppsAction;
|
||||||
|
import org.adempiere.webui.component.WListbox;
|
||||||
|
import org.adempiere.webui.event.DialogEvents;
|
||||||
|
import org.adempiere.webui.event.WTableModelEvent;
|
||||||
|
import org.adempiere.webui.event.WTableModelListener;
|
||||||
|
import org.adempiere.webui.panel.ADForm;
|
||||||
|
import org.adempiere.webui.panel.StatusBarPanel;
|
||||||
|
import org.adempiere.webui.window.FDialog;
|
||||||
|
import org.compiere.apps.form.CreateFromForm;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
import org.compiere.util.Trx;
|
||||||
|
import org.compiere.util.TrxRunnable;
|
||||||
|
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.util.Clients;
|
||||||
|
import org.zkoss.zul.Borderlayout;
|
||||||
|
import org.zkoss.zul.Center;
|
||||||
|
import org.zkoss.zul.North;
|
||||||
|
import org.zkoss.zul.Separator;
|
||||||
|
import org.zkoss.zul.South;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Elaine
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class WCreateFromForm extends ADForm implements EventListener<Event>, WTableModelListener, DialogEvents
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -3703236565441597403L;
|
||||||
|
private CreateFromForm form;
|
||||||
|
|
||||||
|
private Panel parameterPanel = new Panel();
|
||||||
|
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||||
|
private StatusBarPanel statusBar = new StatusBarPanel();
|
||||||
|
private WListbox dataTable = ListboxFactory.newDataTable();
|
||||||
|
|
||||||
|
private boolean isCancel;
|
||||||
|
|
||||||
|
public static final String SELECT_ALL = "SelectAll";
|
||||||
|
|
||||||
|
public WCreateFromForm(CreateFromForm createFrom)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.form = createFrom;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initForm()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
zkInit();
|
||||||
|
confirmPanel.addActionListener(this);
|
||||||
|
|
||||||
|
statusBar.setStatusDB("");
|
||||||
|
tableChanged(null);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void zkInit() throws Exception
|
||||||
|
{
|
||||||
|
Borderlayout contentPane = new Borderlayout();
|
||||||
|
appendChild(contentPane);
|
||||||
|
|
||||||
|
North north = new North();
|
||||||
|
contentPane.appendChild(north);
|
||||||
|
north.appendChild(parameterPanel);
|
||||||
|
|
||||||
|
Center center = new Center();
|
||||||
|
contentPane.appendChild(center);
|
||||||
|
center.appendChild(dataTable);
|
||||||
|
|
||||||
|
WAppsAction selectAllAction = new WAppsAction (SELECT_ALL, null, null);
|
||||||
|
Button selectAllButton = selectAllAction.getButton();
|
||||||
|
confirmPanel.addComponentsLeft(selectAllButton);
|
||||||
|
selectAllButton.addActionListener(this);
|
||||||
|
|
||||||
|
South south = new South();
|
||||||
|
contentPane.appendChild(south);
|
||||||
|
Panel southPanel = new Panel();
|
||||||
|
south.appendChild(southPanel);
|
||||||
|
southPanel.appendChild(new Separator());
|
||||||
|
southPanel.appendChild(confirmPanel);
|
||||||
|
|
||||||
|
southPanel.appendChild(new Separator());
|
||||||
|
southPanel.appendChild(statusBar);
|
||||||
|
|
||||||
|
setWidth("750px");
|
||||||
|
setHeight("550px");
|
||||||
|
setSizable(true);
|
||||||
|
setBorder("normal");
|
||||||
|
contentPane.setWidth("100%");
|
||||||
|
contentPane.setHeight("100%");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEvent(Event e) throws Exception
|
||||||
|
{
|
||||||
|
// OK - Save
|
||||||
|
if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
|
||||||
|
{
|
||||||
|
isCancel = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Trx.run(new TrxRunnable()
|
||||||
|
{
|
||||||
|
public void run(String trxName)
|
||||||
|
{
|
||||||
|
save(trxName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FDialog.error(getWindowNo(), this, "Error", ex.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Cancel
|
||||||
|
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
|
||||||
|
{
|
||||||
|
isCancel = true;
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
// Select All
|
||||||
|
// Trifon
|
||||||
|
else if (e.getTarget().getId().equals(SELECT_ALL)) {
|
||||||
|
ListModelTable model = dataTable.getModel();
|
||||||
|
int rows = model.getSize();
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
model.setValueAt(new Boolean(true), i, 0);
|
||||||
|
}
|
||||||
|
//refresh
|
||||||
|
dataTable.setModel(model);
|
||||||
|
info();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tableChanged (WTableModelEvent e)
|
||||||
|
{
|
||||||
|
int type = -1;
|
||||||
|
if (e != null)
|
||||||
|
{
|
||||||
|
type = e.getType();
|
||||||
|
if (type != WTableModelEvent.CONTENTS_CHANGED)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
info();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean save(String trxName)
|
||||||
|
{
|
||||||
|
ListModelTable model = dataTable.getModel();
|
||||||
|
int rows = model.getSize();
|
||||||
|
if (rows == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return form.save(dataTable, trxName, getGridTab());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info()
|
||||||
|
{
|
||||||
|
ListModelTable model = dataTable.getModel();
|
||||||
|
int rows = model.getRowCount();
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
if (((Boolean) model.getValueAt(i, 0)).booleanValue())
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
setStatusLine(count, null);
|
||||||
|
|
||||||
|
// createFrom.info(dataTable, statusBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatusLine(int selectedRowCount, String text)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder(String.valueOf(selectedRowCount));
|
||||||
|
if (text != null && text.trim().length() > 0) {
|
||||||
|
sb.append(" - ").append(text);
|
||||||
|
}
|
||||||
|
statusBar.setStatusLine(sb.toString());
|
||||||
|
//
|
||||||
|
confirmPanel.getOKButton().setEnabled(selectedRowCount > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WListbox getWListbox()
|
||||||
|
{
|
||||||
|
return dataTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Panel getParameterPanel()
|
||||||
|
{
|
||||||
|
return parameterPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfirmPanel getConfirmPanel()
|
||||||
|
{
|
||||||
|
return confirmPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancel()
|
||||||
|
{
|
||||||
|
return isCancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void postQueryEvent()
|
||||||
|
{
|
||||||
|
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing"));
|
||||||
|
Events.echoEvent("onExecuteQuery", this, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dont call this directly, use internally to handle execute query event
|
||||||
|
*/
|
||||||
|
public void onExecuteQuery()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
form.executeQuery();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Clients.clearBusy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mode getWindowMode() {
|
||||||
|
return Mode.HIGHLIGHTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setVisible(boolean visible) {
|
||||||
|
boolean ok = super.setVisible(visible);
|
||||||
|
if (visible && getProcessInfo() != null)
|
||||||
|
form.initForm();
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,311 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2013 Elaine Tan *
|
|
||||||
* Copyright (C) 2013 Trek Global
|
|
||||||
* 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 static org.compiere.model.SystemIDs.COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.adempiere.webui.apps.AEnv;
|
|
||||||
import org.adempiere.webui.component.Button;
|
|
||||||
import org.adempiere.webui.component.Column;
|
|
||||||
import org.adempiere.webui.component.Columns;
|
|
||||||
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.ListModelTable;
|
|
||||||
import org.adempiere.webui.component.Panel;
|
|
||||||
import org.adempiere.webui.component.Row;
|
|
||||||
import org.adempiere.webui.component.Rows;
|
|
||||||
import org.adempiere.webui.editor.WDateEditor;
|
|
||||||
import org.adempiere.webui.editor.WEditor;
|
|
||||||
import org.adempiere.webui.editor.WNumberEditor;
|
|
||||||
import org.adempiere.webui.editor.WSearchEditor;
|
|
||||||
import org.adempiere.webui.editor.WStringEditor;
|
|
||||||
import org.adempiere.webui.editor.WTableDirEditor;
|
|
||||||
import org.adempiere.webui.window.FDialog;
|
|
||||||
import org.compiere.grid.CreateFromStatementBatch;
|
|
||||||
import org.compiere.model.GridTab;
|
|
||||||
import org.compiere.model.MBankStatement;
|
|
||||||
import org.compiere.model.MColumn;
|
|
||||||
import org.compiere.model.MLookup;
|
|
||||||
import org.compiere.model.MLookupFactory;
|
|
||||||
import org.compiere.model.MPayment;
|
|
||||||
import org.compiere.util.CLogger;
|
|
||||||
import org.compiere.util.DisplayType;
|
|
||||||
import org.compiere.util.Env;
|
|
||||||
import org.compiere.util.Msg;
|
|
||||||
import org.zkoss.zk.ui.event.Event;
|
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
|
||||||
import org.zkoss.zk.ui.event.Events;
|
|
||||||
import org.zkoss.zul.Borderlayout;
|
|
||||||
import org.zkoss.zul.Center;
|
|
||||||
import org.zkoss.zul.Hbox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Elaine
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class WCreateFromStatementBatchUI extends CreateFromStatementBatch implements EventListener<Event>
|
|
||||||
{
|
|
||||||
private WCreateFromWindow window;
|
|
||||||
|
|
||||||
public WCreateFromStatementBatchUI(GridTab tab)
|
|
||||||
{
|
|
||||||
super(tab);
|
|
||||||
log.info(getGridTab().toString());
|
|
||||||
|
|
||||||
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
|
||||||
|
|
||||||
p_WindowNo = getGridTab().getWindowNo();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!dynInit())
|
|
||||||
return;
|
|
||||||
zkInit();
|
|
||||||
setInitOK(true);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "", e);
|
|
||||||
setInitOK(false);
|
|
||||||
}
|
|
||||||
AEnv.showWindow(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Window No */
|
|
||||||
private int p_WindowNo;
|
|
||||||
|
|
||||||
/** Logger */
|
|
||||||
private CLogger log = CLogger.getCLogger(getClass());
|
|
||||||
|
|
||||||
protected Label bankAccountLabel = new Label();
|
|
||||||
protected WTableDirEditor bankAccountField;
|
|
||||||
|
|
||||||
protected Label documentNoLabel = new Label(Msg.translate(Env.getCtx(), "DocumentNo"));
|
|
||||||
protected WStringEditor documentNoField = new WStringEditor();
|
|
||||||
|
|
||||||
protected Label documentTypeLabel = new Label();
|
|
||||||
protected WTableDirEditor documentTypeField;
|
|
||||||
|
|
||||||
protected Label authorizationLabel = new Label();
|
|
||||||
protected WStringEditor authorizationField = new WStringEditor();
|
|
||||||
|
|
||||||
protected Label tenderTypeLabel = new Label();
|
|
||||||
protected WTableDirEditor tenderTypeField;
|
|
||||||
|
|
||||||
protected Label amtFromLabel = new Label(Msg.translate(Env.getCtx(), "PayAmt"));
|
|
||||||
protected WNumberEditor amtFromField = new WNumberEditor("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom"));
|
|
||||||
protected Label amtToLabel = new Label("-");
|
|
||||||
protected WNumberEditor amtToField = new WNumberEditor("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo"));
|
|
||||||
|
|
||||||
protected Label BPartner_idLabel = new Label(Msg.translate(Env.getCtx(), "BPartner"));
|
|
||||||
protected WEditor bPartnerLookup;
|
|
||||||
|
|
||||||
protected Label dateFromLabel = new Label(Msg.translate(Env.getCtx(), "DateTrx"));
|
|
||||||
protected WDateEditor dateFromField = new WDateEditor("DateFrom", false, false, true, Msg.translate(Env.getCtx(), "DateFrom"));
|
|
||||||
protected Label dateToLabel = new Label("-");
|
|
||||||
protected WDateEditor dateToField = new WDateEditor("DateTo", false, false, true, Msg.translate(Env.getCtx(), "DateTo"));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dynamic Init
|
|
||||||
* @throws Exception if Lookups cannot be initialized
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
|
||||||
log.config("");
|
|
||||||
|
|
||||||
super.dynInit();
|
|
||||||
|
|
||||||
//Refresh button
|
|
||||||
Button refreshButton = window.getConfirmPanel().createButton(ConfirmPanel.A_REFRESH);
|
|
||||||
refreshButton.addEventListener(Events.ON_CLICK, this);
|
|
||||||
window.getConfirmPanel().addButton(refreshButton);
|
|
||||||
|
|
||||||
if (getGridTab().getValue("C_BankStatement_ID") == null)
|
|
||||||
{
|
|
||||||
FDialog.error(0, window, "SaveErrorRowNotFound");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.setTitle(getTitle());
|
|
||||||
|
|
||||||
int AD_Column_ID = COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; // C_BankStatement.C_BankAccount_ID
|
|
||||||
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
|
||||||
bankAccountField = new WTableDirEditor ("C_BankAccount_ID", true, false, true, lookup);
|
|
||||||
// Set Default
|
|
||||||
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
|
||||||
bankAccountField.setValue(new Integer(C_BankAccount_ID));
|
|
||||||
// initial Loading
|
|
||||||
authorizationField = new WStringEditor ("authorization", false, false, true, 10, 30, null, null);
|
|
||||||
authorizationField.getComponent().addEventListener(Events.ON_CHANGE, this);
|
|
||||||
|
|
||||||
lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_C_DocType_ID), DisplayType.TableDir);
|
|
||||||
documentTypeField = new WTableDirEditor (MPayment.COLUMNNAME_C_DocType_ID,false,false,true,lookup);
|
|
||||||
documentTypeField.getComponent().addEventListener(Events.ON_CHANGE, this);
|
|
||||||
|
|
||||||
lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_TenderType), DisplayType.List);
|
|
||||||
tenderTypeField = new WTableDirEditor (MPayment.COLUMNNAME_TenderType,false,false,true,lookup);
|
|
||||||
tenderTypeField.getComponent().addEventListener(Events.ON_CHANGE, this);
|
|
||||||
|
|
||||||
lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search);
|
|
||||||
bPartnerLookup = new WSearchEditor ("C_BPartner_ID", false, false, true, lookup);
|
|
||||||
|
|
||||||
Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate);
|
|
||||||
dateToField.setValue(date);
|
|
||||||
|
|
||||||
loadBankAccount();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} // dynInit
|
|
||||||
|
|
||||||
protected void zkInit() throws Exception
|
|
||||||
{
|
|
||||||
bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
|
|
||||||
authorizationLabel.setText(Msg.translate(Env.getCtx(), "R_AuthCode"));
|
|
||||||
|
|
||||||
documentTypeLabel.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
|
|
||||||
tenderTypeLabel.setText(Msg.translate(Env.getCtx(), "TenderType"));
|
|
||||||
|
|
||||||
dateFromField.getComponent().setTooltiptext(Msg.translate(Env.getCtx(), "DateFrom"));
|
|
||||||
dateToField.getComponent().setTooltiptext(Msg.translate(Env.getCtx(), "DateTo"));
|
|
||||||
|
|
||||||
amtFromField.getComponent().setTooltiptext(Msg.translate(Env.getCtx(), "AmtFrom"));
|
|
||||||
amtToField.getComponent().setTooltiptext(Msg.translate(Env.getCtx(), "AmtTo"));
|
|
||||||
|
|
||||||
Borderlayout parameterLayout = new Borderlayout();
|
|
||||||
parameterLayout.setHeight("130px");
|
|
||||||
parameterLayout.setWidth("100%");
|
|
||||||
Panel parameterPanel = window.getParameterPanel();
|
|
||||||
parameterPanel.appendChild(parameterLayout);
|
|
||||||
|
|
||||||
Grid parameterBankLayout = GridFactory.newGridLayout();
|
|
||||||
Panel parameterBankPanel = new Panel();
|
|
||||||
parameterBankPanel.appendChild(parameterBankLayout);
|
|
||||||
|
|
||||||
Center center = new Center();
|
|
||||||
parameterLayout.appendChild(center);
|
|
||||||
center.appendChild(parameterBankPanel);
|
|
||||||
|
|
||||||
Columns columns = new Columns();
|
|
||||||
parameterBankLayout.appendChild(columns);
|
|
||||||
Column column = new Column();
|
|
||||||
columns.appendChild(column);
|
|
||||||
column = new Column();
|
|
||||||
column.setWidth("15%");
|
|
||||||
columns.appendChild(column);
|
|
||||||
column.setWidth("35%");
|
|
||||||
column = new Column();
|
|
||||||
column.setWidth("15%");
|
|
||||||
columns.appendChild(column);
|
|
||||||
column = new Column();
|
|
||||||
column.setWidth("35%");
|
|
||||||
columns.appendChild(column);
|
|
||||||
|
|
||||||
Rows rows = (Rows) parameterBankLayout.newRows();
|
|
||||||
Row row = rows.newRow();
|
|
||||||
row.appendChild(bankAccountLabel.rightAlign());
|
|
||||||
row.appendChild(bankAccountField.getComponent());
|
|
||||||
row.appendChild(documentNoLabel.rightAlign());
|
|
||||||
row.appendChild(documentNoField.getComponent());
|
|
||||||
|
|
||||||
row = rows.newRow();
|
|
||||||
row.appendChild(documentTypeLabel.rightAlign());
|
|
||||||
row.appendChild(documentTypeField.getComponent());
|
|
||||||
row.appendChild(authorizationLabel.rightAlign());
|
|
||||||
row.appendChild(authorizationField.getComponent());
|
|
||||||
|
|
||||||
row = rows.newRow();
|
|
||||||
row.appendChild(tenderTypeLabel.rightAlign());
|
|
||||||
row.appendChild(tenderTypeField.getComponent());
|
|
||||||
|
|
||||||
row.appendChild(amtFromLabel.rightAlign());
|
|
||||||
Hbox hbox = new Hbox();
|
|
||||||
hbox.appendChild(amtFromField.getComponent());
|
|
||||||
hbox.appendChild(amtToLabel.rightAlign());
|
|
||||||
hbox.appendChild(amtToField.getComponent());
|
|
||||||
row.appendChild(hbox);
|
|
||||||
|
|
||||||
row = rows.newRow();
|
|
||||||
row.appendChild(BPartner_idLabel.rightAlign());
|
|
||||||
row.appendChild(bPartnerLookup.getComponent());
|
|
||||||
row.appendChild(dateFromLabel.rightAlign());
|
|
||||||
|
|
||||||
hbox = new Hbox();
|
|
||||||
hbox.appendChild(dateFromField.getComponent());
|
|
||||||
hbox.appendChild(dateToLabel.rightAlign());
|
|
||||||
hbox.appendChild(dateToField.getComponent());
|
|
||||||
row.appendChild(hbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action Listener
|
|
||||||
* @param e event
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void onEvent(Event e) throws Exception
|
|
||||||
{
|
|
||||||
log.config("Action=" + e.getTarget().getId());
|
|
||||||
if(e.getTarget().equals(window.getConfirmPanel().getButton(ConfirmPanel.A_REFRESH)))
|
|
||||||
{
|
|
||||||
loadBankAccount();
|
|
||||||
window.tableChanged(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void loadBankAccount()
|
|
||||||
{
|
|
||||||
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
|
||||||
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
|
||||||
amtFromField.getValue(), amtToField.getValue(),
|
|
||||||
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getValue().toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void loadTableOIS (Vector<?> data)
|
|
||||||
{
|
|
||||||
window.getWListbox().clear();
|
|
||||||
|
|
||||||
// Remove previous listeners
|
|
||||||
window.getWListbox().getModel().removeTableModelListener(window);
|
|
||||||
// Set Model
|
|
||||||
ListModelTable model = new ListModelTable(data);
|
|
||||||
model.addTableModelListener(window);
|
|
||||||
window.getWListbox().setData(model, getOISColumnNames());
|
|
||||||
//
|
|
||||||
|
|
||||||
configureMiniTable(window.getWListbox());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showWindow()
|
|
||||||
{
|
|
||||||
window.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeWindow()
|
|
||||||
{
|
|
||||||
window.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getWindow()
|
|
||||||
{
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright (C) 2009 Low Heng Sin *
|
* Copyright (C) 2013 Elaine Tan *
|
||||||
* Copyright (C) 2009 Idalica Corporation *
|
* Copyright (C) 2013 Trek Global
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
@ -21,6 +21,8 @@ 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.Column;
|
||||||
|
import org.adempiere.webui.component.Columns;
|
||||||
import org.adempiere.webui.component.ConfirmPanel;
|
import org.adempiere.webui.component.ConfirmPanel;
|
||||||
import org.adempiere.webui.component.Grid;
|
import org.adempiere.webui.component.Grid;
|
||||||
import org.adempiere.webui.component.GridFactory;
|
import org.adempiere.webui.component.GridFactory;
|
||||||
|
@ -38,7 +40,6 @@ import org.adempiere.webui.editor.WTableDirEditor;
|
||||||
import org.adempiere.webui.window.FDialog;
|
import org.adempiere.webui.window.FDialog;
|
||||||
import org.compiere.grid.CreateFromStatement;
|
import org.compiere.grid.CreateFromStatement;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.MBankAccount;
|
|
||||||
import org.compiere.model.MBankStatement;
|
import org.compiere.model.MBankStatement;
|
||||||
import org.compiere.model.MColumn;
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
|
@ -55,6 +56,11 @@ import org.zkoss.zul.Borderlayout;
|
||||||
import org.zkoss.zul.Center;
|
import org.zkoss.zul.Center;
|
||||||
import org.zkoss.zul.Hbox;
|
import org.zkoss.zul.Hbox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Elaine
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WCreateFromStatementUI extends CreateFromStatement implements EventListener<Event>
|
public class WCreateFromStatementUI extends CreateFromStatement implements EventListener<Event>
|
||||||
{
|
{
|
||||||
private WCreateFromWindow window;
|
private WCreateFromWindow window;
|
||||||
|
@ -88,7 +94,7 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private CLogger log = CLogger.getCLogger(getClass());
|
private CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
|
||||||
protected Label bankAccountLabel = new Label();
|
protected Label bankAccountLabel = new Label();
|
||||||
protected WTableDirEditor bankAccountField;
|
protected WTableDirEditor bankAccountField;
|
||||||
|
|
||||||
|
@ -164,8 +170,6 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
|
|
||||||
Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate);
|
Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate);
|
||||||
dateToField.setValue(date);
|
dateToField.setValue(date);
|
||||||
|
|
||||||
bankAccount = new MBankAccount(Env.getCtx(), C_BankAccount_ID, null);
|
|
||||||
|
|
||||||
loadBankAccount();
|
loadBankAccount();
|
||||||
|
|
||||||
|
@ -187,7 +191,7 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
amtToField.getComponent().setTooltiptext(Msg.translate(Env.getCtx(), "AmtTo"));
|
amtToField.getComponent().setTooltiptext(Msg.translate(Env.getCtx(), "AmtTo"));
|
||||||
|
|
||||||
Borderlayout parameterLayout = new Borderlayout();
|
Borderlayout parameterLayout = new Borderlayout();
|
||||||
parameterLayout.setHeight("110px");
|
parameterLayout.setHeight("130px");
|
||||||
parameterLayout.setWidth("100%");
|
parameterLayout.setWidth("100%");
|
||||||
Panel parameterPanel = window.getParameterPanel();
|
Panel parameterPanel = window.getParameterPanel();
|
||||||
parameterPanel.appendChild(parameterLayout);
|
parameterPanel.appendChild(parameterLayout);
|
||||||
|
@ -200,6 +204,21 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
parameterLayout.appendChild(center);
|
parameterLayout.appendChild(center);
|
||||||
center.appendChild(parameterBankPanel);
|
center.appendChild(parameterBankPanel);
|
||||||
|
|
||||||
|
Columns columns = new Columns();
|
||||||
|
parameterBankLayout.appendChild(columns);
|
||||||
|
Column column = new Column();
|
||||||
|
columns.appendChild(column);
|
||||||
|
column = new Column();
|
||||||
|
column.setWidth("15%");
|
||||||
|
columns.appendChild(column);
|
||||||
|
column.setWidth("35%");
|
||||||
|
column = new Column();
|
||||||
|
column.setWidth("15%");
|
||||||
|
columns.appendChild(column);
|
||||||
|
column = new Column();
|
||||||
|
column.setWidth("35%");
|
||||||
|
columns.appendChild(column);
|
||||||
|
|
||||||
Rows rows = (Rows) parameterBankLayout.newRows();
|
Rows rows = (Rows) parameterBankLayout.newRows();
|
||||||
Row row = rows.newRow();
|
Row row = rows.newRow();
|
||||||
row.appendChild(bankAccountLabel.rightAlign());
|
row.appendChild(bankAccountLabel.rightAlign());
|
||||||
|
@ -253,9 +272,10 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
|
|
||||||
protected void loadBankAccount()
|
protected void loadBankAccount()
|
||||||
{
|
{
|
||||||
loadTableOIS(getBankData(documentNoField.getValue().toString(), bPartnerLookup.getValue(), dateFromField.getValue(), dateToField.getValue(),
|
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
||||||
amtFromField.getValue(), amtToField.getValue(), documentTypeField.getValue(), tenderTypeField.getValue(),
|
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
||||||
authorizationField.getValue().toString()));
|
amtFromField.getValue(), amtToField.getValue(),
|
||||||
|
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getValue().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
|
@ -284,7 +304,8 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getWindow() {
|
public Object getWindow()
|
||||||
|
{
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,7 +19,6 @@ import java.sql.Timestamp;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.webui.apps.AEnv;
|
|
||||||
import org.adempiere.webui.component.Button;
|
import org.adempiere.webui.component.Button;
|
||||||
import org.adempiere.webui.component.Column;
|
import org.adempiere.webui.component.Column;
|
||||||
import org.adempiere.webui.component.Columns;
|
import org.adempiere.webui.component.Columns;
|
||||||
|
@ -37,9 +36,10 @@ 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.WTableDirEditor;
|
||||||
|
import org.adempiere.webui.panel.ADForm;
|
||||||
|
import org.adempiere.webui.panel.IFormController;
|
||||||
import org.adempiere.webui.window.FDialog;
|
import org.adempiere.webui.window.FDialog;
|
||||||
import org.compiere.grid.CreateFromBatchStatement;
|
import org.compiere.apps.form.StatementCreateFromBatch;
|
||||||
import org.compiere.model.GridTab;
|
|
||||||
import org.compiere.model.MBankStatement;
|
import org.compiere.model.MBankStatement;
|
||||||
import org.compiere.model.MColumn;
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
|
@ -61,32 +61,28 @@ import org.zkoss.zul.Hbox;
|
||||||
* @author Elaine
|
* @author Elaine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WCreateFromBatchStatementUI extends CreateFromBatchStatement implements EventListener<Event>
|
public class WStatementCreateFromBatch extends StatementCreateFromBatch implements IFormController, EventListener<Event>
|
||||||
{
|
{
|
||||||
private WCreateFromWindow window;
|
private WCreateFromForm form;
|
||||||
|
|
||||||
public WCreateFromBatchStatementUI(GridTab tab)
|
public WStatementCreateFromBatch()
|
||||||
|
{
|
||||||
|
form = new WCreateFromForm(this);
|
||||||
|
p_WindowNo = form.getWindowNo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initForm()
|
||||||
{
|
{
|
||||||
super(tab);
|
|
||||||
log.info(getGridTab().toString());
|
|
||||||
|
|
||||||
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
|
||||||
|
|
||||||
p_WindowNo = getGridTab().getWindowNo();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!dynInit())
|
if (!dynInit())
|
||||||
return;
|
return;
|
||||||
zkInit();
|
zkInit();
|
||||||
setInitOK(true);
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "", e);
|
log.log(Level.SEVERE, "", e);
|
||||||
setInitOK(false);
|
|
||||||
}
|
}
|
||||||
AEnv.showWindow(window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Window No */
|
/** Window No */
|
||||||
|
@ -130,22 +126,22 @@ public class WCreateFromBatchStatementUI extends CreateFromBatchStatement implem
|
||||||
*/
|
*/
|
||||||
public boolean dynInit() throws Exception
|
public boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
|
||||||
|
|
||||||
super.dynInit();
|
super.dynInit();
|
||||||
|
|
||||||
|
log.config("");
|
||||||
|
|
||||||
//Refresh button
|
//Refresh button
|
||||||
Button refreshButton = window.getConfirmPanel().createButton(ConfirmPanel.A_REFRESH);
|
Button refreshButton = form.getConfirmPanel().createButton(ConfirmPanel.A_REFRESH);
|
||||||
refreshButton.addEventListener(Events.ON_CLICK, this);
|
refreshButton.addEventListener(Events.ON_CLICK, this);
|
||||||
window.getConfirmPanel().addButton(refreshButton);
|
form.getConfirmPanel().addButton(refreshButton);
|
||||||
|
|
||||||
if (getGridTab().getValue("C_BankStatement_ID") == null)
|
if (form.getGridTab() != null && form.getGridTab().getValue("C_BankStatement_ID") == null)
|
||||||
{
|
{
|
||||||
FDialog.error(0, window, "SaveErrorRowNotFound");
|
FDialog.error(0, form, "SaveErrorRowNotFound");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setTitle(getTitle());
|
form.setTitle(getTitle());
|
||||||
|
|
||||||
int AD_Column_ID = COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; // C_BankStatement.C_BankAccount_ID
|
int AD_Column_ID = COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; // 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);
|
||||||
|
@ -171,7 +167,7 @@ public class WCreateFromBatchStatementUI extends CreateFromBatchStatement implem
|
||||||
Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate);
|
Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate);
|
||||||
dateToField.setValue(date);
|
dateToField.setValue(date);
|
||||||
|
|
||||||
loadBankAccount();
|
form.postQueryEvent();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // dynInit
|
} // dynInit
|
||||||
|
@ -193,7 +189,7 @@ public class WCreateFromBatchStatementUI extends CreateFromBatchStatement implem
|
||||||
Borderlayout parameterLayout = new Borderlayout();
|
Borderlayout parameterLayout = new Borderlayout();
|
||||||
parameterLayout.setHeight("130px");
|
parameterLayout.setHeight("130px");
|
||||||
parameterLayout.setWidth("100%");
|
parameterLayout.setWidth("100%");
|
||||||
Panel parameterPanel = window.getParameterPanel();
|
Panel parameterPanel = form.getParameterPanel();
|
||||||
parameterPanel.appendChild(parameterLayout);
|
parameterPanel.appendChild(parameterLayout);
|
||||||
|
|
||||||
Grid parameterBankLayout = GridFactory.newGridLayout();
|
Grid parameterBankLayout = GridFactory.newGridLayout();
|
||||||
|
@ -263,48 +259,39 @@ public class WCreateFromBatchStatementUI extends CreateFromBatchStatement implem
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
log.config("Action=" + e.getTarget().getId());
|
log.config("Action=" + e.getTarget().getId());
|
||||||
if(e.getTarget().equals(window.getConfirmPanel().getButton(ConfirmPanel.A_REFRESH)))
|
if(e.getTarget().equals(form.getConfirmPanel().getButton(ConfirmPanel.A_REFRESH)))
|
||||||
{
|
{
|
||||||
loadBankAccount();
|
form.postQueryEvent();
|
||||||
window.tableChanged(null);
|
form.tableChanged(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadBankAccount()
|
public void executeQuery()
|
||||||
{
|
{
|
||||||
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
||||||
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
||||||
amtFromField.getValue(), amtToField.getValue(),
|
amtFromField.getValue(), amtToField.getValue(),
|
||||||
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getValue().toString()));
|
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getValue().toString(),
|
||||||
|
form.getGridTab()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
{
|
{
|
||||||
window.getWListbox().clear();
|
form.getWListbox().clear();
|
||||||
|
|
||||||
// Remove previous listeners
|
// Remove previous listeners
|
||||||
window.getWListbox().getModel().removeTableModelListener(window);
|
form.getWListbox().getModel().removeTableModelListener(form);
|
||||||
// Set Model
|
// Set Model
|
||||||
ListModelTable model = new ListModelTable(data);
|
ListModelTable model = new ListModelTable(data);
|
||||||
model.addTableModelListener(window);
|
model.addTableModelListener(form);
|
||||||
window.getWListbox().setData(model, getOISColumnNames());
|
form.getWListbox().setData(model, getOISColumnNames());
|
||||||
//
|
//
|
||||||
|
|
||||||
configureMiniTable(window.getWListbox());
|
configureMiniTable(form.getWListbox());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showWindow()
|
public ADForm getForm()
|
||||||
{
|
{
|
||||||
window.setVisible(true);
|
return form;
|
||||||
}
|
|
||||||
|
|
||||||
public void closeWindow()
|
|
||||||
{
|
|
||||||
window.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getWindow() {
|
|
||||||
return window;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@ import org.adempiere.webui.component.Window;
|
||||||
import org.adempiere.webui.exception.ApplicationException;
|
import org.adempiere.webui.exception.ApplicationException;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
import org.adempiere.webui.util.ADClassNameMap;
|
import org.adempiere.webui.util.ADClassNameMap;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.MForm;
|
import org.compiere.model.MForm;
|
||||||
import org.compiere.process.ProcessInfo;
|
import org.compiere.process.ProcessInfo;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
@ -46,7 +47,7 @@ public abstract class ADForm extends Window implements EventListener<Event>
|
||||||
private static final long serialVersionUID = -5183711788893823434L;
|
private static final long serialVersionUID = -5183711788893823434L;
|
||||||
/** The class' logging enabler */
|
/** The class' logging enabler */
|
||||||
protected static final CLogger logger;
|
protected static final CLogger logger;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
logger = CLogger.getCLogger(ADForm.class);
|
logger = CLogger.getCLogger(ADForm.class);
|
||||||
|
@ -286,6 +287,11 @@ public abstract class ADForm extends Window implements EventListener<Event>
|
||||||
* @return The created form
|
* @return The created form
|
||||||
*/
|
*/
|
||||||
public static ADForm openForm (int adFormID)
|
public static ADForm openForm (int adFormID)
|
||||||
|
{
|
||||||
|
return openForm(adFormID, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ADForm openForm (int adFormID, GridTab gridTab)
|
||||||
{
|
{
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
ADForm form;
|
ADForm form;
|
||||||
|
@ -337,6 +343,7 @@ public abstract class ADForm extends Window implements EventListener<Event>
|
||||||
if (obj instanceof ADForm)
|
if (obj instanceof ADForm)
|
||||||
{
|
{
|
||||||
form = (ADForm)obj;
|
form = (ADForm)obj;
|
||||||
|
form.gridTab = gridTab;
|
||||||
form.init(adFormID, name);
|
form.init(adFormID, name);
|
||||||
return form;
|
return form;
|
||||||
}
|
}
|
||||||
|
@ -344,6 +351,7 @@ public abstract class ADForm extends Window implements EventListener<Event>
|
||||||
{
|
{
|
||||||
IFormController customForm = (IFormController)obj;
|
IFormController customForm = (IFormController)obj;
|
||||||
form = customForm.getForm();
|
form = customForm.getForm();
|
||||||
|
form.gridTab = gridTab;
|
||||||
form.setICustomForm(customForm);
|
form.setICustomForm(customForm);
|
||||||
form.init(adFormID, name);
|
form.init(adFormID, name);
|
||||||
return form;
|
return form;
|
||||||
|
@ -405,4 +413,11 @@ public abstract class ADForm extends Window implements EventListener<Event>
|
||||||
public Mode getWindowMode() {
|
public Mode getWindowMode() {
|
||||||
return Mode.EMBEDDED;
|
return Mode.EMBEDDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GridTab gridTab;
|
||||||
|
|
||||||
|
public GridTab getGridTab()
|
||||||
|
{
|
||||||
|
return gridTab;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2013 Elaine Tan *
|
||||||
|
* Copyright (C) 2013 Trek Global
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.apps.form;
|
||||||
|
|
||||||
|
import org.compiere.apps.IStatusBar;
|
||||||
|
import org.compiere.minigrid.IMiniTable;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Elaine
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class CreateFromForm
|
||||||
|
{
|
||||||
|
/** Logger */
|
||||||
|
protected CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
public abstract void initForm();
|
||||||
|
|
||||||
|
public abstract boolean dynInit() throws Exception;
|
||||||
|
|
||||||
|
public abstract void info(IMiniTable miniTable, IStatusBar statusBar);
|
||||||
|
|
||||||
|
public abstract boolean save(IMiniTable miniTable, String trxName, GridTab gridTab);
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void executeQuery();
|
||||||
|
}
|
|
@ -11,22 +11,26 @@
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.grid;
|
package org.compiere.apps.form;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.apps.IStatusBar;
|
||||||
import org.compiere.minigrid.IMiniTable;
|
import org.compiere.minigrid.IMiniTable;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.MBankStatement;
|
import org.compiere.model.MBankStatement;
|
||||||
import org.compiere.model.MBankStatementLine;
|
import org.compiere.model.MBankStatementLine;
|
||||||
import org.compiere.model.MPayment;
|
import org.compiere.model.MPayment;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
@ -36,24 +40,142 @@ import org.compiere.util.Msg;
|
||||||
* @author Elaine
|
* @author Elaine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class CreateFromBatchStatement extends CreateFromBatch
|
public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
{
|
{
|
||||||
public CreateFromBatchStatement(GridTab mTab)
|
/** Logger */
|
||||||
{
|
protected CLogger log = CLogger.getCLogger(getClass());
|
||||||
super(mTab);
|
|
||||||
log.info(mTab.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean dynInit() throws Exception
|
public boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "X_CreateFromBatch"));
|
setTitle(Msg.getElement(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFromBatch"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSQLWhere(Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
||||||
|
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
||||||
|
{
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("WHERE p.Processed='Y' AND p.IsReconciled='N'");
|
||||||
|
sql.append(" AND p.DocStatus IN ('CO','CL','RE','VO') AND p.PayAmt<>0");
|
||||||
|
sql.append(" AND p.C_BankAccount_ID = ?");
|
||||||
|
sql.append(" AND NOT EXISTS (SELECT * FROM C_BankStatementLine l WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)");
|
||||||
|
|
||||||
|
if(DocType != null)
|
||||||
|
sql.append(" AND p.C_DocType_ID=?");
|
||||||
|
if(TenderType != null && TenderType.toString().length() > 0)
|
||||||
|
sql.append(" AND p.TenderType=?");
|
||||||
|
if(BPartner != null)
|
||||||
|
sql.append(" AND p.C_BPartner_ID=?");
|
||||||
|
|
||||||
|
if(DocumentNo.length() > 0)
|
||||||
|
sql.append(" AND UPPER(p.DocumentNo) LIKE ?");
|
||||||
|
if(AuthCode.length() > 0)
|
||||||
|
sql.append(" AND p.R_AuthCode LIKE ?");
|
||||||
|
|
||||||
|
if(AmtFrom != null || AmtTo != null)
|
||||||
|
{
|
||||||
|
BigDecimal from = (BigDecimal) AmtFrom;
|
||||||
|
BigDecimal to = (BigDecimal) AmtTo;
|
||||||
|
if(from == null && to != null)
|
||||||
|
sql.append(" AND p.PayAmt <= ?");
|
||||||
|
else if(from != null && to == null)
|
||||||
|
sql.append(" AND p.PayAmt >= ?");
|
||||||
|
else if(from != null && to != null)
|
||||||
|
sql.append(" AND p.PayAmt BETWEEN ? AND ?");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DateFrom != null || DateTo != null)
|
||||||
|
{
|
||||||
|
Timestamp from = (Timestamp) DateFrom;
|
||||||
|
Timestamp to = (Timestamp) DateTo;
|
||||||
|
if(from == null && to != null)
|
||||||
|
sql.append(" AND TRUNC(p.DateTrx) <= ?");
|
||||||
|
else if(from != null && to == null)
|
||||||
|
sql.append(" AND TRUNC(p.DateTrx) >= ?");
|
||||||
|
else if(from != null && to != null)
|
||||||
|
sql.append(" AND TRUNC(p.DateTrx) BETWEEN ? AND ?");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.fine(sql.toString());
|
||||||
|
return sql.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setParameters(PreparedStatement pstmt, Object BankAccount, Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
||||||
|
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode, GridTab gridTab)
|
||||||
|
throws SQLException
|
||||||
|
{
|
||||||
|
// Get StatementDate
|
||||||
|
Timestamp ts = (Timestamp) gridTab.getValue("StatementDate");
|
||||||
|
if (ts == null)
|
||||||
|
ts = new Timestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
|
int index = 1;
|
||||||
|
|
||||||
|
pstmt.setTimestamp(index++, ts);
|
||||||
|
pstmt.setInt(index++, BankAccount != null ? (Integer) BankAccount : (Integer) gridTab.getValue("C_BankAccount_ID"));
|
||||||
|
|
||||||
|
if(DocType != null)
|
||||||
|
pstmt.setInt(index++, (Integer) DocType);
|
||||||
|
|
||||||
|
if(TenderType != null && TenderType.toString().length() > 0)
|
||||||
|
pstmt.setString(index++, (String) TenderType);
|
||||||
|
|
||||||
|
if(BPartner != null)
|
||||||
|
pstmt.setInt(index++, (Integer) BPartner);
|
||||||
|
|
||||||
|
if(DocumentNo.length() > 0)
|
||||||
|
pstmt.setString(index++, getSQLText(DocumentNo));
|
||||||
|
|
||||||
|
if(AuthCode.length() > 0)
|
||||||
|
pstmt.setString(index++, getSQLText(AuthCode));
|
||||||
|
|
||||||
|
if(AmtFrom != null || AmtTo != null)
|
||||||
|
{
|
||||||
|
BigDecimal from = (BigDecimal) AmtFrom;
|
||||||
|
BigDecimal to = (BigDecimal) AmtTo;
|
||||||
|
log.fine("Amt From=" + from + ", To=" + to);
|
||||||
|
if(from == null && to != null)
|
||||||
|
pstmt.setBigDecimal(index++, to);
|
||||||
|
else if(from != null && to == null)
|
||||||
|
pstmt.setBigDecimal(index++, from);
|
||||||
|
else if(from != null && to != null)
|
||||||
|
{
|
||||||
|
pstmt.setBigDecimal(index++, from);
|
||||||
|
pstmt.setBigDecimal(index++, to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DateFrom != null || DateTo != null)
|
||||||
|
{
|
||||||
|
Timestamp from = (Timestamp) DateFrom;
|
||||||
|
Timestamp to = (Timestamp) DateTo;
|
||||||
|
log.fine("Date From=" + from + ", To=" + to);
|
||||||
|
if(from == null && to != null)
|
||||||
|
pstmt.setTimestamp(index++, to);
|
||||||
|
else if(from != null && to == null)
|
||||||
|
pstmt.setTimestamp(index++, from);
|
||||||
|
else if(from != null && to != null)
|
||||||
|
{
|
||||||
|
pstmt.setTimestamp(index++, from);
|
||||||
|
pstmt.setTimestamp(index++, to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSQLText(String text)
|
||||||
|
{
|
||||||
|
String s = text.toUpperCase();
|
||||||
|
if(!s.endsWith("%"))
|
||||||
|
s += "%";
|
||||||
|
log.fine( "String=" + s);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
protected Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
protected Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
||||||
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode,
|
||||||
|
GridTab gridTab)
|
||||||
{
|
{
|
||||||
log.config ("C_BankAccount_ID=" + BankAccount);
|
log.config ("C_BankAccount_ID=" + BankAccount);
|
||||||
|
|
||||||
|
@ -80,7 +202,7 @@ public abstract class CreateFromBatchStatement extends CreateFromBatch
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
setParameters(pstmt, BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode);
|
setParameters(pstmt, BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode, gridTab);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while(rs.next())
|
while(rs.next())
|
||||||
{
|
{
|
||||||
|
@ -121,10 +243,10 @@ public abstract class CreateFromBatchStatement extends CreateFromBatch
|
||||||
miniTable.autoSize();
|
miniTable.autoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean save(IMiniTable miniTable, String trxName)
|
public boolean save(IMiniTable miniTable, String trxName, GridTab gridTab)
|
||||||
{
|
{
|
||||||
// fixed values
|
// fixed values
|
||||||
int C_BankStatement_ID = ((Integer)getGridTab().getValue("C_BankStatement_ID")).intValue();
|
int C_BankStatement_ID = ((Integer) gridTab.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());
|
||||||
|
|
||||||
|
@ -144,7 +266,7 @@ public abstract class CreateFromBatchStatement extends CreateFromBatch
|
||||||
sql.append(" AND p.C_BankAccount_ID=?");
|
sql.append(" AND p.C_BankAccount_ID=?");
|
||||||
sql.append(" AND NOT EXISTS (SELECT * FROM C_BankStatementLine l WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)");
|
sql.append(" AND NOT EXISTS (SELECT * FROM C_BankStatementLine l WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)");
|
||||||
|
|
||||||
Timestamp ts = (Timestamp) getGridTab().getValue("StatementDate");
|
Timestamp ts = (Timestamp) gridTab.getValue("StatementDate");
|
||||||
if(ts == null)
|
if(ts == null)
|
||||||
ts = new Timestamp(System.currentTimeMillis());
|
ts = new Timestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
|
@ -215,4 +337,21 @@ public abstract class CreateFromBatchStatement extends CreateFromBatch
|
||||||
|
|
||||||
return columnNames;
|
return columnNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
||||||
|
{
|
||||||
|
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||||
|
BigDecimal total = new BigDecimal(0);
|
||||||
|
int rows = miniTable.getRowCount();
|
||||||
|
int count = 0;
|
||||||
|
for(int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
if(((Boolean) miniTable.getValueAt(i, 0)).booleanValue())
|
||||||
|
{
|
||||||
|
total = total.add((BigDecimal) miniTable.getValueAt(i, 4));
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
statusBar.setStatusLine(String.valueOf(count) + " - " + Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright (C) 2009 Low Heng Sin *
|
* Copyright (C) 2013 Elaine Tan *
|
||||||
* Copyright (C) 2009 Idalica Corporation *
|
* Copyright (C) 2013 Trek Global
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
@ -18,221 +18,63 @@ import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.compiere.apps.IStatusBar;
|
|
||||||
import org.compiere.minigrid.IMiniTable;
|
import org.compiere.minigrid.IMiniTable;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.MBankAccount;
|
|
||||||
import org.compiere.model.MBankStatement;
|
import org.compiere.model.MBankStatement;
|
||||||
import org.compiere.model.MBankStatementLine;
|
import org.compiere.model.MBankStatementLine;
|
||||||
import org.compiere.model.MPayment;
|
import org.compiere.model.MPayment;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.DisplayType;
|
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Transactions for Bank Statements
|
*
|
||||||
|
* @author Elaine
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
|
||||||
* @version $Id: VCreateFromStatement.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
|
||||||
* @author Victor Perez, e-Evolucion
|
|
||||||
* <li> RF [1811114] http://sourceforge.net/tracker/index.php?func=detail&aid=1811114&group_id=176962&atid=879335
|
|
||||||
* @author Teo Sarca, www.arhipac.ro
|
|
||||||
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
|
|
||||||
*/
|
*/
|
||||||
public abstract class CreateFromStatement extends CreateFrom
|
public abstract class CreateFromStatement extends CreateFromBatch
|
||||||
{
|
{
|
||||||
public MBankAccount bankAccount;
|
public CreateFromStatement(GridTab mTab)
|
||||||
|
|
||||||
/**
|
|
||||||
* Protected Constructor
|
|
||||||
* @param mTab MTab
|
|
||||||
*/
|
|
||||||
public CreateFromStatement(GridTab mTab)
|
|
||||||
{
|
{
|
||||||
super(mTab);
|
super(mTab);
|
||||||
log.info(mTab.toString());
|
log.info(mTab.toString());
|
||||||
} // VCreateFromInvoice
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Dynamic Init
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
public boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.getElement(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // dynInit
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
protected Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
||||||
* Construct SQL Where Clause and define parameters
|
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
||||||
* (setParameters needs to set parameters)
|
|
||||||
* Includes first AND
|
|
||||||
* @return sql where clause
|
|
||||||
*/
|
|
||||||
public String getSQLWhere(String DocumentNo, Object BPartner, Object DateFrom, Object DateTo,
|
|
||||||
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
|
||||||
{
|
|
||||||
StringBuilder sql = new StringBuilder("WHERE p.Processed='Y' AND p.IsReconciled='N'"
|
|
||||||
+ " AND p.DocStatus IN ('CO','CL','RE','VO') AND p.PayAmt<>0"
|
|
||||||
+ " AND p.C_BankAccount_ID = ?");
|
|
||||||
|
|
||||||
sql.append( " AND NOT EXISTS (SELECT * FROM C_BankStatementLine l "
|
|
||||||
// Voided Bank Statements have 0 StmtAmt
|
|
||||||
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)");
|
|
||||||
|
|
||||||
if (DocumentNo.length() > 0)
|
|
||||||
sql.append(" AND UPPER(p.DocumentNo) LIKE ?");
|
|
||||||
//
|
|
||||||
if (BPartner != null)
|
|
||||||
sql.append(" AND p.C_BPartner_ID=?");
|
|
||||||
//
|
|
||||||
if (DateFrom != null || DateTo != null)
|
|
||||||
{
|
|
||||||
Timestamp from = (Timestamp) DateFrom;
|
|
||||||
Timestamp to = (Timestamp) DateTo;
|
|
||||||
if (from == null && to != null)
|
|
||||||
sql.append(" AND TRUNC(p.DateTrx) <= ?");
|
|
||||||
else if (from != null && to == null)
|
|
||||||
sql.append(" AND TRUNC(p.DateTrx) >= ?");
|
|
||||||
else if (from != null && to != null)
|
|
||||||
sql.append(" AND TRUNC(p.DateTrx) BETWEEN ? AND ?");
|
|
||||||
}
|
|
||||||
//
|
|
||||||
if (AmtFrom != null || AmtTo != null)
|
|
||||||
{
|
|
||||||
BigDecimal from = (BigDecimal) AmtFrom;
|
|
||||||
BigDecimal to = (BigDecimal) AmtTo;
|
|
||||||
if (from == null && to != null)
|
|
||||||
sql.append(" AND p.PayAmt <= ?");
|
|
||||||
else if (from != null && to == null)
|
|
||||||
sql.append(" AND p.PayAmt >= ?");
|
|
||||||
else if (from != null && to != null)
|
|
||||||
sql.append(" AND p.PayAmt BETWEEN ? AND ?");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(DocType!=null)
|
|
||||||
sql.append(" AND p.C_DocType_ID=?");
|
|
||||||
if(TenderType != null && TenderType.toString().length() > 0)
|
|
||||||
sql.append(" AND p.TenderType=?");
|
|
||||||
if(AuthCode.length() > 0 )
|
|
||||||
sql.append(" AND p.R_AuthCode LIKE ?");
|
|
||||||
|
|
||||||
log.fine(sql.toString());
|
|
||||||
return sql.toString();
|
|
||||||
} // getSQLWhere
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Parameters for Query.
|
|
||||||
* (as defined in getSQLWhere)
|
|
||||||
* @param pstmt statement
|
|
||||||
* @param forCount for counting records
|
|
||||||
* @throws SQLException
|
|
||||||
*/
|
|
||||||
void setParameters(PreparedStatement pstmt, boolean forCount,
|
|
||||||
String DocumentNo, Object BPartner, Object DateFrom, Object DateTo,
|
|
||||||
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
|
||||||
throws SQLException
|
|
||||||
{
|
|
||||||
int index = 1;
|
|
||||||
|
|
||||||
pstmt.setInt(index++, bankAccount.getC_BankAccount_ID());
|
|
||||||
|
|
||||||
if (DocumentNo.length() > 0)
|
|
||||||
pstmt.setString(index++, getSQLText(DocumentNo));
|
|
||||||
//
|
|
||||||
if (BPartner != null)
|
|
||||||
{
|
|
||||||
Integer bp = (Integer) BPartner;
|
|
||||||
pstmt.setInt(index++, bp.intValue());
|
|
||||||
log.fine("BPartner=" + bp);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
if (DateFrom != null || DateTo != null)
|
|
||||||
{
|
|
||||||
Timestamp from = (Timestamp) DateFrom;
|
|
||||||
Timestamp to = (Timestamp) DateTo;
|
|
||||||
log.fine("Date From=" + from + ", To=" + to);
|
|
||||||
if (from == null && to != null)
|
|
||||||
pstmt.setTimestamp(index++, to);
|
|
||||||
else if (from != null && to == null)
|
|
||||||
pstmt.setTimestamp(index++, from);
|
|
||||||
else if (from != null && to != null)
|
|
||||||
{
|
|
||||||
pstmt.setTimestamp(index++, from);
|
|
||||||
pstmt.setTimestamp(index++, to);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
if (AmtFrom != null || AmtTo != null)
|
|
||||||
{
|
|
||||||
BigDecimal from = (BigDecimal) AmtFrom;
|
|
||||||
BigDecimal to = (BigDecimal) AmtTo;
|
|
||||||
log.fine("Amt From=" + from + ", To=" + to);
|
|
||||||
if (from == null && to != null)
|
|
||||||
pstmt.setBigDecimal(index++, to);
|
|
||||||
else if (from != null && to == null)
|
|
||||||
pstmt.setBigDecimal(index++, from);
|
|
||||||
else if (from != null && to != null)
|
|
||||||
{
|
|
||||||
pstmt.setBigDecimal(index++, from);
|
|
||||||
pstmt.setBigDecimal(index++, to);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(DocType!=null)
|
|
||||||
pstmt.setInt(index++, (Integer) DocType);
|
|
||||||
if(TenderType!=null && TenderType.toString().length() > 0 )
|
|
||||||
pstmt.setString(index++, (String) TenderType);
|
|
||||||
if(AuthCode.length() > 0 )
|
|
||||||
pstmt.setString(index++, getSQLText(AuthCode));
|
|
||||||
|
|
||||||
} // setParameters
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get SQL WHERE parameter
|
|
||||||
* @param f field
|
|
||||||
* @return Upper case text with % at the end
|
|
||||||
*/
|
|
||||||
private String getSQLText (String text)
|
|
||||||
{
|
|
||||||
String s = text.toUpperCase();
|
|
||||||
if (!s.endsWith("%"))
|
|
||||||
s += "%";
|
|
||||||
log.fine( "String=" + s);
|
|
||||||
return s;
|
|
||||||
} // getSQLText
|
|
||||||
|
|
||||||
protected Vector<Vector<Object>> getBankData(String DocumentNo, Object BPartner, Object DateFrom, Object DateTo,
|
|
||||||
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
|
||||||
{
|
{
|
||||||
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,"
|
StringBuilder sql = new StringBuilder();
|
||||||
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,pay.DateAcct,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID),"
|
sql.append("SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,");
|
||||||
+ " bp.Name "
|
sql.append("currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,?,null,p.AD_Client_ID,p.AD_Org_ID), bp.Name ");
|
||||||
+ "FROM C_BankAccount ba"
|
sql.append("FROM C_BankAccount ba");
|
||||||
+ " INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)"
|
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
||||||
+ " INNER JOIN C_Payment pay ON (p.C_Payment_ID=pay.C_Payment_ID)"
|
sql.append(" INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)");
|
||||||
+ " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)"
|
sql.append(" 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) ";
|
sql.append(getSQLWhere(BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode));
|
||||||
|
sql.append(" ORDER BY p.DateTrx");
|
||||||
sql = sql + getSQLWhere(DocumentNo, BPartner, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode) + " ORDER BY p.DateTrx";
|
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
setParameters(pstmt, false, DocumentNo, BPartner, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode);
|
setParameters(pstmt, BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode);
|
||||||
rs = pstmt.executeQuery();
|
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
|
||||||
|
@ -249,7 +91,7 @@ public abstract class CreateFromStatement extends CreateFrom
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -260,25 +102,7 @@ public abstract class CreateFromStatement extends CreateFrom
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
protected void configureMiniTable(IMiniTable miniTable)
|
||||||
{
|
|
||||||
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
|
||||||
|
|
||||||
BigDecimal total = new BigDecimal(0.0);
|
|
||||||
int rows = miniTable.getRowCount();
|
|
||||||
int count = 0;
|
|
||||||
for(int i = 0; i < rows; i++)
|
|
||||||
{
|
|
||||||
if(((Boolean) miniTable.getValueAt(i, 0)).booleanValue())
|
|
||||||
{
|
|
||||||
total = total.add((BigDecimal) miniTable.getValueAt(i, 4));
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
statusBar.setStatusLine(String.valueOf(count) + " - " + Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void configureMiniTable (IMiniTable miniTable)
|
|
||||||
{
|
{
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
miniTable.setColumnClass(1, Timestamp.class, false); // 1-TrxDate / nmicoud - idempiere 240 Let user choose the 'Statement Line Date'
|
miniTable.setColumnClass(1, Timestamp.class, false); // 1-TrxDate / nmicoud - idempiere 240 Let user choose the 'Statement Line Date'
|
||||||
|
@ -291,28 +115,24 @@ public abstract class CreateFromStatement extends CreateFrom
|
||||||
miniTable.autoSize();
|
miniTable.autoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Save Statement - Insert Data
|
|
||||||
* @return true if saved
|
|
||||||
*/
|
|
||||||
public boolean save(IMiniTable miniTable, String trxName)
|
public boolean save(IMiniTable miniTable, String trxName)
|
||||||
{
|
{
|
||||||
// fixed values
|
// fixed values
|
||||||
int C_BankStatement_ID = ((Integer)getGridTab().getValue("C_BankStatement_ID")).intValue();
|
int C_BankStatement_ID = ((Integer) getGridTab().getValue("C_BankStatement_ID")).intValue();
|
||||||
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, trxName);
|
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, trxName);
|
||||||
log.config(bs.toString());
|
log.config(bs.toString());
|
||||||
|
|
||||||
// Lines
|
// Lines
|
||||||
for (int i = 0; i < miniTable.getRowCount(); i++)
|
for(int i = 0; i < miniTable.getRowCount(); i++)
|
||||||
{
|
{
|
||||||
if (((Boolean)miniTable.getValueAt(i, 0)).booleanValue())
|
if(((Boolean) miniTable.getValueAt(i, 0)).booleanValue())
|
||||||
{
|
{
|
||||||
Timestamp trxDate = (Timestamp)miniTable.getValueAt(i, 1); // 1-DateTrx
|
Timestamp trxDate = (Timestamp) miniTable.getValueAt(i, 1); // 1-DateTrx
|
||||||
KeyNamePair pp = (KeyNamePair)miniTable.getValueAt(i, 2); // 2-C_Payment_ID
|
KeyNamePair pp = (KeyNamePair) miniTable.getValueAt(i, 2); // 2-C_Payment_ID
|
||||||
int C_Payment_ID = pp.getKey();
|
int C_Payment_ID = pp.getKey();
|
||||||
pp = (KeyNamePair)miniTable.getValueAt(i, 3); // 3-Currency
|
pp = (KeyNamePair) miniTable.getValueAt(i, 3); // 3-Currency
|
||||||
int C_Currency_ID = pp.getKey();
|
int C_Currency_ID = pp.getKey();
|
||||||
BigDecimal TrxAmt = (BigDecimal)miniTable.getValueAt(i, 5); // 5- Conv Amt
|
BigDecimal TrxAmt = (BigDecimal) miniTable.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);
|
||||||
|
@ -323,7 +143,7 @@ public abstract class CreateFromStatement extends CreateFrom
|
||||||
|
|
||||||
bsl.setTrxAmt(TrxAmt);
|
bsl.setTrxAmt(TrxAmt);
|
||||||
bsl.setStmtAmt(TrxAmt);
|
bsl.setStmtAmt(TrxAmt);
|
||||||
bsl.setC_Currency_ID(bankAccount.getC_Currency_ID());
|
bsl.setC_Currency_ID(C_Currency_ID);
|
||||||
|
|
||||||
if (!bsl.save())
|
if (!bsl.save())
|
||||||
log.log(Level.SEVERE, "Line not created #" + i);
|
log.log(Level.SEVERE, "Line not created #" + i);
|
||||||
|
@ -335,7 +155,7 @@ public abstract class CreateFromStatement extends CreateFrom
|
||||||
protected Vector<String> getOISColumnNames()
|
protected Vector<String> getOISColumnNames()
|
||||||
{
|
{
|
||||||
// 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(), "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"));
|
||||||
|
@ -346,4 +166,4 @@ public abstract class CreateFromStatement extends CreateFrom
|
||||||
|
|
||||||
return columnNames;
|
return columnNames;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,169 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2013 Elaine Tan *
|
|
||||||
* Copyright (C) 2013 Trek Global
|
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
|
||||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
||||||
* See the GNU General Public License for more details. *
|
|
||||||
* You should have received a copy of the GNU General Public License along *
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
|
||||||
*****************************************************************************/
|
|
||||||
package org.compiere.grid;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.compiere.minigrid.IMiniTable;
|
|
||||||
import org.compiere.model.GridTab;
|
|
||||||
import org.compiere.model.MBankStatement;
|
|
||||||
import org.compiere.model.MBankStatementLine;
|
|
||||||
import org.compiere.model.MPayment;
|
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.Env;
|
|
||||||
import org.compiere.util.KeyNamePair;
|
|
||||||
import org.compiere.util.Msg;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Elaine
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public abstract class CreateFromStatementBatch extends CreateFromBatch
|
|
||||||
{
|
|
||||||
public CreateFromStatementBatch(GridTab mTab)
|
|
||||||
{
|
|
||||||
super(mTab);
|
|
||||||
log.info(mTab.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
|
||||||
log.config("");
|
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
|
||||||
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
|
||||||
{
|
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder();
|
|
||||||
sql.append("SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,");
|
|
||||||
sql.append("currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,?,null,p.AD_Client_ID,p.AD_Org_ID), bp.Name ");
|
|
||||||
sql.append("FROM C_BankAccount ba");
|
|
||||||
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
|
||||||
sql.append(" INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)");
|
|
||||||
sql.append(" LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) ");
|
|
||||||
sql.append(getSQLWhere(BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode));
|
|
||||||
sql.append(" ORDER BY p.DateTrx");
|
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
|
||||||
setParameters(pstmt, BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
while(rs.next())
|
|
||||||
{
|
|
||||||
Vector<Object> line = new Vector<Object>(6);
|
|
||||||
line.add(new Boolean(false)); // 0-Selection
|
|
||||||
line.add(rs.getTimestamp(1)); // 1-DateTrx
|
|
||||||
KeyNamePair pp = new KeyNamePair(rs.getInt(2), rs.getString(3));
|
|
||||||
line.add(pp); // 2-C_Payment_ID
|
|
||||||
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
|
|
||||||
line.add(pp); // 3-Currency
|
|
||||||
line.add(rs.getBigDecimal(6)); // 4-PayAmt
|
|
||||||
line.add(rs.getBigDecimal(7)); // 5-Conv Amt
|
|
||||||
line.add(rs.getString(8)); // 6-BParner
|
|
||||||
data.add(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
rs = null; pstmt = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void configureMiniTable(IMiniTable miniTable)
|
|
||||||
{
|
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
|
||||||
miniTable.setColumnClass(1, Timestamp.class, false); // 1-TrxDate / nmicoud - idempiere 240 Let user choose the 'Statement Line Date'
|
|
||||||
miniTable.setColumnClass(2, String.class, true); // 2-Payment
|
|
||||||
miniTable.setColumnClass(3, String.class, true); // 3-Currency
|
|
||||||
miniTable.setColumnClass(4, BigDecimal.class, true); // 4-Amount
|
|
||||||
miniTable.setColumnClass(5, BigDecimal.class, true); // 5-ConvAmount
|
|
||||||
miniTable.setColumnClass(6, String.class, true); // 6-BPartner
|
|
||||||
// Table UI
|
|
||||||
miniTable.autoSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean save(IMiniTable miniTable, String trxName)
|
|
||||||
{
|
|
||||||
// fixed values
|
|
||||||
int C_BankStatement_ID = ((Integer) getGridTab().getValue("C_BankStatement_ID")).intValue();
|
|
||||||
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, trxName);
|
|
||||||
log.config(bs.toString());
|
|
||||||
|
|
||||||
// Lines
|
|
||||||
for(int i = 0; i < miniTable.getRowCount(); i++)
|
|
||||||
{
|
|
||||||
if(((Boolean) miniTable.getValueAt(i, 0)).booleanValue())
|
|
||||||
{
|
|
||||||
Timestamp trxDate = (Timestamp) miniTable.getValueAt(i, 1); // 1-DateTrx
|
|
||||||
KeyNamePair pp = (KeyNamePair) miniTable.getValueAt(i, 2); // 2-C_Payment_ID
|
|
||||||
int C_Payment_ID = pp.getKey();
|
|
||||||
pp = (KeyNamePair) miniTable.getValueAt(i, 3); // 3-Currency
|
|
||||||
int C_Currency_ID = pp.getKey();
|
|
||||||
BigDecimal TrxAmt = (BigDecimal) miniTable.getValueAt(i, 5); // 5- Conv Amt
|
|
||||||
|
|
||||||
log.fine("Line Date=" + trxDate
|
|
||||||
+ ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
|
|
||||||
//
|
|
||||||
MBankStatementLine bsl = new MBankStatementLine (bs);
|
|
||||||
bsl.setStatementLineDate(trxDate);
|
|
||||||
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, trxName));
|
|
||||||
|
|
||||||
bsl.setTrxAmt(TrxAmt);
|
|
||||||
bsl.setStmtAmt(TrxAmt);
|
|
||||||
bsl.setC_Currency_ID(C_Currency_ID);
|
|
||||||
|
|
||||||
if (!bsl.save())
|
|
||||||
log.log(Level.SEVERE, "Line not created #" + i);
|
|
||||||
} // if selected
|
|
||||||
} // for all rows
|
|
||||||
return true;
|
|
||||||
} // save
|
|
||||||
|
|
||||||
protected Vector<String> getOISColumnNames()
|
|
||||||
{
|
|
||||||
// Header Info
|
|
||||||
Vector<String> columnNames = new Vector<String>(7);
|
|
||||||
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
|
|
||||||
columnNames.add(Msg.getElement(Env.getCtx(), "C_Payment_ID"));
|
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "Amount"));
|
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "ConvertedAmount"));
|
|
||||||
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
|
|
||||||
|
|
||||||
return columnNames;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,6 +22,6 @@ import org.compiere.model.GridTab;
|
||||||
*/
|
*/
|
||||||
public interface ICreateFromFactory {
|
public interface ICreateFromFactory {
|
||||||
|
|
||||||
public ICreateFrom create(GridTab mTab, String columnName);
|
public ICreateFrom create(GridTab mTab);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue