IDEMPIERE-308 Performance: Replace use of StringBuffer and String concatenation with StringBuilder - thanks to David Peñuela
This commit is contained in:
parent
d561f2b556
commit
7f4c2934c0
|
@ -63,32 +63,32 @@ public class MRelationType extends X_AD_RelationType implements IZoomProvider {
|
||||||
* <b>Warning:</b> Doesn't support POs with more or less than one key
|
* <b>Warning:</b> Doesn't support POs with more or less than one key
|
||||||
* column.
|
* column.
|
||||||
*/
|
*/
|
||||||
final static String SQL = //
|
final static StringBuffer SQL = //
|
||||||
" SELECT " //
|
new StringBuffer(" SELECT " )//
|
||||||
+ " rt.AD_RelationType_ID AS " + COLUMNNAME_AD_RelationType_ID //
|
.append(" rt.AD_RelationType_ID AS ").append(COLUMNNAME_AD_RelationType_ID) //
|
||||||
+ ", rt.Name AS " + COLUMNNAME_Name //
|
.append(", rt.Name AS ").append(COLUMNNAME_Name )//
|
||||||
+ ", rt.IsDirected AS " + COLUMNNAME_IsDirected //
|
.append(", rt.IsDirected AS ").append(COLUMNNAME_IsDirected) //
|
||||||
+ ", ref.AD_Reference_ID AS " + COLUMNNAME_AD_Reference_ID //
|
.append(", ref.AD_Reference_ID AS ").append(COLUMNNAME_AD_Reference_ID) //
|
||||||
+ ", tab.WhereClause AS " + COLUMNNAME_WhereClause //
|
.append(", tab.WhereClause AS ").append(COLUMNNAME_WhereClause) //
|
||||||
+ ", tab.OrderByClause AS " + COLUMNNAME_OrderByClause //
|
.append(", tab.OrderByClause AS ").append(COLUMNNAME_OrderByClause) //
|
||||||
+ " FROM" //
|
.append(" FROM") //
|
||||||
+ " AD_RelationType rt, AD_Reference ref, AD_Ref_Table tab" //
|
.append(" AD_RelationType rt, AD_Reference ref, AD_Ref_Table tab") //
|
||||||
+ " WHERE " //
|
.append(" WHERE ") //
|
||||||
+ " rt.IsActive='Y'" //
|
.append(" rt.IsActive='Y'") //
|
||||||
+ " AND ref.IsActive='Y'" //
|
.append(" AND ref.IsActive='Y'") //
|
||||||
+ " AND ref.ValidationType='T'" // must have table validation
|
.append(" AND ref.ValidationType='T'") // must have table validation
|
||||||
+ " AND (" // join the source AD_Reference
|
.append(" AND (") // join the source AD_Reference
|
||||||
+ " rt.AD_Reference_Source_ID=ref.AD_Reference_ID" //
|
.append(" rt.AD_Reference_Source_ID=ref.AD_Reference_ID") //
|
||||||
+ " OR (" // not directed? -> also join the target AD_Reference
|
.append(" OR (") // not directed? -> also join the target AD_Reference
|
||||||
+ " rt.IsDirected='N' " //
|
.append(" rt.IsDirected='N' ") //
|
||||||
+ " AND rt.AD_Reference_Target_ID=ref.AD_Reference_ID" //
|
.append(" AND rt.AD_Reference_Target_ID=ref.AD_Reference_ID") //
|
||||||
+ " )" //
|
.append(" )") //
|
||||||
+ " )" //
|
.append(" )") //
|
||||||
+ " AND tab.IsActive='Y'" // Join the AD_Reference's AD_Ref_Table
|
.append(" AND tab.IsActive='Y'") // Join the AD_Reference's AD_Ref_Table
|
||||||
+ " AND tab.AD_Reference_ID=ref.AD_Reference_ID" //
|
.append(" AND tab.AD_Reference_ID=ref.AD_Reference_ID") //
|
||||||
+ " AND tab.AD_Table_ID=?" //
|
.append(" AND tab.AD_Table_ID=?") //
|
||||||
+ " AND tab.AD_Key=?" //
|
.append(" AND tab.AD_Key=?") //
|
||||||
+ " ORDER BY rt.Name";
|
.append(" ORDER BY rt.Name");
|
||||||
|
|
||||||
final static String SQL_WINDOW_NAME = "SELECT Name FROM AD_Window WHERE AD_WINDOW_ID=?";
|
final static String SQL_WINDOW_NAME = "SELECT Name FROM AD_Window WHERE AD_WINDOW_ID=?";
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class MRelationType extends X_AD_RelationType implements IZoomProvider {
|
||||||
|
|
||||||
final int colId = MColumn.getColumn_ID(po.get_TableName(), keyColumn);
|
final int colId = MColumn.getColumn_ID(po.get_TableName(), keyColumn);
|
||||||
|
|
||||||
final PreparedStatement pstmt = DB.prepareStatement(SQL, po
|
final PreparedStatement pstmt = DB.prepareStatement(SQL.toString(), po
|
||||||
.get_TrxName());
|
.get_TrxName());
|
||||||
|
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
|
|
@ -326,8 +326,8 @@ public class PromotionRule {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private static Map<Integer, List<Integer>> findM_Promotion_ID(MOrder order) throws Exception {
|
private static Map<Integer, List<Integer>> findM_Promotion_ID(MOrder order) throws Exception {
|
||||||
String select = "SELECT M_Promotion.M_Promotion_ID From M_Promotion Inner Join M_PromotionPreCondition "
|
StringBuffer select = new StringBuffer("SELECT M_Promotion.M_Promotion_ID From M_Promotion Inner Join M_PromotionPreCondition ")
|
||||||
+ " ON (M_Promotion.M_Promotion_ID = M_PromotionPreCondition.M_Promotion_ID)";
|
.append(" ON (M_Promotion.M_Promotion_ID = M_PromotionPreCondition.M_Promotion_ID)");
|
||||||
|
|
||||||
String bpFilter = "M_PromotionPreCondition.C_BPartner_ID = ? OR M_PromotionPreCondition.C_BP_Group_ID = ? OR (M_PromotionPreCondition.C_BPartner_ID IS NULL AND M_PromotionPreCondition.C_BP_Group_ID IS NULL)";
|
String bpFilter = "M_PromotionPreCondition.C_BPartner_ID = ? OR M_PromotionPreCondition.C_BP_Group_ID = ? OR (M_PromotionPreCondition.C_BPartner_ID IS NULL AND M_PromotionPreCondition.C_BP_Group_ID IS NULL)";
|
||||||
String priceListFilter = "M_PromotionPreCondition.M_PriceList_ID IS NULL OR M_PromotionPreCondition.M_PriceList_ID = ?";
|
String priceListFilter = "M_PromotionPreCondition.M_PriceList_ID IS NULL OR M_PromotionPreCondition.M_PriceList_ID = ?";
|
||||||
|
@ -414,12 +414,12 @@ public class PromotionRule {
|
||||||
private static DistributionSet calculateDistributionQty(MPromotionDistribution distribution,
|
private static DistributionSet calculateDistributionQty(MPromotionDistribution distribution,
|
||||||
DistributionSet prevSet, List<Integer> validPromotionLineIDs, Map<Integer, BigDecimal> orderLineQty, List<Integer> orderLineIdList, String trxName) throws Exception {
|
DistributionSet prevSet, List<Integer> validPromotionLineIDs, Map<Integer, BigDecimal> orderLineQty, List<Integer> orderLineIdList, String trxName) throws Exception {
|
||||||
|
|
||||||
String sql = "SELECT C_OrderLine.C_OrderLine_ID FROM M_PromotionLine"
|
StringBuilder sql = new StringBuilder("SELECT C_OrderLine.C_OrderLine_ID FROM M_PromotionLine")
|
||||||
+ " INNER JOIN M_PromotionGroup ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID AND M_PromotionGroup.IsActive = 'Y')"
|
.append(" INNER JOIN M_PromotionGroup ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID AND M_PromotionGroup.IsActive = 'Y')")
|
||||||
+ " INNER JOIN M_PromotionGroupLine ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')"
|
.append(" INNER JOIN M_PromotionGroupLine ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')")
|
||||||
+ " INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)"
|
.append(" INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)")
|
||||||
+ " WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_OrderLine_ID = ?"
|
.append(" WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_OrderLine_ID = ?")
|
||||||
+ " AND M_PromotionLine.IsActive = 'Y'";
|
.append(" AND M_PromotionLine.IsActive = 'Y'");
|
||||||
|
|
||||||
DistributionSet distributionSet = new DistributionSet();
|
DistributionSet distributionSet = new DistributionSet();
|
||||||
List<Integer>eligibleOrderLineIDs = new ArrayList<Integer>();
|
List<Integer>eligibleOrderLineIDs = new ArrayList<Integer>();
|
||||||
|
@ -434,7 +434,7 @@ public class PromotionRule {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
stmt = DB.prepareStatement(sql, trxName);
|
stmt = DB.prepareStatement(sql.toString(), trxName);
|
||||||
stmt.setInt(1, distribution.getM_PromotionLine_ID());
|
stmt.setInt(1, distribution.getM_PromotionLine_ID());
|
||||||
stmt.setInt(2, C_OrderLine_ID);
|
stmt.setInt(2, C_OrderLine_ID);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
@ -547,17 +547,17 @@ public class PromotionRule {
|
||||||
for (MPromotionLine pl : plist) {
|
for (MPromotionLine pl : plist) {
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
if (pl.getM_PromotionGroup_ID() > 0) {
|
if (pl.getM_PromotionGroup_ID() > 0) {
|
||||||
String sql = "SELECT DISTINCT C_OrderLine.C_OrderLine_ID FROM M_PromotionGroup INNER JOIN M_PromotionGroupLine"
|
StringBuilder sql = new StringBuilder("SELECT DISTINCT C_OrderLine.C_OrderLine_ID FROM M_PromotionGroup INNER JOIN M_PromotionGroupLine")
|
||||||
+ " ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')"
|
.append(" ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')")
|
||||||
+ " INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)"
|
.append(" INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)")
|
||||||
+ " INNER JOIN M_PromotionLine ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID)"
|
.append(" INNER JOIN M_PromotionLine ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID)")
|
||||||
+ " WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_Order_ID = ?"
|
.append(" WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_Order_ID = ?")
|
||||||
+ " AND M_PromotionLine.IsActive = 'Y'"
|
.append(" AND M_PromotionLine.IsActive = 'Y'")
|
||||||
+ " AND M_PromotionGroup.IsActive = 'Y'";
|
.append(" AND M_PromotionGroup.IsActive = 'Y'");
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
stmt = DB.prepareStatement(sql, order.get_TrxName());
|
stmt = DB.prepareStatement(sql.toString(), order.get_TrxName());
|
||||||
stmt.setInt(1, pl.getM_PromotionLine_ID());
|
stmt.setInt(1, pl.getM_PromotionLine_ID());
|
||||||
stmt.setInt(2, order.getC_Order_ID());
|
stmt.setInt(2, order.getC_Order_ID());
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
|
@ -47,11 +47,11 @@ public class ResetLockedAccount extends SvrProcess {
|
||||||
if (!user.isLocked())
|
if (!user.isLocked())
|
||||||
throw new AdempiereException("User " + user.getName() + " is not locked");
|
throw new AdempiereException("User " + user.getName() + " is not locked");
|
||||||
|
|
||||||
String sql = "UPDATE AD_User SET IsLocked = 'N', DateAccountLocked=NULL, FailedLoginCount=0, DateLastLogin=NULL, Updated=SysDate "
|
StringBuffer sql = new StringBuffer ("UPDATE AD_User SET IsLocked = 'N', DateAccountLocked=NULL, FailedLoginCount=0, DateLastLogin=NULL, Updated=SysDate ")
|
||||||
+ " WHERE IsLocked='Y' AND AD_Client_ID = ? "
|
.append(" WHERE IsLocked='Y' AND AD_Client_ID = ? ")
|
||||||
+ " AND DateAccountLocked IS NOT NULL "
|
.append(" AND DateAccountLocked IS NOT NULL ")
|
||||||
+ " AND AD_User_ID = " + user.getAD_User_ID();
|
.append(" AND AD_User_ID = " + user.getAD_User_ID());
|
||||||
int no = DB.executeUpdate(sql, new Object[] { p_AD_Client_ID }, false, get_TrxName());
|
int no = DB.executeUpdate(sql.toString(), new Object[] { p_AD_Client_ID }, false, get_TrxName());
|
||||||
if (no < 0)
|
if (no < 0)
|
||||||
throw new AdempiereException("Could not unlock user account" + user.toString());
|
throw new AdempiereException("Could not unlock user account" + user.toString());
|
||||||
|
|
||||||
|
@ -62,26 +62,26 @@ public class ResetLockedAccount extends SvrProcess {
|
||||||
int MAX_ACCOUNT_LOCK_MINUTES = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES, 0);
|
int MAX_ACCOUNT_LOCK_MINUTES = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES, 0);
|
||||||
int MAX_INACTIVE_PERIOD = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_INACTIVE_PERIOD_DAY, 0);
|
int MAX_INACTIVE_PERIOD = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_INACTIVE_PERIOD_DAY, 0);
|
||||||
|
|
||||||
String sql = "UPDATE AD_User SET IsLocked = 'N', DateAccountLocked=NULL, FailedLoginCount=0, DateLastLogin=NULL, Updated=SysDate "
|
StringBuffer sql = new StringBuffer("UPDATE AD_User SET IsLocked = 'N', DateAccountLocked=NULL, FailedLoginCount=0, DateLastLogin=NULL, Updated=SysDate ")
|
||||||
+ " WHERE IsLocked='Y' AND AD_Client_ID IN (0, ?) "
|
.append(" WHERE IsLocked='Y' AND AD_Client_ID IN (0, ?) ")
|
||||||
+ " AND DateAccountLocked IS NOT NULL";
|
.append(" AND DateAccountLocked IS NOT NULL");
|
||||||
|
|
||||||
if (DB.isPostgreSQL())
|
if (DB.isPostgreSQL())
|
||||||
{
|
{
|
||||||
if (MAX_ACCOUNT_LOCK_MINUTES > 0)
|
if (MAX_ACCOUNT_LOCK_MINUTES > 0)
|
||||||
sql += " AND EXTRACT(MINUTE FROM (now()-DateAccountLocked)) * 24 * 60 > " + MAX_ACCOUNT_LOCK_MINUTES;
|
sql.append( " AND EXTRACT(MINUTE FROM (now()-DateAccountLocked)) * 24 * 60 > ").append(MAX_ACCOUNT_LOCK_MINUTES);
|
||||||
if (MAX_INACTIVE_PERIOD > 0)
|
if (MAX_INACTIVE_PERIOD > 0)
|
||||||
sql += " AND EXTRACT(DAY FROM (now()-DateLastLogin)) * 24 <= " + MAX_INACTIVE_PERIOD;
|
sql.append(" AND EXTRACT(DAY FROM (now()-DateLastLogin)) * 24 <= ").append(MAX_INACTIVE_PERIOD);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (MAX_ACCOUNT_LOCK_MINUTES > 0)
|
if (MAX_ACCOUNT_LOCK_MINUTES > 0)
|
||||||
sql += " AND (SysDate-DateAccountLocked) * 24 * 60 > " + MAX_ACCOUNT_LOCK_MINUTES;
|
sql.append(" AND (SysDate-DateAccountLocked) * 24 * 60 > ").append(MAX_ACCOUNT_LOCK_MINUTES);
|
||||||
if (MAX_INACTIVE_PERIOD > 0)
|
if (MAX_INACTIVE_PERIOD > 0)
|
||||||
sql += " AND (SysDate-DateLastLogin) * 24 <= " + MAX_INACTIVE_PERIOD;
|
sql.append(" AND (SysDate-DateLastLogin) * 24 <= ").append(MAX_INACTIVE_PERIOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
int no = DB.executeUpdate(sql, p_AD_Client_ID, get_TrxName());
|
int no = DB.executeUpdate(sql.toString(), p_AD_Client_ID, get_TrxName());
|
||||||
if (no < 0)
|
if (no < 0)
|
||||||
throw new AdempiereException("Could not unlock user account");
|
throw new AdempiereException("Could not unlock user account");
|
||||||
return no + " locked account has been reset";
|
return no + " locked account has been reset";
|
||||||
|
|
|
@ -233,23 +233,23 @@ public class ModelInterfaceGenerator
|
||||||
*/
|
*/
|
||||||
private StringBuffer createColumns(int AD_Table_ID, StringBuffer mandatory) {
|
private StringBuffer createColumns(int AD_Table_ID, StringBuffer mandatory) {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
String sql = "SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory," // 1..3
|
StringBuffer sql = new StringBuffer("SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory,") // 1..3
|
||||||
+ " c.AD_Reference_ID, c.AD_Reference_Value_ID, DefaultValue, SeqNo, " // 4..7
|
.append(" c.AD_Reference_ID, c.AD_Reference_Value_ID, DefaultValue, SeqNo, ") // 4..7
|
||||||
+ " c.FieldLength, c.ValueMin, c.ValueMax, c.VFormat, c.Callout, " // 8..12
|
.append(" c.FieldLength, c.ValueMin, c.ValueMax, c.VFormat, c.Callout, ") // 8..12
|
||||||
+ " c.Name, c.Description, c.ColumnSQL, c.IsEncrypted, c.IsKey " // 13..17
|
.append(" c.Name, c.Description, c.ColumnSQL, c.IsEncrypted, c.IsKey ") // 13..17
|
||||||
+ "FROM AD_Column c "
|
.append("FROM AD_Column c ")
|
||||||
+ "WHERE c.AD_Table_ID=?"
|
.append("WHERE c.AD_Table_ID=?")
|
||||||
// + " AND c.ColumnName <> 'AD_Client_ID'"
|
// + " AND c.ColumnName <> 'AD_Client_ID'"
|
||||||
// + " AND c.ColumnName <> 'AD_Org_ID'"
|
// + " AND c.ColumnName <> 'AD_Org_ID'"
|
||||||
// + " AND c.ColumnName <> 'IsActive'"
|
// + " AND c.ColumnName <> 'IsActive'"
|
||||||
// + " AND c.ColumnName NOT LIKE 'Created%'"
|
// + " AND c.ColumnName NOT LIKE 'Created%'"
|
||||||
// + " AND c.ColumnName NOT LIKE 'Updated%' "
|
// + " AND c.ColumnName NOT LIKE 'Updated%' "
|
||||||
+ " AND c.IsActive='Y'"
|
.append(" AND c.IsActive='Y'")
|
||||||
+ " ORDER BY c.ColumnName";
|
.append(" ORDER BY c.ColumnName");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, AD_Table_ID);
|
pstmt.setInt(1, AD_Table_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
@ -289,7 +289,7 @@ public class ModelInterfaceGenerator
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
throw new DBException(e, sql);
|
throw new DBException(e, sql.toString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -495,15 +495,15 @@ public class ModelInterfaceGenerator
|
||||||
else if ((DisplayType.Table == displayType || DisplayType.Search == displayType)
|
else if ((DisplayType.Table == displayType || DisplayType.Search == displayType)
|
||||||
&& AD_Reference_ID > 0)
|
&& AD_Reference_ID > 0)
|
||||||
{
|
{
|
||||||
String sql = "SELECT c.AD_Reference_ID, c.AD_Reference_Value_ID"
|
StringBuffer sql = new StringBuffer("SELECT c.AD_Reference_ID, c.AD_Reference_Value_ID")
|
||||||
+" FROM AD_Ref_Table rt"
|
.append(" FROM AD_Ref_Table rt")
|
||||||
+" INNER JOIN AD_Column c ON (c.AD_Column_ID=rt.AD_Key)"
|
.append(" INNER JOIN AD_Column c ON (c.AD_Column_ID=rt.AD_Key)")
|
||||||
+" WHERE rt.AD_Reference_ID=?";
|
.append(" WHERE rt.AD_Reference_ID=?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, AD_Reference_ID);
|
pstmt.setInt(1, AD_Reference_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -518,7 +518,7 @@ public class ModelInterfaceGenerator
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
throw new DBException(e, sql);
|
throw new DBException(e, sql.toString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -670,17 +670,17 @@ public class ModelInterfaceGenerator
|
||||||
if (AD_Table_ID == 707 && columnName.equals("Account_ID"))
|
if (AD_Table_ID == 707 && columnName.equals("Account_ID"))
|
||||||
return null;
|
return null;
|
||||||
//
|
//
|
||||||
final String sql = "SELECT t.TableName, t.EntityType, ck.AD_Reference_ID"
|
final StringBuffer sql = new StringBuffer("SELECT t.TableName, t.EntityType, ck.AD_Reference_ID")
|
||||||
+" FROM AD_Ref_Table rt"
|
.append(" FROM AD_Ref_Table rt")
|
||||||
+" INNER JOIN AD_Table t ON (t.AD_Table_ID=rt.AD_Table_ID)"
|
.append(" INNER JOIN AD_Table t ON (t.AD_Table_ID=rt.AD_Table_ID)")
|
||||||
+" INNER JOIN AD_Column ck ON (ck.AD_Table_ID=rt.AD_Table_ID AND ck.AD_Column_ID=rt.AD_Key)"
|
.append(" INNER JOIN AD_Column ck ON (ck.AD_Table_ID=rt.AD_Table_ID AND ck.AD_Column_ID=rt.AD_Key)")
|
||||||
+" WHERE rt.AD_Reference_ID=?"
|
.append(" WHERE rt.AD_Reference_ID=?")
|
||||||
;
|
;
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, AD_Reference_ID);
|
pstmt.setInt(1, AD_Reference_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -705,7 +705,7 @@ public class ModelInterfaceGenerator
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
throw new DBException(e, sql);
|
throw new DBException(e, sql.toString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -841,11 +841,11 @@ public abstract class Doc
|
||||||
// We have a document Type, but no GL info - search for DocType
|
// We have a document Type, but no GL info - search for DocType
|
||||||
if (m_GL_Category_ID == 0)
|
if (m_GL_Category_ID == 0)
|
||||||
{
|
{
|
||||||
String sql = "SELECT GL_Category_ID FROM C_DocType "
|
StringBuilder sql = new StringBuilder("SELECT GL_Category_ID FROM C_DocType ")
|
||||||
+ "WHERE AD_Client_ID=? AND DocBaseType=?";
|
.append("WHERE AD_Client_ID=? AND DocBaseType=?");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, getAD_Client_ID());
|
pstmt.setInt(1, getAD_Client_ID());
|
||||||
pstmt.setString(2, m_DocumentType);
|
pstmt.setString(2, m_DocumentType);
|
||||||
ResultSet rsDT = pstmt.executeQuery();
|
ResultSet rsDT = pstmt.executeQuery();
|
||||||
|
@ -856,19 +856,19 @@ public abstract class Doc
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Still no GL_Category - get Default GL Category
|
// Still no GL_Category - get Default GL Category
|
||||||
if (m_GL_Category_ID == 0)
|
if (m_GL_Category_ID == 0)
|
||||||
{
|
{
|
||||||
String sql = "SELECT GL_Category_ID FROM GL_Category "
|
StringBuilder sql = new StringBuilder("SELECT GL_Category_ID FROM GL_Category ")
|
||||||
+ "WHERE AD_Client_ID=? "
|
.append("WHERE AD_Client_ID=? ")
|
||||||
+ "ORDER BY IsDefault DESC";
|
.append("ORDER BY IsDefault DESC");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, getAD_Client_ID());
|
pstmt.setInt(1, getAD_Client_ID());
|
||||||
ResultSet rsDT = pstmt.executeQuery();
|
ResultSet rsDT = pstmt.executeQuery();
|
||||||
if (rsDT.next())
|
if (rsDT.next())
|
||||||
|
@ -878,7 +878,7 @@ public abstract class Doc
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
|
@ -71,10 +71,10 @@ public class DocLine_Allocation extends DocLine
|
||||||
{
|
{
|
||||||
if (m_C_Invoice_ID == 0)
|
if (m_C_Invoice_ID == 0)
|
||||||
return 0;
|
return 0;
|
||||||
String sql = "SELECT C_Currency_ID "
|
StringBuilder sql = new StringBuilder("SELECT C_Currency_ID ")
|
||||||
+ "FROM C_Invoice "
|
.append("FROM C_Invoice ")
|
||||||
+ "WHERE C_Invoice_ID=?";
|
.append("WHERE C_Invoice_ID=?");
|
||||||
return DB.getSQLValue(null, sql, m_C_Invoice_ID);
|
return DB.getSQLValue(null, sql.toString(), m_C_Invoice_ID);
|
||||||
} // getInvoiceC_Currency_ID
|
} // getInvoiceC_Currency_ID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -68,19 +68,19 @@ public class DocManager {
|
||||||
|
|
||||||
private static void fillDocumentsTableArrays() {
|
private static void fillDocumentsTableArrays() {
|
||||||
if (documentsTableID == null) {
|
if (documentsTableID == null) {
|
||||||
String sql = "SELECT t.AD_Table_ID, t.TableName " +
|
StringBuilder sql = new StringBuilder("SELECT t.AD_Table_ID, t.TableName ")
|
||||||
"FROM AD_Table t, AD_Column c " +
|
.append("FROM AD_Table t, AD_Column c ")
|
||||||
"WHERE t.AD_Table_ID=c.AD_Table_ID AND " +
|
.append("WHERE t.AD_Table_ID=c.AD_Table_ID AND ")
|
||||||
"c.ColumnName='Posted' AND " +
|
.append("c.ColumnName='Posted' AND ")
|
||||||
"IsView='N' " +
|
.append("IsView='N' ")
|
||||||
"ORDER BY t.AD_Table_ID";
|
.append("ORDER BY t.AD_Table_ID");
|
||||||
ArrayList<Integer> tableIDs = new ArrayList<Integer>();
|
ArrayList<Integer> tableIDs = new ArrayList<Integer>();
|
||||||
ArrayList<String> tableNames = new ArrayList<String>();
|
ArrayList<String> tableNames = new ArrayList<String>();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ public class DocManager {
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
throw new DBException(e, sql);
|
throw new DBException(e, sql.toString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,14 +96,14 @@ public final class DocTax
|
||||||
if (AcctType < 0 || AcctType > 4)
|
if (AcctType < 0 || AcctType > 4)
|
||||||
return null;
|
return null;
|
||||||
//
|
//
|
||||||
String sql = "SELECT T_Due_Acct, T_Liability_Acct, T_Credit_Acct, T_Receivables_Acct, T_Expense_Acct "
|
StringBuilder sql = new StringBuilder("SELECT T_Due_Acct, T_Liability_Acct, T_Credit_Acct, T_Receivables_Acct, T_Expense_Acct ")
|
||||||
+ "FROM C_Tax_Acct WHERE C_Tax_ID=? AND C_AcctSchema_ID=?";
|
.append("FROM C_Tax_Acct WHERE C_Tax_ID=? AND C_AcctSchema_ID=?");
|
||||||
int validCombination_ID = 0;
|
int validCombination_ID = 0;
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, m_C_Tax_ID);
|
pstmt.setInt(1, m_C_Tax_ID);
|
||||||
pstmt.setInt(2, as.getC_AcctSchema_ID());
|
pstmt.setInt(2, as.getC_AcctSchema_ID());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
@ -112,7 +112,7 @@ public final class DocTax
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
|
|
@ -628,14 +628,14 @@ public class Doc_AllocationHdr extends Doc
|
||||||
// or Doc.ACCTTYPE_PaymentSelect (AP) or V_Prepayment
|
// or Doc.ACCTTYPE_PaymentSelect (AP) or V_Prepayment
|
||||||
int accountType = Doc.ACCTTYPE_UnallocatedCash;
|
int accountType = Doc.ACCTTYPE_UnallocatedCash;
|
||||||
//
|
//
|
||||||
String sql = "SELECT p.C_BankAccount_ID, d.DocBaseType, p.IsReceipt, p.IsPrepayment "
|
StringBuilder sql = new StringBuilder("SELECT p.C_BankAccount_ID, d.DocBaseType, p.IsReceipt, p.IsPrepayment ")
|
||||||
+ "FROM C_Payment p INNER JOIN C_DocType d ON (p.C_DocType_ID=d.C_DocType_ID) "
|
.append("FROM C_Payment p INNER JOIN C_DocType d ON (p.C_DocType_ID=d.C_DocType_ID) ")
|
||||||
+ "WHERE C_Payment_ID=?";
|
.append("WHERE C_Payment_ID=?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, getTrxName());
|
pstmt = DB.prepareStatement (sql.toString(), getTrxName());
|
||||||
pstmt.setInt (1, C_Payment_ID);
|
pstmt.setInt (1, C_Payment_ID);
|
||||||
rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
if (rs.next ())
|
if (rs.next ())
|
||||||
|
@ -655,7 +655,7 @@ public class Doc_AllocationHdr extends Doc
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -680,10 +680,10 @@ public class Doc_AllocationHdr extends Doc
|
||||||
*/
|
*/
|
||||||
private MAccount getCashAcct (MAcctSchema as, int C_CashLine_ID)
|
private MAccount getCashAcct (MAcctSchema as, int C_CashLine_ID)
|
||||||
{
|
{
|
||||||
String sql = "SELECT c.C_CashBook_ID "
|
StringBuilder sql = new StringBuilder("SELECT c.C_CashBook_ID ")
|
||||||
+ "FROM C_Cash c, C_CashLine cl "
|
.append("FROM C_Cash c, C_CashLine cl ")
|
||||||
+ "WHERE c.C_Cash_ID=cl.C_Cash_ID AND cl.C_CashLine_ID=?";
|
.append("WHERE c.C_Cash_ID=cl.C_Cash_ID AND cl.C_CashLine_ID=?");
|
||||||
setC_CashBook_ID(DB.getSQLValue(null, sql, C_CashLine_ID));
|
setC_CashBook_ID(DB.getSQLValue(null, sql.toString(), C_CashLine_ID));
|
||||||
if (getC_CashBook_ID() <= 0)
|
if (getC_CashBook_ID() <= 0)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "NONE for C_CashLine_ID=" + C_CashLine_ID);
|
log.log(Level.SEVERE, "NONE for C_CashLine_ID=" + C_CashLine_ID);
|
||||||
|
@ -711,20 +711,20 @@ public class Doc_AllocationHdr extends Doc
|
||||||
BigDecimal invoiceSource = null;
|
BigDecimal invoiceSource = null;
|
||||||
BigDecimal invoiceAccounted = null;
|
BigDecimal invoiceAccounted = null;
|
||||||
//
|
//
|
||||||
String sql = "SELECT "
|
StringBuffer sql = new StringBuffer("SELECT ")
|
||||||
+ (invoice.isSOTrx()
|
.append((invoice.isSOTrx()
|
||||||
? "SUM(AmtSourceDr), SUM(AmtAcctDr)" // so
|
? "SUM(AmtSourceDr), SUM(AmtAcctDr)" // so
|
||||||
: "SUM(AmtSourceCr), SUM(AmtAcctCr)") // po
|
: "SUM(AmtSourceCr), SUM(AmtAcctCr)")) // po
|
||||||
+ " FROM Fact_Acct "
|
.append(" FROM Fact_Acct ")
|
||||||
+ "WHERE AD_Table_ID=318 AND Record_ID=?" // Invoice
|
.append("WHERE AD_Table_ID=318 AND Record_ID=?") // Invoice
|
||||||
+ " AND C_AcctSchema_ID=?"
|
.append(" AND C_AcctSchema_ID=?")
|
||||||
+ " AND PostingType='A'";
|
.append(" AND PostingType='A'");
|
||||||
//AND C_Currency_ID=102
|
//AND C_Currency_ID=102
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, getTrxName());
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, invoice.getC_Invoice_ID());
|
pstmt.setInt(1, invoice.getC_Invoice_ID());
|
||||||
pstmt.setInt(2, as.getC_AcctSchema_ID());
|
pstmt.setInt(2, as.getC_AcctSchema_ID());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
@ -736,7 +736,7 @@ public class Doc_AllocationHdr extends Doc
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
@ -856,16 +856,16 @@ public class Doc_AllocationHdr extends Doc
|
||||||
DiscountAccount, discount, WriteOffAccoint, writeOff, isSOTrx);
|
DiscountAccount, discount, WriteOffAccoint, writeOff, isSOTrx);
|
||||||
|
|
||||||
// Get Source Amounts with account
|
// Get Source Amounts with account
|
||||||
String sql = "SELECT * "
|
StringBuilder sql = new StringBuilder("SELECT * ")
|
||||||
+ "FROM Fact_Acct "
|
.append("FROM Fact_Acct ")
|
||||||
+ "WHERE AD_Table_ID=318 AND Record_ID=?" // Invoice
|
.append("WHERE AD_Table_ID=318 AND Record_ID=?") // Invoice
|
||||||
+ " AND C_AcctSchema_ID=?"
|
.append(" AND C_AcctSchema_ID=?")
|
||||||
+ " AND Line_ID IS NULL"; // header lines like tax or total
|
.append(" AND Line_ID IS NULL"); // header lines like tax or total
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, getTrxName());
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, line.getC_Invoice_ID());
|
pstmt.setInt(1, line.getC_Invoice_ID());
|
||||||
pstmt.setInt(2, as.getC_AcctSchema_ID());
|
pstmt.setInt(2, as.getC_AcctSchema_ID());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
@ -874,7 +874,7 @@ public class Doc_AllocationHdr extends Doc
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
|
|
@ -99,14 +99,14 @@ public class Doc_Invoice extends Doc
|
||||||
private DocTax[] loadTaxes()
|
private DocTax[] loadTaxes()
|
||||||
{
|
{
|
||||||
ArrayList<DocTax> list = new ArrayList<DocTax>();
|
ArrayList<DocTax> list = new ArrayList<DocTax>();
|
||||||
String sql = "SELECT it.C_Tax_ID, t.Name, t.Rate, it.TaxBaseAmt, it.TaxAmt, t.IsSalesTax "
|
StringBuilder sql = new StringBuilder("SELECT it.C_Tax_ID, t.Name, t.Rate, it.TaxBaseAmt, it.TaxAmt, t.IsSalesTax ")
|
||||||
+ "FROM C_Tax t, C_InvoiceTax it "
|
.append("FROM C_Tax t, C_InvoiceTax it ")
|
||||||
+ "WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Invoice_ID=?";
|
.append("WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Invoice_ID=?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, getTrxName());
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, get_ID());
|
pstmt.setInt(1, get_ID());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
//
|
//
|
||||||
|
@ -127,7 +127,7 @@ public class Doc_Invoice extends Doc
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -886,13 +886,13 @@ public class Doc_Invoice extends Doc
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer (
|
StringBuffer sql = new StringBuffer (
|
||||||
"UPDATE M_Product_PO po "
|
"UPDATE M_Product_PO po ")
|
||||||
+ "SET PriceLastInv = "
|
.append("SET PriceLastInv = ")
|
||||||
// select
|
// select
|
||||||
+ "(SELECT currencyConvert(il.PriceActual,i.C_Currency_ID,po.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) "
|
.append("(SELECT currencyConvert(il.PriceActual,i.C_Currency_ID,po.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) ")
|
||||||
+ "FROM C_Invoice i, C_InvoiceLine il "
|
.append("FROM C_Invoice i, C_InvoiceLine il ")
|
||||||
+ "WHERE i.C_Invoice_ID=il.C_Invoice_ID"
|
.append("WHERE i.C_Invoice_ID=il.C_Invoice_ID")
|
||||||
+ " AND po.M_Product_ID=il.M_Product_ID AND po.C_BPartner_ID=i.C_BPartner_ID");
|
.append(" AND po.M_Product_ID=il.M_Product_ID AND po.C_BPartner_ID=i.C_BPartner_ID");
|
||||||
//jz + " AND ROWNUM=1 AND i.C_Invoice_ID=").append(get_ID()).append(") ")
|
//jz + " AND ROWNUM=1 AND i.C_Invoice_ID=").append(get_ID()).append(") ")
|
||||||
if (DB.isOracle()) //jz
|
if (DB.isOracle()) //jz
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,17 +164,17 @@ public class Doc_Order extends Doc
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||||
String sql = "SELECT * FROM M_RequisitionLine rl "
|
StringBuilder sql = new StringBuilder("SELECT * FROM M_RequisitionLine rl ")
|
||||||
+ "WHERE EXISTS (SELECT * FROM C_Order o "
|
.append("WHERE EXISTS (SELECT * FROM C_Order o ")
|
||||||
+ " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID) "
|
.append(" INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID) ")
|
||||||
+ "WHERE ol.C_OrderLine_ID=rl.C_OrderLine_ID"
|
.append("WHERE ol.C_OrderLine_ID=rl.C_OrderLine_ID")
|
||||||
+ " AND o.C_Order_ID=?) "
|
.append(" AND o.C_Order_ID=?) ")
|
||||||
+ "ORDER BY rl.C_OrderLine_ID";
|
.append("ORDER BY rl.C_OrderLine_ID");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql.toString(), null);
|
||||||
pstmt.setInt (1, order.getC_Order_ID());
|
pstmt.setInt (1, order.getC_Order_ID());
|
||||||
rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
|
@ -201,7 +201,7 @@ public class Doc_Order extends Doc
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log (Level.SEVERE, sql, e);
|
log.log (Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -234,14 +234,14 @@ public class Doc_Order extends Doc
|
||||||
private DocTax[] loadTaxes()
|
private DocTax[] loadTaxes()
|
||||||
{
|
{
|
||||||
ArrayList<DocTax> list = new ArrayList<DocTax>();
|
ArrayList<DocTax> list = new ArrayList<DocTax>();
|
||||||
String sql = "SELECT it.C_Tax_ID, t.Name, t.Rate, it.TaxBaseAmt, it.TaxAmt, t.IsSalesTax "
|
StringBuilder sql = new StringBuilder("SELECT it.C_Tax_ID, t.Name, t.Rate, it.TaxBaseAmt, it.TaxAmt, t.IsSalesTax ")
|
||||||
+ "FROM C_Tax t, C_OrderTax it "
|
.append("FROM C_Tax t, C_OrderTax it ")
|
||||||
+ "WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Order_ID=?";
|
.append("WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Order_ID=?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, getTrxName());
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, get_ID());
|
pstmt.setInt(1, get_ID());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
//
|
//
|
||||||
|
@ -261,7 +261,7 @@ public class Doc_Order extends Doc
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
@ -462,21 +462,21 @@ public class Doc_Order extends Doc
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer (
|
StringBuffer sql = new StringBuffer (
|
||||||
"UPDATE M_Product_PO po "
|
"UPDATE M_Product_PO po ")
|
||||||
+ "SET PriceLastPO = (SELECT currencyConvert(ol.PriceActual,ol.C_Currency_ID,po.C_Currency_ID,o.DateOrdered,o.C_ConversionType_ID,o.AD_Client_ID,o.AD_Org_ID) "
|
.append("SET PriceLastPO = (SELECT currencyConvert(ol.PriceActual,ol.C_Currency_ID,po.C_Currency_ID,o.DateOrdered,o.C_ConversionType_ID,o.AD_Client_ID,o.AD_Org_ID) ")
|
||||||
+ "FROM C_Order o, C_OrderLine ol "
|
.append("FROM C_Order o, C_OrderLine ol ")
|
||||||
+ "WHERE o.C_Order_ID=ol.C_Order_ID"
|
.append("WHERE o.C_Order_ID=ol.C_Order_ID")
|
||||||
+ " AND po.M_Product_ID=ol.M_Product_ID AND po.C_BPartner_ID=o.C_BPartner_ID ");
|
.append(" AND po.M_Product_ID=ol.M_Product_ID AND po.C_BPartner_ID=o.C_BPartner_ID ");
|
||||||
//jz + " AND ROWNUM=1 AND o.C_Order_ID=").append(get_ID()).append(") ")
|
//jz + " AND ROWNUM=1 AND o.C_Order_ID=").append(get_ID()).append(") ")
|
||||||
if (DB.isOracle()) //jz
|
if (DB.isOracle()) //jz
|
||||||
{
|
{
|
||||||
sql.append(" AND ROWNUM=1 ");
|
sql.append(" AND ROWNUM=1 ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sql.append(" AND ol.C_OrderLine_ID = (SELECT MIN(ol1.C_OrderLine_ID) "
|
sql.append(" AND ol.C_OrderLine_ID = (SELECT MIN(ol1.C_OrderLine_ID) ")
|
||||||
+ "FROM C_Order o1, C_OrderLine ol1 "
|
.append("FROM C_Order o1, C_OrderLine ol1 ")
|
||||||
+ "WHERE o1.C_Order_ID=ol1.C_Order_ID"
|
.append("WHERE o1.C_Order_ID=ol1.C_Order_ID")
|
||||||
+ " AND po.M_Product_ID=ol1.M_Product_ID AND po.C_BPartner_ID=o1.C_BPartner_ID")
|
.append(" AND po.M_Product_ID=ol1.M_Product_ID AND po.C_BPartner_ID=o1.C_BPartner_ID")
|
||||||
.append(" AND o1.C_Order_ID=").append(get_ID()).append(") ");
|
.append(" AND o1.C_Order_ID=").append(get_ID()).append(") ");
|
||||||
sql.append(" AND o.C_Order_ID=").append(get_ID()).append(") ")
|
sql.append(" AND o.C_Order_ID=").append(get_ID()).append(") ")
|
||||||
.append("WHERE EXISTS (SELECT * "
|
.append("WHERE EXISTS (SELECT * "
|
||||||
|
@ -501,20 +501,20 @@ public class Doc_Order extends Doc
|
||||||
int precision = -1;
|
int precision = -1;
|
||||||
//
|
//
|
||||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||||
String sql = "SELECT * FROM C_OrderLine ol "
|
StringBuilder sql = new StringBuilder("SELECT * FROM C_OrderLine ol ")
|
||||||
+ "WHERE EXISTS "
|
.append("WHERE EXISTS ")
|
||||||
+ "(SELECT * FROM C_InvoiceLine il "
|
.append("(SELECT * FROM C_InvoiceLine il ")
|
||||||
+ "WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID"
|
.append("WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID")
|
||||||
+ " AND il.C_InvoiceLine_ID=?)"
|
.append(" AND il.C_InvoiceLine_ID=?)")
|
||||||
+ " OR EXISTS "
|
.append(" OR EXISTS ")
|
||||||
+ "(SELECT * FROM M_MatchPO po "
|
.append("(SELECT * FROM M_MatchPO po ")
|
||||||
+ "WHERE po.C_OrderLine_ID=ol.C_OrderLine_ID"
|
.append("WHERE po.C_OrderLine_ID=ol.C_OrderLine_ID")
|
||||||
+ " AND po.C_InvoiceLine_ID=?)";
|
.append(" AND po.C_InvoiceLine_ID=?)");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql.toString(), null);
|
||||||
pstmt.setInt (1, C_InvoiceLine_ID);
|
pstmt.setInt (1, C_InvoiceLine_ID);
|
||||||
pstmt.setInt (2, C_InvoiceLine_ID);
|
pstmt.setInt (2, C_InvoiceLine_ID);
|
||||||
rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
|
@ -568,7 +568,7 @@ public class Doc_Order extends Doc
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log (Level.SEVERE, sql, e);
|
s_log.log (Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -646,16 +646,16 @@ public class Doc_Order extends Doc
|
||||||
int precision = -1;
|
int precision = -1;
|
||||||
//
|
//
|
||||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||||
String sql = "SELECT * FROM C_OrderLine ol "
|
StringBuilder sql = new StringBuilder("SELECT * FROM C_OrderLine ol ")
|
||||||
+ "WHERE EXISTS "
|
.append("WHERE EXISTS ")
|
||||||
+ "(SELECT * FROM M_InOutLine il "
|
.append("(SELECT * FROM M_InOutLine il ")
|
||||||
+ "WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID"
|
.append("WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID")
|
||||||
+ " AND il.M_InOutLine_ID=?)";
|
.append(" AND il.M_InOutLine_ID=?)");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql.toString(), null);
|
||||||
pstmt.setInt (1, M_InOutLine_ID);
|
pstmt.setInt (1, M_InOutLine_ID);
|
||||||
rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
|
@ -708,7 +708,7 @@ public class Doc_Order extends Doc
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log (Level.SEVERE, sql, e);
|
s_log.log (Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,14 +82,14 @@ public class Doc_Production extends Doc
|
||||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||||
// Production
|
// Production
|
||||||
// -- ProductionLine - the real level
|
// -- ProductionLine - the real level
|
||||||
String sqlPL = "SELECT * FROM M_ProductionLine pl "
|
StringBuilder sqlPL = new StringBuilder("SELECT * FROM M_ProductionLine pl ")
|
||||||
+ "WHERE pl.M_Production_ID=? "
|
.append("WHERE pl.M_Production_ID=? ")
|
||||||
+ "ORDER BY pl.Line";
|
.append("ORDER BY pl.Line");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
PreparedStatement pstmtPL = DB.prepareStatement(sqlPL, getTrxName());
|
PreparedStatement pstmtPL = DB.prepareStatement(sqlPL.toString(), getTrxName());
|
||||||
pstmtPL.setInt(1,get_ID());
|
pstmtPL.setInt(1,get_ID());
|
||||||
ResultSet rsPL = pstmtPL.executeQuery();
|
ResultSet rsPL = pstmtPL.executeQuery();
|
||||||
while (rsPL.next())
|
while (rsPL.next())
|
||||||
|
@ -113,7 +113,7 @@ public class Doc_Production extends Doc
|
||||||
}
|
}
|
||||||
catch (Exception ee)
|
catch (Exception ee)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sqlPL, ee);
|
log.log(Level.SEVERE, sqlPL.toString(), ee);
|
||||||
}
|
}
|
||||||
|
|
||||||
DocLine[] dl = new DocLine[list.size()];
|
DocLine[] dl = new DocLine[list.size()];
|
||||||
|
|
|
@ -168,16 +168,16 @@ public class Doc_ProjectIssue extends Doc
|
||||||
{
|
{
|
||||||
BigDecimal retValue = null;
|
BigDecimal retValue = null;
|
||||||
// Uses PO Date
|
// Uses PO Date
|
||||||
String sql = "SELECT currencyConvert(ol.PriceActual, o.C_Currency_ID, ?, o.DateOrdered, o.C_ConversionType_ID, ?, ?) "
|
StringBuilder sql = new StringBuilder("SELECT currencyConvert(ol.PriceActual, o.C_Currency_ID, ?, o.DateOrdered, o.C_ConversionType_ID, ?, ?) ")
|
||||||
+ "FROM C_OrderLine ol"
|
.append("FROM C_OrderLine ol")
|
||||||
+ " INNER JOIN M_InOutLine iol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID)"
|
.append(" INNER JOIN M_InOutLine iol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID)")
|
||||||
+ " INNER JOIN C_Order o ON (o.C_Order_ID=ol.C_Order_ID) "
|
.append(" INNER JOIN C_Order o ON (o.C_Order_ID=ol.C_Order_ID) ")
|
||||||
+ "WHERE iol.M_InOutLine_ID=?";
|
.append("WHERE iol.M_InOutLine_ID=?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, getTrxName());
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, as.getC_Currency_ID());
|
pstmt.setInt(1, as.getC_Currency_ID());
|
||||||
pstmt.setInt(2, getAD_Client_ID());
|
pstmt.setInt(2, getAD_Client_ID());
|
||||||
pstmt.setInt(3, getAD_Org_ID());
|
pstmt.setInt(3, getAD_Org_ID());
|
||||||
|
@ -193,7 +193,7 @@ public class Doc_ProjectIssue extends Doc
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -215,8 +215,8 @@ public class Doc_ProjectIssue extends Doc
|
||||||
BigDecimal retValue = Env.ZERO;
|
BigDecimal retValue = Env.ZERO;
|
||||||
BigDecimal qty = Env.ZERO;
|
BigDecimal qty = Env.ZERO;
|
||||||
|
|
||||||
String sql = "SELECT ConvertedAmt, Qty FROM S_TimeExpenseLine " +
|
StringBuilder sql = new StringBuilder("SELECT ConvertedAmt, Qty FROM S_TimeExpenseLine ")
|
||||||
" WHERE S_TimeExpenseLine.S_TimeExpenseLine_ID = ?";
|
.append(" WHERE S_TimeExpenseLine.S_TimeExpenseLine_ID = ?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
|
|
|
@ -497,13 +497,13 @@ public final class FactLine extends X_Fact_Acct
|
||||||
if (M_Locator_ID == 0)
|
if (M_Locator_ID == 0)
|
||||||
return;
|
return;
|
||||||
int C_Location_ID = 0;
|
int C_Location_ID = 0;
|
||||||
String sql = "SELECT w.C_Location_ID FROM M_Warehouse w, M_Locator l "
|
StringBuilder sql = new StringBuilder("SELECT w.C_Location_ID FROM M_Warehouse w, M_Locator l ")
|
||||||
+ "WHERE w.M_Warehouse_ID=l.M_Warehouse_ID AND l.M_Locator_ID=?";
|
.append("WHERE w.M_Warehouse_ID=l.M_Warehouse_ID AND l.M_Locator_ID=?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||||
pstmt.setInt(1, M_Locator_ID);
|
pstmt.setInt(1, M_Locator_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -511,7 +511,7 @@ public final class FactLine extends X_Fact_Acct
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -994,16 +994,16 @@ public final class FactLine extends X_Fact_Acct
|
||||||
// get Unearned Revenue Acct from BPartner Group
|
// get Unearned Revenue Acct from BPartner Group
|
||||||
int UnearnedRevenue_Acct = 0;
|
int UnearnedRevenue_Acct = 0;
|
||||||
int new_Account_ID = 0;
|
int new_Account_ID = 0;
|
||||||
String sql = "SELECT ga.UnearnedRevenue_Acct, vc.Account_ID "
|
StringBuilder sql = new StringBuilder("SELECT ga.UnearnedRevenue_Acct, vc.Account_ID ")
|
||||||
+ "FROM C_BP_Group_Acct ga, C_BPartner p, C_ValidCombination vc "
|
.append("FROM C_BP_Group_Acct ga, C_BPartner p, C_ValidCombination vc ")
|
||||||
+ "WHERE ga.C_BP_Group_ID=p.C_BP_Group_ID"
|
.append("WHERE ga.C_BP_Group_ID=p.C_BP_Group_ID")
|
||||||
+ " AND ga.UnearnedRevenue_Acct=vc.C_ValidCombination_ID"
|
.append(" AND ga.UnearnedRevenue_Acct=vc.C_ValidCombination_ID")
|
||||||
+ " AND ga.C_AcctSchema_ID=? AND p.C_BPartner_ID=?";
|
.append(" AND ga.C_AcctSchema_ID=? AND p.C_BPartner_ID=?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||||
pstmt.setInt(1, getC_AcctSchema_ID());
|
pstmt.setInt(1, getC_AcctSchema_ID());
|
||||||
pstmt.setInt(2, C_BPartner_ID);
|
pstmt.setInt(2, C_BPartner_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
@ -1015,7 +1015,7 @@ public final class FactLine extends X_Fact_Acct
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
@ -1061,20 +1061,20 @@ public final class FactLine extends X_Fact_Acct
|
||||||
{
|
{
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
String sql = "SELECT * "
|
StringBuffer sql = new StringBuffer("SELECT * ")
|
||||||
+ "FROM Fact_Acct "
|
.append("FROM Fact_Acct ")
|
||||||
+ "WHERE C_AcctSchema_ID=? AND AD_Table_ID=? AND Record_ID=?"
|
.append("WHERE C_AcctSchema_ID=? AND AD_Table_ID=? AND Record_ID=?")
|
||||||
+ " AND Line_ID=? AND Account_ID=?";
|
.append(" AND Line_ID=? AND Account_ID=?");
|
||||||
// MZ Goodwill
|
// MZ Goodwill
|
||||||
// for Inventory Move
|
// for Inventory Move
|
||||||
if (MMovement.Table_ID == AD_Table_ID)
|
if (MMovement.Table_ID == AD_Table_ID)
|
||||||
sql += " AND M_Locator_ID=?";
|
sql.append(" AND M_Locator_ID=?");
|
||||||
// end MZ
|
// end MZ
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||||
pstmt.setInt(1, getC_AcctSchema_ID());
|
pstmt.setInt(1, getC_AcctSchema_ID());
|
||||||
pstmt.setInt(2, AD_Table_ID);
|
pstmt.setInt(2, AD_Table_ID);
|
||||||
pstmt.setInt(3, Record_ID);
|
pstmt.setInt(3, Record_ID);
|
||||||
|
@ -1141,7 +1141,7 @@ public final class FactLine extends X_Fact_Acct
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
|
|
@ -80,23 +80,23 @@ public class Matcher
|
||||||
{
|
{
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
// (a) Direct Matches
|
// (a) Direct Matches
|
||||||
String sql = "SELECT m1.AD_Client_ID,m2.AD_Org_ID, " // 1..2
|
StringBuilder sql = new StringBuilder("SELECT m1.AD_Client_ID,m2.AD_Org_ID, ") // 1..2
|
||||||
+ "m1.C_InvoiceLine_ID,m2.M_InOutLine_ID,m1.M_Product_ID, " // 3..5
|
.append("m1.C_InvoiceLine_ID,m2.M_InOutLine_ID,m1.M_Product_ID, ") // 3..5
|
||||||
+ "m1.DateTrx,m2.DateTrx, m1.Qty, m2.Qty " // 6..9
|
.append("m1.DateTrx,m2.DateTrx, m1.Qty, m2.Qty ") // 6..9
|
||||||
+ "FROM M_MatchPO m1, M_MatchPO m2 "
|
.append("FROM M_MatchPO m1, M_MatchPO m2 ")
|
||||||
+ "WHERE m1.C_OrderLine_ID=m2.C_OrderLine_ID"
|
.append("WHERE m1.C_OrderLine_ID=m2.C_OrderLine_ID")
|
||||||
+ " AND m1.M_InOutLine_ID IS NULL"
|
.append(" AND m1.M_InOutLine_ID IS NULL")
|
||||||
+ " AND m2.C_InvoiceLine_ID IS NULL"
|
.append(" AND m2.C_InvoiceLine_ID IS NULL")
|
||||||
+ " AND m1.M_Product_ID=m2.M_Product_ID"
|
.append(" AND m1.M_Product_ID=m2.M_Product_ID")
|
||||||
+ " AND m1.AD_Client_ID=?" // #1
|
.append(" AND m1.AD_Client_ID=?") // #1
|
||||||
// Not existing Inv Matches
|
// Not existing Inv Matches
|
||||||
+ " AND NOT EXISTS (SELECT * FROM M_MatchInv mi "
|
.append(" AND NOT EXISTS (SELECT * FROM M_MatchInv mi ")
|
||||||
+ "WHERE mi.C_InvoiceLine_ID=m1.C_InvoiceLine_ID AND mi.M_InOutLine_ID=m2.M_InOutLine_ID)";
|
.append("WHERE mi.C_InvoiceLine_ID=m1.C_InvoiceLine_ID AND mi.M_InOutLine_ID=m2.M_InOutLine_ID)");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, m_AD_Client_ID);
|
pstmt.setInt(1, m_AD_Client_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
|
|
@ -83,18 +83,18 @@ public class ProductInfo
|
||||||
if (m_M_Product_ID == 0)
|
if (m_M_Product_ID == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String sql = "SELECT p.ProductType, pc.Value, " // 1..2
|
StringBuilder sql = new StringBuilder("SELECT p.ProductType, pc.Value, ") // 1..2
|
||||||
+ "p.C_RevenueRecognition_ID,p.C_UOM_ID, " // 3..4
|
.append("p.C_RevenueRecognition_ID,p.C_UOM_ID, ") // 3..4
|
||||||
+ "p.AD_Client_ID,p.AD_Org_ID, " // 5..6
|
.append("p.AD_Client_ID,p.AD_Org_ID, ") // 5..6
|
||||||
+ "p.IsBOM, p.IsStocked " // 7..8
|
.append("p.IsBOM, p.IsStocked ") // 7..8
|
||||||
+ "FROM M_Product_Category pc"
|
.append("FROM M_Product_Category pc")
|
||||||
+ " INNER JOIN M_Product p ON (pc.M_Product_Category_ID=p.M_Product_Category_ID) "
|
.append(" INNER JOIN M_Product p ON (pc.M_Product_Category_ID=p.M_Product_Category_ID) ")
|
||||||
+ "WHERE p.M_Product_ID=?"; // #1
|
.append("WHERE p.M_Product_ID=?"); // #1
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, m_M_Product_ID);
|
pstmt.setInt(1, m_M_Product_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -113,7 +113,7 @@ public class ProductInfo
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
@ -296,9 +296,9 @@ public class ProductInfo
|
||||||
*/
|
*/
|
||||||
private BigDecimal getPOCost (MAcctSchema as)
|
private BigDecimal getPOCost (MAcctSchema as)
|
||||||
{
|
{
|
||||||
String sql = "SELECT C_Currency_ID, PriceList,PricePO,PriceLastPO "
|
StringBuilder sql = new StringBuilder("SELECT C_Currency_ID, PriceList,PricePO,PriceLastPO ")
|
||||||
+ "FROM M_Product_PO WHERE M_Product_ID=? "
|
.append("FROM M_Product_PO WHERE M_Product_ID=? ")
|
||||||
+ "ORDER BY IsCurrentVendor DESC";
|
.append("ORDER BY IsCurrentVendor DESC");
|
||||||
|
|
||||||
int C_Currency_ID = 0;
|
int C_Currency_ID = 0;
|
||||||
BigDecimal PriceList = null;
|
BigDecimal PriceList = null;
|
||||||
|
@ -308,7 +308,7 @@ public class ProductInfo
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, m_M_Product_ID);
|
pstmt.setInt(1, m_M_Product_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -321,7 +321,7 @@ public class ProductInfo
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
|
|
@ -115,12 +115,12 @@ public final class ImpFormat
|
||||||
m_AD_Table_ID = AD_Table_ID;
|
m_AD_Table_ID = AD_Table_ID;
|
||||||
m_tableName = null;
|
m_tableName = null;
|
||||||
m_tablePK = null;
|
m_tablePK = null;
|
||||||
String sql = "SELECT t.TableName,c.ColumnName "
|
StringBuilder sql = new StringBuilder("SELECT t.TableName,c.ColumnName ")
|
||||||
+ "FROM AD_Table t INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID AND c.IsKey='Y') "
|
.append("FROM AD_Table t INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID AND c.IsKey='Y') ")
|
||||||
+ "WHERE t.AD_Table_ID=?";
|
.append("WHERE t.AD_Table_ID=?");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, AD_Table_ID);
|
pstmt.setInt(1, AD_Table_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -301,14 +301,14 @@ public final class ImpFormat
|
||||||
*/
|
*/
|
||||||
private static void loadRows (ImpFormat format, int ID)
|
private static void loadRows (ImpFormat format, int ID)
|
||||||
{
|
{
|
||||||
String sql = "SELECT f.SeqNo,c.ColumnName,f.StartNo,f.EndNo,f.DataType,c.FieldLength," // 1..6
|
StringBuilder sql = new StringBuilder("SELECT f.SeqNo,c.ColumnName,f.StartNo,f.EndNo,f.DataType,c.FieldLength,") // 1..6
|
||||||
+ "f.DataFormat,f.DecimalPoint,f.DivideBy100,f.ConstantValue,f.Callout " // 7..11
|
.append("f.DataFormat,f.DecimalPoint,f.DivideBy100,f.ConstantValue,f.Callout ") // 7..11
|
||||||
+ "FROM AD_ImpFormat_Row f,AD_Column c "
|
.append("FROM AD_ImpFormat_Row f,AD_Column c ")
|
||||||
+ "WHERE f.AD_ImpFormat_ID=? AND f.AD_Column_ID=c.AD_Column_ID AND f.IsActive='Y'"
|
.append("WHERE f.AD_ImpFormat_ID=? AND f.AD_Column_ID=c.AD_Column_ID AND f.IsActive='Y'")
|
||||||
+ "ORDER BY f.SeqNo";
|
.append("ORDER BY f.SeqNo");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt (1, ID);
|
pstmt.setInt (1, ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
@ -327,7 +327,7 @@ public final class ImpFormat
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
} // loadLines
|
} // loadLines
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,13 @@ public class MImpFormat extends X_AD_ImpFormat
|
||||||
public MImpFormatRow[] getRows()
|
public MImpFormatRow[] getRows()
|
||||||
{
|
{
|
||||||
ArrayList<MImpFormatRow> list = new ArrayList<MImpFormatRow>();
|
ArrayList<MImpFormatRow> list = new ArrayList<MImpFormatRow>();
|
||||||
String sql = "SELECT * FROM AD_ImpFormat_Row "
|
StringBuilder sql = new StringBuilder("SELECT * FROM AD_ImpFormat_Row ")
|
||||||
+ "WHERE AD_ImpFormat_ID=? "
|
.append("WHERE AD_ImpFormat_ID=? ")
|
||||||
+ "ORDER BY SeqNo";
|
.append("ORDER BY SeqNo");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
||||||
pstmt.setInt (1, getAD_ImpFormat_ID());
|
pstmt.setInt (1, getAD_ImpFormat_ID());
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
ResultSet rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
|
|
|
@ -57,13 +57,15 @@ public class GridFieldVO implements Serializable
|
||||||
public static String getSQL (Properties ctx)
|
public static String getSQL (Properties ctx)
|
||||||
{
|
{
|
||||||
// IsActive is part of View
|
// IsActive is part of View
|
||||||
String sql = "SELECT * FROM AD_Field_v WHERE AD_Tab_ID=?"
|
StringBuffer sql;
|
||||||
+ " ORDER BY IsDisplayed DESC, SeqNo";
|
|
||||||
if (!Env.isBaseLanguage(ctx, "AD_Tab"))
|
if (!Env.isBaseLanguage(ctx, "AD_Tab"))
|
||||||
sql = "SELECT * FROM AD_Field_vt WHERE AD_Tab_ID=?"
|
sql = new StringBuffer("SELECT * FROM AD_Field_vt WHERE AD_Tab_ID=?")
|
||||||
+ " AND AD_Language='" + Env.getAD_Language(ctx) + "'"
|
.append(" AND AD_Language='" + Env.getAD_Language(ctx) + "'")
|
||||||
+ " ORDER BY IsDisplayed DESC, SeqNo";
|
.append(" ORDER BY IsDisplayed DESC, SeqNo");
|
||||||
return sql;
|
else
|
||||||
|
sql = new StringBuffer("SELECT * FROM AD_Field_v WHERE AD_Tab_ID=?")
|
||||||
|
.append(" ORDER BY IsDisplayed DESC, SeqNo");
|
||||||
|
return sql.toString();
|
||||||
} // getSQL
|
} // getSQL
|
||||||
|
|
||||||
public String InfoFactoryClass = null;
|
public String InfoFactoryClass = null;
|
||||||
|
|
|
@ -559,18 +559,18 @@ public class GridWindow implements Serializable
|
||||||
{
|
{
|
||||||
if (recalc || m_modelUpdated == null)
|
if (recalc || m_modelUpdated == null)
|
||||||
{
|
{
|
||||||
String sql = "SELECT MAX(w.Updated), MAX(t.Updated), MAX(tt.Updated), MAX(f.Updated), MAX(c.Updated) "
|
StringBuilder sql = new StringBuilder("SELECT MAX(w.Updated), MAX(t.Updated), MAX(tt.Updated), MAX(f.Updated), MAX(c.Updated) ")
|
||||||
+ "FROM AD_Window w"
|
.append("FROM AD_Window w")
|
||||||
+ " INNER JOIN AD_Tab t ON (w.AD_Window_ID=t.AD_Window_ID)"
|
.append(" INNER JOIN AD_Tab t ON (w.AD_Window_ID=t.AD_Window_ID)")
|
||||||
+ " INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID)"
|
.append(" INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID)")
|
||||||
+ " INNER JOIN AD_Field f ON (t.AD_Tab_ID=f.AD_Tab_ID)"
|
.append(" INNER JOIN AD_Field f ON (t.AD_Tab_ID=f.AD_Tab_ID)")
|
||||||
+ " INNER JOIN AD_Column c ON (f.AD_Column_ID=c.AD_Column_ID) "
|
.append(" INNER JOIN AD_Column c ON (f.AD_Column_ID=c.AD_Column_ID) ")
|
||||||
+ "WHERE w.AD_Window_ID=?";
|
.append("WHERE w.AD_Window_ID=?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql.toString(), null);
|
||||||
pstmt.setInt (1, getAD_Window_ID());
|
pstmt.setInt (1, getAD_Window_ID());
|
||||||
rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
if (rs.next ())
|
if (rs.next ())
|
||||||
|
@ -592,7 +592,7 @@ public class GridWindow implements Serializable
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log (Level.SEVERE, sql, e);
|
log.log (Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,21 +77,21 @@ public class CalloutUser extends CalloutEngine
|
||||||
if (C_BPartner_ID == null || C_BPartner_ID.intValue() == 0)
|
if (C_BPartner_ID == null || C_BPartner_ID.intValue() == 0)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
String sql = "SELECT p.AD_Language,p.C_PaymentTerm_ID,"
|
StringBuilder sql = new StringBuilder("SELECT p.AD_Language,p.C_PaymentTerm_ID,")
|
||||||
+ " COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference,"
|
.append (" COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference,")
|
||||||
+ " p.SO_Description,p.IsDiscountPrinted,"
|
.append (" p.SO_Description,p.IsDiscountPrinted,")
|
||||||
+ " p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable,"
|
.append (" p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable,")
|
||||||
+ " l.C_BPartner_Location_ID,c.AD_User_ID,"
|
.append (" l.C_BPartner_Location_ID,c.AD_User_ID,")
|
||||||
+ " COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID "
|
.append (" COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID ")
|
||||||
+ "FROM C_BPartner p"
|
.append ("FROM C_BPartner p")
|
||||||
+ " INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)"
|
.append (" INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)")
|
||||||
+ " LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID AND l.IsBillTo='Y' AND l.IsActive='Y')"
|
.append (" LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID AND l.IsBillTo='Y' AND l.IsActive='Y')")
|
||||||
+ " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID) "
|
.append (" LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID) ")
|
||||||
+ "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
|
.append ("WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"); // #1
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, C_BPartner_ID.intValue());
|
pstmt.setInt(1, C_BPartner_ID.intValue());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
//
|
//
|
||||||
|
@ -130,7 +130,7 @@ public class CalloutUser extends CalloutEngine
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
return e.getLocalizedMessage();
|
return e.getLocalizedMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue