IDEMPIERE-137 Enhancement of GL Reconciliation
Ambidexter GL Reconciliation
This commit is contained in:
parent
18e001b341
commit
54a143f241
|
@ -0,0 +1,39 @@
|
|||
-- Remove Old Primary Key Fact_Acct_ID
|
||||
ALTER TABLE Fact_Reconciliation DROP CONSTRAINT fact_reconciliation_key
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:04:01 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
UPDATE AD_Column SET IsKey='N',Updated=TO_DATE('2012-02-03 22:04:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59777
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:07:48 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,EntityType,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,200001,0,'Fact_Reconciliation_ID',TO_DATE('2012-02-03 22:07:45','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Accounting Fact Reconciliation','Accounting Fact Reconciliation',TO_DATE('2012-02-03 22:07:45','YYYY-MM-DD HH24:MI:SS'),100)
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:07:48 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=200001 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:08:29 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,EntityType,FieldLength,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,200014,200001,0,13,53286,'Fact_Reconciliation_ID',TO_DATE('2012-02-03 22:08:22','YYYY-MM-DD HH24:MI:SS'),100,'D',10,'Y','Y','N','N','N','N','Y','Y','N','N','N','N','N','Accounting Fact Reconciliation',0,TO_DATE('2012-02-03 22:08:22','YYYY-MM-DD HH24:MI:SS'),100,0)
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:08:29 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=200014 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:08:33 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
ALTER TABLE Fact_Reconciliation ADD Fact_Reconciliation_ID NUMBER(10) NOT NULL
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:08:33 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
ALTER TABLE Fact_Reconciliation ADD CONSTRAINT Fact_Reconciliation_Key PRIMARY KEY (Fact_Reconciliation_ID)
|
||||
;
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
-- Remove Old Primary Key Fact_Acct_ID
|
||||
ALTER TABLE Fact_Reconciliation DROP CONSTRAINT fact_reconciliation_key
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:04:01 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
UPDATE AD_Column SET IsKey='N',Updated=TO_TIMESTAMP('2012-02-03 22:04:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59777
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:07:48 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,EntityType,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,200001,0,'Fact_Reconciliation_ID',TO_TIMESTAMP('2012-02-03 22:07:45','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Accounting Fact Reconciliation','Accounting Fact Reconciliation',TO_TIMESTAMP('2012-02-03 22:07:45','YYYY-MM-DD HH24:MI:SS'),100)
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:07:48 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=200001 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:08:29 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,EntityType,FieldLength,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,200014,200001,0,13,53286,'Fact_Reconciliation_ID',TO_TIMESTAMP('2012-02-03 22:08:22','YYYY-MM-DD HH24:MI:SS'),100,'D',10,'Y','Y','N','N','N','N','Y','Y','N','N','N','N','N','Accounting Fact Reconciliation',0,TO_TIMESTAMP('2012-02-03 22:08:22','YYYY-MM-DD HH24:MI:SS'),100,0)
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:08:29 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=200014 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:08:33 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
ALTER TABLE Fact_Reconciliation ADD COLUMN Fact_Reconciliation_ID NUMERIC(10) NOT NULL
|
||||
;
|
||||
|
||||
-- Feb 3, 2012 10:08:33 PM ICT
|
||||
-- Ambidexter GL Reconciliation
|
||||
ALTER TABLE Fact_Reconciliation ADD CONSTRAINT Fact_Reconciliation_Key PRIMARY KEY (Fact_Reconciliation_ID)
|
||||
;
|
||||
|
|
@ -9,9 +9,9 @@ public class MFactReconciliation extends X_Fact_Reconciliation {
|
|||
*/
|
||||
private static final long serialVersionUID = 7569838866747051210L;
|
||||
|
||||
public MFactReconciliation(Properties ctx, int Fact_Acct_ID,
|
||||
public MFactReconciliation(Properties ctx, int Fact_Reconciliation_ID,
|
||||
String trxName) {
|
||||
super(ctx, Fact_Acct_ID, trxName);
|
||||
super(ctx, Fact_Reconciliation_ID, trxName);
|
||||
}
|
||||
|
||||
public MFactReconciliation(Properties ctx, ResultSet rs, String trxName) {
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
* Contributors: *
|
||||
* Colin Rooney (croo) Patch 1605368 Fixed Payment Terms & Only due *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps.form;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
@ -23,6 +5,9 @@ import java.awt.Dimension;
|
|||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.beans.VetoableChangeListener;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -32,6 +17,7 @@ import java.text.DecimalFormat;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
@ -52,7 +38,6 @@ import org.compiere.grid.ed.VCheckBox;
|
|||
import org.compiere.grid.ed.VComboBox;
|
||||
import org.compiere.grid.ed.VDate;
|
||||
import org.compiere.grid.ed.VLookup;
|
||||
import org.compiere.minigrid.ColumnInfo;
|
||||
import org.compiere.minigrid.IDColumn;
|
||||
import org.compiere.minigrid.MiniTable;
|
||||
import org.compiere.model.MClient;
|
||||
|
@ -61,12 +46,9 @@ import org.compiere.model.MLookup;
|
|||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.plaf.CompiereColor;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.swing.CLabel;
|
||||
import org.compiere.swing.CPanel;
|
||||
import org.compiere.swing.CTextField;
|
||||
import org.compiere.util.ASyncProcess;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
|
@ -74,16 +56,20 @@ import org.compiere.util.Env;
|
|||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
/**
|
||||
* Create manual match of accounting facts
|
||||
*/
|
||||
public class VFactReconcile extends CPanel
|
||||
implements FormPanel, ActionListener, TableModelListener, ASyncProcess
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4319867865736797328L;
|
||||
public class VFactReconcile extends FactReconcile
|
||||
implements FormPanel, ActionListener, TableModelListener, VetoableChangeListener {
|
||||
|
||||
/** Window No */
|
||||
private int m_WindowNo = 0;
|
||||
/** FormFrame */
|
||||
private FormFrame m_frame;
|
||||
|
||||
/** Format */
|
||||
private DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||
/** Number of selected rows */
|
||||
private int m_noSelected = 0;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VFactReconcile.class);
|
||||
|
||||
/**
|
||||
* Initialize Panel
|
||||
|
@ -108,25 +94,7 @@ public class VFactReconcile extends CPanel
|
|||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // init
|
||||
|
||||
/** Window No */
|
||||
private int m_WindowNo = 0;
|
||||
/** FormFrame */
|
||||
private FormFrame m_frame;
|
||||
|
||||
/** Format */
|
||||
private DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||
/** SQL for Query */
|
||||
private String m_sql;
|
||||
/** Number of selected rows */
|
||||
private int m_noSelected = 0;
|
||||
/** Client ID */
|
||||
private int m_AD_Client_ID = 0;
|
||||
/**/
|
||||
private boolean m_isLocked = false;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VFactReconcile.class);
|
||||
|
||||
|
||||
//
|
||||
private CPanel mainPanel = new CPanel();
|
||||
private BorderLayout mainLayout = new BorderLayout();
|
||||
|
@ -160,8 +128,6 @@ public class VFactReconcile extends CPanel
|
|||
private CLabel labelProduct = new CLabel();
|
||||
private VLookup fieldProduct = null;
|
||||
private boolean loading = false;
|
||||
private int idColIndex = 3;
|
||||
private int amtColIndex = 1;
|
||||
private CLabel differenceLabel = new CLabel();
|
||||
private CTextField differenceField = new CTextField();
|
||||
|
||||
|
@ -171,7 +137,7 @@ public class VFactReconcile extends CPanel
|
|||
*/
|
||||
private void jbInit() throws Exception
|
||||
{
|
||||
CompiereColor.setBackground(this);
|
||||
//CompiereColor.setBackground(this);
|
||||
//
|
||||
mainPanel.setLayout(mainLayout);
|
||||
parameterLayout = new MigLayout("fillx, wrap 4, hidemode 0", " [150:150][250:250][100:100][200:200]");
|
||||
|
@ -258,32 +224,32 @@ public class VFactReconcile extends CPanel
|
|||
* - Load Document Type
|
||||
* - Init Table
|
||||
*/
|
||||
private void dynInit()
|
||||
public void dynInit()
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
//
|
||||
m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
|
||||
|
||||
int AD_Column_ID = 2513; // Fact_Acct.C_AcctSchema_ID
|
||||
MLookup lookupAS = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
||||
int AD_Column_ID = FactReconcile.col_C_AcctSchema_ID; // Fact_Acct.C_AcctSchema_ID
|
||||
MLookup lookupAS = MLookupFactory.get (ctx, m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
||||
fieldAcctSchema = new VLookup("C_AcctSchema_ID", true, false, true, lookupAS);
|
||||
fieldAcctSchema.addActionListener(this);
|
||||
MClient.get(Env.getCtx()).getAcctSchema().getC_AcctSchema_ID();
|
||||
fieldAcctSchema.setValue(MClient.get(Env.getCtx()).getAcctSchema().getC_AcctSchema_ID());
|
||||
|
||||
fieldAcctSchema.setValue(MClient.get(ctx).getAcctSchema().getC_AcctSchema_ID());
|
||||
|
||||
Dimension dim = fieldAcctSchema.getPreferredSize();
|
||||
dim.width = 300;
|
||||
fieldAcctSchema.setPreferredSize(dim);
|
||||
|
||||
// Organization filter selection
|
||||
AD_Column_ID = 839; //C_Period.AD_Org_ID (needed to allow org 0)
|
||||
MLookup lookupOrg = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
||||
AD_Column_ID = FactReconcile.col_AD_Org_ID; //C_Period.AD_Org_ID (needed to allow org 0)
|
||||
MLookup lookupOrg = MLookupFactory.get(ctx, m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
||||
fieldOrg = new VLookup("AD_Org_ID", true, false, true, lookupOrg);
|
||||
if (lookupOrg.containsKey(0))
|
||||
fieldOrg.setValue(0);
|
||||
else
|
||||
fieldOrg.setValue(Env.getAD_Org_ID(Env.getCtx()));
|
||||
fieldOrg.setValue(Env.getAD_Org_ID(ctx));
|
||||
|
||||
|
||||
dim = fieldOrg.getPreferredSize();
|
||||
|
@ -291,184 +257,118 @@ public class VFactReconcile extends CPanel
|
|||
fieldOrg.setPreferredSize(dim);
|
||||
|
||||
// BPartner
|
||||
AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
|
||||
MLookup lookupBP = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search);
|
||||
AD_Column_ID = FactReconcile.col_C_BPartner_ID; // C_Invoice.C_BPartner_ID
|
||||
MLookup lookupBP = MLookupFactory.get (ctx, m_WindowNo, 0, AD_Column_ID, DisplayType.Search);
|
||||
fieldBPartner = new VLookup("C_BPartner_ID", false, false, true, lookupBP);
|
||||
|
||||
// Product
|
||||
AD_Column_ID = 2527; // Fact_Acct.M_Product_ID
|
||||
MLookup lookupProduct = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search);
|
||||
AD_Column_ID = FactReconcile.col_M_Product_ID; // Fact_Acct.M_Product_ID
|
||||
MLookup lookupProduct = MLookupFactory.get (ctx, m_WindowNo, 0, AD_Column_ID, DisplayType.Search);
|
||||
fieldProduct = new VLookup("M_Product_ID", false, false, true, lookupProduct);
|
||||
|
||||
|
||||
// Account
|
||||
KeyNamePair pp;
|
||||
String sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT ev.C_ElementValue_ID, ev.Value || ' ' || ev.Name FROM C_ElementValue ev", "ev",
|
||||
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO)
|
||||
+ "AND ev.IsActive='Y' AND ev.IsSummary='N' "
|
||||
+ "AND ev.C_Element_ID IN (SELECT C_Element_ID FROM C_AcctSchema_Element ase "
|
||||
+ "WHERE ase.ElementType='AC' AND ase.AD_Client_ID=" + m_AD_Client_ID + ") "
|
||||
+ "ORDER BY 2";
|
||||
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||
fieldAccount.addItem(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
Vector<KeyNamePair> vector = getAccount();
|
||||
for(int i=0;i<vector.size();i++)
|
||||
fieldAccount.addItem(vector.get(i));
|
||||
AutoCompletion.enable(fieldAccount);
|
||||
fieldAccount.setMandatory(true);
|
||||
fieldAccount.setSelectedIndex(0);
|
||||
|
||||
m_sql = miniTable.prepareTable(new ColumnInfo[] {
|
||||
new ColumnInfo(Msg.translate(ctx, "Amt"), "abs(fa.amtacctdr-fa.amtacctcr)", BigDecimal.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "AmtAcct"), "(fa.amtacctdr-fa.amtacctcr)", BigDecimal.class,true,true,null),
|
||||
new ColumnInfo("DR/CR", "(CASE WHEN (fa.amtacctdr-fa.amtacctcr) < 0 THEN 'CR' ELSE 'DR' END)", String.class),
|
||||
new ColumnInfo(" ", "fa.Fact_Acct_ID", IDColumn.class, false, false, null),
|
||||
new ColumnInfo(Msg.translate(ctx, "C_BPartner_ID"), "bp.Name", String.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "DateAcct"), "fa.DateAcct", Timestamp.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "GL_Category_ID"), "glc.Name", String.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "M_Product_ID"), "p.Value", String.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "Qty"), "Qty", BigDecimal.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "Description"), "fa.Description", String.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "MatchCode"), "r.MatchCode", String.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "DateTrx"), "fa.DateTrx", Timestamp.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "AD_Org_ID"), "o.Value", String.class)},
|
||||
// FROM
|
||||
"Fact_Acct fa"
|
||||
+ " LEFT OUTER JOIN Fact_Reconciliation r ON (fa.Fact_Acct_ID=r.Fact_Acct_ID)"
|
||||
+ " LEFT OUTER JOIN C_BPartner bp ON (fa.C_BPartner_ID=bp.C_BPartner_ID)"
|
||||
+ " LEFT OUTER JOIN AD_Org o ON (o.AD_Org_ID=fa.AD_Org_ID)"
|
||||
+ " LEFT OUTER JOIN M_Product p ON (p.M_Product_ID=fa.M_Product_ID)"
|
||||
+ " LEFT OUTER JOIN GL_Category glc ON (fa.GL_Category_ID=glc.GL_Category_ID)",
|
||||
// WHERE
|
||||
" fa.AD_Client_ID=?", // additional where & order in loadTableInfo()
|
||||
true, "fa");
|
||||
//
|
||||
miniTable.getModel().addTableModelListener(this);
|
||||
miniTable.setColumnVisibility(miniTable.getColumnModel().getColumn(1), false);
|
||||
//loadData();
|
||||
|
||||
} // dynInit
|
||||
|
||||
/**
|
||||
* Query and create TableInfo
|
||||
*/
|
||||
private void loadTableInfo()
|
||||
{
|
||||
log.config("");
|
||||
// not yet initialized
|
||||
if (m_sql == null)
|
||||
return;
|
||||
loading = true;
|
||||
|
||||
|
||||
|
||||
String sql = m_sql;
|
||||
public void loadData(){
|
||||
KeyNamePair pp = (KeyNamePair)fieldAccount.getSelectedItem();
|
||||
int Account_ID = pp.getKey();
|
||||
if (Account_ID != 0)
|
||||
sql += " AND fa.Account_ID=?";
|
||||
m_Account_ID = Account_ID;
|
||||
|
||||
if ( ((Integer) fieldAcctSchema.getValue()) > 0 )
|
||||
sql += " AND fa.C_AcctSchema_ID = ?";
|
||||
|
||||
sql += " AND ((SELECT SUM(f.amtacctdr-f.amtacctcr) FROM Fact_Reconciliation rec " +
|
||||
" INNER JOIN Fact_Acct f ON (f.Fact_Acct_ID = rec.Fact_Acct_ID) " +
|
||||
" WHERE r.MatchCode=rec.MatchCode) ";
|
||||
if ( isReconciled.isSelected() )
|
||||
sql += "= 0) ";
|
||||
else
|
||||
sql += "<> 0 OR r.MatchCode IS NULL) ";
|
||||
|
||||
|
||||
|
||||
if ( fieldBPartner.getValue() != null )
|
||||
sql += " AND fa.C_BPartner_ID = ?";
|
||||
|
||||
if ( fieldProduct.getValue() != null )
|
||||
sql += " AND fa.M_Product_ID = ?";
|
||||
|
||||
if ( fieldDateAcct.getValue() != null )
|
||||
sql += " AND fa.DateAcct >= ?";
|
||||
|
||||
if ( fieldDateAcct2.getValue() != null )
|
||||
sql += " AND fa.DateAcct <= ?";
|
||||
|
||||
|
||||
sql += " ORDER BY 1,5,3,6";
|
||||
if(fieldOrg.getValue()!=null)
|
||||
m_AD_Org_ID = (Integer)fieldOrg.getValue();
|
||||
|
||||
if(fieldAcctSchema.getValue()!=null)
|
||||
m_C_AcctSchema_ID = (Integer)fieldAcctSchema.getValue();
|
||||
|
||||
log.finest(sql + "Account_ID =" + Account_ID );
|
||||
// Get facts
|
||||
try
|
||||
{
|
||||
int index = 1;
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
|
||||
pstmt.setInt(index++, m_AD_Client_ID); // Client
|
||||
|
||||
pstmt.setInt(index++, (Integer) fieldAccount.getValue()); // account
|
||||
|
||||
if ( ((Integer) fieldAcctSchema.getValue()) > 0 )
|
||||
pstmt.setInt(index++, (Integer) fieldAcctSchema.getValue());
|
||||
|
||||
if ( fieldBPartner.getValue() != null )
|
||||
pstmt.setInt(index++, (Integer) fieldBPartner.getValue());
|
||||
|
||||
if ( fieldProduct.getValue() != null )
|
||||
pstmt.setInt(index++, (Integer) fieldProduct.getValue());
|
||||
|
||||
if ( fieldDateAcct.getValue() != null )
|
||||
pstmt.setTimestamp(index++, (Timestamp) fieldDateAcct.getValue());
|
||||
|
||||
|
||||
if ( fieldDateAcct2.getValue() != null )
|
||||
pstmt.setTimestamp(index++, (Timestamp) fieldDateAcct2.getValue());
|
||||
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
miniTable.loadTable(rs);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
log.log(Level.FINE, sql);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
loading = false;
|
||||
if(isReconciled.getValue()!=null)
|
||||
m_isReconciled = (Boolean)isReconciled.getValue();
|
||||
|
||||
calculateSelection();
|
||||
} // loadTableInfo
|
||||
|
||||
if(fieldBPartner.getValue()!=null)
|
||||
m_C_BPartner_ID = (Integer)fieldBPartner.getValue();
|
||||
|
||||
if((Integer)fieldProduct.getValue()!=null)
|
||||
m_M_Product_ID = (Integer)fieldProduct.getValue();
|
||||
|
||||
if(fieldDateAcct.getValue()!=null)
|
||||
m_DateAcct = (Timestamp)fieldDateAcct.getValue();
|
||||
|
||||
if(fieldDateAcct2.getValue()!=null)
|
||||
m_DateAcct2 = (Timestamp)fieldDateAcct2.getValue();
|
||||
|
||||
// Set Model
|
||||
Vector<Vector<Object>> data = getData();
|
||||
Vector<String> columnNames = getColumnNames();
|
||||
|
||||
// Remove Previous Listeners
|
||||
miniTable.getModel().removeTableModelListener(this);
|
||||
|
||||
DefaultTableModel modelI = new DefaultTableModel(data, columnNames);
|
||||
modelI.addTableModelListener(this);
|
||||
miniTable.setModel(modelI);
|
||||
setColumnClass(miniTable);
|
||||
//miniTable.setColumnVisibility(miniTable.getColumnModel().getColumn(1), false);
|
||||
miniTable.setColorColumn(amtColIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
* Calculate selected rows.
|
||||
* - add up selected rows
|
||||
*/
|
||||
public void dispose()
|
||||
public void calculateSelection()
|
||||
{
|
||||
if (m_frame != null)
|
||||
m_frame.dispose();
|
||||
m_frame = null;
|
||||
} // dispose
|
||||
m_noSelected = 0;
|
||||
BigDecimal selectedAmt = new BigDecimal(0.0);
|
||||
|
||||
int rows = miniTable.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
boolean isSelected = (Boolean)miniTable.getModel().getValueAt(i, selectedColIndex);
|
||||
if (isSelected)
|
||||
{
|
||||
BigDecimal amt = (BigDecimal)miniTable.getModel().getValueAt(i, amtColIndex);
|
||||
if (amt != null)
|
||||
selectedAmt = selectedAmt.add(amt);
|
||||
m_noSelected++;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* ActionListener
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
// Information
|
||||
StringBuffer info = new StringBuffer();
|
||||
info.append(m_noSelected).append(" ").append(Msg.getMsg(Env.getCtx(), "Selected")).append(" / ").append(miniTable.getRowCount());
|
||||
|
||||
differenceField.setText(m_format.format(selectedAmt));
|
||||
dataStatus.setText(info.toString());
|
||||
//
|
||||
bGenerate.setEnabled(m_noSelected != 0 && Env.ZERO.compareTo(selectedAmt) == 0 && !isReconciled.isSelected());
|
||||
bReset.setEnabled(m_noSelected > 0 && isReconciled.isSelected());
|
||||
} // calculateSelection
|
||||
|
||||
@Override
|
||||
public void vetoableChange(PropertyChangeEvent evt)
|
||||
throws PropertyVetoException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent e) {
|
||||
if (! loading )
|
||||
calculateSelection();
|
||||
} // valueChanged
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// Generate Reconciliation
|
||||
if (e.getSource() == bGenerate)
|
||||
{
|
||||
|
@ -489,10 +389,45 @@ public class VFactReconcile extends CPanel
|
|||
|
||||
// Update
|
||||
else if (e.getSource() == bRefresh)
|
||||
loadTableInfo();
|
||||
|
||||
} // actionPerformed
|
||||
loadData();
|
||||
}
|
||||
|
||||
private void generateReconciliation() {
|
||||
log.info("");
|
||||
//
|
||||
miniTable.stopEditor(true);
|
||||
if (miniTable.getRowCount() == 0)
|
||||
return;
|
||||
miniTable.setRowSelectionInterval(0,0);
|
||||
calculateSelection();
|
||||
if (m_noSelected == 0)
|
||||
return;
|
||||
|
||||
|
||||
String format = "yyyy-MM-dd HH:mm:ss.SSS";
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
String time = sdf.format(cal.getTime());
|
||||
|
||||
for ( int r = 0; r < miniTable.getModel().getRowCount(); r++ )
|
||||
{
|
||||
boolean isSelected = (Boolean)miniTable.getModel().getValueAt(r, selectedColIndex);
|
||||
|
||||
if (isSelected)
|
||||
{
|
||||
KeyNamePair pp = (KeyNamePair)miniTable.getModel().getValueAt(r, idColIndex);
|
||||
|
||||
int factId = pp.getKey();
|
||||
|
||||
boolean result = generate(factId, time);
|
||||
if(!result)
|
||||
continue;
|
||||
|
||||
((DefaultTableModel) miniTable.getModel()).removeRow(r--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom to target
|
||||
* @param AD_Window_ID window id
|
||||
|
@ -506,13 +441,14 @@ public class VFactReconcile extends CPanel
|
|||
|
||||
if ( selected == -1 )
|
||||
return;
|
||||
|
||||
KeyNamePair pp = (KeyNamePair)miniTable.getModel().getValueAt(selected, idColIndex);
|
||||
|
||||
int factId = ((IDColumn) miniTable.getModel().getValueAt(selected, idColIndex)).getRecord_ID();
|
||||
int factId = pp.getKey();
|
||||
|
||||
AEnv.zoom(270, factId);
|
||||
} // zoom
|
||||
|
||||
|
||||
|
||||
private void resetReconciliation() {
|
||||
log.info("");
|
||||
//
|
||||
|
@ -526,160 +462,28 @@ public class VFactReconcile extends CPanel
|
|||
|
||||
for ( int r = 0; r < miniTable.getModel().getRowCount(); r++ )
|
||||
{
|
||||
if ( ((IDColumn) miniTable.getModel().getValueAt(r, idColIndex)).isSelected() )
|
||||
boolean isSelected = (Boolean)miniTable.getModel().getValueAt(r, selectedColIndex);
|
||||
|
||||
if (isSelected)
|
||||
{
|
||||
int factId = ((IDColumn) miniTable.getModel().getValueAt(r, idColIndex )).getRecord_ID();
|
||||
KeyNamePair pp = (KeyNamePair)miniTable.getModel().getValueAt(r, idColIndex);
|
||||
|
||||
int factId = pp.getKey();
|
||||
|
||||
MFactReconciliation rec = new Query(Env.getCtx(), MFactReconciliation.Table_Name, "Fact_Acct_ID = ?", null)
|
||||
.setParameters(new Object[] {factId}).first();
|
||||
|
||||
if ( rec == null )
|
||||
{
|
||||
boolean result = reset(factId);
|
||||
if(!result)
|
||||
continue;
|
||||
}
|
||||
|
||||
rec.setMatchCode(null);
|
||||
rec.saveEx();
|
||||
|
||||
((DefaultTableModel) miniTable.getModel()).removeRow(r--);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Table Model Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void tableChanged(TableModelEvent e)
|
||||
{
|
||||
if (! loading )
|
||||
calculateSelection();
|
||||
} // valueChanged
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (m_frame != null)
|
||||
m_frame.dispose();
|
||||
m_frame = null;
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Calculate selected rows.
|
||||
* - add up selected rows
|
||||
*/
|
||||
public void calculateSelection()
|
||||
{
|
||||
m_noSelected = 0;
|
||||
BigDecimal selectedAmt = new BigDecimal(0.0);
|
||||
|
||||
int rows = miniTable.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
IDColumn id = (IDColumn)miniTable.getModel().getValueAt(i, idColIndex);
|
||||
if (id.isSelected())
|
||||
{
|
||||
BigDecimal amt = (BigDecimal)miniTable.getModel().getValueAt(i, amtColIndex);
|
||||
if (amt != null)
|
||||
selectedAmt = selectedAmt.add(amt);
|
||||
m_noSelected++;
|
||||
}
|
||||
}
|
||||
|
||||
// Information
|
||||
StringBuffer info = new StringBuffer();
|
||||
info.append(m_noSelected).append(" ").append(Msg.getMsg(Env.getCtx(), "Selected")).append(" / ").append(miniTable.getRowCount());
|
||||
|
||||
differenceField.setText(m_format.format(selectedAmt));
|
||||
dataStatus.setText(info.toString());
|
||||
//
|
||||
bGenerate.setEnabled(m_noSelected != 0 && Env.ZERO.compareTo(selectedAmt) == 0 && !isReconciled.isSelected());
|
||||
bReset.setEnabled(m_noSelected > 0 && isReconciled.isSelected());
|
||||
} // calculateSelection
|
||||
|
||||
/**
|
||||
* Generate Reconciliation record
|
||||
*/
|
||||
private void generateReconciliation()
|
||||
{
|
||||
log.info("");
|
||||
//
|
||||
miniTable.stopEditor(true);
|
||||
if (miniTable.getRowCount() == 0)
|
||||
return;
|
||||
miniTable.setRowSelectionInterval(0,0);
|
||||
calculateSelection();
|
||||
if (m_noSelected == 0)
|
||||
return;
|
||||
|
||||
|
||||
String format = "yyyy-MM-dd HH:mm:ss.SSS";
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
String time = sdf.format(cal.getTime());
|
||||
|
||||
String matchcode = "Manual: " + Env.getContext(Env.getCtx(), "#AD_User_Name") + " " + time;
|
||||
|
||||
for ( int r = 0; r < miniTable.getModel().getRowCount(); r++ )
|
||||
{
|
||||
if ( ((IDColumn) miniTable.getModel().getValueAt(r, idColIndex)).isSelected() )
|
||||
{
|
||||
int factId = ((IDColumn) miniTable.getModel().getValueAt(r, idColIndex )).getRecord_ID();
|
||||
|
||||
MFactReconciliation rec = new Query(Env.getCtx(), MFactReconciliation.Table_Name, "Fact_Acct_ID = ?", null)
|
||||
.setParameters(new Object[] {factId}).first();
|
||||
|
||||
if ( rec == null )
|
||||
{
|
||||
rec = new MFactReconciliation(Env.getCtx(), 0, null);
|
||||
rec.setFact_Acct_ID(factId);
|
||||
}
|
||||
|
||||
rec.setMatchCode(matchcode);
|
||||
rec.saveEx();
|
||||
|
||||
((DefaultTableModel) miniTable.getModel()).removeRow(r--);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock User Interface
|
||||
* Called from the Worker before processing
|
||||
* @param pi process info
|
||||
*/
|
||||
public void lockUI (ProcessInfo pi)
|
||||
{
|
||||
this.setEnabled(false);
|
||||
m_isLocked = true;
|
||||
} // lockUI
|
||||
|
||||
/**
|
||||
* Unlock User Interface.
|
||||
* Called from the Worker when processing is done
|
||||
* @param pi process info
|
||||
*/
|
||||
public void unlockUI (ProcessInfo pi)
|
||||
{
|
||||
this.setEnabled(true);
|
||||
m_isLocked = false;
|
||||
} // unlockUI
|
||||
|
||||
/**
|
||||
* Is the UI locked (Internal method)
|
||||
* @return true, if UI is locked
|
||||
*/
|
||||
public boolean isUILocked()
|
||||
{
|
||||
return m_isLocked;
|
||||
} // isLoacked
|
||||
|
||||
/**
|
||||
* Method to be executed async.
|
||||
* Called from the ASyncProcess worker
|
||||
* @param pi process info
|
||||
*/
|
||||
public void executeASync (ProcessInfo pi)
|
||||
{
|
||||
log.config("-");
|
||||
} // executeASync
|
||||
|
||||
} // VPaySelect
|
||||
}
|
||||
|
|
|
@ -0,0 +1,468 @@
|
|||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Checkbox;
|
||||
import org.adempiere.webui.component.Grid;
|
||||
import org.adempiere.webui.component.GridFactory;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.ListItem;
|
||||
import org.adempiere.webui.component.ListModelTable;
|
||||
import org.adempiere.webui.component.Listbox;
|
||||
import org.adempiere.webui.component.ListboxFactory;
|
||||
import org.adempiere.webui.component.Panel;
|
||||
import org.adempiere.webui.component.Row;
|
||||
import org.adempiere.webui.component.Rows;
|
||||
import org.adempiere.webui.component.Textbox;
|
||||
import org.adempiere.webui.component.WListbox;
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
import org.adempiere.webui.editor.WDateEditor;
|
||||
import org.adempiere.webui.editor.WSearchEditor;
|
||||
import org.adempiere.webui.editor.WTableDirEditor;
|
||||
import org.adempiere.webui.event.ValueChangeEvent;
|
||||
import org.adempiere.webui.event.ValueChangeListener;
|
||||
import org.adempiere.webui.event.WTableModelEvent;
|
||||
import org.adempiere.webui.event.WTableModelListener;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.panel.CustomForm;
|
||||
import org.adempiere.webui.panel.IFormController;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.compiere.apps.form.FactReconcile;
|
||||
import org.compiere.minigrid.IDColumn;
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zkex.zul.Borderlayout;
|
||||
import org.zkoss.zkex.zul.Center;
|
||||
import org.zkoss.zkex.zul.North;
|
||||
import org.zkoss.zkex.zul.South;
|
||||
|
||||
public class WFactReconcile extends FactReconcile
|
||||
implements IFormController, EventListener, WTableModelListener, ValueChangeListener{
|
||||
|
||||
private CustomForm form = new CustomForm();
|
||||
|
||||
/** Format */
|
||||
private DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||
/** Number of selected rows */
|
||||
private int m_noSelected = 0;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(WFactReconcile.class);
|
||||
|
||||
/**
|
||||
* Initialize Panel
|
||||
*/
|
||||
public WFactReconcile()
|
||||
{
|
||||
Env.setContext(Env.getCtx(), form.getWindowNo(), "IsSOTrx", "Y"); // defaults to no
|
||||
try
|
||||
{
|
||||
super.dynInit();
|
||||
dynInit();
|
||||
zkInit();
|
||||
//calculate();
|
||||
//southPanel.appendChild(new Separator());
|
||||
//southPanel.appendChild(statusBar);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // init
|
||||
|
||||
private Borderlayout mainLayout = new Borderlayout();
|
||||
private Panel parameterPanel = new Panel();
|
||||
private Label labelAcctSchema = new Label();
|
||||
private WTableDirEditor fieldAcctSchema = null;
|
||||
private Grid parameterLayout = GridFactory.newGridLayout();
|
||||
private Label labelOrg = new Label();
|
||||
private WTableDirEditor fieldOrg = null;
|
||||
private Label labelReconciled = new Label();
|
||||
private Checkbox isReconciled = new Checkbox();
|
||||
private Label labelAccount = new Label();
|
||||
private Listbox fieldAccount = null;
|
||||
private Label labelBPartner = new Label();
|
||||
private WSearchEditor fieldBPartner = null;
|
||||
|
||||
// data panel
|
||||
private Label dataStatus = new Label();
|
||||
private WListbox miniTable = ListboxFactory.newDataTable();
|
||||
|
||||
// command panel
|
||||
private Panel commandPanel = new Panel();
|
||||
ConfirmPanel cp = new ConfirmPanel();
|
||||
private Button bCancel = cp.createButton(ConfirmPanel.A_CANCEL);
|
||||
private Button bGenerate = cp.createButton(ConfirmPanel.A_PROCESS);
|
||||
private Button bReset = cp.createButton(ConfirmPanel.A_RESET);
|
||||
private Button bZoom = cp.createButton(ConfirmPanel.A_ZOOM);
|
||||
private Borderlayout commandLayout = new Borderlayout();
|
||||
private Button bRefresh = cp.createButton(ConfirmPanel.A_REFRESH);
|
||||
private Label labelDateAcct = new Label();
|
||||
private WDateEditor fieldDateAcct = new WDateEditor();
|
||||
private Label labelDateAcct2 = new Label();
|
||||
private WDateEditor fieldDateAcct2 = new WDateEditor();
|
||||
|
||||
private Label labelProduct = new Label();
|
||||
private WSearchEditor fieldProduct = null;
|
||||
private boolean loading = false;
|
||||
private Label differenceLabel = new Label();
|
||||
private Textbox differenceField = new Textbox();
|
||||
|
||||
/**
|
||||
* Static Init
|
||||
* @throws Exception
|
||||
*/
|
||||
private void zkInit() throws Exception
|
||||
{
|
||||
//
|
||||
form.appendChild(mainLayout);
|
||||
parameterPanel.appendChild(parameterLayout);
|
||||
bRefresh.addActionListener(this);
|
||||
bReset.addActionListener(this);
|
||||
bZoom.addActionListener(this);
|
||||
bGenerate.setEnabled(false);
|
||||
bReset.setEnabled(false);
|
||||
//bRefresh.setText(Msg.getMsg(Env.getCtx(), "Query"));
|
||||
bGenerate.setLabel(Msg.getMsg(Env.getCtx(),"Process"));
|
||||
bReset.setLabel(Msg.getMsg(Env.getCtx(),"Reset"));
|
||||
bZoom.setLabel(Msg.translate(Env.getCtx(), "Fact_Acct_ID"));
|
||||
|
||||
//
|
||||
labelAcctSchema.setText(Msg.translate(Env.getCtx(), "C_AcctSchema_ID"));
|
||||
labelAccount.setText(Msg.translate(Env.getCtx(), "Account_ID"));
|
||||
labelBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
|
||||
labelDateAcct.setText(Msg.translate(Env.getCtx(), "DateAcct"));
|
||||
labelDateAcct2.setText("-");
|
||||
labelProduct.setText(Msg.translate(Env.getCtx(), "M_Product_ID"));
|
||||
//
|
||||
labelOrg.setText(Msg.translate(Env.getCtx(), "AD_Org_ID"));
|
||||
labelReconciled.setText(" ");
|
||||
isReconciled.setText(Msg.translate(Env.getCtx(), "IsReconciled"));
|
||||
dataStatus.setText(" ");
|
||||
|
||||
|
||||
differenceLabel.setText(Msg.getMsg(Env.getCtx(), "Difference"));
|
||||
//differenceField.setBackground(AdempierePLAF.getFieldBackground_Inactive());
|
||||
//differenceField.setEditable(false);
|
||||
differenceField.setText("0");
|
||||
//differenceField.setColumns(8);
|
||||
//differenceField.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
//
|
||||
bGenerate.addActionListener(this);
|
||||
bCancel.addActionListener(this);
|
||||
|
||||
// Parameter Panel
|
||||
North north = new North();
|
||||
north.setStyle("border: none");
|
||||
mainLayout.appendChild(north);
|
||||
north.appendChild(parameterPanel);
|
||||
|
||||
Rows rows = null;
|
||||
Row row = null;
|
||||
parameterLayout.setWidth("800px");
|
||||
rows = parameterLayout.newRows();
|
||||
row = rows.newRow();
|
||||
row.appendChild(labelAcctSchema.rightAlign());
|
||||
row.appendChild(fieldAcctSchema.getComponent());
|
||||
row.appendChild(labelOrg.rightAlign());
|
||||
row.appendChild(fieldOrg.getComponent());
|
||||
row = rows.newRow();
|
||||
row.appendChild(labelAccount.rightAlign());
|
||||
row.appendChild(fieldAccount);
|
||||
row.appendChild(labelReconciled);
|
||||
row.appendChild(isReconciled);
|
||||
row = rows.newRow();
|
||||
row.appendChild(labelBPartner.rightAlign());
|
||||
row.appendChild(fieldBPartner.getComponent());
|
||||
row.appendChild(labelProduct.rightAlign());
|
||||
row.appendChild(fieldProduct.getComponent());
|
||||
row = rows.newRow();
|
||||
row.appendChild(labelDateAcct.rightAlign());
|
||||
row.appendChild(fieldDateAcct.getComponent());
|
||||
row.appendChild(labelDateAcct2.rightAlign());
|
||||
row.appendChild(fieldDateAcct2.getComponent());
|
||||
row = rows.newRow();
|
||||
row.appendChild(bRefresh);
|
||||
|
||||
// Data Panel
|
||||
Center center = new Center();
|
||||
mainLayout.appendChild(center);
|
||||
center.appendChild(miniTable);
|
||||
miniTable.setWidth("99%");
|
||||
miniTable.setHeight("99%");
|
||||
center.setStyle("border: none");
|
||||
|
||||
// Command Panel
|
||||
South south = new South();
|
||||
south.setStyle("border: none");
|
||||
mainLayout.appendChild(south);
|
||||
south.appendChild(commandPanel);
|
||||
commandPanel.appendChild(commandLayout);
|
||||
commandPanel.appendChild(bZoom);
|
||||
commandPanel.appendChild(differenceLabel);
|
||||
commandPanel.appendChild(differenceField);
|
||||
commandPanel.appendChild(bGenerate);
|
||||
commandPanel.appendChild(bReset);
|
||||
commandPanel.appendChild(bCancel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic Init (prepare dynamic fields)
|
||||
* @throws Exception if Lookups cannot be initialized
|
||||
*/
|
||||
public void dynInit() throws Exception
|
||||
{
|
||||
|
||||
m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
|
||||
// AcctSchema
|
||||
int AD_Column_ID = FactReconcile.col_C_AcctSchema_ID; // Fact_Acct.C_AcctSchema_ID
|
||||
MLookup lookupAS = MLookupFactory.get (Env.getCtx(), form.getWindowNo(), 0, AD_Column_ID, DisplayType.TableDir);
|
||||
fieldAcctSchema = new WTableDirEditor("C_AcctSchema_ID", true, false, true, lookupAS);
|
||||
fieldAcctSchema.setValue(MClient.get(Env.getCtx()).getAcctSchema().getC_AcctSchema_ID());
|
||||
fieldAcctSchema.addValueChangeListener(this);
|
||||
|
||||
// Organization
|
||||
AD_Column_ID = FactReconcile.col_AD_Org_ID; //C_Period.AD_Org_ID (needed to allow org 0)
|
||||
MLookup lookupOrg = MLookupFactory.get(Env.getCtx(), form.getWindowNo(), 0, AD_Column_ID, DisplayType.TableDir);
|
||||
fieldOrg = new WTableDirEditor("AD_Org_ID", true, false, true, lookupOrg);
|
||||
if (lookupOrg.containsKey(0))
|
||||
fieldOrg.setValue(0);
|
||||
else
|
||||
fieldOrg.setValue(Env.getAD_Org_ID(Env.getCtx()));
|
||||
|
||||
// BPartner
|
||||
AD_Column_ID = FactReconcile.col_C_BPartner_ID; // C_Invoice.C_BPartner_ID
|
||||
MLookup lookupBP = MLookupFactory.get (Env.getCtx(), form.getWindowNo(), 0, AD_Column_ID, DisplayType.Search);
|
||||
fieldBPartner = new WSearchEditor("C_BPartner_ID", false, false, true, lookupBP);
|
||||
|
||||
// Product
|
||||
AD_Column_ID = FactReconcile.col_M_Product_ID; // Fact_Acct.M_Product_ID
|
||||
MLookup lookupProduct = MLookupFactory.get (Env.getCtx(), form.getWindowNo(), 0, AD_Column_ID, DisplayType.Search);
|
||||
fieldProduct = new WSearchEditor("M_Product_ID", false, false, true, lookupProduct);
|
||||
|
||||
// Account
|
||||
Vector<KeyNamePair> vector = getAccount();
|
||||
KeyNamePair[] listAccount = new KeyNamePair[vector.size()];
|
||||
for(int i=0;i<vector.size();i++)
|
||||
listAccount[i] = vector.get(i);
|
||||
fieldAccount = new Listbox(listAccount);
|
||||
fieldAccount.setMold("select");
|
||||
fieldAccount.setSelectedIndex(0);
|
||||
|
||||
}
|
||||
|
||||
public void loadData(){
|
||||
ListItem listAccount = fieldAccount.getSelectedItem();
|
||||
int Account_ID = 0;
|
||||
if(listAccount!=null){
|
||||
Account_ID = (Integer)listAccount.getValue();
|
||||
}
|
||||
|
||||
if (Account_ID != 0)
|
||||
m_Account_ID = Account_ID;
|
||||
|
||||
if(fieldOrg.getValue()!=null)
|
||||
m_AD_Org_ID = (Integer)fieldOrg.getValue();
|
||||
|
||||
if(fieldAcctSchema.getValue()!=null)
|
||||
m_C_AcctSchema_ID = (Integer)fieldAcctSchema.getValue();
|
||||
|
||||
m_isReconciled = isReconciled.isChecked();
|
||||
|
||||
if(fieldBPartner.getValue()!=null)
|
||||
m_C_BPartner_ID = (Integer)fieldBPartner.getValue();
|
||||
|
||||
if((Integer)fieldProduct.getValue()!=null)
|
||||
m_M_Product_ID = (Integer)fieldProduct.getValue();
|
||||
|
||||
if(fieldDateAcct.getValue()!=null)
|
||||
m_DateAcct = (Timestamp)fieldDateAcct.getValue();
|
||||
|
||||
if(fieldDateAcct2.getValue()!=null)
|
||||
m_DateAcct2 = (Timestamp)fieldDateAcct2.getValue();
|
||||
|
||||
// Set Model
|
||||
Vector<Vector<Object>> data = getData();
|
||||
Vector<String> columnNames = getColumnNames();
|
||||
|
||||
// Remove Previous Listeners
|
||||
miniTable.getModel().removeTableModelListener(this);
|
||||
|
||||
ListModelTable modelI = new ListModelTable(data);
|
||||
modelI.addTableModelListener(this);
|
||||
miniTable.setData(modelI, columnNames);
|
||||
setColumnClass(miniTable);
|
||||
miniTable.setColorColumn(amtColIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate selected rows.
|
||||
* - add up selected rows
|
||||
*/
|
||||
public void calculateSelection()
|
||||
{
|
||||
m_noSelected = 0;
|
||||
BigDecimal selectedAmt = new BigDecimal(0.0);
|
||||
|
||||
int rows = miniTable.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
boolean isSelected = (Boolean)miniTable.getModel().getValueAt(i, selectedColIndex);
|
||||
if (isSelected)
|
||||
{
|
||||
BigDecimal amt = (BigDecimal)miniTable.getModel().getValueAt(i, amtColIndex);
|
||||
if (amt != null)
|
||||
selectedAmt = selectedAmt.add(amt);
|
||||
m_noSelected++;
|
||||
}
|
||||
}
|
||||
|
||||
// Information
|
||||
StringBuffer info = new StringBuffer();
|
||||
info.append(m_noSelected).append(" ").append(Msg.getMsg(Env.getCtx(), "Selected")).append(" / ").append(miniTable.getRowCount());
|
||||
|
||||
differenceField.setText(m_format.format(selectedAmt));
|
||||
dataStatus.setText(info.toString());
|
||||
//
|
||||
bGenerate.setEnabled(m_noSelected != 0 && Env.ZERO.compareTo(selectedAmt) == 0 && !isReconciled.isSelected());
|
||||
bReset.setEnabled(m_noSelected > 0 && isReconciled.isSelected());
|
||||
} // calculateSelection
|
||||
|
||||
@Override
|
||||
public void valueChange(ValueChangeEvent evt) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tableChanged(WTableModelEvent event) {
|
||||
if (! loading )
|
||||
calculateSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
log.config("");
|
||||
if (event.getTarget().equals(bGenerate))
|
||||
generateReconciliation();
|
||||
|
||||
else if (event.getTarget().equals(bReset))
|
||||
resetReconciliation();
|
||||
|
||||
else if (event.getTarget().equals(bZoom))
|
||||
zoom();
|
||||
|
||||
else if (event.getTarget().equals(bCancel))
|
||||
SessionManager.getAppDesktop().closeActiveWindow();
|
||||
|
||||
else if (event.getTarget().equals(bRefresh))
|
||||
loadData();
|
||||
|
||||
}
|
||||
|
||||
private void generateReconciliation() {
|
||||
log.info("");
|
||||
//
|
||||
//miniTable.stopEditor(true);
|
||||
if (miniTable.getRowCount() == 0)
|
||||
return;
|
||||
//miniTable.setRowSelectionInterval(0,0);
|
||||
calculateSelection();
|
||||
if (m_noSelected == 0)
|
||||
return;
|
||||
|
||||
String format = "yyyy-MM-dd HH:mm:ss.SSS";
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
String time = sdf.format(cal.getTime());
|
||||
|
||||
for ( int r = 0; r < miniTable.getModel().getRowCount(); r++ )
|
||||
{
|
||||
boolean isSelected = (Boolean)miniTable.getModel().getValueAt(r, selectedColIndex);
|
||||
|
||||
if (isSelected)
|
||||
{
|
||||
KeyNamePair pp = (KeyNamePair)miniTable.getModel().getValueAt(r, idColIndex);
|
||||
|
||||
int factId = pp.getKey();
|
||||
|
||||
boolean result = generate(factId, time);
|
||||
if(!result)
|
||||
continue;
|
||||
|
||||
((ListModelTable) miniTable.getModel()).remove(r--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom to target
|
||||
* @param AD_Window_ID window id
|
||||
* @param zoomQuery zoom query
|
||||
*/
|
||||
protected void zoom ()
|
||||
{
|
||||
log.info("");
|
||||
|
||||
int selected = miniTable.getSelectedRow();
|
||||
|
||||
if ( selected == -1 )
|
||||
return;
|
||||
|
||||
KeyNamePair pp = (KeyNamePair)miniTable.getModel().getValueAt(selected, idColIndex);
|
||||
|
||||
int factId = pp.getKey();
|
||||
|
||||
AEnv.zoom(270, factId);
|
||||
} // zoom
|
||||
|
||||
private void resetReconciliation() {
|
||||
log.info("");
|
||||
if (miniTable.getRowCount() == 0)
|
||||
return;
|
||||
calculateSelection();
|
||||
if (m_noSelected == 0)
|
||||
return;
|
||||
|
||||
for ( int r = 0; r < miniTable.getModel().getRowCount(); r++ )
|
||||
{
|
||||
boolean isSelected = (Boolean)miniTable.getModel().getValueAt(r, selectedColIndex);
|
||||
|
||||
if (isSelected)
|
||||
{
|
||||
KeyNamePair pp = (KeyNamePair)miniTable.getModel().getValueAt(r, idColIndex);
|
||||
|
||||
int factId = pp.getKey();
|
||||
|
||||
boolean result = reset(factId);
|
||||
if(!result)
|
||||
continue;
|
||||
|
||||
((ListModelTable) miniTable.getModel()).remove(r--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ADForm getForm() {
|
||||
return form;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,279 @@
|
|||
package org.compiere.apps.form;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import org.compiere.minigrid.IMiniTable;
|
||||
import org.compiere.model.MFactReconciliation;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
public class FactReconcile {
|
||||
|
||||
/** Logger */
|
||||
public static CLogger log = CLogger.getCLogger(MFactReconciliation.class);
|
||||
|
||||
public int m_AD_Client_ID = 0;
|
||||
public int m_AD_Org_ID = 0;
|
||||
public int m_Account_ID = 0;
|
||||
public int m_C_AcctSchema_ID = 0;
|
||||
public boolean m_isReconciled = false;
|
||||
public int m_C_BPartner_ID = 0;
|
||||
public int m_M_Product_ID = 0;
|
||||
public Timestamp m_DateAcct = null;
|
||||
public Timestamp m_DateAcct2 = null;
|
||||
|
||||
public int selectedColIndex = 2;
|
||||
public int idColIndex = 8;
|
||||
public int amtColIndex = 0;
|
||||
|
||||
static protected int col_C_AcctSchema_ID = 2513; // Fact_Acct.C_AcctSchema_ID
|
||||
static protected int col_AD_Org_ID = 839; // C_Period.AD_Org_ID (needed to allow org 0)
|
||||
static protected int col_C_BPartner_ID = 3499; // C_Invoice.C_BPartner_ID
|
||||
static protected int col_M_Product_ID = 2527; // Fact_Acct.M_Product_ID
|
||||
|
||||
|
||||
public void dynInit() throws Exception
|
||||
{
|
||||
m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
}
|
||||
|
||||
public Vector<String> getColumnNames()
|
||||
{
|
||||
// Header Info
|
||||
Vector<String> columnNames = new Vector<String>();
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "Amt"));
|
||||
//columnNames.add(Msg.translate(Env.getCtx(), "AmtAcct"));
|
||||
columnNames.add("DR/CR");
|
||||
columnNames.add("Fact Acct");
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "DateAcct"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "GL_Category_ID"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "M_Product_ID"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "Qty"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "Description"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "MatchCode"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "DateTrx"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "AD_Org_ID"));
|
||||
|
||||
return columnNames;
|
||||
}
|
||||
|
||||
public Vector<Vector<Object>> getData() {
|
||||
|
||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||
|
||||
StringBuffer sql = new StringBuffer("SELECT abs(fa.amtacctdr-fa.amtacctcr), (fa.amtacctdr-fa.amtacctcr)," // 1-2
|
||||
+ " (CASE WHEN (fa.amtacctdr-fa.amtacctcr) < 0 THEN 'CR' ELSE 'DR' END), fa.Fact_Acct_ID, bp.name, DateAcct,"
|
||||
+ " glc.name, p.name, Qty, fa.Description, r.MatchCode, fa.DateTrx, o.value"
|
||||
+ " FROM Fact_Acct fa"
|
||||
+ " LEFT OUTER JOIN Fact_Reconciliation r ON (fa.Fact_Acct_ID=r.Fact_Acct_ID)"
|
||||
+ " LEFT OUTER JOIN C_BPartner bp ON (fa.C_BPartner_ID=bp.C_BPartner_ID)"
|
||||
+ " LEFT OUTER JOIN AD_Org o ON (o.AD_Org_ID=fa.AD_Org_ID)"
|
||||
+ " LEFT OUTER JOIN M_Product p ON (p.M_Product_ID=fa.M_Product_ID)"
|
||||
+ " LEFT OUTER JOIN GL_Category glc ON (fa.GL_Category_ID=glc.GL_Category_ID)"
|
||||
+ " WHERE fa.AD_Client_ID=?");
|
||||
|
||||
// role security
|
||||
sql = new StringBuffer( MRole.getDefault(Env.getCtx(), false).addAccessSQL( sql.toString(), "fa", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO ) );
|
||||
|
||||
// Parameter
|
||||
if(m_AD_Org_ID>0)
|
||||
sql.append(" AND fa.AD_Org_ID=?");
|
||||
|
||||
if(m_Account_ID>0)
|
||||
sql.append(" AND fa.Account_ID=?");
|
||||
|
||||
if(m_C_AcctSchema_ID>0)
|
||||
sql.append(" AND fa.C_AcctSchema_ID=?");
|
||||
|
||||
sql.append(" AND ((SELECT SUM(f.amtacctdr-f.amtacctcr) FROM Fact_Reconciliation rec "
|
||||
+ " INNER JOIN Fact_Acct f ON (f.Fact_Acct_ID = rec.Fact_Acct_ID) "
|
||||
+ " WHERE r.MatchCode=rec.MatchCode) ");
|
||||
if(m_isReconciled)
|
||||
sql.append(" =0)");
|
||||
else
|
||||
sql.append(" <> 0 OR r.MatchCode IS NULL)");
|
||||
|
||||
if(m_C_BPartner_ID>0)
|
||||
sql.append(" AND fa.C_BPartner_ID=?");
|
||||
|
||||
if(m_M_Product_ID>0)
|
||||
sql.append(" AND fa.M_Product_ID=?");
|
||||
|
||||
if(m_DateAcct!=null)
|
||||
sql.append(" AND fa.DateAcct>=?");
|
||||
|
||||
if(m_DateAcct2!=null)
|
||||
sql.append(" AND fa.DateAcct<=?");
|
||||
|
||||
sql.append(" ORDER BY 1,5,3,6");
|
||||
|
||||
log.fine("SQL=" + sql.toString());
|
||||
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
int i = 1;
|
||||
pstmt.setInt(i++, m_AD_Client_ID);
|
||||
|
||||
if(m_AD_Org_ID>0)
|
||||
pstmt.setInt(i++, m_AD_Org_ID);
|
||||
|
||||
if(m_Account_ID>0)
|
||||
pstmt.setInt(i++, m_Account_ID);
|
||||
|
||||
if(m_C_AcctSchema_ID>0)
|
||||
pstmt.setInt(i++, m_C_AcctSchema_ID);
|
||||
|
||||
if(m_C_BPartner_ID>0)
|
||||
pstmt.setInt(i++, m_C_BPartner_ID);
|
||||
|
||||
if(m_M_Product_ID>0)
|
||||
pstmt.setInt(i++, m_M_Product_ID);
|
||||
|
||||
if(m_DateAcct!=null)
|
||||
pstmt.setTimestamp(i++, m_DateAcct);
|
||||
|
||||
if(m_DateAcct2!=null)
|
||||
pstmt.setTimestamp(i++, m_DateAcct2);
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
Vector<Object> line = new Vector<Object>();
|
||||
//line.add(rs.getBigDecimal(1)); // 1-Amt
|
||||
line.add(rs.getBigDecimal(2)); // 2-AmtAcct
|
||||
line.add(rs.getString(3)); // 3-DR/CR
|
||||
line.add(new Boolean(false)); // 4-Fact_Acct_ID
|
||||
line.add(rs.getString(5)); // 5-BP
|
||||
line.add(rs.getTimestamp(6)); // 6-DateAcct
|
||||
line.add(rs.getString(7)); // 7-GL Category
|
||||
line.add(rs.getString(8)); // 8-Product
|
||||
line.add(rs.getBigDecimal(9)); // 9-Qty
|
||||
KeyNamePair pp = new KeyNamePair(rs.getInt(4), rs.getString(10)); // 10 Fact_Acct_ID - description
|
||||
line.add(pp);
|
||||
line.add(rs.getString(11)); // 11-MatchCode
|
||||
line.add(rs.getTimestamp(12)); // 12-DateTrx
|
||||
line.add(rs.getString(13)); // 13-Org
|
||||
//
|
||||
data.add(line);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setColumnClass(IMiniTable miniTable)
|
||||
{
|
||||
int i = 0;
|
||||
//miniTable.setColumnClass(i++, BigDecimal.class, true); // 1-Amt
|
||||
miniTable.setColumnClass(i++, BigDecimal.class, true); // 2-AmtAcct
|
||||
miniTable.setColumnClass(i++, String.class, true); // 3-DR/CR
|
||||
miniTable.setColumnClass(i++, Boolean.class, false); // 4-Selected
|
||||
miniTable.setColumnClass(i++, String.class, true); // 5-BP
|
||||
miniTable.setColumnClass(i++, Timestamp.class, true); // 6-DateAcct
|
||||
miniTable.setColumnClass(i++, String.class, true); // 7-GL Category
|
||||
miniTable.setColumnClass(i++, String.class, true); // 8-Product
|
||||
miniTable.setColumnClass(i++, BigDecimal.class, true); // 9-Qty
|
||||
miniTable.setColumnClass(i++, String.class, true); // 10-Description
|
||||
miniTable.setColumnClass(i++, String.class, true); // 11-MatchCode
|
||||
miniTable.setColumnClass(i++, Timestamp.class, true); // 12-DateTrx
|
||||
miniTable.setColumnClass(i++, String.class, true); // 13-Org
|
||||
// Table UI
|
||||
miniTable.autoSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Reconciliation record
|
||||
* @return
|
||||
*/
|
||||
public boolean generate(int factId, String time)
|
||||
{
|
||||
log.info("");
|
||||
|
||||
String matchcode = "Manual: " + Env.getContext(Env.getCtx(), "#AD_User_Name") + " " + time;
|
||||
|
||||
MFactReconciliation rec = new Query(Env.getCtx(), MFactReconciliation.Table_Name, "Fact_Acct_ID = ?", null)
|
||||
.setParameters(new Object[] {factId}).first();
|
||||
|
||||
if ( rec == null )
|
||||
{
|
||||
rec = new MFactReconciliation(Env.getCtx(), 0, null);
|
||||
rec.setFact_Acct_ID(factId);
|
||||
}
|
||||
|
||||
rec.setMatchCode(matchcode);
|
||||
return rec.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Reconciliation record
|
||||
* @return
|
||||
*/
|
||||
public boolean reset(int factId)
|
||||
{
|
||||
log.info("");
|
||||
|
||||
MFactReconciliation rec = new Query(Env.getCtx(), MFactReconciliation.Table_Name, "Fact_Acct_ID = ?", null)
|
||||
.setParameters(new Object[] {factId}).first();
|
||||
|
||||
if ( rec == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
rec.setMatchCode(null);
|
||||
return rec.save();
|
||||
}
|
||||
|
||||
protected Vector<KeyNamePair> getAccount(){
|
||||
Vector<KeyNamePair> vector = new Vector<KeyNamePair>();
|
||||
String sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT ev.C_ElementValue_ID, ev.Value || ' ' || ev.Name FROM C_ElementValue ev", "ev",
|
||||
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO)
|
||||
+ "AND ev.IsActive='Y' AND ev.IsSummary='N' "
|
||||
+ "AND ev.C_Element_ID IN (SELECT C_Element_ID FROM C_AcctSchema_Element ase "
|
||||
+ "WHERE ase.ElementType='AC' AND ase.AD_Client_ID=" + m_AD_Client_ID + ") "
|
||||
+ "ORDER BY 2";
|
||||
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
vector.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue