Refactor custom form - ID: 2787613
This commit is contained in:
parent
757d689a32
commit
4629e3dd26
|
@ -0,0 +1,287 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2009 Low Heng Sin *
|
||||
* Copyright (C) 2009 Idalica Corporation *
|
||||
* 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.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.X_M_Cost;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
public class Merge
|
||||
{
|
||||
private static final long serialVersionUID = 149783846292562740L;
|
||||
/** Window No */
|
||||
public int m_WindowNo = 0;
|
||||
/** Total Count */
|
||||
public int m_totalCount = 0;
|
||||
/** Error Log */
|
||||
public StringBuffer m_errorLog = new StringBuffer();
|
||||
/** Connection */
|
||||
//private Connection m_con = null;
|
||||
private Trx m_trx = null;
|
||||
/** Logger */
|
||||
public static CLogger log = CLogger.getCLogger(Merge.class);
|
||||
|
||||
public static String AD_ORG_ID = "AD_Org_ID";
|
||||
public static String C_BPARTNER_ID = "C_BPartner_ID";
|
||||
public static String AD_USER_ID = "AD_User_ID";
|
||||
public static String M_PRODUCT_ID = "M_Product_ID";
|
||||
|
||||
/** Tables to delete (not update) for AD_Org */
|
||||
public static String[] s_delete_Org = new String[]
|
||||
{"AD_OrgInfo", "AD_Role_OrgAccess"};
|
||||
/** Tables to delete (not update) for AD_User */
|
||||
public static String[] s_delete_User = new String[]
|
||||
{"AD_User_Roles"};
|
||||
/** Tables to delete (not update) for C_BPartner */
|
||||
public static String[] s_delete_BPartner = new String[]
|
||||
{"C_BP_Employee_Acct", "C_BP_Vendor_Acct", "C_BP_Customer_Acct",
|
||||
"T_Aging"};
|
||||
/** Tables to delete (not update) for M_Product */
|
||||
public static String[] s_delete_Product = new String[]
|
||||
{"M_Product_PO", "M_Replenish", "T_Replenish",
|
||||
"M_ProductPrice", "M_Product_Costing",
|
||||
"M_Cost", // teo_sarca [ 1704554 ]
|
||||
"M_Product_Trl", "M_Product_Acct"}; // M_Storage
|
||||
|
||||
public String[] m_columnName = null;
|
||||
public String[] m_deleteTables = null;
|
||||
|
||||
public void updateDeleteTable(String columnName)
|
||||
{
|
||||
// ** Update **
|
||||
if (columnName.equals(AD_ORG_ID))
|
||||
m_deleteTables = s_delete_Org;
|
||||
else if (columnName.equals(AD_USER_ID))
|
||||
m_deleteTables = s_delete_User;
|
||||
else if (columnName.equals(C_BPARTNER_ID))
|
||||
m_deleteTables = s_delete_BPartner;
|
||||
else if (columnName.equals(M_PRODUCT_ID))
|
||||
m_deleteTables = s_delete_Product;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Merge.
|
||||
* @param ColumnName column
|
||||
* @param from_ID from
|
||||
* @param to_ID to
|
||||
* @return true if merged
|
||||
*/
|
||||
public boolean merge (String ColumnName, int from_ID, int to_ID)
|
||||
{
|
||||
String TableName = ColumnName.substring(0, ColumnName.length()-3);
|
||||
log.config(ColumnName
|
||||
+ " - From=" + from_ID + ",To=" + to_ID);
|
||||
|
||||
boolean success = true;
|
||||
m_totalCount = 0;
|
||||
m_errorLog = new StringBuffer();
|
||||
String sql = "SELECT t.TableName, c.ColumnName "
|
||||
+ "FROM AD_Table t"
|
||||
+ " INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID) "
|
||||
+ "WHERE t.IsView='N'"
|
||||
+ " AND t.TableName NOT IN ('C_TaxDeclarationAcct')"
|
||||
+ " AND ("
|
||||
+ "(c.ColumnName=? AND c.IsKey='N' AND c.ColumnSQL IS NULL)" // #1 - direct
|
||||
+ " OR "
|
||||
+ "c.AD_Reference_Value_ID IN " // Table Reference
|
||||
+ "(SELECT rt.AD_Reference_ID FROM AD_Ref_Table rt"
|
||||
+ " INNER JOIN AD_Column cc ON (rt.AD_Table_ID=cc.AD_Table_ID AND rt.AD_Key=cc.AD_Column_ID) "
|
||||
+ "WHERE cc.IsKey='Y' AND cc.ColumnName=?)" // #2
|
||||
+ ") "
|
||||
+ "ORDER BY t.LoadSeq DESC";
|
||||
PreparedStatement pstmt = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
m_trx = Trx.get(Trx.createTrxName("merge"), true);
|
||||
//
|
||||
pstmt = DB.prepareStatement(sql, Trx.createTrxName());
|
||||
pstmt.setString(1, ColumnName);
|
||||
pstmt.setString(2, ColumnName);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
String tName = rs.getString(1);
|
||||
String cName = rs.getString(2);
|
||||
if (!TableName.equals(tName)) // to be sure - sql should prevent it
|
||||
{
|
||||
int count = mergeTable (tName, cName, from_ID, to_ID);
|
||||
if (count < 0)
|
||||
success = false;
|
||||
else
|
||||
m_totalCount += count;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
//
|
||||
log.config("Success=" + success
|
||||
+ " - " + ColumnName + " - From=" + from_ID + ",To=" + to_ID);
|
||||
if (success)
|
||||
{
|
||||
sql = "DELETE " + TableName + " WHERE " + ColumnName + "=" + from_ID;
|
||||
|
||||
|
||||
|
||||
|
||||
if ( DB.executeUpdate(sql, m_trx.getTrxName()) < 0 )
|
||||
{
|
||||
m_errorLog.append(Env.NL).append("DELETE ").append(TableName)
|
||||
.append(" - ");
|
||||
success = false;
|
||||
log.config(m_errorLog.toString());
|
||||
m_trx.rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
if (success)
|
||||
m_trx.commit();
|
||||
else
|
||||
m_trx.rollback();
|
||||
|
||||
m_trx.close();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, ColumnName, ex);
|
||||
}
|
||||
// Cleanup
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
pstmt = null;
|
||||
return success;
|
||||
} // merge
|
||||
|
||||
|
||||
/**
|
||||
* Merge Table
|
||||
* @param TableName table
|
||||
* @param ColumnName column
|
||||
* @param from_ID from
|
||||
* @param to_ID to
|
||||
* @return -1 for error or number of changes
|
||||
*/
|
||||
public int mergeTable (String TableName, String ColumnName, int from_ID, int to_ID)
|
||||
{
|
||||
log.fine(TableName + "." + ColumnName + " - From=" + from_ID + ",To=" + to_ID);
|
||||
String sql = "UPDATE " + TableName
|
||||
+ " SET " + ColumnName + "=" + to_ID
|
||||
+ " WHERE " + ColumnName + "=" + from_ID;
|
||||
boolean delete = false;
|
||||
for (int i = 0; i < m_deleteTables.length; i++)
|
||||
{
|
||||
if (m_deleteTables[i].equals(TableName))
|
||||
{
|
||||
delete = true;
|
||||
sql = "DELETE " + TableName + " WHERE " + ColumnName + "=" + from_ID;
|
||||
}
|
||||
}
|
||||
// Delete newly created MCost records - teo_sarca [ 1704554 ]
|
||||
if (delete && X_M_Cost.Table_Name.equals(TableName) && M_PRODUCT_ID.equals(ColumnName))
|
||||
{
|
||||
sql += " AND " + X_M_Cost.COLUMNNAME_CurrentCostPrice + "=0"
|
||||
+ " AND " + X_M_Cost.COLUMNNAME_CurrentQty + "=0"
|
||||
+ " AND " + X_M_Cost.COLUMNNAME_CumulatedAmt + "=0"
|
||||
+ " AND " + X_M_Cost.COLUMNNAME_CumulatedQty + "=0";
|
||||
}
|
||||
|
||||
int count = DB.executeUpdate(sql, m_trx.getTrxName());
|
||||
|
||||
|
||||
if ( count < 0 )
|
||||
{
|
||||
|
||||
count = -1;
|
||||
m_errorLog.append(Env.NL)
|
||||
.append(delete ? "DELETE " : "UPDATE ")
|
||||
.append(TableName).append(" - ")
|
||||
.append(" - ").append(sql);
|
||||
log.config(m_errorLog.toString());
|
||||
m_trx.rollback();
|
||||
|
||||
}
|
||||
log.fine(count
|
||||
+ (delete ? " -Delete- " : " -Update- ") + TableName);
|
||||
|
||||
|
||||
return count;
|
||||
} // mergeTable
|
||||
|
||||
/**
|
||||
* Post Merge
|
||||
* @param ColumnName column name
|
||||
* @param to_ID ID
|
||||
*/
|
||||
public void postMerge (String ColumnName, int to_ID)
|
||||
{
|
||||
if (ColumnName.equals(AD_ORG_ID))
|
||||
{
|
||||
|
||||
}
|
||||
else if (ColumnName.equals(AD_USER_ID))
|
||||
{
|
||||
|
||||
}
|
||||
else if (ColumnName.equals(C_BPARTNER_ID))
|
||||
{
|
||||
MBPartner bp = new MBPartner (Env.getCtx(), to_ID, null);
|
||||
if (bp.get_ID() != 0)
|
||||
{
|
||||
MPayment[] payments = MPayment.getOfBPartner(Env.getCtx(), bp.getC_BPartner_ID(), null);
|
||||
for (int i = 0; i < payments.length; i++)
|
||||
{
|
||||
MPayment payment = payments[i];
|
||||
if (payment.testAllocation())
|
||||
payment.save();
|
||||
}
|
||||
MInvoice[] invoices = MInvoice.getOfBPartner(Env.getCtx(), bp.getC_BPartner_ID(), null);
|
||||
for (int i = 0; i < invoices.length; i++)
|
||||
{
|
||||
MInvoice invoice = invoices[i];
|
||||
if (invoice.testAllocation())
|
||||
invoice.save();
|
||||
}
|
||||
bp.setTotalOpenBalance();
|
||||
bp.setActualLifeTimeValue();
|
||||
bp.save();
|
||||
}
|
||||
}
|
||||
else if (ColumnName.equals(M_PRODUCT_ID))
|
||||
{
|
||||
|
||||
}
|
||||
} // postMerge
|
||||
}
|
|
@ -0,0 +1,228 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2009 Low Heng Sin *
|
||||
* Copyright (C) 2009 Idalica Corporation *
|
||||
* 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.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MLookupInfo;
|
||||
import org.compiere.model.MPaySelectionCheck;
|
||||
import org.compiere.model.MPaymentBatch;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
|
||||
public class PayPrint {
|
||||
|
||||
/** Window No */
|
||||
public int m_WindowNo = 0;
|
||||
/** Used Bank Account */
|
||||
public int m_C_BankAccount_ID = -1;
|
||||
|
||||
/** Payment Information */
|
||||
public MPaySelectionCheck[] m_checks = null;
|
||||
/** Payment Batch */
|
||||
public MPaymentBatch m_batch = null;
|
||||
/** Logger */
|
||||
public static CLogger log = CLogger.getCLogger(PayPrint.class);
|
||||
|
||||
public ArrayList<KeyNamePair> getPaySelectionData()
|
||||
{
|
||||
ArrayList<KeyNamePair> data = new ArrayList<KeyNamePair>();
|
||||
|
||||
log.config("");
|
||||
int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
|
||||
// Load PaySelect
|
||||
String sql = "SELECT C_PaySelection_ID, Name || ' - ' || TotalAmt FROM C_PaySelection "
|
||||
+ "WHERE AD_Client_ID=? AND Processed='Y' AND IsActive='Y'"
|
||||
+ "ORDER BY PayDate DESC";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, AD_Client_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
while (rs.next())
|
||||
{
|
||||
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||
data.add(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public String bank;
|
||||
public String currency;
|
||||
public BigDecimal balance;
|
||||
|
||||
/**
|
||||
* PaySelect changed - load Bank
|
||||
*/
|
||||
public void loadPaySelectInfo(int C_PaySelection_ID)
|
||||
{
|
||||
// load Banks from PaySelectLine
|
||||
m_C_BankAccount_ID = -1;
|
||||
String sql = "SELECT ps.C_BankAccount_ID, b.Name || ' ' || ba.AccountNo," // 1..2
|
||||
+ " c.ISO_Code, CurrentBalance " // 3..4
|
||||
+ "FROM C_PaySelection ps"
|
||||
+ " INNER JOIN C_BankAccount ba ON (ps.C_BankAccount_ID=ba.C_BankAccount_ID)"
|
||||
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID)"
|
||||
+ " INNER JOIN C_Currency c ON (ba.C_Currency_ID=c.C_Currency_ID) "
|
||||
+ "WHERE ps.C_PaySelection_ID=? AND ps.Processed='Y' AND ba.IsActive='Y'";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_PaySelection_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
m_C_BankAccount_ID = rs.getInt(1);
|
||||
bank = rs.getString(2);
|
||||
currency = rs.getString(3);
|
||||
balance = rs.getBigDecimal(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_C_BankAccount_ID = -1;
|
||||
bank = "";
|
||||
currency = "";
|
||||
balance = Env.ZERO;
|
||||
log.log(Level.SEVERE, "No active BankAccount for C_PaySelection_ID=" + C_PaySelection_ID);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
} // loadPaySelectInfo
|
||||
|
||||
/**
|
||||
* Bank changed - load PaymentRule
|
||||
*/
|
||||
public ArrayList<ValueNamePair> loadPaymentRule(int C_PaySelection_ID)
|
||||
{
|
||||
ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();
|
||||
|
||||
// load PaymentRule for Bank
|
||||
int AD_Reference_ID = 195; // MLookupInfo.getAD_Reference_ID("All_Payment Rule");
|
||||
Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
|
||||
MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
|
||||
String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY"))
|
||||
+ " AND " + info.KeyColumn
|
||||
+ " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) "
|
||||
+ info.Query.substring(info.Query.indexOf(" ORDER BY"));
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_PaySelection_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
while (rs.next())
|
||||
{
|
||||
ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
|
||||
data.add(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
if (data.size() == 0)
|
||||
log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);
|
||||
|
||||
return data;
|
||||
} // loadPaymentRule
|
||||
|
||||
public String noPayments;
|
||||
public Integer documentNo;
|
||||
|
||||
|
||||
/**
|
||||
* PaymentRule changed - load DocumentNo, NoPayments,
|
||||
* enable/disable EFT, Print
|
||||
*/
|
||||
public String loadPaymentRuleInfo(int C_PaySelection_ID, String PaymentRule)
|
||||
{
|
||||
String msg = null;
|
||||
|
||||
String sql = "SELECT COUNT(*) "
|
||||
+ "FROM C_PaySelectionCheck "
|
||||
+ "WHERE C_PaySelection_ID=?";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_PaySelection_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
if (rs.next())
|
||||
noPayments = String.valueOf(rs.getInt(1));
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
// DocumentNo
|
||||
sql = "SELECT CurrentNext "
|
||||
+ "FROM C_BankAccountDoc "
|
||||
+ "WHERE C_BankAccount_ID=? AND PaymentRule=? AND IsActive='Y'";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_C_BankAccount_ID);
|
||||
pstmt.setString(2, PaymentRule);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
if (rs.next())
|
||||
documentNo = new Integer(rs.getInt(1));
|
||||
else
|
||||
{
|
||||
log.log(Level.SEVERE, "VPayPrint.loadPaymentRuleInfo - No active BankAccountDoc for C_BankAccount_ID="
|
||||
+ m_C_BankAccount_ID + " AND PaymentRule=" + PaymentRule);
|
||||
msg = "VPayPrintNoDoc";
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
return msg;
|
||||
} // loadPaymentRuleInfo
|
||||
}
|
|
@ -0,0 +1,474 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2009 Low Heng Sin *
|
||||
* Copyright (C) 2009 Idalica Corporation *
|
||||
* 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.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.minigrid.ColumnInfo;
|
||||
import org.compiere.minigrid.IDColumn;
|
||||
import org.compiere.minigrid.IMiniTable;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MLookupInfo;
|
||||
import org.compiere.model.MPaySelection;
|
||||
import org.compiere.model.MPaySelectionLine;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.X_C_Order;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
|
||||
public class PaySelect
|
||||
{
|
||||
/** @todo withholding */
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2872767371244295934L;
|
||||
|
||||
/** Window No */
|
||||
public int m_WindowNo = 0;
|
||||
|
||||
/** Format */
|
||||
public DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||
/** Bank Balance */
|
||||
private BigDecimal m_bankBalance = new BigDecimal(0.0);
|
||||
/** SQL for Query */
|
||||
private String m_sql;
|
||||
/** Number of selected rows */
|
||||
public int m_noSelected = 0;
|
||||
/** Client ID */
|
||||
private int m_AD_Client_ID = 0;
|
||||
/**/
|
||||
public boolean m_isLocked = false;
|
||||
/** Payment Selection */
|
||||
public MPaySelection m_ps = null;
|
||||
/** Logger */
|
||||
public static CLogger log = CLogger.getCLogger(PaySelect.class);
|
||||
|
||||
public ArrayList<BankInfo> getBankAccountData()
|
||||
{
|
||||
ArrayList<BankInfo> data = new ArrayList<BankInfo>();
|
||||
//
|
||||
m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
// Bank Account Info
|
||||
String sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT ba.C_BankAccount_ID," // 1
|
||||
+ "b.Name || ' ' || ba.AccountNo AS Name," // 2
|
||||
+ "ba.C_Currency_ID, c.ISO_Code," // 3..4
|
||||
+ "ba.CurrentBalance " // 5
|
||||
+ "FROM C_Bank b, C_BankAccount ba, C_Currency c "
|
||||
+ "WHERE b.C_Bank_ID=ba.C_Bank_ID"
|
||||
+ " AND ba.C_Currency_ID=c.C_Currency_ID "
|
||||
+ " AND EXISTS (SELECT * FROM C_BankAccountDoc d WHERE d.C_BankAccount_ID=ba.C_BankAccount_ID) "
|
||||
+ "ORDER BY 2",
|
||||
"b", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RW);
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
boolean transfers = false;
|
||||
BankInfo bi = new BankInfo (rs.getInt(1), rs.getInt(3),
|
||||
rs.getString(2), rs.getString(4),
|
||||
rs.getBigDecimal(5), transfers);
|
||||
data.add(bi);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public ArrayList<KeyNamePair> getBPartnerData()
|
||||
{
|
||||
ArrayList<KeyNamePair> data = new ArrayList<KeyNamePair>();
|
||||
|
||||
// Optional BusinessPartner with unpaid AP Invoices
|
||||
KeyNamePair pp = new KeyNamePair(0, "");
|
||||
data.add(pp);
|
||||
|
||||
String sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT bp.C_BPartner_ID, bp.Name FROM C_BPartner bp", "bp",
|
||||
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO)
|
||||
+ " AND EXISTS (SELECT * FROM C_Invoice i WHERE bp.C_BPartner_ID=i.C_BPartner_ID"
|
||||
// X_C_Order.PAYMENTRULE_DirectDebit
|
||||
+ " AND (i.IsSOTrx='N' OR (i.IsSOTrx='Y' AND i.PaymentRule='D'))"
|
||||
+ " AND i.IsPaid<>'Y') "
|
||||
+ "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));
|
||||
data.add(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public ArrayList<KeyNamePair> getDocTypeData()
|
||||
{
|
||||
ArrayList<KeyNamePair> data = new ArrayList<KeyNamePair>();
|
||||
String sql = null;
|
||||
/**Document type**/
|
||||
try
|
||||
{
|
||||
sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT doc.c_doctype_id,doc.name FROM c_doctype doc WHERE doc.ad_client_id = ? AND doc.docbasetype in ('API','APC') ORDER BY 2", "doc",
|
||||
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
||||
|
||||
KeyNamePair dt = new KeyNamePair(0, "");
|
||||
data.add(dt);
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_AD_Client_ID); // Client
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
dt = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||
data.add(dt);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public void prepareTable(IMiniTable miniTable)
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
/** prepare MiniTable
|
||||
*
|
||||
SELECT i.C_Invoice_ID, i.DateInvoiced+p.NetDays AS DateDue,
|
||||
bp.Name, i.DocumentNo, c.ISO_Code, i.GrandTotal,
|
||||
paymentTermDiscount(i.GrandTotal, i.C_PaymentTerm_ID, i.DateInvoiced, SysDate) AS Discount,
|
||||
SysDate-paymentTermDueDays(i.C_PaymentTerm_ID,i.DateInvoiced) AS DiscountDate,
|
||||
i.GrandTotal-paymentTermDiscount(i.GrandTotal,i.C_PaymentTerm_ID,i.DateInvoiced,SysDate) AS DueAmount,
|
||||
currencyConvert(i.GrandTotal-paymentTermDiscount(i.GrandTotal,i.C_PaymentTerm_ID,i.DateInvoiced,SysDate,null),
|
||||
i.C_Currency_ID,xx100,SysDate) AS PayAmt
|
||||
FROM C_Invoice i, C_BPartner bp, C_Currency c, C_PaymentTerm p
|
||||
WHERE i.IsSOTrx='N'
|
||||
AND i.C_BPartner_ID=bp.C_BPartner_ID
|
||||
AND i.C_Currency_ID=c.C_Currency_ID
|
||||
AND i.C_PaymentTerm_ID=p.C_PaymentTerm_ID
|
||||
AND i.DocStatus IN ('CO','CL')
|
||||
ORDER BY 2,3
|
||||
*/
|
||||
|
||||
m_sql = miniTable.prepareTable(new ColumnInfo[] {
|
||||
// 0..4
|
||||
new ColumnInfo(" ", "i.C_Invoice_ID", IDColumn.class, false, false, null),
|
||||
new ColumnInfo(Msg.translate(ctx, "DueDate"), "paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DateDue", Timestamp.class, true, true, null),
|
||||
new ColumnInfo(Msg.translate(ctx, "C_BPartner_ID"), "bp.Name", KeyNamePair.class, true, false, "i.C_BPartner_ID"),
|
||||
new ColumnInfo(Msg.translate(ctx, "DocumentNo"), "i.DocumentNo", String.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "C_Currency_ID"), "c.ISO_Code", KeyNamePair.class, true, false, "i.C_Currency_ID"),
|
||||
// 5..9
|
||||
new ColumnInfo(Msg.translate(ctx, "GrandTotal"), "i.GrandTotal", BigDecimal.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "DiscountAmt"), "paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?)", BigDecimal.class),
|
||||
new ColumnInfo(Msg.getMsg(ctx, "DiscountDate"), "SysDate-paymentTermDueDays(i.C_PaymentTerm_ID,i.DateInvoiced,SysDate)", Timestamp.class),
|
||||
new ColumnInfo(Msg.getMsg(ctx, "AmountDue"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class),
|
||||
new ColumnInfo(Msg.getMsg(ctx, "AmountPay"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)-paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class)
|
||||
},
|
||||
// FROM
|
||||
"C_Invoice_v i"
|
||||
+ " INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID)"
|
||||
+ " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID)"
|
||||
+ " INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID)",
|
||||
// WHERE
|
||||
"i.IsSOTrx=? AND IsPaid='N'"
|
||||
// Different Payment Selection
|
||||
+ " AND NOT EXISTS (SELECT * FROM C_PaySelectionLine psl"
|
||||
+ " WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND psl.C_PaySelectionCheck_ID IS NOT NULL"
|
||||
+ " AND psl.C_PaySelectionCheck_ID NOT IN "
|
||||
+ " (SELECT psc.C_PaySelectionCheck_ID FROM C_PaySelectionCheck psc, C_Payment p"
|
||||
+ " WHERE psc.C_PaySelectionCheck_ID = psl.C_PaySelectionCheck_ID"
|
||||
+ " AND psc.C_Payment_ID = p.C_Payment_ID"
|
||||
+ " AND p.DocStatus IN ('RE','VO')))"
|
||||
+ " AND i.DocStatus IN ('CO','CL')"
|
||||
+ " AND i.AD_Client_ID=?", // additional where & order in loadTableInfo()
|
||||
true, "i");
|
||||
} // dynInit
|
||||
|
||||
/**
|
||||
* Load Bank Info - Load Info from Bank Account and valid Documents (PaymentRule)
|
||||
*/
|
||||
public ArrayList<ValueNamePair> getPaymentRuleData(BankInfo bi)
|
||||
{
|
||||
if (bi == null)
|
||||
return null;
|
||||
m_bankBalance = bi.Balance;
|
||||
|
||||
ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();
|
||||
|
||||
int AD_Reference_ID = 195; // MLookupInfo.getAD_Reference_ID("All_Payment Rule");
|
||||
Language language = Env.getLanguage(Env.getCtx());
|
||||
MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
|
||||
String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY"))
|
||||
+ " AND " + info.KeyColumn
|
||||
+ " IN (SELECT PaymentRule FROM C_BankAccountDoc WHERE C_BankAccount_ID=?) "
|
||||
+ info.Query.substring(info.Query.indexOf(" ORDER BY"));
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, bi.C_BankAccount_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
ValueNamePair vp = null;
|
||||
while (rs.next())
|
||||
{
|
||||
vp = new ValueNamePair(rs.getString(2), rs.getString(3)); // returns also not active
|
||||
data.add(vp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query and create TableInfo
|
||||
*/
|
||||
public void loadTableInfo(BankInfo bi, Timestamp payDate, ValueNamePair paymentRule, boolean onlyDue,
|
||||
KeyNamePair bpartner, KeyNamePair docType, IMiniTable miniTable)
|
||||
{
|
||||
log.config("");
|
||||
// not yet initialized
|
||||
if (m_sql == null)
|
||||
return;
|
||||
|
||||
String sql = m_sql;
|
||||
// Parameters
|
||||
String isSOTrx = "N";
|
||||
if (paymentRule != null && X_C_Order.PAYMENTRULE_DirectDebit.equals(paymentRule.getValue()))
|
||||
{
|
||||
isSOTrx = "Y";
|
||||
sql += " AND i.PaymentRule='" + X_C_Order.PAYMENTRULE_DirectDebit + "'";
|
||||
}
|
||||
//
|
||||
if (onlyDue)
|
||||
sql += " AND paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) <= ?";
|
||||
//
|
||||
KeyNamePair pp = bpartner;
|
||||
int C_BPartner_ID = pp.getKey();
|
||||
if (C_BPartner_ID != 0)
|
||||
sql += " AND i.C_BPartner_ID=?";
|
||||
//Document Type
|
||||
KeyNamePair dt = docType;
|
||||
int c_doctype_id = dt.getKey();
|
||||
if (c_doctype_id != 0)
|
||||
sql += " AND i.c_doctype_id =?";
|
||||
sql += " ORDER BY 2,3";
|
||||
|
||||
log.finest(sql + " - C_Currency_ID=" + bi.C_Currency_ID + ", C_BPartner_ID=" + C_BPartner_ID + ", C_doctype_id=" + c_doctype_id );
|
||||
// Get Open Invoices
|
||||
try
|
||||
{
|
||||
int index = 1;
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setTimestamp(index++, payDate); // DiscountAmt
|
||||
pstmt.setInt(index++, bi.C_Currency_ID); // DueAmt
|
||||
pstmt.setTimestamp(index++, payDate);
|
||||
pstmt.setTimestamp(index++, payDate); // PayAmt
|
||||
pstmt.setInt(index++, bi.C_Currency_ID);
|
||||
pstmt.setTimestamp(index++, payDate);
|
||||
pstmt.setString(index++, isSOTrx); // IsSOTrx
|
||||
pstmt.setInt(index++, m_AD_Client_ID); // Client
|
||||
if (onlyDue)
|
||||
pstmt.setTimestamp(index++, payDate);
|
||||
if (C_BPartner_ID != 0)
|
||||
pstmt.setInt(index++, C_BPartner_ID);
|
||||
if (c_doctype_id != 0) //Document type
|
||||
pstmt.setInt(index++, c_doctype_id );
|
||||
//
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
miniTable.loadTable(rs);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
} // loadTableInfo
|
||||
|
||||
/**
|
||||
* Calculate selected rows.
|
||||
* - add up selected rows
|
||||
*/
|
||||
public String calculateSelection(IMiniTable miniTable)
|
||||
{
|
||||
m_noSelected = 0;
|
||||
BigDecimal invoiceAmt = new BigDecimal(0.0);
|
||||
|
||||
int rows = miniTable.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
IDColumn id = (IDColumn)miniTable.getValueAt(i, 0);
|
||||
if (id.isSelected())
|
||||
{
|
||||
BigDecimal amt = (BigDecimal)miniTable.getValueAt(i, 9);
|
||||
if (amt != null)
|
||||
invoiceAmt = invoiceAmt.add(amt);
|
||||
m_noSelected++;
|
||||
}
|
||||
}
|
||||
|
||||
// Information
|
||||
BigDecimal remaining = m_bankBalance.subtract(invoiceAmt);
|
||||
StringBuffer info = new StringBuffer();
|
||||
info.append(m_noSelected).append(" ").append(Msg.getMsg(Env.getCtx(), "Selected")).append(" - ");
|
||||
info.append(m_format.format(invoiceAmt)).append(", ");
|
||||
info.append(Msg.getMsg(Env.getCtx(), "Remaining")).append(" ").append(m_format.format(remaining));
|
||||
return info.toString();
|
||||
} // calculateSelection
|
||||
|
||||
public Trx trx = null;
|
||||
|
||||
/**
|
||||
* Generate PaySelection
|
||||
*/
|
||||
public String generatePaySelect(IMiniTable miniTable, ValueNamePair paymentRule, Timestamp payDate, BankInfo bi)
|
||||
{
|
||||
log.info("");
|
||||
// String trxName Trx.createTrxName("PaySelect");
|
||||
// Trx trx = Trx.get(trxName, true); trx needs to be committed too
|
||||
String trxName = null;
|
||||
trx = null;
|
||||
|
||||
String PaymentRule = paymentRule.getValue();
|
||||
|
||||
// Create Header
|
||||
m_ps = new MPaySelection(Env.getCtx(), 0, trxName);
|
||||
m_ps.setName (Msg.getMsg(Env.getCtx(), "VPaySelect")
|
||||
+ " - " + paymentRule.getName()
|
||||
+ " - " + payDate);
|
||||
m_ps.setPayDate (payDate);
|
||||
m_ps.setC_BankAccount_ID(bi.C_BankAccount_ID);
|
||||
m_ps.setIsApproved(true);
|
||||
if (!m_ps.save())
|
||||
{
|
||||
m_ps = null;
|
||||
return Msg.translate(Env.getCtx(), "C_PaySelection_ID");
|
||||
}
|
||||
log.config(m_ps.toString());
|
||||
|
||||
// Create Lines
|
||||
int rows = miniTable.getRowCount();
|
||||
int line = 0;
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
IDColumn id = (IDColumn)miniTable.getValueAt(i, 0);
|
||||
if (id.isSelected())
|
||||
{
|
||||
line += 10;
|
||||
MPaySelectionLine psl = new MPaySelectionLine (m_ps, line, PaymentRule);
|
||||
int C_Invoice_ID = id.getRecord_ID().intValue();
|
||||
BigDecimal OpenAmt = (BigDecimal)miniTable.getValueAt(i, 8);
|
||||
BigDecimal PayAmt = (BigDecimal)miniTable.getValueAt(i, 9);
|
||||
boolean isSOTrx = false;
|
||||
//
|
||||
psl.setInvoice(C_Invoice_ID, isSOTrx,
|
||||
OpenAmt, PayAmt, OpenAmt.subtract(PayAmt));
|
||||
if (!psl.save(trxName))
|
||||
{
|
||||
return Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID");
|
||||
}
|
||||
log.fine("C_Invoice_ID=" + C_Invoice_ID + ", PayAmt=" + PayAmt);
|
||||
}
|
||||
} // for all rows in table
|
||||
|
||||
return null;
|
||||
} // generatePaySelect
|
||||
|
||||
/**************************************************************************
|
||||
* Bank Account Info
|
||||
*/
|
||||
public class BankInfo
|
||||
{
|
||||
/**
|
||||
* BankInfo
|
||||
* @param newC_BankAccount_ID
|
||||
* @param newC_Currency_ID
|
||||
* @param newName
|
||||
* @param newCurrency
|
||||
* @param newBalance
|
||||
* @param newTransfers
|
||||
*/
|
||||
public BankInfo (int newC_BankAccount_ID, int newC_Currency_ID,
|
||||
String newName, String newCurrency, BigDecimal newBalance, boolean newTransfers)
|
||||
{
|
||||
C_BankAccount_ID = newC_BankAccount_ID;
|
||||
C_Currency_ID = newC_Currency_ID;
|
||||
Name = newName;
|
||||
Currency = newCurrency;
|
||||
Balance = newBalance;
|
||||
}
|
||||
int C_BankAccount_ID;
|
||||
int C_Currency_ID;
|
||||
String Name;
|
||||
public String Currency;
|
||||
public BigDecimal Balance;
|
||||
boolean Transfers;
|
||||
|
||||
/**
|
||||
* to String
|
||||
* @return info
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
} // BankInfo
|
||||
|
||||
} // VPaySelect
|
|
@ -0,0 +1,205 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2009 Low Heng Sin *
|
||||
* Copyright (C) 2009 Idalica Corporation *
|
||||
* 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.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MTree;
|
||||
import org.compiere.model.MTree_Node;
|
||||
import org.compiere.model.MTree_NodeBP;
|
||||
import org.compiere.model.MTree_NodeMM;
|
||||
import org.compiere.model.MTree_NodePR;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
public class TreeMaintenance {
|
||||
|
||||
/** Window No */
|
||||
public int m_WindowNo = 0;
|
||||
/** Active Tree */
|
||||
public MTree m_tree;
|
||||
/** Logger */
|
||||
public static CLogger log = CLogger.getCLogger(TreeMaintenance.class);
|
||||
|
||||
public KeyNamePair[] getTreeData()
|
||||
{
|
||||
return DB.getKeyNamePairs(MRole.getDefault().addAccessSQL(
|
||||
"SELECT AD_Tree_ID, Name FROM AD_Tree WHERE TreeType NOT IN ('BB','PC') ORDER BY 2",
|
||||
"AD_Tree", MRole.SQL_NOTQUALIFIED, MRole.SQL_RW), false);
|
||||
}
|
||||
|
||||
public ArrayList<ListItem> getTreeItemData()
|
||||
{
|
||||
ArrayList<ListItem> data = new ArrayList<ListItem>();
|
||||
|
||||
String fromClause = m_tree.getSourceTableName(false); // fully qualified
|
||||
String columnNameX = m_tree.getSourceTableName(true);
|
||||
String actionColor = m_tree.getActionColorName();
|
||||
|
||||
String sql = "SELECT t." + columnNameX
|
||||
+ "_ID,t.Name,t.Description,t.IsSummary,"
|
||||
+ actionColor
|
||||
+ " FROM " + fromClause
|
||||
// + " WHERE t.IsActive='Y'" // R/O
|
||||
+ " ORDER BY 2";
|
||||
sql = MRole.getDefault().addAccessSQL(sql,
|
||||
"t", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
||||
log.config(sql);
|
||||
//
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
ListItem item = new ListItem(rs.getInt(1), rs.getString(2),
|
||||
rs.getString(3), "Y".equals(rs.getString(4)), rs.getString(5));
|
||||
data.add(item);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action: Add Node to Tree
|
||||
* @param item item
|
||||
*/
|
||||
public void addNode(ListItem item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
// May cause Error if in tree
|
||||
if (m_tree.isProduct())
|
||||
{
|
||||
MTree_NodePR node = new MTree_NodePR (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
else if (m_tree.isBPartner())
|
||||
{
|
||||
MTree_NodeBP node = new MTree_NodeBP (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
else if (m_tree.isMenu())
|
||||
{
|
||||
MTree_NodeMM node = new MTree_NodeMM (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
MTree_Node node = new MTree_Node (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
}
|
||||
} // action_treeAdd
|
||||
|
||||
/**
|
||||
* Action: Delete Node from Tree
|
||||
* @param item item
|
||||
*/
|
||||
public void deleteNode(ListItem item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
if (m_tree.isProduct())
|
||||
{
|
||||
MTree_NodePR node = MTree_NodePR.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
else if (m_tree.isBPartner())
|
||||
{
|
||||
MTree_NodeBP node = MTree_NodeBP.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
else if (m_tree.isMenu())
|
||||
{
|
||||
MTree_NodeMM node = MTree_NodeMM.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
MTree_Node node = MTree_Node.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
}
|
||||
} // action_treeDelete
|
||||
|
||||
/**************************************************************************
|
||||
* Tree Maintenance List Item
|
||||
*/
|
||||
public class ListItem
|
||||
{
|
||||
/**
|
||||
* ListItem
|
||||
* @param ID
|
||||
* @param Name
|
||||
* @param Description
|
||||
* @param summary
|
||||
* @param ImageIndicator
|
||||
*/
|
||||
public ListItem (int ID, String Name, String Description,
|
||||
boolean summary, String ImageIndicator)
|
||||
{
|
||||
id = ID;
|
||||
name = Name;
|
||||
description = Description;
|
||||
isSummary = summary;
|
||||
imageIndicator = ImageIndicator;
|
||||
} // ListItem
|
||||
|
||||
/** ID */
|
||||
public int id;
|
||||
/** Name */
|
||||
public String name;
|
||||
/** Description */
|
||||
public String description;
|
||||
/** Summary */
|
||||
public boolean isSummary;
|
||||
/** Indicator */
|
||||
public String imageIndicator; // Menu - Action
|
||||
|
||||
/**
|
||||
* To String
|
||||
* @return String Representation
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
String retValue = name;
|
||||
if (description != null && description.length() > 0)
|
||||
retValue += " (" + description + ")";
|
||||
return retValue;
|
||||
} // toString
|
||||
|
||||
} // ListItem
|
||||
}
|
|
@ -0,0 +1,195 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2009 Low Heng Sin *
|
||||
* Copyright (C) 2009 Idalica Corporation *
|
||||
* 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.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.apps.IStatusBar;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.GridWindow;
|
||||
import org.compiere.model.GridWindowVO;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
public class TrxMaterial {
|
||||
|
||||
/** Window No */
|
||||
public int m_WindowNo = 0;
|
||||
/** MWindow */
|
||||
public GridWindow m_mWindow = null;
|
||||
/** MTab pointer */
|
||||
public GridTab m_mTab = null;
|
||||
|
||||
public MQuery m_staticQuery = null;
|
||||
/** Logger */
|
||||
public static CLogger log = CLogger.getCLogger(TrxMaterial.class);
|
||||
|
||||
/**
|
||||
* Dynamic Layout (Grid).
|
||||
* Based on AD_Window: Material Transactions
|
||||
*/
|
||||
public void dynInit(IStatusBar statusBar)
|
||||
{
|
||||
m_staticQuery = new MQuery();
|
||||
m_staticQuery.addRestriction("AD_Client_ID", MQuery.EQUAL, Env.getAD_Client_ID(Env.getCtx()));
|
||||
int AD_Window_ID = 223; // Hardcoded
|
||||
GridWindowVO wVO = AEnv.getMWindowVO (m_WindowNo, AD_Window_ID, 0);
|
||||
if (wVO == null)
|
||||
return;
|
||||
m_mWindow = new GridWindow (wVO);
|
||||
m_mTab = m_mWindow.getTab(0);
|
||||
m_mWindow.initTab(0);
|
||||
//
|
||||
m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
|
||||
m_mTab.query(false);
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(" ");
|
||||
} // dynInit
|
||||
|
||||
/**************************************************************************
|
||||
* Refresh - Create Query and refresh grid
|
||||
*/
|
||||
public void refresh(Object organization, Object locator, Object product, Object movementType,
|
||||
Timestamp movementDateFrom, Timestamp movementDateTo, IStatusBar statusBar)
|
||||
{
|
||||
/**
|
||||
* Create Where Clause
|
||||
*/
|
||||
MQuery query = m_staticQuery.deepCopy();
|
||||
// Organization
|
||||
if (organization != null && organization.toString().length() > 0)
|
||||
query.addRestriction("AD_Org_ID", MQuery.EQUAL, organization);
|
||||
// Locator
|
||||
if (locator != null && locator.toString().length() > 0)
|
||||
query.addRestriction("M_Locator_ID", MQuery.EQUAL, locator);
|
||||
// Product
|
||||
if (product != null && product.toString().length() > 0)
|
||||
query.addRestriction("M_Product_ID", MQuery.EQUAL, product);
|
||||
// MovementType
|
||||
if (movementType != null && movementType.toString().length() > 0)
|
||||
query.addRestriction("MovementType", MQuery.EQUAL, movementType);
|
||||
// DateFrom
|
||||
if (movementDateFrom != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.GREATER_EQUAL, movementDateFrom);
|
||||
// DateTO
|
||||
if (movementDateTo != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.LESS_EQUAL, movementDateTo);
|
||||
log.info( "VTrxMaterial.refresh query=" + query.toString());
|
||||
|
||||
/**
|
||||
* Refresh/Requery
|
||||
*/
|
||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "StartSearch"), false);
|
||||
//
|
||||
m_mTab.setQuery(query);
|
||||
m_mTab.query(false);
|
||||
//
|
||||
int no = m_mTab.getRowCount();
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(Integer.toString(no));
|
||||
} // refresh
|
||||
|
||||
public int AD_Window_ID;
|
||||
public MQuery query;
|
||||
|
||||
/**
|
||||
* Zoom
|
||||
*/
|
||||
public void zoom()
|
||||
{
|
||||
log.info("");
|
||||
//
|
||||
AD_Window_ID = 0;
|
||||
String ColumnName = null;
|
||||
String SQL = null;
|
||||
//
|
||||
int lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_InOutLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_InOutLine_ID=" + lineID);
|
||||
if (Env.getContext(Env.getCtx(), m_WindowNo, "MovementType").startsWith("C"))
|
||||
AD_Window_ID = 169; // Customer
|
||||
else
|
||||
AD_Window_ID = 184; // Vendor
|
||||
ColumnName = "M_InOut_ID";
|
||||
SQL = "SELECT M_InOut_ID FROM M_InOutLine WHERE M_InOutLine_ID=?";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_InventoryLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_InventoryLine_ID=" + lineID);
|
||||
AD_Window_ID = 168;
|
||||
ColumnName = "M_Inventory_ID";
|
||||
SQL = "SELECT M_Inventory_ID FROM M_InventoryLine WHERE M_InventoryLine_ID=?";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_MovementLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_MovementLine_ID=" + lineID);
|
||||
AD_Window_ID = 170;
|
||||
ColumnName = "M_Movement_ID";
|
||||
SQL = "SELECT M_Movement_ID FROM M_MovementLine WHERE M_MovementLine_ID=?";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_ProductionLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_ProductionLine_ID=" + lineID);
|
||||
AD_Window_ID = 191;
|
||||
ColumnName = "M_Production_ID";
|
||||
SQL = "SELECT M_Production_ID FROM M_ProductionLine WHERE M_ProductionLine_ID=?";
|
||||
}
|
||||
else
|
||||
log.fine("Not found WindowNo=" + m_WindowNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (AD_Window_ID == 0)
|
||||
return;
|
||||
|
||||
// Get Parent ID
|
||||
int parentID = 0;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
|
||||
pstmt.setInt(1, lineID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
parentID = rs.getInt(1);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, SQL, e);
|
||||
}
|
||||
query = MQuery.getEqualQuery(ColumnName, parentID);
|
||||
log.config("AD_Window_ID=" + AD_Window_ID + " - " + query);
|
||||
if (parentID == 0)
|
||||
log.log(Level.SEVERE, "No ParentValue - " + SQL + " - " + lineID);
|
||||
} // zoom
|
||||
}
|
|
@ -22,26 +22,17 @@ import java.awt.Font;
|
|||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.apps.ADialog;
|
||||
import org.compiere.apps.ConfirmPanel;
|
||||
import org.compiere.grid.ed.VLookup;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.X_M_Cost;
|
||||
import org.compiere.swing.CLabel;
|
||||
import org.compiere.swing.CPanel;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
/**
|
||||
* Merge Dialog.
|
||||
|
@ -50,55 +41,21 @@ import org.compiere.util.Trx;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VMerge.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class VMerge extends CPanel
|
||||
implements FormPanel, ActionListener
|
||||
public class VMerge extends Merge implements FormPanel, ActionListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 149783846292562740L;
|
||||
/** Window No */
|
||||
private int m_WindowNo = 0;
|
||||
|
||||
private CPanel panel = new CPanel();
|
||||
|
||||
/** FormFrame */
|
||||
private FormFrame m_frame;
|
||||
/** Total Count */
|
||||
private int m_totalCount = 0;
|
||||
/** Error Log */
|
||||
private StringBuffer m_errorLog = new StringBuffer();
|
||||
/** Connection */
|
||||
//private Connection m_con = null;
|
||||
private Trx m_trx = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VMerge.class);
|
||||
|
||||
static private String AD_ORG_ID = "AD_Org_ID";
|
||||
static private String C_BPARTNER_ID = "C_BPartner_ID";
|
||||
static private String AD_USER_ID = "AD_User_ID";
|
||||
static private String M_PRODUCT_ID = "M_Product_ID";
|
||||
|
||||
/** Tables to delete (not update) for AD_Org */
|
||||
static private String[] s_delete_Org = new String[]
|
||||
{"AD_OrgInfo", "AD_Role_OrgAccess"};
|
||||
/** Tables to delete (not update) for AD_User */
|
||||
static private String[] s_delete_User = new String[]
|
||||
{"AD_User_Roles"};
|
||||
/** Tables to delete (not update) for C_BPartner */
|
||||
static private String[] s_delete_BPartner = new String[]
|
||||
{"C_BP_Employee_Acct", "C_BP_Vendor_Acct", "C_BP_Customer_Acct",
|
||||
"T_Aging"};
|
||||
/** Tables to delete (not update) for M_Product */
|
||||
static private String[] s_delete_Product = new String[]
|
||||
{"M_Product_PO", "M_Replenish", "T_Replenish",
|
||||
"M_ProductPrice", "M_Product_Costing",
|
||||
"M_Cost", // teo_sarca [ 1704554 ]
|
||||
"M_Product_Trl", "M_Product_Acct"}; // M_Storage
|
||||
|
||||
private String[] m_columnName = null;
|
||||
private CLabel[] m_label = null;
|
||||
private VLookup[] m_from = null;
|
||||
private VLookup[] m_to = null;
|
||||
private String[] m_deleteTables = null;
|
||||
|
||||
|
||||
private BorderLayout mainLayout = new BorderLayout();
|
||||
private CPanel CenterPanel = new CPanel();
|
||||
|
@ -121,7 +78,7 @@ public class VMerge extends CPanel
|
|||
{
|
||||
preInit();
|
||||
jbInit ();
|
||||
frame.getContentPane().add(this, BorderLayout.CENTER);
|
||||
frame.getContentPane().add(panel, BorderLayout.CENTER);
|
||||
// frame.getContentPane().add(statusBar, BorderLayout.SOUTH);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -133,7 +90,7 @@ public class VMerge extends CPanel
|
|||
/**
|
||||
* Pre Init
|
||||
*/
|
||||
private void preInit()
|
||||
public void preInit()
|
||||
{
|
||||
int count = 4; // ** Update **
|
||||
m_columnName = new String[count];
|
||||
|
@ -172,11 +129,11 @@ public class VMerge extends CPanel
|
|||
*/
|
||||
void jbInit () throws Exception
|
||||
{
|
||||
this.setLayout (mainLayout);
|
||||
panel.setLayout (mainLayout);
|
||||
mainLayout.setHgap (5);
|
||||
mainLayout.setVgap (5);
|
||||
//
|
||||
this.add (confirmPanel, BorderLayout.SOUTH);
|
||||
panel.add (confirmPanel, BorderLayout.SOUTH);
|
||||
confirmPanel.addActionListener(this);
|
||||
//
|
||||
centerLayout.setHgap (5);
|
||||
|
@ -185,7 +142,7 @@ public class VMerge extends CPanel
|
|||
centerLayout.setRows (m_label.length+1);
|
||||
//
|
||||
CenterPanel.setLayout (centerLayout);
|
||||
this.add (CenterPanel, BorderLayout.CENTER);
|
||||
panel.add (CenterPanel, BorderLayout.CENTER);
|
||||
CenterPanel.add (new CLabel(), null);
|
||||
CenterPanel.add (mergeFromLabel, null);
|
||||
CenterPanel.add (mergeToLabel, null);
|
||||
|
@ -227,12 +184,13 @@ public class VMerge extends CPanel
|
|||
dispose();
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
||||
String columnName = null;
|
||||
String from_Info = null;
|
||||
String to_Info = null;
|
||||
int from_ID = 0;
|
||||
int to_ID = 0;
|
||||
|
||||
// get first merge pair
|
||||
for (int i = 0; (i < m_columnName.length && from_ID == 0 && to_ID == 0); i++)
|
||||
{
|
||||
|
@ -262,247 +220,31 @@ public class VMerge extends CPanel
|
|||
|
||||
String msg = Msg.getMsg(Env.getCtx(), "MergeFrom") + " = " + from_Info
|
||||
+ "\n" + Msg.getMsg(Env.getCtx(), "MergeTo") + " = " + to_Info;
|
||||
if (!ADialog.ask(m_WindowNo, this, "MergeQuestion", msg))
|
||||
if (!ADialog.ask(m_WindowNo, panel, "MergeQuestion", msg))
|
||||
return;
|
||||
|
||||
// ** Update **
|
||||
if (columnName.equals(AD_ORG_ID))
|
||||
m_deleteTables = s_delete_Org;
|
||||
else if (columnName.equals(AD_USER_ID))
|
||||
m_deleteTables = s_delete_User;
|
||||
else if (columnName.equals(C_BPARTNER_ID))
|
||||
m_deleteTables = s_delete_BPartner;
|
||||
else if (columnName.equals(M_PRODUCT_ID))
|
||||
m_deleteTables = s_delete_Product;
|
||||
updateDeleteTable(columnName);
|
||||
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
confirmPanel.getOKButton().setEnabled(false);
|
||||
//
|
||||
boolean success = merge (columnName, from_ID, to_ID);
|
||||
postMerge(columnName, to_ID);
|
||||
//
|
||||
confirmPanel.getOKButton().setEnabled(true);
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
panel.setCursor(Cursor.getDefaultCursor());
|
||||
//
|
||||
if (success)
|
||||
{
|
||||
ADialog.info (m_WindowNo, this, "MergeSuccess",
|
||||
ADialog.info (m_WindowNo, panel, "MergeSuccess",
|
||||
msg + " #" + m_totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
ADialog.error(m_WindowNo, this, "MergeError",
|
||||
ADialog.error(m_WindowNo, panel, "MergeError",
|
||||
m_errorLog.toString());
|
||||
return;
|
||||
}
|
||||
dispose();
|
||||
} // actionPerformed
|
||||
|
||||
|
||||
/**
|
||||
* Merge.
|
||||
* @param ColumnName column
|
||||
* @param from_ID from
|
||||
* @param to_ID to
|
||||
* @return true if merged
|
||||
*/
|
||||
private boolean merge (String ColumnName, int from_ID, int to_ID)
|
||||
{
|
||||
String TableName = ColumnName.substring(0, ColumnName.length()-3);
|
||||
log.config(ColumnName
|
||||
+ " - From=" + from_ID + ",To=" + to_ID);
|
||||
|
||||
boolean success = true;
|
||||
m_totalCount = 0;
|
||||
m_errorLog = new StringBuffer();
|
||||
String sql = "SELECT t.TableName, c.ColumnName "
|
||||
+ "FROM AD_Table t"
|
||||
+ " INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID) "
|
||||
+ "WHERE t.IsView='N'"
|
||||
+ " AND t.TableName NOT IN ('C_TaxDeclarationAcct')"
|
||||
+ " AND ("
|
||||
+ "(c.ColumnName=? AND c.IsKey='N' AND c.ColumnSQL IS NULL)" // #1 - direct
|
||||
+ " OR "
|
||||
+ "c.AD_Reference_Value_ID IN " // Table Reference
|
||||
+ "(SELECT rt.AD_Reference_ID FROM AD_Ref_Table rt"
|
||||
+ " INNER JOIN AD_Column cc ON (rt.AD_Table_ID=cc.AD_Table_ID AND rt.AD_Key=cc.AD_Column_ID) "
|
||||
+ "WHERE cc.IsKey='Y' AND cc.ColumnName=?)" // #2
|
||||
+ ") "
|
||||
+ "ORDER BY t.LoadSeq DESC";
|
||||
PreparedStatement pstmt = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
m_trx = Trx.get(Trx.createTrxName("merge"), true);
|
||||
//
|
||||
pstmt = DB.prepareStatement(sql, Trx.createTrxName());
|
||||
pstmt.setString(1, ColumnName);
|
||||
pstmt.setString(2, ColumnName);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
String tName = rs.getString(1);
|
||||
String cName = rs.getString(2);
|
||||
if (!TableName.equals(tName)) // to be sure - sql should prevent it
|
||||
{
|
||||
int count = mergeTable (tName, cName, from_ID, to_ID);
|
||||
if (count < 0)
|
||||
success = false;
|
||||
else
|
||||
m_totalCount += count;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
//
|
||||
log.config("Success=" + success
|
||||
+ " - " + ColumnName + " - From=" + from_ID + ",To=" + to_ID);
|
||||
if (success)
|
||||
{
|
||||
sql = "DELETE " + TableName + " WHERE " + ColumnName + "=" + from_ID;
|
||||
|
||||
|
||||
|
||||
|
||||
if ( DB.executeUpdate(sql, m_trx.getTrxName()) < 0 )
|
||||
{
|
||||
m_errorLog.append(Env.NL).append("DELETE ").append(TableName)
|
||||
.append(" - ");
|
||||
success = false;
|
||||
log.config(m_errorLog.toString());
|
||||
m_trx.rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
if (success)
|
||||
m_trx.commit();
|
||||
else
|
||||
m_trx.rollback();
|
||||
|
||||
m_trx.close();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, ColumnName, ex);
|
||||
}
|
||||
// Cleanup
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
pstmt = null;
|
||||
return success;
|
||||
} // merge
|
||||
|
||||
|
||||
/**
|
||||
* Merge Table
|
||||
* @param TableName table
|
||||
* @param ColumnName column
|
||||
* @param from_ID from
|
||||
* @param to_ID to
|
||||
* @return -1 for error or number of changes
|
||||
*/
|
||||
private int mergeTable (String TableName, String ColumnName, int from_ID, int to_ID)
|
||||
{
|
||||
log.fine(TableName + "." + ColumnName + " - From=" + from_ID + ",To=" + to_ID);
|
||||
String sql = "UPDATE " + TableName
|
||||
+ " SET " + ColumnName + "=" + to_ID
|
||||
+ " WHERE " + ColumnName + "=" + from_ID;
|
||||
boolean delete = false;
|
||||
for (int i = 0; i < m_deleteTables.length; i++)
|
||||
{
|
||||
if (m_deleteTables[i].equals(TableName))
|
||||
{
|
||||
delete = true;
|
||||
sql = "DELETE " + TableName + " WHERE " + ColumnName + "=" + from_ID;
|
||||
}
|
||||
}
|
||||
// Delete newly created MCost records - teo_sarca [ 1704554 ]
|
||||
if (delete && X_M_Cost.Table_Name.equals(TableName) && M_PRODUCT_ID.equals(ColumnName))
|
||||
{
|
||||
sql += " AND " + X_M_Cost.COLUMNNAME_CurrentCostPrice + "=0"
|
||||
+ " AND " + X_M_Cost.COLUMNNAME_CurrentQty + "=0"
|
||||
+ " AND " + X_M_Cost.COLUMNNAME_CumulatedAmt + "=0"
|
||||
+ " AND " + X_M_Cost.COLUMNNAME_CumulatedQty + "=0";
|
||||
}
|
||||
|
||||
int count = DB.executeUpdate(sql, m_trx.getTrxName());
|
||||
|
||||
|
||||
if ( count < 0 )
|
||||
{
|
||||
|
||||
count = -1;
|
||||
m_errorLog.append(Env.NL)
|
||||
.append(delete ? "DELETE " : "UPDATE ")
|
||||
.append(TableName).append(" - ")
|
||||
.append(" - ").append(sql);
|
||||
log.config(m_errorLog.toString());
|
||||
m_trx.rollback();
|
||||
|
||||
}
|
||||
log.fine(count
|
||||
+ (delete ? " -Delete- " : " -Update- ") + TableName);
|
||||
|
||||
|
||||
return count;
|
||||
} // mergeTable
|
||||
|
||||
/**
|
||||
* Post Merge
|
||||
* @param ColumnName column name
|
||||
* @param to_ID ID
|
||||
*/
|
||||
private void postMerge (String ColumnName, int to_ID)
|
||||
{
|
||||
if (ColumnName.equals(AD_ORG_ID))
|
||||
{
|
||||
|
||||
}
|
||||
else if (ColumnName.equals(AD_USER_ID))
|
||||
{
|
||||
|
||||
}
|
||||
else if (ColumnName.equals(C_BPARTNER_ID))
|
||||
{
|
||||
MBPartner bp = new MBPartner (Env.getCtx(), to_ID, null);
|
||||
if (bp.get_ID() != 0)
|
||||
{
|
||||
MPayment[] payments = MPayment.getOfBPartner(Env.getCtx(), bp.getC_BPartner_ID(), null);
|
||||
for (int i = 0; i < payments.length; i++)
|
||||
{
|
||||
MPayment payment = payments[i];
|
||||
if (payment.testAllocation())
|
||||
payment.save();
|
||||
}
|
||||
MInvoice[] invoices = MInvoice.getOfBPartner(Env.getCtx(), bp.getC_BPartner_ID(), null);
|
||||
for (int i = 0; i < invoices.length; i++)
|
||||
{
|
||||
MInvoice invoice = invoices[i];
|
||||
if (invoice.testAllocation())
|
||||
invoice.save();
|
||||
}
|
||||
bp.setTotalOpenBalance();
|
||||
bp.setActualLifeTimeValue();
|
||||
bp.save();
|
||||
}
|
||||
}
|
||||
else if (ColumnName.equals(M_PRODUCT_ID))
|
||||
{
|
||||
|
||||
}
|
||||
} // postMerge
|
||||
|
||||
|
||||
} // VMerge
|
||||
|
|
|
@ -24,9 +24,7 @@ import java.awt.GridBagLayout;
|
|||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
@ -35,8 +33,6 @@ import javax.swing.JFileChooser;
|
|||
import org.compiere.apps.ADialog;
|
||||
import org.compiere.apps.ConfirmPanel;
|
||||
import org.compiere.grid.ed.VNumber;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MLookupInfo;
|
||||
import org.compiere.model.MPaySelectionCheck;
|
||||
import org.compiere.model.MPaymentBatch;
|
||||
import org.compiere.plaf.CompiereColor;
|
||||
|
@ -45,13 +41,11 @@ import org.compiere.print.ReportEngine;
|
|||
import org.compiere.swing.CComboBox;
|
||||
import org.compiere.swing.CLabel;
|
||||
import org.compiere.swing.CPanel;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
|
||||
|
@ -61,14 +55,15 @@ import org.compiere.util.ValueNamePair;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VPayPrint.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class VPayPrint extends CPanel
|
||||
implements FormPanel, ActionListener
|
||||
public class VPayPrint extends PayPrint implements FormPanel, ActionListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6359854263967310497L;
|
||||
|
||||
private CPanel panel = new CPanel();
|
||||
|
||||
/**
|
||||
* Initialize Panel
|
||||
* @param WindowNo window
|
||||
|
@ -92,19 +87,9 @@ public class VPayPrint extends CPanel
|
|||
}
|
||||
} // init
|
||||
|
||||
/** Window No */
|
||||
private int m_WindowNo = 0;
|
||||
|
||||
/** FormFrame */
|
||||
private FormFrame m_frame;
|
||||
/** Used Bank Account */
|
||||
private int m_C_BankAccount_ID = -1;
|
||||
|
||||
/** Payment Information */
|
||||
private MPaySelectionCheck[] m_checks = null;
|
||||
/** Payment Batch */
|
||||
private MPaymentBatch m_batch = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VPayPrint.class);
|
||||
|
||||
// Static Variables
|
||||
private CPanel centerPanel = new CPanel();
|
||||
|
@ -136,7 +121,7 @@ public class VPayPrint extends CPanel
|
|||
*/
|
||||
private void jbInit() throws Exception
|
||||
{
|
||||
CompiereColor.setBackground(this);
|
||||
CompiereColor.setBackground(panel);
|
||||
//
|
||||
southPanel.setLayout(southLayout);
|
||||
southLayout.setAlignment(FlowLayout.RIGHT);
|
||||
|
@ -207,33 +192,17 @@ public class VPayPrint extends CPanel
|
|||
*/
|
||||
private void dynInit()
|
||||
{
|
||||
log.config("");
|
||||
int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
ArrayList<KeyNamePair> data = getPaySelectionData();
|
||||
for(KeyNamePair pp : data)
|
||||
fPaySelect.addItem(pp);
|
||||
|
||||
// Load PaySelect
|
||||
String sql = "SELECT C_PaySelection_ID, Name || ' - ' || TotalAmt FROM C_PaySelection "
|
||||
+ "WHERE AD_Client_ID=? AND Processed='Y' AND IsActive='Y'"
|
||||
+ "ORDER BY PayDate DESC";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, AD_Client_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
while (rs.next())
|
||||
{
|
||||
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||
fPaySelect.addItem(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if (fPaySelect.getItemCount() == 0)
|
||||
ADialog.info(m_WindowNo, this, "VPayPrintNoRecords");
|
||||
ADialog.info(m_WindowNo, panel, "VPayPrintNoRecords");
|
||||
else
|
||||
{
|
||||
fPaySelect.setSelectedIndex(0);
|
||||
loadPaySelectInfo();
|
||||
}
|
||||
} // dynInit
|
||||
|
||||
/**
|
||||
|
@ -298,43 +267,13 @@ public class VPayPrint extends CPanel
|
|||
if (fPaySelect.getSelectedIndex() == -1)
|
||||
return;
|
||||
|
||||
// load Banks from PaySelectLine
|
||||
int C_PaySelection_ID = ((KeyNamePair)fPaySelect.getSelectedItem()).getKey();
|
||||
m_C_BankAccount_ID = -1;
|
||||
String sql = "SELECT ps.C_BankAccount_ID, b.Name || ' ' || ba.AccountNo," // 1..2
|
||||
+ " c.ISO_Code, CurrentBalance " // 3..4
|
||||
+ "FROM C_PaySelection ps"
|
||||
+ " INNER JOIN C_BankAccount ba ON (ps.C_BankAccount_ID=ba.C_BankAccount_ID)"
|
||||
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID)"
|
||||
+ " INNER JOIN C_Currency c ON (ba.C_Currency_ID=c.C_Currency_ID) "
|
||||
+ "WHERE ps.C_PaySelection_ID=? AND ps.Processed='Y' AND ba.IsActive='Y'";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_PaySelection_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
m_C_BankAccount_ID = rs.getInt(1);
|
||||
fBank.setText(rs.getString(2));
|
||||
fCurrency.setText(rs.getString(3));
|
||||
fBalance.setValue(rs.getBigDecimal(4));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_C_BankAccount_ID = -1;
|
||||
fBank.setText("");
|
||||
fCurrency.setText("");
|
||||
fBalance.setValue(Env.ZERO);
|
||||
log.log(Level.SEVERE, "No active BankAccount for C_PaySelection_ID=" + C_PaySelection_ID);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
loadPaySelectInfo(C_PaySelection_ID);
|
||||
|
||||
fBank.setText(bank);
|
||||
fCurrency.setText(currency);
|
||||
fBalance.setValue(balance);
|
||||
|
||||
loadPaymentRule();
|
||||
} // loadPaySelectInfo
|
||||
|
||||
|
@ -347,36 +286,16 @@ public class VPayPrint extends CPanel
|
|||
if (m_C_BankAccount_ID == -1)
|
||||
return;
|
||||
|
||||
// load PaymentRule for Bank
|
||||
int C_PaySelection_ID = ((KeyNamePair)fPaySelect.getSelectedItem()).getKey();
|
||||
fPaymentRule.removeAllItems();
|
||||
int AD_Reference_ID = 195; // MLookupInfo.getAD_Reference_ID("All_Payment Rule");
|
||||
Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
|
||||
MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
|
||||
String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY"))
|
||||
+ " AND " + info.KeyColumn
|
||||
+ " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) "
|
||||
+ info.Query.substring(info.Query.indexOf(" ORDER BY"));
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_PaySelection_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
while (rs.next())
|
||||
{
|
||||
ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
|
||||
fPaymentRule.addItem(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if (fPaymentRule.getItemCount() == 0)
|
||||
log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);
|
||||
|
||||
int C_PaySelection_ID = ((KeyNamePair)fPaySelect.getSelectedItem()).getKey();
|
||||
ArrayList<ValueNamePair> data = loadPaymentRule(C_PaySelection_ID);
|
||||
for(ValueNamePair pp : data)
|
||||
fPaymentRule.addItem(pp);
|
||||
|
||||
if (fPaymentRule.getItemCount() > 0)
|
||||
fPaymentRule.setSelectedIndex(0);
|
||||
|
||||
loadPaymentRuleInfo();
|
||||
} // loadPaymentRule
|
||||
|
||||
|
@ -395,52 +314,18 @@ public class VPayPrint extends CPanel
|
|||
fNoPayments.setText(" ");
|
||||
|
||||
int C_PaySelection_ID = ((KeyNamePair)fPaySelect.getSelectedItem()).getKey();
|
||||
String sql = "SELECT COUNT(*) "
|
||||
+ "FROM C_PaySelectionCheck "
|
||||
+ "WHERE C_PaySelection_ID=?";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_PaySelection_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
if (rs.next())
|
||||
fNoPayments.setText(String.valueOf(rs.getInt(1)));
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
String msg = loadPaymentRuleInfo(C_PaySelection_ID, PaymentRule);
|
||||
|
||||
if(noPayments != null)
|
||||
fNoPayments.setText(noPayments);
|
||||
|
||||
bProcess.setEnabled(PaymentRule.equals("T"));
|
||||
|
||||
// DocumentNo
|
||||
sql = "SELECT CurrentNext "
|
||||
+ "FROM C_BankAccountDoc "
|
||||
+ "WHERE C_BankAccount_ID=? AND PaymentRule=? AND IsActive='Y'";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_C_BankAccount_ID);
|
||||
pstmt.setString(2, PaymentRule);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
if (rs.next())
|
||||
fDocumentNo.setValue(new Integer(rs.getInt(1)));
|
||||
else
|
||||
{
|
||||
log.log(Level.SEVERE, "VPayPrint.loadPaymentRuleInfo - No active BankAccountDoc for C_BankAccount_ID="
|
||||
+ m_C_BankAccount_ID + " AND PaymentRule=" + PaymentRule);
|
||||
ADialog.error(m_WindowNo, this, "VPayPrintNoDoc");
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if(documentNo != null)
|
||||
fDocumentNo.setValue(documentNo);
|
||||
|
||||
if(msg != null && msg.length() > 0)
|
||||
ADialog.error(m_WindowNo, panel, msg);
|
||||
} // loadPaymentRuleInfo
|
||||
|
||||
|
||||
|
@ -460,16 +345,16 @@ public class VPayPrint extends CPanel
|
|||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.setSelectedFile(new java.io.File("paymentExport.txt"));
|
||||
if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION)
|
||||
if (fc.showSaveDialog(panel) != JFileChooser.APPROVE_OPTION)
|
||||
return;
|
||||
|
||||
// Create File
|
||||
int no = MPaySelectionCheck.exportToFile(m_checks, fc.getSelectedFile());
|
||||
ADialog.info(m_WindowNo, this, "Saved",
|
||||
ADialog.info(m_WindowNo, panel, "Saved",
|
||||
fc.getSelectedFile().getAbsolutePath() + "\n"
|
||||
+ Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
|
||||
|
||||
if (ADialog.ask(m_WindowNo, this, "VPayPrintSuccess?"))
|
||||
if (ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?"))
|
||||
{
|
||||
// int lastDocumentNo =
|
||||
MPaySelectionCheck.confirmPrint (m_checks, m_batch);
|
||||
|
@ -500,7 +385,7 @@ public class VPayPrint extends CPanel
|
|||
if (!getChecks(PaymentRule))
|
||||
return;
|
||||
|
||||
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
boolean somethingPrinted = false;
|
||||
boolean directPrint = !Ini.isPropertyBool(Ini.P_PRINTPREVIEW);
|
||||
|
@ -509,13 +394,13 @@ public class VPayPrint extends CPanel
|
|||
{
|
||||
MPaySelectionCheck check = m_checks[i];
|
||||
// ReportCtrl will check BankAccountDoc for PrintFormat
|
||||
boolean ok = ReportCtl.startDocumentPrint(ReportEngine.CHECK, check.get_ID(), null, Env.getWindowNo(this), directPrint);
|
||||
boolean ok = ReportCtl.startDocumentPrint(ReportEngine.CHECK, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
|
||||
if (!somethingPrinted && ok)
|
||||
somethingPrinted = true;
|
||||
}
|
||||
|
||||
// Confirm Print and Update BankAccountDoc
|
||||
if (somethingPrinted && ADialog.ask(m_WindowNo, this, "VPayPrintSuccess?"))
|
||||
if (somethingPrinted && ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?"))
|
||||
{
|
||||
int lastDocumentNo = MPaySelectionCheck.confirmPrint (m_checks, m_batch);
|
||||
if (lastDocumentNo != 0)
|
||||
|
@ -528,16 +413,16 @@ public class VPayPrint extends CPanel
|
|||
}
|
||||
} // confirm
|
||||
|
||||
if (ADialog.ask(m_WindowNo, this, "VPayPrintPrintRemittance"))
|
||||
if (ADialog.ask(m_WindowNo, panel, "VPayPrintPrintRemittance"))
|
||||
{
|
||||
for (int i = 0; i < m_checks.length; i++)
|
||||
{
|
||||
MPaySelectionCheck check = m_checks[i];
|
||||
ReportCtl.startDocumentPrint(ReportEngine.REMITTANCE, check.get_ID(), null, Env.getWindowNo(this), directPrint);
|
||||
ReportCtl.startDocumentPrint(ReportEngine.REMITTANCE, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
|
||||
}
|
||||
} // remittance
|
||||
|
||||
this.setCursor(Cursor.getDefaultCursor());
|
||||
panel.setCursor(Cursor.getDefaultCursor());
|
||||
dispose();
|
||||
} // cmd_print
|
||||
|
||||
|
@ -553,7 +438,7 @@ public class VPayPrint extends CPanel
|
|||
if (fPaySelect.getSelectedIndex() == -1 || m_C_BankAccount_ID == -1
|
||||
|| fPaymentRule.getSelectedIndex() == -1 || fDocumentNo.getValue() == null)
|
||||
{
|
||||
ADialog.error(m_WindowNo, this, "VPayPrintNoRecords",
|
||||
ADialog.error(m_WindowNo, panel, "VPayPrintNoRecords",
|
||||
"(" + Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID") + "=0)");
|
||||
return false;
|
||||
}
|
||||
|
@ -564,16 +449,16 @@ public class VPayPrint extends CPanel
|
|||
|
||||
log.config("C_PaySelection_ID=" + C_PaySelection_ID + ", PaymentRule=" + PaymentRule + ", DocumentNo=" + startDocumentNo);
|
||||
//
|
||||
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
// get Slecetions
|
||||
m_checks = MPaySelectionCheck.get(C_PaySelection_ID, PaymentRule, startDocumentNo, null);
|
||||
|
||||
this.setCursor(Cursor.getDefaultCursor());
|
||||
panel.setCursor(Cursor.getDefaultCursor());
|
||||
//
|
||||
if (m_checks == null || m_checks.length == 0)
|
||||
{
|
||||
ADialog.error(m_WindowNo, this, "VPayPrintNoRecords",
|
||||
ADialog.error(m_WindowNo, panel, "VPayPrintNoRecords",
|
||||
"(" + Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID") + " #0");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -25,13 +25,8 @@ import java.awt.GridBagLayout;
|
|||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Properties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
@ -43,33 +38,23 @@ import javax.swing.event.TableModelListener;
|
|||
import org.compiere.apps.ADialog;
|
||||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.apps.ConfirmPanel;
|
||||
import org.compiere.apps.IProcessParameter;
|
||||
import org.compiere.apps.ProcessCtl;
|
||||
import org.compiere.apps.ProcessParameter;
|
||||
import org.compiere.apps.ProcessParameterPanel;
|
||||
import org.compiere.grid.ed.VCheckBox;
|
||||
import org.compiere.grid.ed.VComboBox;
|
||||
import org.compiere.grid.ed.VDate;
|
||||
import org.compiere.minigrid.ColumnInfo;
|
||||
import org.compiere.minigrid.IDColumn;
|
||||
import org.compiere.minigrid.MiniTable;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MLookupInfo;
|
||||
import org.compiere.model.MPaySelection;
|
||||
import org.compiere.model.MPaySelectionLine;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.X_C_Order;
|
||||
import org.compiere.model.X_C_PaySelection;
|
||||
import org.compiere.plaf.CompiereColor;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.swing.CLabel;
|
||||
import org.compiere.swing.CPanel;
|
||||
import org.compiere.util.ASyncProcess;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
|
||||
/**
|
||||
|
@ -81,8 +66,7 @@ import org.compiere.util.ValueNamePair;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VPaySelect.java,v 1.2 2008/07/11 08:20:12 cruiz Exp $
|
||||
*/
|
||||
public class VPaySelect extends CPanel
|
||||
implements FormPanel, ActionListener, TableModelListener, ASyncProcess
|
||||
public class VPaySelect extends PaySelect implements FormPanel, ActionListener, TableModelListener, ASyncProcess
|
||||
{
|
||||
/** @todo withholding */
|
||||
|
||||
|
@ -91,6 +75,8 @@ public class VPaySelect extends CPanel
|
|||
*/
|
||||
private static final long serialVersionUID = 2872767371244295934L;
|
||||
|
||||
private CPanel panel = new CPanel();
|
||||
|
||||
/**
|
||||
* Initialize Panel
|
||||
* @param WindowNo window
|
||||
|
@ -114,28 +100,9 @@ public class VPaySelect extends CPanel
|
|||
}
|
||||
} // init
|
||||
|
||||
/** Window No */
|
||||
private int m_WindowNo = 0;
|
||||
/** FormFrame */
|
||||
private FormFrame m_frame;
|
||||
|
||||
/** Format */
|
||||
private DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||
/** Bank Balance */
|
||||
private BigDecimal m_bankBalance = new BigDecimal(0.0);
|
||||
/** 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;
|
||||
/** Payment Selection */
|
||||
private MPaySelection m_ps = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VPaySelect.class);
|
||||
|
||||
//
|
||||
private CPanel mainPanel = new CPanel();
|
||||
private BorderLayout mainLayout = new BorderLayout();
|
||||
|
@ -171,7 +138,7 @@ public class VPaySelect extends CPanel
|
|||
*/
|
||||
private void jbInit() throws Exception
|
||||
{
|
||||
CompiereColor.setBackground(this);
|
||||
CompiereColor.setBackground(panel);
|
||||
//
|
||||
mainPanel.setLayout(mainLayout);
|
||||
parameterPanel.setLayout(parameterLayout);
|
||||
|
@ -254,157 +221,30 @@ public class VPaySelect extends CPanel
|
|||
*/
|
||||
private void dynInit()
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
//
|
||||
m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
// Bank Account Info
|
||||
String sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT ba.C_BankAccount_ID," // 1
|
||||
+ "b.Name || ' ' || ba.AccountNo AS Name," // 2
|
||||
+ "ba.C_Currency_ID, c.ISO_Code," // 3..4
|
||||
+ "ba.CurrentBalance " // 5
|
||||
+ "FROM C_Bank b, C_BankAccount ba, C_Currency c "
|
||||
+ "WHERE b.C_Bank_ID=ba.C_Bank_ID"
|
||||
+ " AND ba.C_Currency_ID=c.C_Currency_ID "
|
||||
+ " AND EXISTS (SELECT * FROM C_BankAccountDoc d WHERE d.C_BankAccount_ID=ba.C_BankAccount_ID) "
|
||||
+ "ORDER BY 2",
|
||||
"b", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RW);
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
boolean transfers = false;
|
||||
BankInfo bi = new BankInfo (rs.getInt(1), rs.getInt(3),
|
||||
rs.getString(2), rs.getString(4),
|
||||
rs.getBigDecimal(5), transfers);
|
||||
fieldBankAccount.addItem(bi);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
ArrayList<BankInfo> bankAccountData = getBankAccountData();
|
||||
for(BankInfo bi : bankAccountData)
|
||||
fieldBankAccount.addItem(bi);
|
||||
|
||||
if (fieldBankAccount.getItemCount() == 0)
|
||||
ADialog.error(m_WindowNo, this, "VPaySelectNoBank");
|
||||
ADialog.error(m_WindowNo, panel, "VPaySelectNoBank");
|
||||
else
|
||||
fieldBankAccount.setSelectedIndex(0);
|
||||
|
||||
// Optional BusinessPartner with unpaid AP Invoices
|
||||
KeyNamePair pp = new KeyNamePair(0, "");
|
||||
fieldBPartner.addItem(pp);
|
||||
sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT bp.C_BPartner_ID, bp.Name FROM C_BPartner bp", "bp",
|
||||
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO)
|
||||
+ " AND EXISTS (SELECT * FROM C_Invoice i WHERE bp.C_BPartner_ID=i.C_BPartner_ID"
|
||||
// X_C_Order.PAYMENTRULE_DirectDebit
|
||||
+ " AND (i.IsSOTrx='N' OR (i.IsSOTrx='Y' AND i.PaymentRule='D'))"
|
||||
+ " AND i.IsPaid<>'Y') "
|
||||
+ "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));
|
||||
fieldBPartner.addItem(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
ArrayList<KeyNamePair> bpartnerData = getBPartnerData();
|
||||
for(KeyNamePair pp : bpartnerData)
|
||||
fieldBPartner.addItem(pp);
|
||||
fieldBPartner.setSelectedIndex(0);
|
||||
|
||||
/**Document type**/
|
||||
try
|
||||
{
|
||||
sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT doc.c_doctype_id,doc.name FROM c_doctype doc WHERE doc.ad_client_id = ? AND doc.docbasetype in ('API','APC') ORDER BY 2", "doc",
|
||||
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
||||
ArrayList<KeyNamePair> docTypeData = getDocTypeData();
|
||||
for(KeyNamePair pp : docTypeData)
|
||||
fieldDtype.addItem(pp);
|
||||
|
||||
KeyNamePair dt = new KeyNamePair(0, "");
|
||||
fieldDtype.addItem(dt);
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_AD_Client_ID); // Client
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
prepareTable(miniTable);
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
dt = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||
fieldDtype.addItem(dt);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
/** prepare MiniTable
|
||||
*
|
||||
SELECT i.C_Invoice_ID, i.DateInvoiced+p.NetDays AS DateDue,
|
||||
bp.Name, i.DocumentNo, c.ISO_Code, i.GrandTotal,
|
||||
paymentTermDiscount(i.GrandTotal, i.C_PaymentTerm_ID, i.DateInvoiced, SysDate) AS Discount,
|
||||
SysDate-paymentTermDueDays(i.C_PaymentTerm_ID,i.DateInvoiced) AS DiscountDate,
|
||||
i.GrandTotal-paymentTermDiscount(i.GrandTotal,i.C_PaymentTerm_ID,i.DateInvoiced,SysDate) AS DueAmount,
|
||||
currencyConvert(i.GrandTotal-paymentTermDiscount(i.GrandTotal,i.C_PaymentTerm_ID,i.DateInvoiced,SysDate,null),
|
||||
i.C_Currency_ID,xx100,SysDate) AS PayAmt
|
||||
FROM C_Invoice i, C_BPartner bp, C_Currency c, C_PaymentTerm p
|
||||
WHERE i.IsSOTrx='N'
|
||||
AND i.C_BPartner_ID=bp.C_BPartner_ID
|
||||
AND i.C_Currency_ID=c.C_Currency_ID
|
||||
AND i.C_PaymentTerm_ID=p.C_PaymentTerm_ID
|
||||
AND i.DocStatus IN ('CO','CL')
|
||||
ORDER BY 2,3
|
||||
*/
|
||||
|
||||
m_sql = miniTable.prepareTable(new ColumnInfo[] {
|
||||
// 0..4
|
||||
new ColumnInfo(" ", "i.C_Invoice_ID", IDColumn.class, false, false, null),
|
||||
new ColumnInfo(Msg.translate(ctx, "DueDate"), "paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DateDue", Timestamp.class, true, true, null),
|
||||
new ColumnInfo(Msg.translate(ctx, "C_BPartner_ID"), "bp.Name", KeyNamePair.class, true, false, "i.C_BPartner_ID"),
|
||||
new ColumnInfo(Msg.translate(ctx, "DocumentNo"), "i.DocumentNo", String.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "C_Currency_ID"), "c.ISO_Code", KeyNamePair.class, true, false, "i.C_Currency_ID"),
|
||||
// 5..9
|
||||
new ColumnInfo(Msg.translate(ctx, "GrandTotal"), "i.GrandTotal", BigDecimal.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "DiscountAmt"), "paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?)", BigDecimal.class),
|
||||
new ColumnInfo(Msg.getMsg(ctx, "DiscountDate"), "SysDate-paymentTermDueDays(i.C_PaymentTerm_ID,i.DateInvoiced,SysDate)", Timestamp.class),
|
||||
new ColumnInfo(Msg.getMsg(ctx, "AmountDue"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class),
|
||||
new ColumnInfo(Msg.getMsg(ctx, "AmountPay"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)-paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class)
|
||||
},
|
||||
// FROM
|
||||
"C_Invoice_v i"
|
||||
+ " INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID)"
|
||||
+ " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID)"
|
||||
+ " INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID)",
|
||||
// WHERE
|
||||
"i.IsSOTrx=? AND IsPaid='N'"
|
||||
// Different Payment Selection
|
||||
+ " AND NOT EXISTS (SELECT * FROM C_PaySelectionLine psl"
|
||||
+ " WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND psl.C_PaySelectionCheck_ID IS NOT NULL"
|
||||
+ " AND psl.C_PaySelectionCheck_ID NOT IN "
|
||||
+ " (SELECT psc.C_PaySelectionCheck_ID FROM C_PaySelectionCheck psc, C_Payment p"
|
||||
+ " WHERE psc.C_PaySelectionCheck_ID = psl.C_PaySelectionCheck_ID"
|
||||
+ " AND psc.C_Payment_ID = p.C_Payment_ID"
|
||||
+ " AND p.DocStatus IN ('RE','VO')))"
|
||||
+ " AND i.DocStatus IN ('CO','CL')"
|
||||
+ " AND i.AD_Client_ID=?", // additional where & order in loadTableInfo()
|
||||
true, "i");
|
||||
//
|
||||
miniTable.getModel().addTableModelListener(this);
|
||||
//
|
||||
fieldPayDate.setMandatory(true);
|
||||
fieldPayDate.setValue(new Timestamp(System.currentTimeMillis()));
|
||||
|
||||
} // dynInit
|
||||
|
||||
/**
|
||||
|
@ -417,37 +257,14 @@ public class VPaySelect extends CPanel
|
|||
return;
|
||||
labelCurrency.setText(bi.Currency);
|
||||
labelBalance.setText(m_format.format(bi.Balance));
|
||||
m_bankBalance = bi.Balance;
|
||||
|
||||
// PaymentRule
|
||||
fieldPaymentRule.removeAllItems();
|
||||
int AD_Reference_ID = 195; // MLookupInfo.getAD_Reference_ID("All_Payment Rule");
|
||||
Language language = Env.getLanguage(Env.getCtx());
|
||||
MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
|
||||
String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY"))
|
||||
+ " AND " + info.KeyColumn
|
||||
+ " IN (SELECT PaymentRule FROM C_BankAccountDoc WHERE C_BankAccount_ID=?) "
|
||||
+ info.Query.substring(info.Query.indexOf(" ORDER BY"));
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, bi.C_BankAccount_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
ValueNamePair vp = null;
|
||||
while (rs.next())
|
||||
{
|
||||
vp = new ValueNamePair(rs.getString(2), rs.getString(3)); // returns also not active
|
||||
fieldPaymentRule.addItem(vp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
fieldPaymentRule.setSelectedIndex(0);
|
||||
|
||||
ArrayList<ValueNamePair> paymentRuleData = getPaymentRuleData(bi);
|
||||
for(ValueNamePair vp : paymentRuleData)
|
||||
fieldPaymentRule.addItem(vp);
|
||||
fieldPaymentRule.setSelectedIndex(0);
|
||||
} // loadBankInfo
|
||||
|
||||
/**
|
||||
|
@ -455,70 +272,18 @@ public class VPaySelect extends CPanel
|
|||
*/
|
||||
private void loadTableInfo()
|
||||
{
|
||||
log.config("");
|
||||
// not yet initialized
|
||||
if (m_sql == null)
|
||||
return;
|
||||
|
||||
String sql = m_sql;
|
||||
// Parameters
|
||||
Timestamp payDate = (Timestamp)fieldPayDate.getValue();
|
||||
miniTable.setColorCompare(payDate);
|
||||
log.config("PayDate=" + payDate);
|
||||
BankInfo bi = (BankInfo)fieldBankAccount.getSelectedItem();
|
||||
//
|
||||
String isSOTrx = "N";
|
||||
ValueNamePair vp = (ValueNamePair)fieldPaymentRule.getSelectedItem();
|
||||
if (vp != null && X_C_Order.PAYMENTRULE_DirectDebit.equals(vp.getValue()))
|
||||
{
|
||||
isSOTrx = "Y";
|
||||
sql += " AND i.PaymentRule='" + X_C_Order.PAYMENTRULE_DirectDebit + "'";
|
||||
}
|
||||
//
|
||||
if (onlyDue.isSelected())
|
||||
sql += " AND paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) <= ?";
|
||||
//
|
||||
KeyNamePair pp = (KeyNamePair)fieldBPartner.getSelectedItem();
|
||||
int C_BPartner_ID = pp.getKey();
|
||||
if (C_BPartner_ID != 0)
|
||||
sql += " AND i.C_BPartner_ID=?";
|
||||
//Document Type
|
||||
KeyNamePair dt = (KeyNamePair)fieldDtype.getSelectedItem();
|
||||
int c_doctype_id = dt.getKey();
|
||||
if (c_doctype_id != 0)
|
||||
sql += " AND i.c_doctype_id =?";
|
||||
sql += " ORDER BY 2,3";
|
||||
|
||||
log.finest(sql + " - C_Currency_ID=" + bi.C_Currency_ID + ", C_BPartner_ID=" + C_BPartner_ID + ", C_doctype_id=" + c_doctype_id );
|
||||
// Get Open Invoices
|
||||
try
|
||||
{
|
||||
int index = 1;
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setTimestamp(index++, payDate); // DiscountAmt
|
||||
pstmt.setInt(index++, bi.C_Currency_ID); // DueAmt
|
||||
pstmt.setTimestamp(index++, payDate);
|
||||
pstmt.setTimestamp(index++, payDate); // PayAmt
|
||||
pstmt.setInt(index++, bi.C_Currency_ID);
|
||||
pstmt.setTimestamp(index++, payDate);
|
||||
pstmt.setString(index++, isSOTrx); // IsSOTrx
|
||||
pstmt.setInt(index++, m_AD_Client_ID); // Client
|
||||
if (onlyDue.isSelected())
|
||||
pstmt.setTimestamp(index++, payDate);
|
||||
if (C_BPartner_ID != 0)
|
||||
pstmt.setInt(index++, C_BPartner_ID);
|
||||
if (c_doctype_id != 0) //Document type
|
||||
pstmt.setInt(index++, c_doctype_id );
|
||||
//
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
miniTable.loadTable(rs);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
BankInfo bi = (BankInfo)fieldBankAccount.getSelectedItem();
|
||||
|
||||
ValueNamePair paymentRule = (ValueNamePair)fieldPaymentRule.getSelectedItem();
|
||||
KeyNamePair bpartner = (KeyNamePair)fieldBPartner.getSelectedItem();
|
||||
KeyNamePair docType = (KeyNamePair)fieldDtype.getSelectedItem();
|
||||
|
||||
loadTableInfo(bi, payDate, paymentRule, onlyDue.isSelected(), bpartner, docType, miniTable);
|
||||
|
||||
calculateSelection();
|
||||
} // loadTableInfo
|
||||
|
||||
|
@ -575,29 +340,7 @@ public class VPaySelect extends CPanel
|
|||
*/
|
||||
public void calculateSelection()
|
||||
{
|
||||
m_noSelected = 0;
|
||||
BigDecimal invoiceAmt = new BigDecimal(0.0);
|
||||
|
||||
int rows = miniTable.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
IDColumn id = (IDColumn)miniTable.getModel().getValueAt(i, 0);
|
||||
if (id.isSelected())
|
||||
{
|
||||
BigDecimal amt = (BigDecimal)miniTable.getModel().getValueAt(i, 9);
|
||||
if (amt != null)
|
||||
invoiceAmt = invoiceAmt.add(amt);
|
||||
m_noSelected++;
|
||||
}
|
||||
}
|
||||
|
||||
// Information
|
||||
BigDecimal remaining = m_bankBalance.subtract(invoiceAmt);
|
||||
StringBuffer info = new StringBuffer();
|
||||
info.append(m_noSelected).append(" ").append(Msg.getMsg(Env.getCtx(), "Selected")).append(" - ");
|
||||
info.append(m_format.format(invoiceAmt)).append(", ");
|
||||
info.append(Msg.getMsg(Env.getCtx(), "Remaining")).append(" ").append(m_format.format(remaining));
|
||||
dataStatus.setText(info.toString());
|
||||
dataStatus.setText(calculateSelection(miniTable));
|
||||
//
|
||||
bGenerate.setEnabled(m_noSelected != 0);
|
||||
} // calculateSelection
|
||||
|
@ -607,12 +350,6 @@ public class VPaySelect extends CPanel
|
|||
*/
|
||||
private void generatePaySelect()
|
||||
{
|
||||
log.info("");
|
||||
// String trxName Trx.createTrxName("PaySelect");
|
||||
// Trx trx = Trx.get(trxName, true); trx needs to be committed too
|
||||
String trxName = null;
|
||||
Trx trx = null;
|
||||
//
|
||||
miniTable.stopEditor(true);
|
||||
if (miniTable.getRowCount() == 0)
|
||||
return;
|
||||
|
@ -621,54 +358,17 @@ public class VPaySelect extends CPanel
|
|||
if (m_noSelected == 0)
|
||||
return;
|
||||
|
||||
String PaymentRule = ((ValueNamePair)fieldPaymentRule.getSelectedItem()).getValue();
|
||||
String msg = generatePaySelect(miniTable, (ValueNamePair) fieldPaymentRule.getSelectedItem(),
|
||||
fieldPayDate.getTimestamp(), (BankInfo)fieldBankAccount.getSelectedItem());
|
||||
|
||||
// Create Header
|
||||
m_ps = new MPaySelection(Env.getCtx(), 0, trxName);
|
||||
m_ps.setName (Msg.getMsg(Env.getCtx(), "VPaySelect")
|
||||
+ " - " + ((ValueNamePair)fieldPaymentRule.getSelectedItem()).getName()
|
||||
+ " - " + fieldPayDate.getTimestamp());
|
||||
m_ps.setPayDate (fieldPayDate.getTimestamp());
|
||||
BankInfo bi = (BankInfo)fieldBankAccount.getSelectedItem();
|
||||
m_ps.setC_BankAccount_ID(bi.C_BankAccount_ID);
|
||||
m_ps.setIsApproved(true);
|
||||
if (!m_ps.save())
|
||||
if(msg != null && msg.length() > 0)
|
||||
{
|
||||
ADialog.error(m_WindowNo, this, "SaveError", Msg.translate(Env.getCtx(), "C_PaySelection_ID"));
|
||||
m_ps = null;
|
||||
ADialog.error(m_WindowNo, panel, "SaveError", msg);
|
||||
return;
|
||||
}
|
||||
log.config(m_ps.toString());
|
||||
|
||||
// Create Lines
|
||||
int rows = miniTable.getRowCount();
|
||||
int line = 0;
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
IDColumn id = (IDColumn)miniTable.getModel().getValueAt(i, 0);
|
||||
if (id.isSelected())
|
||||
{
|
||||
line += 10;
|
||||
MPaySelectionLine psl = new MPaySelectionLine (m_ps, line, PaymentRule);
|
||||
int C_Invoice_ID = id.getRecord_ID().intValue();
|
||||
BigDecimal OpenAmt = (BigDecimal)miniTable.getModel().getValueAt(i, 8);
|
||||
BigDecimal PayAmt = (BigDecimal)miniTable.getModel().getValueAt(i, 9);
|
||||
boolean isSOTrx = false;
|
||||
//
|
||||
psl.setInvoice(C_Invoice_ID, isSOTrx,
|
||||
OpenAmt, PayAmt, OpenAmt.subtract(PayAmt));
|
||||
if (!psl.save(trxName))
|
||||
{
|
||||
ADialog.error(m_WindowNo, this, "SaveError", Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID"));
|
||||
return;
|
||||
}
|
||||
log.fine("C_Invoice_ID=" + C_Invoice_ID + ", PayAmt=" + PayAmt);
|
||||
}
|
||||
} // for all rows in table
|
||||
|
||||
|
||||
// Ask to Post it
|
||||
if (!ADialog.ask(m_WindowNo, this, "VPaySelectGenerate?", "(" + m_ps.getName() + ")"))
|
||||
if (!ADialog.ask(m_WindowNo, panel, "VPaySelectGenerate?", "(" + m_ps.getName() + ")"))
|
||||
return;
|
||||
|
||||
// Prepare Process
|
||||
|
@ -678,8 +378,9 @@ public class VPaySelect extends CPanel
|
|||
pi.setAD_User_ID (Env.getAD_User_ID(Env.getCtx()));
|
||||
pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));
|
||||
|
||||
ProcessParameterPanel pp = new ProcessParameterPanel(m_WindowNo, pi);
|
||||
// Execute Process
|
||||
ProcessCtl.process(this, m_WindowNo, pi, trx);
|
||||
ProcessCtl.process(this, m_WindowNo, (IProcessParameter) pp, pi, trx);
|
||||
// ProcessCtl worker = new ProcessCtl(this, pi, trx);
|
||||
// worker.start(); // complete tasks in unlockUI
|
||||
} // generatePaySelect
|
||||
|
@ -691,7 +392,7 @@ public class VPaySelect extends CPanel
|
|||
*/
|
||||
public void lockUI (ProcessInfo pi)
|
||||
{
|
||||
this.setEnabled(false);
|
||||
panel.setEnabled(false);
|
||||
m_isLocked = true;
|
||||
} // lockUI
|
||||
|
||||
|
@ -705,7 +406,7 @@ public class VPaySelect extends CPanel
|
|||
// this.setEnabled(true);
|
||||
// m_isLocked = false;
|
||||
// Ask to Print it // Window is disposed
|
||||
if (!ADialog.ask(0, this, "VPaySelectPrint?", "(" + pi.getSummary() + ")"))
|
||||
if (!ADialog.ask(0, panel, "VPaySelectPrint?", "(" + pi.getSummary() + ")"))
|
||||
return;
|
||||
|
||||
// Start PayPrint
|
||||
|
@ -720,7 +421,7 @@ public class VPaySelect extends CPanel
|
|||
}
|
||||
//
|
||||
ff.pack();
|
||||
this.setVisible(false);
|
||||
panel.setVisible(false);
|
||||
AEnv.addToWindowManager(ff);
|
||||
AEnv.showCenterScreen(ff);
|
||||
this.dispose();
|
||||
|
@ -744,46 +445,4 @@ public class VPaySelect extends CPanel
|
|||
{
|
||||
log.config("-");
|
||||
} // executeASync
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Bank Account Info
|
||||
*/
|
||||
public class BankInfo
|
||||
{
|
||||
/**
|
||||
* BankInfo
|
||||
* @param newC_BankAccount_ID
|
||||
* @param newC_Currency_ID
|
||||
* @param newName
|
||||
* @param newCurrency
|
||||
* @param newBalance
|
||||
* @param newTransfers
|
||||
*/
|
||||
public BankInfo (int newC_BankAccount_ID, int newC_Currency_ID,
|
||||
String newName, String newCurrency, BigDecimal newBalance, boolean newTransfers)
|
||||
{
|
||||
C_BankAccount_ID = newC_BankAccount_ID;
|
||||
C_Currency_ID = newC_Currency_ID;
|
||||
Name = newName;
|
||||
Currency = newCurrency;
|
||||
Balance = newBalance;
|
||||
}
|
||||
int C_BankAccount_ID;
|
||||
int C_Currency_ID;
|
||||
String Name;
|
||||
String Currency;
|
||||
BigDecimal Balance;
|
||||
boolean Transfers;
|
||||
|
||||
/**
|
||||
* to String
|
||||
* @return info
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
} // BankInfo
|
||||
|
||||
} // VPaySelect
|
||||
|
|
|
@ -22,8 +22,7 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.DefaultListModel;
|
||||
|
@ -36,20 +35,13 @@ import javax.swing.event.ListSelectionEvent;
|
|||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import org.compiere.grid.tree.VTreePanel;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MTree;
|
||||
import org.compiere.model.MTreeNode;
|
||||
import org.compiere.model.MTree_Node;
|
||||
import org.compiere.model.MTree_NodeBP;
|
||||
import org.compiere.model.MTree_NodeMM;
|
||||
import org.compiere.model.MTree_NodePR;
|
||||
import org.compiere.swing.CButton;
|
||||
import org.compiere.swing.CCheckBox;
|
||||
import org.compiere.swing.CComboBox;
|
||||
import org.compiere.swing.CLabel;
|
||||
import org.compiere.swing.CPanel;
|
||||
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;
|
||||
|
@ -60,22 +52,18 @@ import org.compiere.util.Msg;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VTreeMaintenance.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class VTreeMaintenance extends CPanel
|
||||
public class VTreeMaintenance extends TreeMaintenance
|
||||
implements FormPanel, ActionListener, ListSelectionListener, PropertyChangeListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3679450924195670486L;
|
||||
/** Window No */
|
||||
private int m_WindowNo = 0;
|
||||
|
||||
private CPanel panel = new CPanel();
|
||||
|
||||
/** FormFrame */
|
||||
private FormFrame m_frame;
|
||||
/** Active Tree */
|
||||
private MTree m_tree;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VTreeMaintenance.class);
|
||||
|
||||
|
||||
private BorderLayout mainLayout = new BorderLayout ();
|
||||
private CPanel northPanel = new CPanel ();
|
||||
|
@ -108,7 +96,7 @@ public class VTreeMaintenance extends CPanel
|
|||
{
|
||||
preInit();
|
||||
jbInit ();
|
||||
frame.getContentPane().add(this, BorderLayout.CENTER);
|
||||
frame.getContentPane().add(panel, BorderLayout.CENTER);
|
||||
// frame.getContentPane().add(statusBar, BorderLayout.SOUTH);
|
||||
action_loadTree();
|
||||
}
|
||||
|
@ -123,10 +111,7 @@ public class VTreeMaintenance extends CPanel
|
|||
*/
|
||||
private void preInit()
|
||||
{
|
||||
KeyNamePair[] trees = DB.getKeyNamePairs(MRole.getDefault().addAccessSQL(
|
||||
"SELECT AD_Tree_ID, Name FROM AD_Tree WHERE TreeType NOT IN ('BB','PC') ORDER BY 2",
|
||||
"AD_Tree", MRole.SQL_NOTQUALIFIED, MRole.SQL_RW), false);
|
||||
treeField = new CComboBox(trees);
|
||||
treeField = new CComboBox(getTreeData());
|
||||
treeField.addActionListener(this);
|
||||
//
|
||||
centerTree = new VTreePanel (m_WindowNo, false, true);
|
||||
|
@ -139,7 +124,7 @@ public class VTreeMaintenance extends CPanel
|
|||
*/
|
||||
private void jbInit () throws Exception
|
||||
{
|
||||
this.setLayout (mainLayout);
|
||||
panel.setLayout (mainLayout);
|
||||
treeLabel.setText (Msg.translate(Env.getCtx(), "AD_Tree_ID"));
|
||||
cbAllNodes.setEnabled (false);
|
||||
cbAllNodes.setText (Msg.translate(Env.getCtx(), "IsAllNodes"));
|
||||
|
@ -155,7 +140,7 @@ public class VTreeMaintenance extends CPanel
|
|||
northPanel.setLayout (northLayout);
|
||||
northLayout.setAlignment (FlowLayout.LEFT);
|
||||
//
|
||||
this.add (northPanel, BorderLayout.NORTH);
|
||||
panel.add (northPanel, BorderLayout.NORTH);
|
||||
northPanel.add (treeLabel, null);
|
||||
northPanel.add (treeField, null);
|
||||
northPanel.add (cbAllNodes, null);
|
||||
|
@ -165,7 +150,7 @@ public class VTreeMaintenance extends CPanel
|
|||
northPanel.add (bDelete, null);
|
||||
northPanel.add (bDeleteAll, null);
|
||||
//
|
||||
this.add (splitPane, BorderLayout.CENTER);
|
||||
panel.add (splitPane, BorderLayout.CENTER);
|
||||
splitPane.add (centerTree, JSplitPane.LEFT);
|
||||
splitPane.add (new JScrollPane(centerList), JSplitPane.RIGHT);
|
||||
centerList.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
|
||||
|
@ -221,43 +206,13 @@ public class VTreeMaintenance extends CPanel
|
|||
bDelete.setEnabled(!m_tree.isAllNodes());
|
||||
bDeleteAll.setEnabled(!m_tree.isAllNodes());
|
||||
//
|
||||
String fromClause = m_tree.getSourceTableName(false); // fully qualified
|
||||
String columnNameX = m_tree.getSourceTableName(true);
|
||||
String actionColor = m_tree.getActionColorName();
|
||||
|
||||
// List
|
||||
DefaultListModel model = new DefaultListModel();
|
||||
String sql = "SELECT t." + columnNameX
|
||||
+ "_ID,t.Name,t.Description,t.IsSummary,"
|
||||
+ actionColor
|
||||
+ " FROM " + fromClause
|
||||
// + " WHERE t.IsActive='Y'" // R/O
|
||||
+ " ORDER BY 2";
|
||||
sql = MRole.getDefault().addAccessSQL(sql,
|
||||
"t", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
||||
log.config(sql);
|
||||
//
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
ListItem item = new ListItem(rs.getInt(1), rs.getString(2),
|
||||
rs.getString(3), "Y".equals(rs.getString(4)), rs.getString(5));
|
||||
model.addElement(item);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
ArrayList<ListItem> items = getTreeItemData();
|
||||
for(ListItem item : items)
|
||||
model.addElement(item);
|
||||
|
||||
// List
|
||||
log.config("#" + model.getSize());
|
||||
centerList.setModel(model);
|
||||
|
@ -319,27 +274,9 @@ public class VTreeMaintenance extends CPanel
|
|||
{
|
||||
centerTree.nodeChanged(true, item.id, item.name,
|
||||
item.description, item.isSummary, item.imageIndicator);
|
||||
|
||||
// May cause Error if in tree
|
||||
if (m_tree.isProduct())
|
||||
{
|
||||
MTree_NodePR node = new MTree_NodePR (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
else if (m_tree.isBPartner())
|
||||
{
|
||||
MTree_NodeBP node = new MTree_NodeBP (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
else if (m_tree.isMenu())
|
||||
{
|
||||
MTree_NodeMM node = new MTree_NodeMM (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
MTree_Node node = new MTree_Node (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
addNode(item);
|
||||
}
|
||||
} // action_treeAdd
|
||||
|
||||
|
@ -354,31 +291,8 @@ public class VTreeMaintenance extends CPanel
|
|||
{
|
||||
centerTree.nodeChanged(false, item.id, item.name,
|
||||
item.description, item.isSummary, item.imageIndicator);
|
||||
//
|
||||
if (m_tree.isProduct())
|
||||
{
|
||||
MTree_NodePR node = MTree_NodePR.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
else if (m_tree.isBPartner())
|
||||
{
|
||||
MTree_NodeBP node = MTree_NodeBP.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
else if (m_tree.isMenu())
|
||||
{
|
||||
MTree_NodeMM node = MTree_NodeMM.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
MTree_Node node = MTree_Node.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
|
||||
deleteNode(item);
|
||||
}
|
||||
} // action_treeDelete
|
||||
|
||||
|
@ -415,52 +329,4 @@ public class VTreeMaintenance extends CPanel
|
|||
}
|
||||
} // action_treeDeleteAll
|
||||
|
||||
/**************************************************************************
|
||||
* Tree Maintenance List Item
|
||||
*/
|
||||
class ListItem
|
||||
{
|
||||
/**
|
||||
* ListItem
|
||||
* @param ID
|
||||
* @param Name
|
||||
* @param Description
|
||||
* @param summary
|
||||
* @param ImageIndicator
|
||||
*/
|
||||
public ListItem (int ID, String Name, String Description,
|
||||
boolean summary, String ImageIndicator)
|
||||
{
|
||||
id = ID;
|
||||
name = Name;
|
||||
description = Description;
|
||||
isSummary = summary;
|
||||
imageIndicator = ImageIndicator;
|
||||
} // ListItem
|
||||
|
||||
/** ID */
|
||||
public int id;
|
||||
/** Name */
|
||||
public String name;
|
||||
/** Description */
|
||||
public String description;
|
||||
/** Summary */
|
||||
public boolean isSummary;
|
||||
/** Indicator */
|
||||
public String imageIndicator; // Menu - Action
|
||||
|
||||
/**
|
||||
* To String
|
||||
* @return String Representation
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
String retValue = name;
|
||||
if (description != null && description.length() > 0)
|
||||
retValue += " (" + description + ")";
|
||||
return retValue;
|
||||
} // toString
|
||||
|
||||
} // ListItem
|
||||
|
||||
} // VTreeMaintenance
|
||||
|
|
|
@ -25,9 +25,6 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.VetoableChangeListener;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
@ -42,17 +39,11 @@ import org.compiere.grid.GridController;
|
|||
import org.compiere.grid.ed.VDate;
|
||||
import org.compiere.grid.ed.VLocator;
|
||||
import org.compiere.grid.ed.VLookup;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.GridWindow;
|
||||
import org.compiere.model.GridWindowVO;
|
||||
import org.compiere.model.MLocatorLookup;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.plaf.CompiereColor;
|
||||
import org.compiere.swing.CPanel;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
@ -63,28 +54,21 @@ import org.compiere.util.Msg;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VTrxMaterial.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class VTrxMaterial extends CPanel
|
||||
public class VTrxMaterial extends TrxMaterial
|
||||
implements FormPanel, ActionListener, VetoableChangeListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 7435309844451490697L;
|
||||
/** Window No */
|
||||
private int m_WindowNo = 0;
|
||||
|
||||
private CPanel panel = new CPanel();
|
||||
|
||||
/** FormFrame */
|
||||
private FormFrame m_frame;
|
||||
/** Grid Controller */
|
||||
private GridController m_gridController;
|
||||
|
||||
/** GridController */
|
||||
private GridController m_gridController = null;
|
||||
/** MWindow */
|
||||
private GridWindow m_mWindow = null;
|
||||
/** MTab pointer */
|
||||
private GridTab m_mTab = null;
|
||||
|
||||
private MQuery m_staticQuery = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VTrxMaterial.class);
|
||||
//
|
||||
private CPanel mainPanel = new CPanel();
|
||||
private BorderLayout mainLayout = new BorderLayout();
|
||||
|
@ -139,7 +123,7 @@ public class VTrxMaterial extends CPanel
|
|||
*/
|
||||
void jbInit() throws Exception
|
||||
{
|
||||
CompiereColor.setBackground(this);
|
||||
CompiereColor.setBackground(panel);
|
||||
mainPanel.setLayout(mainLayout);
|
||||
mainLayout.setVgap(10);
|
||||
parameterPanel.setLayout(parameterLayout);
|
||||
|
@ -220,24 +204,10 @@ public class VTrxMaterial extends CPanel
|
|||
*/
|
||||
private void dynInit()
|
||||
{
|
||||
m_staticQuery = new MQuery();
|
||||
m_staticQuery.addRestriction("AD_Client_ID", MQuery.EQUAL, Env.getAD_Client_ID(Env.getCtx()));
|
||||
int AD_Window_ID = 223; // Hardcoded
|
||||
GridWindowVO wVO = AEnv.getMWindowVO (m_WindowNo, AD_Window_ID, 0);
|
||||
if (wVO == null)
|
||||
return;
|
||||
m_mWindow = new GridWindow (wVO);
|
||||
m_mTab = m_mWindow.getTab(0);
|
||||
m_mWindow.initTab(0);
|
||||
//
|
||||
super.dynInit(statusBar);
|
||||
m_gridController = new GridController();
|
||||
m_gridController.initGrid(m_mTab, true, m_WindowNo, null, null);
|
||||
mainPanel.add(m_gridController, BorderLayout.CENTER);
|
||||
//
|
||||
m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
|
||||
m_mTab.query(false);
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(" ");
|
||||
} // dynInit
|
||||
|
||||
|
||||
|
@ -300,144 +270,37 @@ public class VTrxMaterial extends CPanel
|
|||
*/
|
||||
private void refresh()
|
||||
{
|
||||
/**
|
||||
* Create Where Clause
|
||||
*/
|
||||
MQuery query = m_staticQuery.deepCopy();
|
||||
// Organization
|
||||
Object value = orgField.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
query.addRestriction("AD_Org_ID", MQuery.EQUAL, value);
|
||||
// Locator
|
||||
value = locatorField.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
query.addRestriction("M_Locator_ID", MQuery.EQUAL, value);
|
||||
// Product
|
||||
value = productField.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
query.addRestriction("M_Product_ID", MQuery.EQUAL, value);
|
||||
// MovementType
|
||||
value = mtypeField.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
query.addRestriction("MovementType", MQuery.EQUAL, value);
|
||||
// DateFrom
|
||||
Timestamp ts = (Timestamp)dateFField.getValue();
|
||||
if (ts != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.GREATER_EQUAL, ts);
|
||||
// DateTO
|
||||
ts = (Timestamp)dateTField.getValue();
|
||||
if (ts != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.LESS_EQUAL, ts);
|
||||
log.info( "VTrxMaterial.refresh query=" + query.toString());
|
||||
Object organization = orgField.getValue();
|
||||
Object locator = locatorField.getValue();
|
||||
Object product = productField.getValue();
|
||||
Object movementType = mtypeField.getValue();
|
||||
Timestamp movementDateFrom = (Timestamp)dateFField.getValue();
|
||||
Timestamp movementDateTo = (Timestamp)dateTField.getValue();
|
||||
|
||||
/**
|
||||
* Refresh/Requery
|
||||
*/
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "StartSearch"), false);
|
||||
//
|
||||
m_mTab.setQuery(query);
|
||||
m_mTab.query(false);
|
||||
//
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
int no = m_mTab.getRowCount();
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(Integer.toString(no));
|
||||
panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
refresh(organization, locator, product, movementType, movementDateFrom, movementDateTo, statusBar);
|
||||
panel.setCursor(Cursor.getDefaultCursor());
|
||||
} // refresh
|
||||
|
||||
/**
|
||||
* Zoom
|
||||
*/
|
||||
private void zoom()
|
||||
public void zoom()
|
||||
{
|
||||
log.info("");
|
||||
//
|
||||
int AD_Window_ID = 0;
|
||||
String ColumnName = null;
|
||||
String SQL = null;
|
||||
//
|
||||
int lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_InOutLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_InOutLine_ID=" + lineID);
|
||||
if (Env.getContext(Env.getCtx(), m_WindowNo, "MovementType").startsWith("C"))
|
||||
AD_Window_ID = 169; // Customer
|
||||
else
|
||||
AD_Window_ID = 184; // Vendor
|
||||
ColumnName = "M_InOut_ID";
|
||||
SQL = "SELECT M_InOut_ID FROM M_InOutLine WHERE M_InOutLine_ID=?";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_InventoryLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_InventoryLine_ID=" + lineID);
|
||||
AD_Window_ID = 168;
|
||||
ColumnName = "M_Inventory_ID";
|
||||
SQL = "SELECT M_Inventory_ID FROM M_InventoryLine WHERE M_InventoryLine_ID=?";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_MovementLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_MovementLine_ID=" + lineID);
|
||||
AD_Window_ID = 170;
|
||||
ColumnName = "M_Movement_ID";
|
||||
SQL = "SELECT M_Movement_ID FROM M_MovementLine WHERE M_MovementLine_ID=?";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_ProductionLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_ProductionLine_ID=" + lineID);
|
||||
AD_Window_ID = 191;
|
||||
ColumnName = "M_Production_ID";
|
||||
SQL = "SELECT M_Production_ID FROM M_ProductionLine WHERE M_ProductionLine_ID=?";
|
||||
}
|
||||
else
|
||||
log.fine("Not found WindowNo=" + m_WindowNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (AD_Window_ID == 0)
|
||||
return;
|
||||
|
||||
// Get Parent ID
|
||||
int parentID = 0;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
|
||||
pstmt.setInt(1, lineID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
parentID = rs.getInt(1);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, SQL, e);
|
||||
}
|
||||
MQuery query = MQuery.getEqualQuery(ColumnName, parentID);
|
||||
log.config("AD_Window_ID=" + AD_Window_ID + " - " + query);
|
||||
if (parentID == 0)
|
||||
log.log(Level.SEVERE, "No ParentValue - " + SQL + " - " + lineID);
|
||||
super.zoom();
|
||||
|
||||
// Zoom
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
AWindow frame = new AWindow();
|
||||
if (!frame.initWindow(AD_Window_ID, query))
|
||||
{
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
panel.setCursor(Cursor.getDefaultCursor());
|
||||
return;
|
||||
}
|
||||
AEnv.addToWindowManager(frame);
|
||||
AEnv.showCenterScreen(frame);
|
||||
frame = null;
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
panel.setCursor(Cursor.getDefaultCursor());
|
||||
} // zoom
|
||||
|
||||
} // VTrxMaterial
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
|
@ -31,20 +29,16 @@ import org.adempiere.webui.editor.WEditor;
|
|||
import org.adempiere.webui.editor.WSearchEditor;
|
||||
import org.adempiere.webui.editor.WTableDirEditor;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.panel.CustomForm;
|
||||
import org.adempiere.webui.panel.ICustomForm;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.compiere.apps.form.Merge;
|
||||
import org.compiere.model.Lookup;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.X_M_Cost;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
import org.zkoss.zk.au.out.AuEcho;
|
||||
import org.zkoss.zk.ui.Desktop;
|
||||
import org.zkoss.zk.ui.DesktopUnavailableException;
|
||||
|
@ -63,50 +57,18 @@ import org.zkoss.zkex.zul.South;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VMerge.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class WMerge extends ADForm
|
||||
implements EventListener
|
||||
public class WMerge extends Merge implements ICustomForm, EventListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5797395051958101596L;
|
||||
private int m_totalCount = 0;
|
||||
/** Error Log */
|
||||
private StringBuffer m_errorLog = new StringBuffer();
|
||||
/** Connection */
|
||||
//private Connection m_con = null;
|
||||
private Trx m_trx = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(WMerge.class);
|
||||
|
||||
static private String AD_ORG_ID = "AD_Org_ID";
|
||||
static private String C_BPARTNER_ID = "C_BPartner_ID";
|
||||
static private String AD_USER_ID = "AD_User_ID";
|
||||
static private String M_PRODUCT_ID = "M_Product_ID";
|
||||
private CustomForm form = new CustomForm();
|
||||
|
||||
/** Tables to delete (not update) for AD_Org */
|
||||
static private String[] s_delete_Org = new String[]
|
||||
{"AD_OrgInfo"};
|
||||
/** Tables to delete (not update) for AD_User */
|
||||
static private String[] s_delete_User = new String[]
|
||||
{"AD_User_Roles"};
|
||||
/** Tables to delete (not update) for C_BPartner */
|
||||
static private String[] s_delete_BPartner = new String[]
|
||||
{"C_BP_Employee_Acct", "C_BP_Vendor_Acct", "C_BP_Customer_Acct",
|
||||
"T_Aging"};
|
||||
/** Tables to delete (not update) for M_Product */
|
||||
static private String[] s_delete_Product = new String[]
|
||||
{"M_Product_PO", "M_Replenish", "T_Replenish",
|
||||
"M_ProductPrice", "M_Product_Costing",
|
||||
"M_Cost", // teo_sarca [ 1704554 ]
|
||||
"M_Product_Trl", "M_Product_Acct"}; // M_Storage
|
||||
|
||||
private String[] m_columnName = null;
|
||||
private Label[] m_label = null;
|
||||
private WEditor[] m_from = null;
|
||||
private WEditor[] m_to = null;
|
||||
private String[] m_deleteTables = null;
|
||||
|
||||
|
||||
private Borderlayout mainLayout = new Borderlayout();
|
||||
private Panel CenterPanel = new Panel();
|
||||
|
@ -120,7 +82,7 @@ public class WMerge extends ADForm
|
|||
/**
|
||||
* Initialize Panel
|
||||
*/
|
||||
protected void initForm()
|
||||
public WMerge()
|
||||
{
|
||||
log.info( "VMerge.init - WinNo=" + m_WindowNo);
|
||||
try
|
||||
|
@ -184,7 +146,7 @@ public class WMerge extends ADForm
|
|||
*/
|
||||
void jbInit () throws Exception
|
||||
{
|
||||
this.appendChild (mainLayout);
|
||||
form.appendChild (mainLayout);
|
||||
mainLayout.setHeight("100%");
|
||||
mainLayout.setWidth("100%");
|
||||
//
|
||||
|
@ -275,25 +237,17 @@ public class WMerge extends ADForm
|
|||
|
||||
m_msg = Msg.getMsg(Env.getCtx(), "MergeFrom") + " = " + from_Info
|
||||
+ "\n" + Msg.getMsg(Env.getCtx(), "MergeTo") + " = " + to_Info;
|
||||
if (!FDialog.ask(m_WindowNo, this, "MergeQuestion", m_msg))
|
||||
if (!FDialog.ask(m_WindowNo, form, "MergeQuestion", m_msg))
|
||||
return;
|
||||
|
||||
// ** Update **
|
||||
if (columnName.equals(AD_ORG_ID))
|
||||
m_deleteTables = s_delete_Org;
|
||||
else if (columnName.equals(AD_USER_ID))
|
||||
m_deleteTables = s_delete_User;
|
||||
else if (columnName.equals(C_BPARTNER_ID))
|
||||
m_deleteTables = s_delete_BPartner;
|
||||
else if (columnName.equals(M_PRODUCT_ID))
|
||||
m_deleteTables = s_delete_Product;
|
||||
updateDeleteTable(columnName);
|
||||
|
||||
Clients.showBusy("Processing...", true);
|
||||
|
||||
if (!getDesktop().isServerPushEnabled())
|
||||
getDesktop().enableServerPush(true);
|
||||
if (!form.getDesktop().isServerPushEnabled())
|
||||
form.getDesktop().enableServerPush(true);
|
||||
|
||||
MergeRunnable runnable = new MergeRunnable(columnName, from_ID, to_ID, this.getDesktop());
|
||||
MergeRunnable runnable = new MergeRunnable(columnName, from_ID, to_ID, form.getDesktop());
|
||||
new Thread(runnable).start();
|
||||
|
||||
} // actionPerformed
|
||||
|
@ -318,7 +272,7 @@ public class WMerge extends ADForm
|
|||
postMerge(columnName, to_ID);
|
||||
} finally{
|
||||
Clients.showBusy(null, false);
|
||||
Clients.response(new AuEcho(WMerge.this, "onAfterProcess", null));
|
||||
Clients.response(new AuEcho(form, "onAfterProcess", null));
|
||||
//release full control of desktop
|
||||
Executions.deactivate(desktop);
|
||||
}
|
||||
|
@ -334,221 +288,20 @@ public class WMerge extends ADForm
|
|||
{
|
||||
if (m_success)
|
||||
{
|
||||
FDialog.info (m_WindowNo, this, "MergeSuccess",
|
||||
FDialog.info (m_WindowNo, form, "MergeSuccess",
|
||||
m_msg + " #" + m_totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
FDialog.error(m_WindowNo, this, "MergeError",
|
||||
FDialog.error(m_WindowNo, form, "MergeError",
|
||||
m_errorLog.toString());
|
||||
return;
|
||||
}
|
||||
dispose();
|
||||
}
|
||||
/**
|
||||
* Merge.
|
||||
* @param ColumnName column
|
||||
* @param from_ID from
|
||||
* @param to_ID to
|
||||
* @return true if merged
|
||||
*/
|
||||
private boolean merge (String ColumnName, int from_ID, int to_ID)
|
||||
|
||||
public ADForm getForm()
|
||||
{
|
||||
String TableName = ColumnName.substring(0, ColumnName.length()-3);
|
||||
log.config(ColumnName
|
||||
+ " - From=" + from_ID + ",To=" + to_ID);
|
||||
|
||||
boolean success = true;
|
||||
m_totalCount = 0;
|
||||
m_errorLog = new StringBuffer();
|
||||
String sql = "SELECT t.TableName, c.ColumnName "
|
||||
+ "FROM AD_Table t"
|
||||
+ " INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID) "
|
||||
+ "WHERE t.IsView='N'"
|
||||
+ " AND t.TableName NOT IN ('C_TaxDeclarationAcct')"
|
||||
+ " AND ("
|
||||
+ "(c.ColumnName=? AND c.IsKey='N')" // #1 - direct
|
||||
+ " OR "
|
||||
+ "c.AD_Reference_Value_ID IN " // Table Reference
|
||||
+ "(SELECT rt.AD_Reference_ID FROM AD_Ref_Table rt"
|
||||
+ " INNER JOIN AD_Column cc ON (rt.AD_Table_ID=cc.AD_Table_ID AND rt.AD_Key=cc.AD_Column_ID) "
|
||||
+ "WHERE cc.IsKey='Y' AND cc.ColumnName=?)" // #2
|
||||
+ ") "
|
||||
+ "ORDER BY t.LoadSeq DESC";
|
||||
PreparedStatement pstmt = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
m_trx = Trx.get(Trx.createTrxName("merge"), true);
|
||||
//
|
||||
pstmt = DB.prepareStatement(sql, Trx.createTrxName());
|
||||
pstmt.setString(1, ColumnName);
|
||||
pstmt.setString(2, ColumnName);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
String tName = rs.getString(1);
|
||||
String cName = rs.getString(2);
|
||||
if (!TableName.equals(tName)) // to be sure - sql should prevent it
|
||||
{
|
||||
int count = mergeTable (tName, cName, from_ID, to_ID);
|
||||
if (count < 0)
|
||||
success = false;
|
||||
else
|
||||
m_totalCount += count;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
//
|
||||
log.config("Success=" + success
|
||||
+ " - " + ColumnName + " - From=" + from_ID + ",To=" + to_ID);
|
||||
if (success)
|
||||
{
|
||||
sql = "DELETE " + TableName + " WHERE " + ColumnName + "=" + from_ID;
|
||||
|
||||
|
||||
|
||||
|
||||
if ( DB.executeUpdate(sql, m_trx.getTrxName()) < 0 )
|
||||
{
|
||||
m_errorLog.append(Env.NL).append("DELETE ").append(TableName)
|
||||
.append(" - ");
|
||||
success = false;
|
||||
log.config(m_errorLog.toString());
|
||||
m_trx.rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
if (success)
|
||||
m_trx.commit();
|
||||
else
|
||||
m_trx.rollback();
|
||||
|
||||
m_trx.close();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, ColumnName, ex);
|
||||
}
|
||||
// Cleanup
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
pstmt = null;
|
||||
return success;
|
||||
} // merge
|
||||
|
||||
|
||||
/**
|
||||
* Merge Table
|
||||
* @param TableName table
|
||||
* @param ColumnName column
|
||||
* @param from_ID from
|
||||
* @param to_ID to
|
||||
* @return -1 for error or number of changes
|
||||
*/
|
||||
private int mergeTable (String TableName, String ColumnName, int from_ID, int to_ID)
|
||||
{
|
||||
log.fine(TableName + "." + ColumnName + " - From=" + from_ID + ",To=" + to_ID);
|
||||
String sql = "UPDATE " + TableName
|
||||
+ " SET " + ColumnName + "=" + to_ID
|
||||
+ " WHERE " + ColumnName + "=" + from_ID;
|
||||
boolean delete = false;
|
||||
for (int i = 0; i < m_deleteTables.length; i++)
|
||||
{
|
||||
if (m_deleteTables[i].equals(TableName))
|
||||
{
|
||||
delete = true;
|
||||
sql = "DELETE " + TableName + " WHERE " + ColumnName + "=" + from_ID;
|
||||
}
|
||||
}
|
||||
// Delete newly created MCost records - teo_sarca [ 1704554 ]
|
||||
if (delete && X_M_Cost.Table_Name.equals(TableName) && M_PRODUCT_ID.equals(ColumnName))
|
||||
{
|
||||
sql += " AND " + X_M_Cost.COLUMNNAME_CurrentCostPrice + "=0"
|
||||
+ " AND " + X_M_Cost.COLUMNNAME_CurrentQty + "=0"
|
||||
+ " AND " + X_M_Cost.COLUMNNAME_CumulatedAmt + "=0"
|
||||
+ " AND " + X_M_Cost.COLUMNNAME_CumulatedQty + "=0";
|
||||
}
|
||||
|
||||
int count = DB.executeUpdate(sql, m_trx.getTrxName());
|
||||
|
||||
|
||||
if ( count < 0 )
|
||||
{
|
||||
|
||||
count = -1;
|
||||
m_errorLog.append(Env.NL)
|
||||
.append(delete ? "DELETE " : "UPDATE ")
|
||||
.append(TableName).append(" - ")
|
||||
.append(" - ").append(sql);
|
||||
log.config(m_errorLog.toString());
|
||||
m_trx.rollback();
|
||||
|
||||
}
|
||||
log.fine(count
|
||||
+ (delete ? " -Delete- " : " -Update- ") + TableName);
|
||||
|
||||
|
||||
return count;
|
||||
} // mergeTable
|
||||
|
||||
/**
|
||||
* Post Merge
|
||||
* @param ColumnName column name
|
||||
* @param to_ID ID
|
||||
*/
|
||||
private void postMerge (String ColumnName, int to_ID)
|
||||
{
|
||||
if (ColumnName.equals(AD_ORG_ID))
|
||||
{
|
||||
|
||||
}
|
||||
else if (ColumnName.equals(AD_USER_ID))
|
||||
{
|
||||
|
||||
}
|
||||
else if (ColumnName.equals(C_BPARTNER_ID))
|
||||
{
|
||||
MBPartner bp = new MBPartner (Env.getCtx(), to_ID, null);
|
||||
if (bp.get_ID() != 0)
|
||||
{
|
||||
MPayment[] payments = MPayment.getOfBPartner(Env.getCtx(), bp.getC_BPartner_ID(), null);
|
||||
for (int i = 0; i < payments.length; i++)
|
||||
{
|
||||
MPayment payment = payments[i];
|
||||
if (payment.testAllocation())
|
||||
payment.save();
|
||||
}
|
||||
MInvoice[] invoices = MInvoice.getOfBPartner(Env.getCtx(), bp.getC_BPartner_ID(), null);
|
||||
for (int i = 0; i < invoices.length; i++)
|
||||
{
|
||||
MInvoice invoice = invoices[i];
|
||||
if (invoice.testAllocation())
|
||||
invoice.save();
|
||||
}
|
||||
bp.setTotalOpenBalance();
|
||||
bp.setActualLifeTimeValue();
|
||||
bp.save();
|
||||
}
|
||||
}
|
||||
else if (ColumnName.equals(M_PRODUCT_ID))
|
||||
{
|
||||
|
||||
}
|
||||
} // postMerge
|
||||
|
||||
|
||||
return form;
|
||||
}
|
||||
} // VMerge
|
||||
|
|
|
@ -18,9 +18,6 @@ package org.adempiere.webui.apps.form;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
@ -39,19 +36,18 @@ import org.adempiere.webui.component.Rows;
|
|||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.editor.WNumberEditor;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.panel.CustomForm;
|
||||
import org.adempiere.webui.panel.ICustomForm;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.adempiere.webui.window.SimplePDFViewer;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MLookupInfo;
|
||||
import org.compiere.apps.form.PayPrint;
|
||||
import org.compiere.model.MPaySelectionCheck;
|
||||
import org.compiere.model.MPaymentBatch;
|
||||
import org.compiere.print.ReportEngine;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
|
@ -67,18 +63,19 @@ import org.zkoss.zul.Filedownload;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VPayPrint.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class WPayPrint extends ADForm
|
||||
implements EventListener
|
||||
public class WPayPrint extends PayPrint implements ICustomForm, EventListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3005095685182033400L;
|
||||
|
||||
private CustomForm form = new CustomForm();
|
||||
|
||||
/**
|
||||
* Initialize Panel
|
||||
*/
|
||||
protected void initForm()
|
||||
public WPayPrint()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -87,7 +84,7 @@ public class WPayPrint extends ADForm
|
|||
Borderlayout contentLayout = new Borderlayout();
|
||||
contentLayout.setWidth("100%");
|
||||
contentLayout.setHeight("100%");
|
||||
this.appendChild(contentLayout);
|
||||
form.appendChild(contentLayout);
|
||||
Center center = new Center();
|
||||
contentLayout.appendChild(center);
|
||||
center.appendChild(centerPanel);
|
||||
|
@ -102,16 +99,6 @@ public class WPayPrint extends ADForm
|
|||
}
|
||||
} // init
|
||||
|
||||
/** Used Bank Account */
|
||||
private int m_C_BankAccount_ID = -1;
|
||||
|
||||
/** Payment Information */
|
||||
private MPaySelectionCheck[] m_checks = null;
|
||||
/** Payment Batch */
|
||||
private MPaymentBatch m_batch = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(WPayPrint.class);
|
||||
|
||||
// Static Variables
|
||||
private Panel centerPanel = new Panel();
|
||||
private ConfirmPanel southPanel = new ConfirmPanel(true, false, false, false, false, false, false);
|
||||
|
@ -195,6 +182,7 @@ public class WPayPrint extends ADForm
|
|||
row.appendChild(lNoPayments.rightAlign());
|
||||
row.appendChild(fNoPayments);
|
||||
|
||||
southPanel.getButton(ConfirmPanel.A_OK).setVisible(false);
|
||||
} // VPayPrint
|
||||
|
||||
/**
|
||||
|
@ -202,33 +190,12 @@ public class WPayPrint extends ADForm
|
|||
*/
|
||||
private void dynInit()
|
||||
{
|
||||
log.config("");
|
||||
int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
ArrayList<KeyNamePair> data = getPaySelectionData();
|
||||
for(KeyNamePair pp : data)
|
||||
fPaySelect.addItem(pp);
|
||||
|
||||
// Load PaySelect
|
||||
String sql = "SELECT C_PaySelection_ID, Name || ' - ' || TotalAmt FROM C_PaySelection "
|
||||
+ "WHERE AD_Client_ID=? AND Processed='Y' AND IsActive='Y'"
|
||||
+ "ORDER BY PayDate DESC";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, AD_Client_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
while (rs.next())
|
||||
{
|
||||
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
|
||||
fPaySelect.addItem(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if (fPaySelect.getItemCount() == 0)
|
||||
FDialog.info(m_WindowNo, this, "VPayPrintNoRecords");
|
||||
FDialog.info(m_WindowNo, form, "VPayPrintNoRecords");
|
||||
else
|
||||
{
|
||||
fPaySelect.setSelectedIndex(0);
|
||||
|
@ -299,41 +266,12 @@ public class WPayPrint extends ADForm
|
|||
|
||||
// load Banks from PaySelectLine
|
||||
int C_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
|
||||
m_C_BankAccount_ID = -1;
|
||||
String sql = "SELECT ps.C_BankAccount_ID, b.Name || ' ' || ba.AccountNo," // 1..2
|
||||
+ " c.ISO_Code, CurrentBalance " // 3..4
|
||||
+ "FROM C_PaySelection ps"
|
||||
+ " INNER JOIN C_BankAccount ba ON (ps.C_BankAccount_ID=ba.C_BankAccount_ID)"
|
||||
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID)"
|
||||
+ " INNER JOIN C_Currency c ON (ba.C_Currency_ID=c.C_Currency_ID) "
|
||||
+ "WHERE ps.C_PaySelection_ID=? AND ps.Processed='Y' AND ba.IsActive='Y'";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_PaySelection_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
m_C_BankAccount_ID = rs.getInt(1);
|
||||
fBank.setText(rs.getString(2));
|
||||
fCurrency.setText(rs.getString(3));
|
||||
fBalance.setValue(rs.getBigDecimal(4));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_C_BankAccount_ID = -1;
|
||||
fBank.setText("");
|
||||
fCurrency.setText("");
|
||||
fBalance.setValue(Env.ZERO);
|
||||
log.log(Level.SEVERE, "No active BankAccount for C_PaySelection_ID=" + C_PaySelection_ID);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
loadPaySelectInfo(C_PaySelection_ID);
|
||||
|
||||
fBank.setText(bank);
|
||||
fCurrency.setText(currency);
|
||||
fBalance.setValue(balance);
|
||||
|
||||
loadPaymentRule();
|
||||
} // loadPaySelectInfo
|
||||
|
||||
|
@ -346,38 +284,17 @@ public class WPayPrint extends ADForm
|
|||
if (m_C_BankAccount_ID == -1)
|
||||
return;
|
||||
|
||||
fPaymentRule.removeAllItems();
|
||||
|
||||
// load PaymentRule for Bank
|
||||
int C_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
|
||||
fPaymentRule.removeAllItems();
|
||||
int AD_Reference_ID = 195; // MLookupInfo.getAD_Reference_ID("All_Payment Rule");
|
||||
Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
|
||||
MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
|
||||
String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY"))
|
||||
+ " AND " + info.KeyColumn
|
||||
+ " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) "
|
||||
+ info.Query.substring(info.Query.indexOf(" ORDER BY"));
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_PaySelection_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
while (rs.next())
|
||||
{
|
||||
ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
|
||||
fPaymentRule.addItem(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if (fPaymentRule.getItemCount() == 0)
|
||||
log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);
|
||||
else
|
||||
ArrayList<ValueNamePair> data = loadPaymentRule(C_PaySelection_ID);
|
||||
for(ValueNamePair pp : data)
|
||||
fPaymentRule.addItem(pp);
|
||||
|
||||
if (fPaymentRule.getItemCount() > 0)
|
||||
fPaymentRule.setSelectedIndex(0);
|
||||
|
||||
loadPaymentRuleInfo();
|
||||
} // loadPaymentRule
|
||||
|
||||
|
@ -396,52 +313,18 @@ public class WPayPrint extends ADForm
|
|||
fNoPayments.setText(" ");
|
||||
|
||||
int C_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
|
||||
String sql = "SELECT COUNT(*) "
|
||||
+ "FROM C_PaySelectionCheck "
|
||||
+ "WHERE C_PaySelection_ID=?";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_PaySelection_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
if (rs.next())
|
||||
fNoPayments.setText(String.valueOf(rs.getInt(1)));
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
String msg = loadPaymentRuleInfo(C_PaySelection_ID, PaymentRule);
|
||||
|
||||
if(noPayments != null)
|
||||
fNoPayments.setText(noPayments);
|
||||
|
||||
bProcess.setEnabled(PaymentRule.equals("T"));
|
||||
|
||||
// DocumentNo
|
||||
sql = "SELECT CurrentNext "
|
||||
+ "FROM C_BankAccountDoc "
|
||||
+ "WHERE C_BankAccount_ID=? AND PaymentRule=? AND IsActive='Y'";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_C_BankAccount_ID);
|
||||
pstmt.setString(2, PaymentRule);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
if (rs.next())
|
||||
fDocumentNo.setValue(new Integer(rs.getInt(1)));
|
||||
else
|
||||
{
|
||||
log.log(Level.SEVERE, "VPayPrint.loadPaymentRuleInfo - No active BankAccountDoc for C_BankAccount_ID="
|
||||
+ m_C_BankAccount_ID + " AND PaymentRule=" + PaymentRule);
|
||||
FDialog.error(m_WindowNo, this, "VPayPrintNoDoc");
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if(documentNo != null)
|
||||
fDocumentNo.setValue(documentNo);
|
||||
|
||||
if(msg != null && msg.length() > 0)
|
||||
FDialog.error(m_WindowNo, form, msg);
|
||||
} // loadPaymentRuleInfo
|
||||
|
||||
|
||||
|
@ -464,7 +347,7 @@ public class WPayPrint extends ADForm
|
|||
MPaySelectionCheck.exportToFile(m_checks, tempFile);
|
||||
Filedownload.save(new FileInputStream(tempFile), "plain/text", "paymentExport.txt");
|
||||
|
||||
if (FDialog.ask(m_WindowNo, this, "VPayPrintSuccess?"))
|
||||
if (FDialog.ask(m_WindowNo, form, "VPayPrintSuccess?"))
|
||||
{
|
||||
// int lastDocumentNo =
|
||||
MPaySelectionCheck.confirmPrint (m_checks, m_batch);
|
||||
|
@ -525,7 +408,7 @@ public class WPayPrint extends ADForm
|
|||
{
|
||||
File outFile = File.createTempFile("WPayPrint", null);
|
||||
AEnv.mergePdf(pdfList, outFile);
|
||||
chequeViewer = new SimplePDFViewer(this.getFormName(), new FileInputStream(outFile));
|
||||
chequeViewer = new SimplePDFViewer(form.getFormName(), new FileInputStream(outFile));
|
||||
chequeViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
||||
chequeViewer.setWidth("100%");
|
||||
}
|
||||
|
@ -547,7 +430,7 @@ public class WPayPrint extends ADForm
|
|||
}
|
||||
|
||||
SimplePDFViewer remitViewer = null;
|
||||
if (FDialog.ask(m_WindowNo, this, "VPayPrintPrintRemittance"))
|
||||
if (FDialog.ask(m_WindowNo, form, "VPayPrintPrintRemittance"))
|
||||
{
|
||||
pdfList = new ArrayList<File>();
|
||||
for (int i = 0; i < m_checks.length; i++)
|
||||
|
@ -571,7 +454,7 @@ public class WPayPrint extends ADForm
|
|||
File outFile = File.createTempFile("WPayPrint", null);
|
||||
AEnv.mergePdf(pdfList, outFile);
|
||||
String name = Msg.translate(Env.getCtx(), "Remittance");
|
||||
remitViewer = new SimplePDFViewer(this.getFormName() + " - " + name, new FileInputStream(outFile));
|
||||
remitViewer = new SimplePDFViewer(form.getFormName() + " - " + name, new FileInputStream(outFile));
|
||||
remitViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
||||
remitViewer.setWidth("100%");
|
||||
}
|
||||
|
@ -602,7 +485,7 @@ public class WPayPrint extends ADForm
|
|||
if (fPaySelect.getSelectedIndex() == -1 || m_C_BankAccount_ID == -1
|
||||
|| fPaymentRule.getSelectedIndex() == -1 || fDocumentNo.getValue() == null)
|
||||
{
|
||||
FDialog.error(m_WindowNo, this, "VPayPrintNoRecords",
|
||||
FDialog.error(m_WindowNo, form, "VPayPrintNoRecords",
|
||||
"(" + Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID") + "=0)");
|
||||
return false;
|
||||
}
|
||||
|
@ -619,7 +502,7 @@ public class WPayPrint extends ADForm
|
|||
//
|
||||
if (m_checks == null || m_checks.length == 0)
|
||||
{
|
||||
FDialog.error(m_WindowNo, this, "VPayPrintNoRecords",
|
||||
FDialog.error(m_WindowNo, form, "VPayPrintNoRecords",
|
||||
"(" + Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID") + " #0");
|
||||
return false;
|
||||
}
|
||||
|
@ -627,4 +510,8 @@ public class WPayPrint extends ADForm
|
|||
return true;
|
||||
} // getChecks
|
||||
|
||||
public ADForm getForm() {
|
||||
return form;
|
||||
}
|
||||
|
||||
} // PayPrint
|
||||
|
|
|
@ -18,13 +18,8 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Properties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.apps.ProcessModalDialog;
|
||||
|
@ -44,29 +39,18 @@ import org.adempiere.webui.editor.WDateEditor;
|
|||
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.ICustomForm;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.compiere.minigrid.ColumnInfo;
|
||||
import org.compiere.minigrid.IDColumn;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MLookupInfo;
|
||||
import org.compiere.model.MPaySelection;
|
||||
import org.compiere.model.MPaySelectionLine;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.X_C_Order;
|
||||
import org.compiere.apps.form.PaySelect;
|
||||
import org.compiere.model.X_C_PaySelection;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.ASyncProcess;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
import org.zkoss.zk.au.out.AuEcho;
|
||||
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
@ -87,8 +71,8 @@ import org.zkoss.zul.Space;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VPaySelect.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class WPaySelect extends ADForm
|
||||
implements EventListener, WTableModelListener, ASyncProcess
|
||||
public class WPaySelect extends PaySelect
|
||||
implements ICustomForm, EventListener, WTableModelListener, ASyncProcess
|
||||
{
|
||||
/** @todo withholding */
|
||||
|
||||
|
@ -97,38 +81,7 @@ public class WPaySelect extends ADForm
|
|||
*/
|
||||
private static final long serialVersionUID = -6031404894392912610L;
|
||||
|
||||
/**
|
||||
* Initialize Panel
|
||||
*/
|
||||
protected void initForm()
|
||||
{
|
||||
try
|
||||
{
|
||||
zkInit();
|
||||
dynInit();
|
||||
southPanel.appendChild(new Separator());
|
||||
southPanel.appendChild(commandPanel);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // init
|
||||
|
||||
/** Format */
|
||||
private DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||
/** Bank Balance */
|
||||
private BigDecimal m_bankBalance = new BigDecimal(0.0);
|
||||
/** 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;
|
||||
/** Payment Selection */
|
||||
private MPaySelection m_ps = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(WPaySelect.class);
|
||||
private CustomForm form = new CustomForm();
|
||||
|
||||
//
|
||||
private Panel mainPanel = new Panel();
|
||||
|
@ -153,10 +106,32 @@ public class WPaySelect extends ADForm
|
|||
private WDateEditor fieldPayDate = new WDateEditor();
|
||||
private Label labelPaymentRule = new Label();
|
||||
private Listbox fieldPaymentRule = ListboxFactory.newDropdownListbox();
|
||||
private Label labelDtype = new Label();
|
||||
private Listbox fieldDtype = ListboxFactory.newDropdownListbox();
|
||||
private Panel southPanel;
|
||||
private ProcessInfo m_pi;
|
||||
private boolean m_isLock;
|
||||
|
||||
/**
|
||||
* Initialize Panel
|
||||
*/
|
||||
public WPaySelect()
|
||||
{
|
||||
try
|
||||
{
|
||||
zkInit();
|
||||
dynInit();
|
||||
|
||||
loadBankInfo();
|
||||
southPanel.appendChild(new Separator());
|
||||
southPanel.appendChild(commandPanel);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // init
|
||||
|
||||
/**
|
||||
* Static Init
|
||||
* @throws Exception
|
||||
|
@ -164,7 +139,7 @@ public class WPaySelect extends ADForm
|
|||
private void zkInit() throws Exception
|
||||
{
|
||||
//
|
||||
this.appendChild(mainPanel);
|
||||
form.appendChild(mainPanel);
|
||||
mainPanel.appendChild(mainLayout);
|
||||
mainPanel.setStyle("width: 100%; height: 100%; padding: 0; margin: 0");
|
||||
mainLayout.setHeight("100%");
|
||||
|
@ -179,6 +154,8 @@ public class WPaySelect extends ADForm
|
|||
labelPayDate.setText(Msg.translate(Env.getCtx(), "PayDate"));
|
||||
labelPaymentRule.setText(Msg.translate(Env.getCtx(), "PaymentRule"));
|
||||
fieldPaymentRule.addActionListener(this);
|
||||
labelDtype.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
|
||||
fieldDtype.addActionListener(this);
|
||||
//
|
||||
labelBankBalance.setText(Msg.translate(Env.getCtx(), "CurrentBalance"));
|
||||
labelBalance.setText("0");
|
||||
|
@ -212,6 +189,13 @@ public class WPaySelect extends ADForm
|
|||
row.appendChild(onlyDue);
|
||||
row.appendChild(new Space());
|
||||
|
||||
row = rows.newRow();
|
||||
row.appendChild(labelDtype.rightAlign());
|
||||
row.appendChild(fieldDtype);
|
||||
row.appendChild(new Space());
|
||||
row.appendChild(new Space());
|
||||
row.appendChild(new Space());
|
||||
|
||||
row = rows.newRow();
|
||||
row.appendChild(labelPayDate.rightAlign());
|
||||
row.appendChild(fieldPayDate.getComponent());
|
||||
|
@ -230,6 +214,7 @@ public class WPaySelect extends ADForm
|
|||
center.appendChild(miniTable);
|
||||
//
|
||||
commandPanel.addButton(bGenerate);
|
||||
commandPanel.getButton(ConfirmPanel.A_OK).setVisible(false);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
|
@ -240,127 +225,30 @@ public class WPaySelect extends ADForm
|
|||
*/
|
||||
private void dynInit()
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
ArrayList<BankInfo> bankAccountData = getBankAccountData();
|
||||
for(BankInfo bi : bankAccountData)
|
||||
fieldBankAccount.appendItem(bi.toString(), bi);
|
||||
|
||||
// Bank Account Info
|
||||
String sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT ba.C_BankAccount_ID," // 1
|
||||
+ "b.Name || ' ' || ba.AccountNo AS Name," // 2
|
||||
+ "ba.C_Currency_ID, c.ISO_Code," // 3..4
|
||||
+ "ba.CurrentBalance " // 5
|
||||
+ "FROM C_Bank b, C_BankAccount ba, C_Currency c "
|
||||
+ "WHERE b.C_Bank_ID=ba.C_Bank_ID"
|
||||
+ " AND ba.C_Currency_ID=c.C_Currency_ID "
|
||||
+ " AND EXISTS (SELECT * FROM C_BankAccountDoc d WHERE d.C_BankAccount_ID=ba.C_BankAccount_ID) "
|
||||
+ "ORDER BY 2",
|
||||
"b", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RW);
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
boolean transfers = false;
|
||||
BankInfo bi = new BankInfo (rs.getInt(1), rs.getInt(3),
|
||||
rs.getString(2), rs.getString(4),
|
||||
rs.getBigDecimal(5), transfers);
|
||||
fieldBankAccount.appendItem(bi.toString(), bi);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if (fieldBankAccount.getItemCount() == 0)
|
||||
FDialog.error(m_WindowNo, this, "VPaySelectNoBank");
|
||||
FDialog.error(m_WindowNo, form, "VPaySelectNoBank");
|
||||
else
|
||||
fieldBankAccount.setSelectedIndex(0);
|
||||
loadBankInfo();
|
||||
|
||||
// Optional BusinessPartner with unpaid AP Invoices
|
||||
KeyNamePair pp = new KeyNamePair(0, "");
|
||||
fieldBPartner.addItem(pp);
|
||||
sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT bp.C_BPartner_ID, bp.Name FROM C_BPartner bp", "bp",
|
||||
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO)
|
||||
+ " AND EXISTS (SELECT * FROM C_Invoice i WHERE bp.C_BPartner_ID=i.C_BPartner_ID"
|
||||
// X_C_Order.PAYMENTRULE_DirectDebit
|
||||
+ " AND (i.IsSOTrx='N' OR (i.IsSOTrx='Y' AND i.PaymentRule='D'))"
|
||||
+ " AND i.IsPaid<>'Y') "
|
||||
+ "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));
|
||||
fieldBPartner.addItem(pp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
ArrayList<KeyNamePair> bpartnerData = getBPartnerData();
|
||||
for(KeyNamePair pp : bpartnerData)
|
||||
fieldBPartner.appendItem(pp.getName(), pp);
|
||||
fieldBPartner.setSelectedIndex(0);
|
||||
|
||||
/** prepare MiniTable
|
||||
*
|
||||
SELECT i.C_Invoice_ID, i.DateInvoiced+p.NetDays AS DateDue,
|
||||
bp.Name, i.DocumentNo, c.ISO_Code, i.GrandTotal,
|
||||
paymentTermDiscount(i.GrandTotal, i.C_PaymentTerm_ID, i.DateInvoiced, SysDate) AS Discount,
|
||||
SysDate-paymentTermDueDays(i.C_PaymentTerm_ID,i.DateInvoiced) AS DiscountDate,
|
||||
i.GrandTotal-paymentTermDiscount(i.GrandTotal,i.C_PaymentTerm_ID,i.DateInvoiced,SysDate) AS DueAmount,
|
||||
currencyConvert(i.GrandTotal-paymentTermDiscount(i.GrandTotal,i.C_PaymentTerm_ID,i.DateInvoiced,SysDate,null),
|
||||
i.C_Currency_ID,xx100,SysDate) AS PayAmt
|
||||
FROM C_Invoice i, C_BPartner bp, C_Currency c, C_PaymentTerm p
|
||||
WHERE i.IsSOTrx='N'
|
||||
AND i.C_BPartner_ID=bp.C_BPartner_ID
|
||||
AND i.C_Currency_ID=c.C_Currency_ID
|
||||
AND i.C_PaymentTerm_ID=p.C_PaymentTerm_ID
|
||||
AND i.DocStatus IN ('CO','CL')
|
||||
ORDER BY 2,3
|
||||
*/
|
||||
ArrayList<KeyNamePair> docTypeData = getDocTypeData();
|
||||
for(KeyNamePair pp : docTypeData)
|
||||
fieldDtype.appendItem(pp.getName(), pp);
|
||||
|
||||
prepareTable(miniTable);
|
||||
|
||||
m_sql = miniTable.prepareTable(new ColumnInfo[] {
|
||||
// 0..4
|
||||
new ColumnInfo(" ", "i.C_Invoice_ID", IDColumn.class, false, false, null),
|
||||
new ColumnInfo(Msg.translate(ctx, "DueDate"), "paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DateDue", Timestamp.class, true, true, null),
|
||||
new ColumnInfo(Msg.translate(ctx, "C_BPartner_ID"), "bp.Name", KeyNamePair.class, true, false, "i.C_BPartner_ID"),
|
||||
new ColumnInfo(Msg.translate(ctx, "DocumentNo"), "i.DocumentNo", String.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "C_Currency_ID"), "c.ISO_Code", KeyNamePair.class, true, false, "i.C_Currency_ID"),
|
||||
// 5..9
|
||||
new ColumnInfo(Msg.translate(ctx, "GrandTotal"), "i.GrandTotal", BigDecimal.class),
|
||||
new ColumnInfo(Msg.translate(ctx, "DiscountAmt"), "paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?)", BigDecimal.class),
|
||||
new ColumnInfo(Msg.getMsg(ctx, "DiscountDate"), "SysDate-paymentTermDueDays(i.C_PaymentTerm_ID,i.DateInvoiced,SysDate)", Timestamp.class),
|
||||
new ColumnInfo(Msg.getMsg(ctx, "AmountDue"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class),
|
||||
new ColumnInfo(Msg.getMsg(ctx, "AmountPay"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)-paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class)
|
||||
},
|
||||
// FROM
|
||||
"C_Invoice_v i"
|
||||
+ " INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID)"
|
||||
+ " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID)"
|
||||
+ " INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID)",
|
||||
// WHERE
|
||||
"i.IsSOTrx=? AND IsPaid='N'"
|
||||
// Different Payment Selection
|
||||
+ " AND NOT EXISTS (SELECT * FROM C_PaySelectionLine psl"
|
||||
+ " WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND psl.C_PaySelectionCheck_ID IS NOT NULL)"
|
||||
+ " AND i.DocStatus IN ('CO','CL')"
|
||||
+ " AND i.AD_Client_ID=?", // additional where & order in loadTableInfo()
|
||||
true, "i");
|
||||
//
|
||||
miniTable.getModel().addTableModelListener(this);
|
||||
//
|
||||
fieldPayDate.setMandatory(true);
|
||||
fieldPayDate.setValue(new Timestamp(System.currentTimeMillis()));
|
||||
//
|
||||
m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
} // dynInit
|
||||
|
||||
/**
|
||||
|
@ -373,37 +261,14 @@ public class WPaySelect extends ADForm
|
|||
return;
|
||||
labelCurrency.setText(bi.Currency);
|
||||
labelBalance.setText(m_format.format(bi.Balance));
|
||||
m_bankBalance = bi.Balance;
|
||||
|
||||
// PaymentRule
|
||||
fieldPaymentRule.removeAllItems();
|
||||
int AD_Reference_ID = 195; // MLookupInfo.getAD_Reference_ID("All_Payment Rule");
|
||||
Language language = Env.getLanguage(Env.getCtx());
|
||||
MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
|
||||
String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY"))
|
||||
+ " AND " + info.KeyColumn
|
||||
+ " IN (SELECT PaymentRule FROM C_BankAccountDoc WHERE C_BankAccount_ID=?) "
|
||||
+ info.Query.substring(info.Query.indexOf(" ORDER BY"));
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, bi.C_BankAccount_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
ValueNamePair vp = null;
|
||||
while (rs.next())
|
||||
{
|
||||
vp = new ValueNamePair(rs.getString(2), rs.getString(3)); // returns also not active
|
||||
fieldPaymentRule.addItem(vp);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
fieldPaymentRule.setSelectedIndex(0);
|
||||
|
||||
ArrayList<ValueNamePair> paymentRuleData = getPaymentRuleData(bi);
|
||||
for(ValueNamePair vp : paymentRuleData)
|
||||
fieldPaymentRule.appendItem(vp.getName(), vp);
|
||||
fieldPaymentRule.setSelectedIndex(0);
|
||||
} // loadBankInfo
|
||||
|
||||
/**
|
||||
|
@ -411,64 +276,18 @@ public class WPaySelect extends ADForm
|
|||
*/
|
||||
private void loadTableInfo()
|
||||
{
|
||||
log.config("");
|
||||
// not yet initialized
|
||||
if (m_sql == null)
|
||||
return;
|
||||
|
||||
String sql = m_sql;
|
||||
// Parameters
|
||||
Timestamp payDate = (Timestamp)fieldPayDate.getValue();
|
||||
miniTable.setColorCompare(payDate);
|
||||
log.config("PayDate=" + payDate);
|
||||
BankInfo bi = (BankInfo)fieldBankAccount.getSelectedItem().getValue();
|
||||
//
|
||||
String isSOTrx = "N";
|
||||
ValueNamePair vp = (ValueNamePair)fieldPaymentRule.getSelectedItem().toValueNamePair();
|
||||
if (vp != null && X_C_Order.PAYMENTRULE_DirectDebit.equals(vp.getValue()))
|
||||
{
|
||||
isSOTrx = "Y";
|
||||
sql += " AND i.PaymentRule='" + X_C_Order.PAYMENTRULE_DirectDebit + "'";
|
||||
}
|
||||
//
|
||||
if (onlyDue.isSelected())
|
||||
sql += " AND paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) <= ?";
|
||||
//
|
||||
KeyNamePair pp = (KeyNamePair)fieldBPartner.getSelectedItem().toKeyNamePair();
|
||||
int C_BPartner_ID = pp.getKey();
|
||||
if (C_BPartner_ID != 0)
|
||||
sql += " AND i.C_BPartner_ID=?";
|
||||
sql += " ORDER BY 2,3";
|
||||
//
|
||||
log.finest(sql + " - C_Currecny_ID=" + bi.C_Currency_ID + ", C_BPartner_ID=" + C_BPartner_ID);
|
||||
|
||||
// Get Open Invoices
|
||||
try
|
||||
{
|
||||
int index = 1;
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setTimestamp(index++, payDate); // DiscountAmt
|
||||
pstmt.setInt(index++, bi.C_Currency_ID); // DueAmt
|
||||
pstmt.setTimestamp(index++, payDate);
|
||||
pstmt.setTimestamp(index++, payDate); // PayAmt
|
||||
pstmt.setInt(index++, bi.C_Currency_ID);
|
||||
pstmt.setTimestamp(index++, payDate);
|
||||
pstmt.setString(index++, isSOTrx); // IsSOTrx
|
||||
pstmt.setInt(index++, m_AD_Client_ID); // Client
|
||||
if (onlyDue.isSelected())
|
||||
pstmt.setTimestamp(index++, payDate);
|
||||
if (C_BPartner_ID != 0)
|
||||
pstmt.setInt(index++, C_BPartner_ID);
|
||||
//
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
miniTable.loadTable(rs);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
BankInfo bi = (BankInfo)fieldBankAccount.getSelectedItem().getValue();
|
||||
|
||||
ValueNamePair paymentRule = (ValueNamePair) fieldPaymentRule.getSelectedItem().getValue();
|
||||
KeyNamePair bpartner = (KeyNamePair) fieldBPartner.getSelectedItem().getValue();
|
||||
KeyNamePair docType = (KeyNamePair) fieldDtype.getSelectedItem().getValue();
|
||||
|
||||
loadTableInfo(bi, payDate, paymentRule, onlyDue.isSelected(), bpartner, docType, miniTable);
|
||||
|
||||
calculateSelection();
|
||||
} // loadTableInfo
|
||||
|
||||
|
@ -501,7 +320,7 @@ public class WPaySelect extends ADForm
|
|||
dispose();
|
||||
|
||||
// Update Open Invoices
|
||||
else if (e.getTarget() == fieldBPartner || e.getTarget() == bRefresh)
|
||||
else if (e.getTarget() == fieldBPartner || e.getTarget() == bRefresh || e.getTarget() == fieldDtype)
|
||||
loadTableInfo();
|
||||
|
||||
} // actionPerformed
|
||||
|
@ -522,29 +341,7 @@ public class WPaySelect extends ADForm
|
|||
*/
|
||||
public void calculateSelection()
|
||||
{
|
||||
m_noSelected = 0;
|
||||
BigDecimal invoiceAmt = new BigDecimal(0.0);
|
||||
|
||||
int rows = miniTable.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
IDColumn id = (IDColumn)miniTable.getModel().getValueAt(i, 0);
|
||||
if (id.isSelected())
|
||||
{
|
||||
BigDecimal amt = (BigDecimal)miniTable.getModel().getValueAt(i, 9);
|
||||
if (amt != null)
|
||||
invoiceAmt = invoiceAmt.add(amt);
|
||||
m_noSelected++;
|
||||
}
|
||||
}
|
||||
|
||||
// Information
|
||||
BigDecimal remaining = m_bankBalance.subtract(invoiceAmt);
|
||||
StringBuffer info = new StringBuffer();
|
||||
info.append(m_noSelected).append(" ").append(Msg.getMsg(Env.getCtx(), "Selected")).append(" - ");
|
||||
info.append(m_format.format(invoiceAmt)).append(", ");
|
||||
info.append(Msg.getMsg(Env.getCtx(), "Remaining")).append(" ").append(m_format.format(remaining));
|
||||
dataStatus.setText(info.toString());
|
||||
dataStatus.setText(calculateSelection(miniTable));
|
||||
//
|
||||
bGenerate.setEnabled(m_noSelected != 0);
|
||||
} // calculateSelection
|
||||
|
@ -554,12 +351,6 @@ public class WPaySelect extends ADForm
|
|||
*/
|
||||
private void generatePaySelect()
|
||||
{
|
||||
log.info("");
|
||||
// String trxName Trx.createTrxName("PaySelect");
|
||||
// Trx trx = Trx.get(trxName, true); trx needs to be committed too
|
||||
String trxName = null;
|
||||
Trx trx = null;
|
||||
//
|
||||
if (miniTable.getRowCount() == 0)
|
||||
return;
|
||||
miniTable.setSelectedIndices(new int[]{0});
|
||||
|
@ -567,67 +358,31 @@ public class WPaySelect extends ADForm
|
|||
if (m_noSelected == 0)
|
||||
return;
|
||||
|
||||
String PaymentRule = ((ValueNamePair)fieldPaymentRule.getSelectedItem().toValueNamePair()).getValue();
|
||||
String msg = generatePaySelect(miniTable, (ValueNamePair) fieldPaymentRule.getSelectedItem().getValue(),
|
||||
new Timestamp(fieldPayDate.getComponent().getValue().getTime()),
|
||||
(BankInfo)fieldBankAccount.getSelectedItem().getValue());
|
||||
|
||||
// Create Header
|
||||
m_ps = new MPaySelection(Env.getCtx(), 0, trxName);
|
||||
m_ps.setName (Msg.getMsg(Env.getCtx(), "VPaySelect")
|
||||
+ " - " + ((ValueNamePair)fieldPaymentRule.getSelectedItem().toValueNamePair()).getName()
|
||||
+ " - " + fieldPayDate.getValue());
|
||||
m_ps.setPayDate (new Timestamp(fieldPayDate.getComponent().getValue().getTime()));
|
||||
BankInfo bi = (BankInfo)fieldBankAccount.getSelectedItem().getValue();
|
||||
m_ps.setC_BankAccount_ID(bi.C_BankAccount_ID);
|
||||
m_ps.setIsApproved(true);
|
||||
if (!m_ps.save())
|
||||
if(msg != null && msg.length() > 0)
|
||||
{
|
||||
FDialog.error(m_WindowNo, this, "SaveError", Msg.translate(Env.getCtx(), "C_PaySelection_ID"));
|
||||
m_ps = null;
|
||||
FDialog.error(m_WindowNo, form, "SaveError", msg);
|
||||
return;
|
||||
}
|
||||
log.config(m_ps.toString());
|
||||
|
||||
// Create Lines
|
||||
int rows = miniTable.getRowCount();
|
||||
int line = 0;
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
IDColumn id = (IDColumn)miniTable.getModel().getValueAt(i, 0);
|
||||
if (id.isSelected())
|
||||
{
|
||||
line += 10;
|
||||
MPaySelectionLine psl = new MPaySelectionLine (m_ps, line, PaymentRule);
|
||||
int C_Invoice_ID = id.getRecord_ID().intValue();
|
||||
BigDecimal OpenAmt = (BigDecimal)miniTable.getModel().getValueAt(i, 8);
|
||||
BigDecimal PayAmt = (BigDecimal)miniTable.getModel().getValueAt(i, 9);
|
||||
boolean isSOTrx = false;
|
||||
//
|
||||
psl.setInvoice(C_Invoice_ID, isSOTrx,
|
||||
OpenAmt, PayAmt, OpenAmt.subtract(PayAmt));
|
||||
if (!psl.save(trxName))
|
||||
{
|
||||
FDialog.error(m_WindowNo, this, "SaveError", Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID"));
|
||||
return;
|
||||
}
|
||||
log.fine("C_Invoice_ID=" + C_Invoice_ID + ", PayAmt=" + PayAmt);
|
||||
}
|
||||
} // for all rows in table
|
||||
|
||||
|
||||
// Ask to Post it
|
||||
if (!FDialog.ask(m_WindowNo, this, "VPaySelectGenerate?", "(" + m_ps.getName() + ")"))
|
||||
if (!FDialog.ask(m_WindowNo, form, "VPaySelectGenerate?", "(" + m_ps.getName() + ")"))
|
||||
return;
|
||||
|
||||
// Prepare Process
|
||||
int AD_Proces_ID = 155; // C_PaySelection_CreatePayment
|
||||
|
||||
// Execute Process
|
||||
ProcessModalDialog dialog = new ProcessModalDialog(null, getFormName(), this, m_WindowNo,
|
||||
ProcessModalDialog dialog = new ProcessModalDialog(null, form.getFormName(), this, m_WindowNo,
|
||||
AD_Proces_ID, X_C_PaySelection.Table_ID, m_ps.getC_PaySelection_ID(), false);
|
||||
if (dialog.isValid()) {
|
||||
try {
|
||||
dialog.setWidth("500px");
|
||||
dialog.setVisible(true);
|
||||
dialog.setPage(this.getPage());
|
||||
dialog.setPage(form.getPage());
|
||||
dialog.doModal();
|
||||
} catch (SuspendNotAllowedException e) {
|
||||
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
|
@ -658,16 +413,13 @@ public class WPaySelect extends ADForm
|
|||
m_isLock = false;
|
||||
m_pi = pi;
|
||||
Clients.showBusy(null, false);
|
||||
Clients.response(new AuEcho(this, "onAfterProcess", null));
|
||||
} // unlockUI
|
||||
|
||||
public void onAfterProcess()
|
||||
{
|
||||
if (!FDialog.ask(0, this, "VPaySelectPrint?", "(" + m_pi.getSummary() + ")"))
|
||||
{
|
||||
dispose();
|
||||
return;
|
||||
}
|
||||
//TODO: The response returned is always Cancel
|
||||
// if (!FDialog.ask(0, form, "VPaySelectPrint?", "(" + m_pi.getSummary() + ")"))
|
||||
// {
|
||||
// dispose();
|
||||
// return;
|
||||
// }
|
||||
|
||||
this.dispose();
|
||||
|
||||
|
@ -676,51 +428,11 @@ public class WPaySelect extends ADForm
|
|||
ADForm form = SessionManager.getAppDesktop().openForm(AD_Form_ID);
|
||||
if (m_ps != null)
|
||||
{
|
||||
WPayPrint pp = (WPayPrint)form;
|
||||
WPayPrint pp = (WPayPrint) form.getICustomForm();
|
||||
pp.setPaySelection(m_ps.getC_PaySelection_ID());
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Bank Account Info
|
||||
*/
|
||||
public class BankInfo
|
||||
{
|
||||
/**
|
||||
* BankInfo
|
||||
* @param newC_BankAccount_ID
|
||||
* @param newC_Currency_ID
|
||||
* @param newName
|
||||
* @param newCurrency
|
||||
* @param newBalance
|
||||
* @param newTransfers
|
||||
*/
|
||||
public BankInfo (int newC_BankAccount_ID, int newC_Currency_ID,
|
||||
String newName, String newCurrency, BigDecimal newBalance, boolean newTransfers)
|
||||
{
|
||||
C_BankAccount_ID = newC_BankAccount_ID;
|
||||
C_Currency_ID = newC_Currency_ID;
|
||||
Name = newName;
|
||||
Currency = newCurrency;
|
||||
Balance = newBalance;
|
||||
}
|
||||
int C_BankAccount_ID;
|
||||
int C_Currency_ID;
|
||||
String Name;
|
||||
String Currency;
|
||||
BigDecimal Balance;
|
||||
boolean Transfers;
|
||||
|
||||
/**
|
||||
* to String
|
||||
* @return info
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
} // BankInfo
|
||||
|
||||
public void executeASync(ProcessInfo pi) {
|
||||
}
|
||||
|
||||
|
@ -728,4 +440,7 @@ public class WPaySelect extends ADForm
|
|||
return m_isLock;
|
||||
}
|
||||
|
||||
public ADForm getForm() {
|
||||
return form;
|
||||
}
|
||||
} // VPaySelect
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
@ -30,17 +28,13 @@ import org.adempiere.webui.component.Panel;
|
|||
import org.adempiere.webui.component.SimpleListModel;
|
||||
import org.adempiere.webui.component.SimpleTreeModel;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.panel.CustomForm;
|
||||
import org.adempiere.webui.panel.ICustomForm;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.apps.form.TreeMaintenance;
|
||||
import org.compiere.model.MTree;
|
||||
import org.compiere.model.MTreeNode;
|
||||
import org.compiere.model.MTree_Node;
|
||||
import org.compiere.model.MTree_NodeBP;
|
||||
import org.compiere.model.MTree_NodeMM;
|
||||
import org.compiere.model.MTree_NodePR;
|
||||
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;
|
||||
|
@ -64,17 +58,14 @@ import org.zkoss.zul.Treeitem;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VTreeMaintenance.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class WTreeMaintenance extends ADForm implements EventListener
|
||||
public class WTreeMaintenance extends TreeMaintenance implements ICustomForm, EventListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3630156132596215136L;
|
||||
/** Active Tree */
|
||||
private MTree m_tree;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(WTreeMaintenance.class);
|
||||
|
||||
private CustomForm form = new CustomForm();
|
||||
|
||||
private Borderlayout mainLayout = new Borderlayout ();
|
||||
private Panel northPanel = new Panel ();
|
||||
|
@ -92,8 +83,7 @@ public class WTreeMaintenance extends ADForm implements EventListener
|
|||
private Listbox centerList = new Listbox();
|
||||
|
||||
|
||||
@Override
|
||||
public void initForm()
|
||||
public WTreeMaintenance()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -113,10 +103,7 @@ public class WTreeMaintenance extends ADForm implements EventListener
|
|||
*/
|
||||
private void preInit()
|
||||
{
|
||||
KeyNamePair[] trees = DB.getKeyNamePairs(MRole.getDefault().addAccessSQL(
|
||||
"SELECT AD_Tree_ID, Name FROM AD_Tree WHERE TreeType NOT IN ('BB','PC') ORDER BY 2",
|
||||
"AD_Tree", MRole.SQL_NOTQUALIFIED, MRole.SQL_RW), false);
|
||||
treeField = new Listbox(trees);
|
||||
treeField = new Listbox(getTreeData());
|
||||
treeField.setMold("select");
|
||||
treeField.addActionListener(this);
|
||||
treeField.setSelectedIndex(0);
|
||||
|
@ -136,10 +123,10 @@ public class WTreeMaintenance extends ADForm implements EventListener
|
|||
bDelete.setSrc("images/StepForward24.png");
|
||||
bDeleteAll.setSrc("images/FastForward24.png");
|
||||
|
||||
this.setWidth("99%");
|
||||
this.setHeight("100%");
|
||||
this.setStyle("position: absolute; padding: 0; margin: 0");
|
||||
this.appendChild (mainLayout);
|
||||
form.setWidth("99%");
|
||||
form.setHeight("100%");
|
||||
form.setStyle("position: absolute; padding: 0; margin: 0");
|
||||
form.appendChild (mainLayout);
|
||||
mainLayout.setWidth("100%");
|
||||
mainLayout.setHeight("100%");
|
||||
mainLayout.setStyle("position: absolute");
|
||||
|
@ -267,41 +254,13 @@ public class WTreeMaintenance extends ADForm implements EventListener
|
|||
String fromClause = m_tree.getSourceTableName(false); // fully qualified
|
||||
String columnNameX = m_tree.getSourceTableName(true);
|
||||
String actionColor = m_tree.getActionColorName();
|
||||
|
||||
// List
|
||||
SimpleListModel model = new SimpleListModel();
|
||||
String sql = "SELECT t." + columnNameX
|
||||
+ "_ID,t.Name,t.Description,t.IsSummary,"
|
||||
+ actionColor
|
||||
+ " FROM " + fromClause
|
||||
// + " WHERE t.IsActive='Y'" // R/O
|
||||
+ " ORDER BY 2";
|
||||
sql = MRole.getDefault().addAccessSQL(sql,
|
||||
"t", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
||||
log.config(sql);
|
||||
//
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
ListItem item = new ListItem(rs.getInt(1), rs.getString(2),
|
||||
rs.getString(3), "Y".equals(rs.getString(4)), rs.getString(5));
|
||||
model.addElement(item);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
// List
|
||||
ArrayList<ListItem> items = getTreeItemData();
|
||||
for(ListItem item : items)
|
||||
model.addElement(item);
|
||||
|
||||
log.config("#" + model.getSize());
|
||||
centerList.setItemRenderer(model);
|
||||
centerList.setModel(model);
|
||||
|
@ -400,26 +359,7 @@ public class WTreeMaintenance extends ADForm implements EventListener
|
|||
model.addNode(stn);
|
||||
}
|
||||
// May cause Error if in tree
|
||||
if (m_tree.isProduct())
|
||||
{
|
||||
MTree_NodePR node = new MTree_NodePR (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
else if (m_tree.isBPartner())
|
||||
{
|
||||
MTree_NodeBP node = new MTree_NodeBP (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
else if (m_tree.isMenu())
|
||||
{
|
||||
MTree_NodeMM node = new MTree_NodeMM (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
MTree_Node node = new MTree_Node (m_tree, item.id);
|
||||
node.save();
|
||||
}
|
||||
addNode(item);
|
||||
}
|
||||
} // action_treeAdd
|
||||
|
||||
|
@ -438,30 +378,7 @@ public class WTreeMaintenance extends ADForm implements EventListener
|
|||
model.removeNode(stn);
|
||||
|
||||
//
|
||||
if (m_tree.isProduct())
|
||||
{
|
||||
MTree_NodePR node = MTree_NodePR.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
else if (m_tree.isBPartner())
|
||||
{
|
||||
MTree_NodeBP node = MTree_NodeBP.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
else if (m_tree.isMenu())
|
||||
{
|
||||
MTree_NodeMM node = MTree_NodeMM.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
MTree_Node node = MTree_Node.get (m_tree, item.id);
|
||||
if (node != null)
|
||||
node.delete(true);
|
||||
}
|
||||
deleteNode(item);
|
||||
}
|
||||
} // action_treeDelete
|
||||
|
||||
|
@ -501,52 +418,9 @@ public class WTreeMaintenance extends ADForm implements EventListener
|
|||
}
|
||||
} // action_treeDeleteAll
|
||||
|
||||
/**************************************************************************
|
||||
* Tree Maintenance List Item
|
||||
*/
|
||||
class ListItem
|
||||
public ADForm getForm()
|
||||
{
|
||||
/**
|
||||
* ListItem
|
||||
* @param ID
|
||||
* @param Name
|
||||
* @param Description
|
||||
* @param summary
|
||||
* @param ImageIndicator
|
||||
*/
|
||||
public ListItem (int ID, String Name, String Description,
|
||||
boolean summary, String ImageIndicator)
|
||||
{
|
||||
id = ID;
|
||||
name = Name;
|
||||
description = Description;
|
||||
isSummary = summary;
|
||||
imageIndicator = ImageIndicator;
|
||||
} // ListItem
|
||||
|
||||
/** ID */
|
||||
public int id;
|
||||
/** Name */
|
||||
public String name;
|
||||
/** Description */
|
||||
public String description;
|
||||
/** Summary */
|
||||
public boolean isSummary;
|
||||
/** Indicator */
|
||||
public String imageIndicator; // Menu - Action
|
||||
|
||||
/**
|
||||
* To String
|
||||
* @return String Representation
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
String retValue = name;
|
||||
if (description != null && description.length() > 0)
|
||||
retValue += " (" + description + ")";
|
||||
return retValue;
|
||||
} // toString
|
||||
|
||||
} // ListItem
|
||||
return form;
|
||||
}
|
||||
|
||||
} // VTreeMaintenance
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
@ -40,17 +37,14 @@ import org.adempiere.webui.event.ValueChangeEvent;
|
|||
import org.adempiere.webui.event.ValueChangeListener;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.panel.ADTabpanel;
|
||||
import org.adempiere.webui.panel.CustomForm;
|
||||
import org.adempiere.webui.panel.ICustomForm;
|
||||
import org.adempiere.webui.panel.StatusBarPanel;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.GridWindow;
|
||||
import org.compiere.model.GridWindowVO;
|
||||
import org.compiere.apps.form.TrxMaterial;
|
||||
import org.compiere.model.MLocatorLookup;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
@ -68,23 +62,19 @@ import org.zkoss.zul.Separator;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VTrxMaterial.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class WTrxMaterial extends ADForm
|
||||
implements EventListener, ValueChangeListener
|
||||
public class WTrxMaterial extends TrxMaterial
|
||||
implements ICustomForm, EventListener, ValueChangeListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2141669182129214237L;
|
||||
|
||||
private CustomForm form = new CustomForm();
|
||||
|
||||
/** GridController */
|
||||
private ADTabpanel m_gridController = null;
|
||||
/** MWindow */
|
||||
private GridWindow m_mWindow = null;
|
||||
/** MTab pointer */
|
||||
private GridTab m_mTab = null;
|
||||
|
||||
private MQuery m_staticQuery = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(WTrxMaterial.class);
|
||||
//
|
||||
private Panel mainPanel = new Panel();
|
||||
private Borderlayout mainLayout = new Borderlayout();
|
||||
|
@ -110,7 +100,7 @@ public class WTrxMaterial extends ADForm
|
|||
/**
|
||||
* Initialize Panel
|
||||
*/
|
||||
protected void initForm()
|
||||
public WTrxMaterial()
|
||||
{
|
||||
log.info("");
|
||||
try
|
||||
|
@ -131,7 +121,7 @@ public class WTrxMaterial extends ADForm
|
|||
*/
|
||||
void zkInit() throws Exception
|
||||
{
|
||||
this.appendChild(mainPanel);
|
||||
form.appendChild(mainPanel);
|
||||
mainPanel.setStyle("width: 99%; height: 100%; border: none; padding: 0; margin: 0");
|
||||
mainPanel.appendChild(mainLayout);
|
||||
mainLayout.setWidth("100%");
|
||||
|
@ -213,16 +203,9 @@ public class WTrxMaterial extends ADForm
|
|||
*/
|
||||
private void dynInit()
|
||||
{
|
||||
m_staticQuery = new MQuery();
|
||||
m_staticQuery.addRestriction("AD_Client_ID", MQuery.EQUAL, Env.getAD_Client_ID(Env.getCtx()));
|
||||
int AD_Window_ID = 223; // Hardcoded
|
||||
GridWindowVO wVO = AEnv.getMWindowVO (m_WindowNo, AD_Window_ID, 0);
|
||||
if (wVO == null)
|
||||
return;
|
||||
m_mWindow = new GridWindow (wVO);
|
||||
m_mTab = m_mWindow.getTab(0);
|
||||
m_mWindow.initTab(0);
|
||||
super.dynInit(statusBar);
|
||||
//
|
||||
|
||||
m_gridController = new ADTabpanel();
|
||||
m_gridController.init(null, m_WindowNo, m_mTab, m_mWindow);
|
||||
if (!m_gridController.isGridView())
|
||||
|
@ -231,11 +214,6 @@ public class WTrxMaterial extends ADForm
|
|||
mainLayout.appendChild(center);
|
||||
center.setFlex(true);
|
||||
center.appendChild(m_gridController);
|
||||
//
|
||||
m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
|
||||
m_mTab.query(false);
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(" ");
|
||||
} // dynInit
|
||||
|
||||
|
||||
|
@ -281,132 +259,30 @@ public class WTrxMaterial extends ADForm
|
|||
*/
|
||||
private void refresh()
|
||||
{
|
||||
/**
|
||||
* Create Where Clause
|
||||
*/
|
||||
MQuery query = m_staticQuery.deepCopy();
|
||||
// Organization
|
||||
Object value = orgField.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
query.addRestriction("AD_Org_ID", MQuery.EQUAL, value);
|
||||
// Locator
|
||||
value = locatorField.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
query.addRestriction("M_Locator_ID", MQuery.EQUAL, value);
|
||||
// Product
|
||||
value = productField.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
query.addRestriction("M_Product_ID", MQuery.EQUAL, value);
|
||||
// MovementType
|
||||
value = mtypeField.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
query.addRestriction("MovementType", MQuery.EQUAL, value);
|
||||
// DateFrom
|
||||
Timestamp ts = (Timestamp)dateFField.getValue();
|
||||
if (ts != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.GREATER_EQUAL, ts);
|
||||
// DateTO
|
||||
ts = (Timestamp)dateTField.getValue();
|
||||
if (ts != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.LESS_EQUAL, ts);
|
||||
log.info( "VTrxMaterial.refresh query=" + query.toString());
|
||||
Object organization = orgField.getValue();
|
||||
Object locator = locatorField.getValue();
|
||||
Object product = productField.getValue();
|
||||
Object movementType = mtypeField.getValue();
|
||||
Timestamp movementDateFrom = (Timestamp)dateFField.getValue();
|
||||
Timestamp movementDateTo = (Timestamp)dateTField.getValue();
|
||||
|
||||
/**
|
||||
* Refresh/Requery
|
||||
*/
|
||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "StartSearch"), false);
|
||||
//
|
||||
m_mTab.setQuery(query);
|
||||
m_mTab.query(false);
|
||||
//
|
||||
int no = m_mTab.getRowCount();
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(Integer.toString(no));
|
||||
refresh(organization, locator, product, movementType, movementDateFrom, movementDateTo, statusBar);
|
||||
} // refresh
|
||||
|
||||
/**
|
||||
* Zoom
|
||||
*/
|
||||
private void zoom()
|
||||
public void zoom()
|
||||
{
|
||||
log.info("");
|
||||
//
|
||||
int AD_Window_ID = 0;
|
||||
String ColumnName = null;
|
||||
String SQL = null;
|
||||
//
|
||||
int lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_InOutLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_InOutLine_ID=" + lineID);
|
||||
if (Env.getContext(Env.getCtx(), m_WindowNo, "MovementType").startsWith("C"))
|
||||
AD_Window_ID = 169; // Customer
|
||||
else
|
||||
AD_Window_ID = 184; // Vendor
|
||||
ColumnName = "M_InOut_ID";
|
||||
SQL = "SELECT M_InOut_ID FROM M_InOutLine WHERE M_InOutLine_ID=?";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_InventoryLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_InventoryLine_ID=" + lineID);
|
||||
AD_Window_ID = 168;
|
||||
ColumnName = "M_Inventory_ID";
|
||||
SQL = "SELECT M_Inventory_ID FROM M_InventoryLine WHERE M_InventoryLine_ID=?";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_MovementLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_MovementLine_ID=" + lineID);
|
||||
AD_Window_ID = 170;
|
||||
ColumnName = "M_Movement_ID";
|
||||
SQL = "SELECT M_Movement_ID FROM M_MovementLine WHERE M_MovementLine_ID=?";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_ProductionLine_ID");
|
||||
if (lineID != 0)
|
||||
{
|
||||
log.fine("M_ProductionLine_ID=" + lineID);
|
||||
AD_Window_ID = 191;
|
||||
ColumnName = "M_Production_ID";
|
||||
SQL = "SELECT M_Production_ID FROM M_ProductionLine WHERE M_ProductionLine_ID=?";
|
||||
}
|
||||
else
|
||||
log.fine("Not found WindowNo=" + m_WindowNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (AD_Window_ID == 0)
|
||||
return;
|
||||
|
||||
// Get Parent ID
|
||||
int parentID = 0;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
|
||||
pstmt.setInt(1, lineID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
parentID = rs.getInt(1);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, SQL, e);
|
||||
}
|
||||
MQuery query = MQuery.getEqualQuery(ColumnName, parentID);
|
||||
log.config("AD_Window_ID=" + AD_Window_ID + " - " + query);
|
||||
if (parentID == 0)
|
||||
log.log(Level.SEVERE, "No ParentValue - " + SQL + " - " + lineID);
|
||||
super.zoom();
|
||||
|
||||
// Zoom
|
||||
AEnv.zoom(AD_Window_ID, query);
|
||||
} // zoom
|
||||
|
||||
public ADForm getForm()
|
||||
{
|
||||
return form;
|
||||
}
|
||||
|
||||
} // VTrxMaterial
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.adempiere.webui.component.Window;
|
|||
import org.adempiere.webui.exception.ApplicationException;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.util.ADClassNameMap;
|
||||
import org.compiere.apps.form.GenForm;
|
||||
import org.compiere.model.MForm;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -64,6 +63,8 @@ public abstract class ADForm extends Window implements EventListener
|
|||
|
||||
private ProcessInfo m_pi;
|
||||
|
||||
private ICustomForm m_customForm;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -228,6 +229,7 @@ public abstract class ADForm extends Window implements EventListener
|
|||
if(o instanceof ADForm)
|
||||
{
|
||||
form = (ADForm)o;
|
||||
form.setICustomForm(customForm);
|
||||
form.init(adFormID, name);
|
||||
return form;
|
||||
}
|
||||
|
@ -275,4 +277,14 @@ public abstract class ADForm extends Window implements EventListener
|
|||
{
|
||||
return m_pi;
|
||||
}
|
||||
|
||||
public void setICustomForm(ICustomForm customForm)
|
||||
{
|
||||
m_customForm = customForm;
|
||||
}
|
||||
|
||||
public ICustomForm getICustomForm()
|
||||
{
|
||||
return m_customForm;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue