IDEMPIERE-308 Performance: Replace with StringBuilder / Thanks to Richard Morales and David Peñuela

This commit is contained in:
Carlos Ruiz 2012-09-25 13:05:52 -05:00
parent bda4e5736d
commit d9d27e6990
12 changed files with 571 additions and 547 deletions

View File

@ -108,8 +108,8 @@ public class LanguageMaintenance extends SvrProcess
m_language.saveEx(); m_language.saveEx();
} }
} }
StringBuilder msgreturn = new StringBuilder("@Deleted@=").append(deleteNo).append(" - @Inserted@=").append(insertNo);
return "@Deleted@=" + deleteNo + " - @Inserted@=" + insertNo; return msgreturn.toString();
} // doIt } // doIt

View File

@ -61,21 +61,21 @@ public class AD_PrintPaper_Default extends SvrProcess
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
StringBuffer sql = new StringBuffer(""); StringBuilder sql = new StringBuilder();
int cnt = 0; int cnt = 0;
log.info("Set Print Format"); log.info("Set Print Format");
try try
{ {
sql.append("UPDATE AD_PrintFormat pf " sql.append("UPDATE AD_PrintFormat pf ")
+ "SET AD_PrintPaper_ID = " + p_Record_ID + " " .append("SET AD_PrintPaper_ID = ").append(p_Record_ID).append(" ")
+ "WHERE EXISTS (SELECT * FROM AD_PrintPaper pp " .append("WHERE EXISTS (SELECT * FROM AD_PrintPaper pp ")
+ "WHERE pf.AD_PrintPaper_ID=pp.AD_PrintPaper_ID " .append("WHERE pf.AD_PrintPaper_ID=pp.AD_PrintPaper_ID ")
+ "AND IsLandscape = (SELECT IsLandscape FROM AD_PrintPaper " .append("AND IsLandscape = (SELECT IsLandscape FROM AD_PrintPaper ")
+ "WHERE AD_PrintPaper_ID=" + p_Record_ID + "))"); .append("WHERE AD_PrintPaper_ID=").append(p_Record_ID).append("))");
if (p_AD_Client_ID != -1) { if (p_AD_Client_ID != -1) {
sql.append(" AND AD_Client_ID = " + p_AD_Client_ID); sql.append(" AND AD_Client_ID = ").append(p_AD_Client_ID);
} }
cnt = DB.executeUpdate(sql.toString(), get_TrxName()); cnt = DB.executeUpdate(sql.toString(), get_TrxName());
log.info("Updated " + cnt + " columns"); log.info("Updated " + cnt + " columns");

View File

@ -76,7 +76,7 @@ public class AcctSchemaDefaultCopy extends SvrProcess
if (acct == null || acct.get_ID() == 0) if (acct == null || acct.get_ID() == 0)
throw new AdempiereSystemError("Default Not Found - C_AcctSchema_ID=" + p_C_AcctSchema_ID); throw new AdempiereSystemError("Default Not Found - C_AcctSchema_ID=" + p_C_AcctSchema_ID);
String sql = null; StringBuilder sql;
int updated = 0; int updated = 0;
int created = 0; int created = 0;
int updatedTotal = 0; int updatedTotal = 0;
@ -85,88 +85,88 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update existing Product Category // Update existing Product Category
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE M_Product_Category_Acct pa " sql = new StringBuilder("UPDATE M_Product_Category_Acct pa ")
+ "SET P_Revenue_Acct=" + acct.getP_Revenue_Acct() .append("SET P_Revenue_Acct=").append(acct.getP_Revenue_Acct())
+ ", P_Expense_Acct=" + acct.getP_Expense_Acct() .append(", P_Expense_Acct=").append(acct.getP_Expense_Acct())
+ ", P_CostAdjustment_Acct=" + acct.getP_CostAdjustment_Acct() .append(", P_CostAdjustment_Acct=").append(acct.getP_CostAdjustment_Acct())
+ ", P_InventoryClearing_Acct=" + acct.getP_InventoryClearing_Acct() .append(", P_InventoryClearing_Acct=").append(acct.getP_InventoryClearing_Acct())
+ ", P_Asset_Acct=" + acct.getP_Asset_Acct() .append(", P_Asset_Acct=").append(acct.getP_Asset_Acct())
+ ", P_COGS_Acct=" + acct.getP_COGS_Acct() .append(", P_COGS_Acct=").append(acct.getP_COGS_Acct())
+ ", P_PurchasePriceVariance_Acct=" + acct.getP_PurchasePriceVariance_Acct() .append(", P_PurchasePriceVariance_Acct=").append(acct.getP_PurchasePriceVariance_Acct())
+ ", P_InvoicePriceVariance_Acct=" + acct.getP_InvoicePriceVariance_Acct() .append(", P_InvoicePriceVariance_Acct=").append(acct.getP_InvoicePriceVariance_Acct())
+ ", P_AverageCostVariance_Acct=" + acct.getP_AverageCostVariance_Acct() .append(", P_AverageCostVariance_Acct=").append(acct.getP_AverageCostVariance_Acct())
+ ", P_TradeDiscountRec_Acct=" + acct.getP_TradeDiscountRec_Acct() .append(", P_TradeDiscountRec_Acct=").append(acct.getP_TradeDiscountRec_Acct())
+ ", P_TradeDiscountGrant_Acct=" + acct.getP_TradeDiscountGrant_Acct() .append(", P_TradeDiscountGrant_Acct=").append(acct.getP_TradeDiscountGrant_Acct())
+ ", P_WIP_Acct=" + acct.getP_WIP_Acct() .append(", P_WIP_Acct=").append(acct.getP_WIP_Acct())
+ ", P_FloorStock_Acct=" + acct.getP_FloorStock_Acct() .append(", P_FloorStock_Acct=").append(acct.getP_FloorStock_Acct())
+ ", P_MethodChangeVariance_Acct=" + acct.getP_MethodChangeVariance_Acct() .append(", P_MethodChangeVariance_Acct=").append(acct.getP_MethodChangeVariance_Acct())
+ ", P_UsageVariance_Acct=" + acct.getP_UsageVariance_Acct() .append(", P_UsageVariance_Acct=").append(acct.getP_UsageVariance_Acct())
+ ", P_RateVariance_Acct=" + acct.getP_RateVariance_Acct() .append(", P_RateVariance_Acct=").append(acct.getP_RateVariance_Acct())
+ ", P_MixVariance_Acct=" + acct.getP_MixVariance_Acct() .append(", P_MixVariance_Acct=").append(acct.getP_MixVariance_Acct())
+ ", P_Labor_Acct=" + acct.getP_Labor_Acct() .append(", P_Labor_Acct=").append(acct.getP_Labor_Acct())
+ ", P_Burden_Acct=" + acct.getP_Burden_Acct() .append(", P_Burden_Acct=").append(acct.getP_Burden_Acct())
+ ", P_CostOfProduction_Acct=" + acct.getP_CostOfProduction_Acct() .append(", P_CostOfProduction_Acct=").append(acct.getP_CostOfProduction_Acct())
+ ", P_OutsideProcessing_Acct=" + acct.getP_OutsideProcessing_Acct() .append(", P_OutsideProcessing_Acct=").append(acct.getP_OutsideProcessing_Acct())
+ ", P_Overhead_Acct=" + acct.getP_Overhead_Acct() .append(", P_Overhead_Acct=").append(acct.getP_Overhead_Acct())
+ ", P_Scrap_Acct=" + acct.getP_Scrap_Acct() .append(", P_Scrap_Acct=").append(acct.getP_Scrap_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE pa.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE pa.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM M_Product_Category p " .append(" AND EXISTS (SELECT * FROM M_Product_Category p ")
+ "WHERE p.M_Product_Category_ID=pa.M_Product_Category_ID)"; .append("WHERE p.M_Product_Category_ID=pa.M_Product_Category_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @M_Product_Category_ID@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @M_Product_Category_ID@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert new Product Category // Insert new Product Category
sql = "INSERT INTO M_Product_Category_Acct " sql = new StringBuilder("INSERT INTO M_Product_Category_Acct ")
+ "(M_Product_Category_ID, C_AcctSchema_ID," .append("(M_Product_Category_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " P_Revenue_Acct, P_Expense_Acct, P_CostAdjustment_Acct, P_InventoryClearing_Acct, P_Asset_Acct, P_CoGs_Acct," .append(" P_Revenue_Acct, P_Expense_Acct, P_CostAdjustment_Acct, P_InventoryClearing_Acct, P_Asset_Acct, P_CoGs_Acct,")
+ " P_PurchasePriceVariance_Acct, P_InvoicePriceVariance_Acct, P_AverageCostVariance_Acct," .append(" P_PurchasePriceVariance_Acct, P_InvoicePriceVariance_Acct, P_AverageCostVariance_Acct,")
+ " P_TradeDiscountRec_Acct, P_TradeDiscountGrant_Acct," .append(" P_TradeDiscountRec_Acct, P_TradeDiscountGrant_Acct," )
+ " P_WIP_Acct,P_FloorStock_Acct,P_MethodChangeVariance_Acct,P_UsageVariance_Acct,P_RateVariance_Acct," .append(" P_WIP_Acct,P_FloorStock_Acct,P_MethodChangeVariance_Acct,P_UsageVariance_Acct,P_RateVariance_Acct,")
+ " P_MixVariance_Acct,P_Labor_Acct,P_Burden_Acct,P_CostOfProduction_Acct,P_OutsideProcessing_Acct,P_Overhead_Acct,P_Scrap_Acct) " .append(" P_MixVariance_Acct,P_Labor_Acct,P_Burden_Acct,P_CostOfProduction_Acct,P_OutsideProcessing_Acct,P_Overhead_Acct,P_Scrap_Acct) ")
+ " SELECT p.M_Product_Category_ID, acct.C_AcctSchema_ID," .append(" SELECT p.M_Product_Category_ID, acct.C_AcctSchema_ID,")
+ " p.AD_Client_ID, p.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" p.AD_Client_ID, p.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.P_Revenue_Acct, acct.P_Expense_Acct, acct.P_CostAdjustment_Acct, acct.P_InventoryClearing_Acct, acct.P_Asset_Acct, acct.P_CoGs_Acct," .append(" acct.P_Revenue_Acct, acct.P_Expense_Acct, acct.P_CostAdjustment_Acct, acct.P_InventoryClearing_Acct, acct.P_Asset_Acct, acct.P_CoGs_Acct,")
+ " acct.P_PurchasePriceVariance_Acct, acct.P_InvoicePriceVariance_Acct, acct.P_AverageCostVariance_Acct," .append(" acct.P_PurchasePriceVariance_Acct, acct.P_InvoicePriceVariance_Acct, acct.P_AverageCostVariance_Acct,")
+ " acct.P_TradeDiscountRec_Acct, acct.P_TradeDiscountGrant_Acct," .append(" acct.P_TradeDiscountRec_Acct, acct.P_TradeDiscountGrant_Acct,")
+ " acct.P_WIP_Acct,acct.P_FloorStock_Acct,acct.P_MethodChangeVariance_Acct,acct.P_UsageVariance_Acct,acct.P_RateVariance_Acct," .append(" acct.P_WIP_Acct,acct.P_FloorStock_Acct,acct.P_MethodChangeVariance_Acct,acct.P_UsageVariance_Acct,acct.P_RateVariance_Acct,")
+ " acct.P_MixVariance_Acct,acct.P_Labor_Acct,acct.P_Burden_Acct,acct.P_CostOfProduction_Acct,acct.P_OutsideProcessing_Acct,P_Overhead_Acct,P_Scrap_Acct " .append(" acct.P_MixVariance_Acct,acct.P_Labor_Acct,acct.P_Burden_Acct,acct.P_CostOfProduction_Acct,acct.P_OutsideProcessing_Acct,P_Overhead_Acct,P_Scrap_Acct ")
+ "FROM M_Product_Category p" .append("FROM M_Product_Category p")
+ " INNER JOIN C_AcctSchema_Default acct ON (p.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (p.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM M_Product_Category_Acct pa " .append(" AND NOT EXISTS (SELECT * FROM M_Product_Category_Acct pa ")
+ "WHERE pa.M_Product_Category_ID=p.M_Product_Category_ID" .append("WHERE pa.M_Product_Category_ID=p.M_Product_Category_ID")
+ " AND pa.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND pa.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @M_Product_Category_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @M_Product_Category_ID@");
createdTotal += created; createdTotal += created;
if (!p_CopyOverwriteAcct) // Insert new Products if (!p_CopyOverwriteAcct) // Insert new Products
{ {
sql = "INSERT INTO M_Product_Acct " sql = new StringBuilder("INSERT INTO M_Product_Acct ")
+ "(M_Product_ID, C_AcctSchema_ID," .append("(M_Product_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " P_Revenue_Acct, P_Expense_Acct, P_CostAdjustment_Acct, P_InventoryClearing_Acct, P_Asset_Acct, P_CoGs_Acct," .append(" P_Revenue_Acct, P_Expense_Acct, P_CostAdjustment_Acct, P_InventoryClearing_Acct, P_Asset_Acct, P_CoGs_Acct,")
+ " P_PurchasePriceVariance_Acct, P_InvoicePriceVariance_Acct, P_AverageCostVariance_Acct," .append(" P_PurchasePriceVariance_Acct, P_InvoicePriceVariance_Acct, P_AverageCostVariance_Acct,")
+ " P_TradeDiscountRec_Acct, P_TradeDiscountGrant_Acct, " .append(" P_TradeDiscountRec_Acct, P_TradeDiscountGrant_Acct, ")
+ " P_WIP_Acct,P_FloorStock_Acct,P_MethodChangeVariance_Acct,P_UsageVariance_Acct,P_RateVariance_Acct," .append(" P_WIP_Acct,P_FloorStock_Acct,P_MethodChangeVariance_Acct,P_UsageVariance_Acct,P_RateVariance_Acct,")
+ " P_MixVariance_Acct,P_Labor_Acct,P_Burden_Acct,P_CostOfProduction_Acct,P_OutsideProcessing_Acct,P_Overhead_Acct,P_Scrap_Acct) " .append(" P_MixVariance_Acct,P_Labor_Acct,P_Burden_Acct,P_CostOfProduction_Acct,P_OutsideProcessing_Acct,P_Overhead_Acct,P_Scrap_Acct) ")
+ "SELECT p.M_Product_ID, acct.C_AcctSchema_ID," .append("SELECT p.M_Product_ID, acct.C_AcctSchema_ID,")
+ " p.AD_Client_ID, p.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" p.AD_Client_ID, p.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.P_Revenue_Acct, acct.P_Expense_Acct, acct.P_CostAdjustment_Acct, acct.P_InventoryClearing_Acct, acct.P_Asset_Acct, acct.P_CoGs_Acct," .append(" acct.P_Revenue_Acct, acct.P_Expense_Acct, acct.P_CostAdjustment_Acct, acct.P_InventoryClearing_Acct, acct.P_Asset_Acct, acct.P_CoGs_Acct,")
+ " acct.P_PurchasePriceVariance_Acct, acct.P_InvoicePriceVariance_Acct, acct.P_AverageCostVariance_Acct," .append(" acct.P_PurchasePriceVariance_Acct, acct.P_InvoicePriceVariance_Acct, acct.P_AverageCostVariance_Acct,")
+ " acct.P_TradeDiscountRec_Acct, acct.P_TradeDiscountGrant_Acct," .append(" acct.P_TradeDiscountRec_Acct, acct.P_TradeDiscountGrant_Acct,")
+ " acct.P_WIP_Acct,acct.P_FloorStock_Acct,acct.P_MethodChangeVariance_Acct,acct.P_UsageVariance_Acct,acct.P_RateVariance_Acct," .append(" acct.P_WIP_Acct,acct.P_FloorStock_Acct,acct.P_MethodChangeVariance_Acct,acct.P_UsageVariance_Acct,acct.P_RateVariance_Acct,")
+ " acct.P_MixVariance_Acct,acct.P_Labor_Acct,acct.P_Burden_Acct,acct.P_CostOfProduction_Acct,acct.P_OutsideProcessing_Acct,acct.P_Overhead_Acct,acct.P_Scrap_Acct " .append(" acct.P_MixVariance_Acct,acct.P_Labor_Acct,acct.P_Burden_Acct,acct.P_CostOfProduction_Acct,acct.P_OutsideProcessing_Acct,acct.P_Overhead_Acct,acct.P_Scrap_Acct ")
+ "FROM M_Product p" .append("FROM M_Product p")
+ " INNER JOIN M_Product_Category_Acct acct ON (acct.M_Product_Category_ID=p.M_Product_Category_ID)" .append(" INNER JOIN M_Product_Category_Acct acct ON (acct.M_Product_Category_ID=p.M_Product_Category_ID)")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND p.M_Product_Category_ID=acct.M_Product_Category_ID" .append(" AND p.M_Product_Category_ID=acct.M_Product_Category_ID")
+ " AND NOT EXISTS (SELECT * FROM M_Product_Acct pa " .append(" AND NOT EXISTS (SELECT * FROM M_Product_Acct pa ")
+ "WHERE pa.M_Product_ID=p.M_Product_ID" .append("WHERE pa.M_Product_ID=p.M_Product_ID")
+ " AND pa.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND pa.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @M_Product_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @M_Product_ID@");
createdTotal += created; createdTotal += created;
} }
@ -175,51 +175,51 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update Business Partner Group // Update Business Partner Group
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE C_BP_Group_Acct a " sql = new StringBuilder("UPDATE C_BP_Group_Acct a ")
+ "SET C_Receivable_Acct=" + acct.getC_Receivable_Acct() .append("SET C_Receivable_Acct=").append(acct.getC_Receivable_Acct())
+ ", C_Receivable_Services_Acct=" + acct.getC_Receivable_Services_Acct() .append(", C_Receivable_Services_Acct=").append(acct.getC_Receivable_Services_Acct())
+ ", C_Prepayment_Acct=" + acct.getC_Prepayment_Acct() .append(", C_Prepayment_Acct=").append(acct.getC_Prepayment_Acct())
+ ", V_Liability_Acct=" + acct.getV_Liability_Acct() .append(", V_Liability_Acct=").append(acct.getV_Liability_Acct())
+ ", V_Liability_Services_Acct=" + acct.getV_Liability_Services_Acct() .append(", V_Liability_Services_Acct=").append(acct.getV_Liability_Services_Acct())
+ ", V_Prepayment_Acct=" + acct.getV_Prepayment_Acct() .append(", V_Prepayment_Acct=").append(acct.getV_Prepayment_Acct())
+ ", PayDiscount_Exp_Acct=" + acct.getPayDiscount_Exp_Acct() .append(", PayDiscount_Exp_Acct=").append(acct.getPayDiscount_Exp_Acct())
+ ", PayDiscount_Rev_Acct=" + acct.getPayDiscount_Rev_Acct() .append(", PayDiscount_Rev_Acct=").append(acct.getPayDiscount_Rev_Acct())
+ ", WriteOff_Acct=" + acct.getWriteOff_Acct() .append(", WriteOff_Acct=").append(acct.getWriteOff_Acct())
+ ", NotInvoicedReceipts_Acct=" + acct.getNotInvoicedReceipts_Acct() .append(", NotInvoicedReceipts_Acct=").append(acct.getNotInvoicedReceipts_Acct())
+ ", UnEarnedRevenue_Acct=" + acct.getUnEarnedRevenue_Acct() .append(", UnEarnedRevenue_Acct=").append(acct.getUnEarnedRevenue_Acct())
+ ", NotInvoicedRevenue_Acct=" + acct.getNotInvoicedRevenue_Acct() .append(", NotInvoicedRevenue_Acct=").append(acct.getNotInvoicedRevenue_Acct())
+ ", NotInvoicedReceivables_Acct=" + acct.getNotInvoicedReceivables_Acct() .append(", NotInvoicedReceivables_Acct=").append(acct.getNotInvoicedReceivables_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE a.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE a.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM C_BP_Group_Acct x " .append(" AND EXISTS (SELECT * FROM C_BP_Group_Acct x ")
+ "WHERE x.C_BP_Group_ID=a.C_BP_Group_ID)"; .append("WHERE x.C_BP_Group_ID=a.C_BP_Group_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @C_BP_Group_ID@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @C_BP_Group_ID@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert Business Partner Group // Insert Business Partner Group
sql = "INSERT INTO C_BP_Group_Acct " sql = new StringBuilder("INSERT INTO C_BP_Group_Acct ")
+ "(C_BP_Group_ID, C_AcctSchema_ID," .append("(C_BP_Group_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " C_Receivable_Acct, C_Receivable_Services_Acct, C_PrePayment_Acct," .append(" C_Receivable_Acct, C_Receivable_Services_Acct, C_PrePayment_Acct,")
+ " V_Liability_Acct, V_Liability_Services_Acct, V_PrePayment_Acct," .append(" V_Liability_Acct, V_Liability_Services_Acct, V_PrePayment_Acct,")
+ " PayDiscount_Exp_Acct, PayDiscount_Rev_Acct, WriteOff_Acct," .append(" PayDiscount_Exp_Acct, PayDiscount_Rev_Acct, WriteOff_Acct,")
+ " NotInvoicedReceipts_Acct, UnEarnedRevenue_Acct," .append(" NotInvoicedReceipts_Acct, UnEarnedRevenue_Acct,")
+ " NotInvoicedRevenue_Acct, NotInvoicedReceivables_Acct) " .append(" NotInvoicedRevenue_Acct, NotInvoicedReceivables_Acct) ")
+ "SELECT x.C_BP_Group_ID, acct.C_AcctSchema_ID," .append("SELECT x.C_BP_Group_ID, acct.C_AcctSchema_ID,")
+ " x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.C_Receivable_Acct, acct.C_Receivable_Services_Acct, acct.C_PrePayment_Acct," .append(" acct.C_Receivable_Acct, acct.C_Receivable_Services_Acct, acct.C_PrePayment_Acct,")
+ " acct.V_Liability_Acct, acct.V_Liability_Services_Acct, acct.V_PrePayment_Acct," .append(" acct.V_Liability_Acct, acct.V_Liability_Services_Acct, acct.V_PrePayment_Acct,")
+ " acct.PayDiscount_Exp_Acct, acct.PayDiscount_Rev_Acct, acct.WriteOff_Acct," .append(" acct.PayDiscount_Exp_Acct, acct.PayDiscount_Rev_Acct, acct.WriteOff_Acct,")
+ " acct.NotInvoicedReceipts_Acct, acct.UnEarnedRevenue_Acct," .append(" acct.NotInvoicedReceipts_Acct, acct.UnEarnedRevenue_Acct,")
+ " acct.NotInvoicedRevenue_Acct, acct.NotInvoicedReceivables_Acct " .append(" acct.NotInvoicedRevenue_Acct, acct.NotInvoicedReceivables_Acct ")
+ "FROM C_BP_Group x" .append("FROM C_BP_Group x")
+ " INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM C_BP_Group_Acct a " .append(" AND NOT EXISTS (SELECT * FROM C_BP_Group_Acct a ")
+ "WHERE a.C_BP_Group_ID=x.C_BP_Group_ID" .append("WHERE a.C_BP_Group_ID=x.C_BP_Group_ID")
+ " AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_BP_Group_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_BP_Group_ID@");
createdTotal += created; createdTotal += created;
@ -227,69 +227,69 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update Business Partner - Employee // Update Business Partner - Employee
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE C_BP_Employee_Acct a " sql = new StringBuilder("UPDATE C_BP_Employee_Acct a ")
+ "SET E_Expense_Acct=" + acct.getE_Expense_Acct() .append("SET E_Expense_Acct=").append(acct.getE_Expense_Acct())
+ ", E_Prepayment_Acct=" + acct.getE_Prepayment_Acct() .append(", E_Prepayment_Acct=").append(acct.getE_Prepayment_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE a.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE a.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM C_BP_Employee_Acct x " .append(" AND EXISTS (SELECT * FROM C_BP_Employee_Acct x ")
+ "WHERE x.C_BPartner_ID=a.C_BPartner_ID)"; .append("WHERE x.C_BPartner_ID=a.C_BPartner_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @C_BPartner_ID@ @IsEmployee@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @C_BPartner_ID@ @IsEmployee@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert new Business Partner - Employee // Insert new Business Partner - Employee
sql = "INSERT INTO C_BP_Employee_Acct " sql = new StringBuilder("INSERT INTO C_BP_Employee_Acct ")
+ "(C_BPartner_ID, C_AcctSchema_ID," .append("(C_BPartner_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " E_Expense_Acct, E_Prepayment_Acct) " .append(" E_Expense_Acct, E_Prepayment_Acct) ")
+ "SELECT x.C_BPartner_ID, acct.C_AcctSchema_ID," .append("SELECT x.C_BPartner_ID, acct.C_AcctSchema_ID,")
+ " x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.E_Expense_Acct, acct.E_Prepayment_Acct " .append(" acct.E_Expense_Acct, acct.E_Prepayment_Acct ")
+ "FROM C_BPartner x" .append("FROM C_BPartner x")
+ " INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM C_BP_Employee_Acct a " .append(" AND NOT EXISTS (SELECT * FROM C_BP_Employee_Acct a ")
+ "WHERE a.C_BPartner_ID=x.C_BPartner_ID" .append("WHERE a.C_BPartner_ID=x.C_BPartner_ID")
+ " AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_BPartner_ID@ @IsEmployee@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_BPartner_ID@ @IsEmployee@");
createdTotal += created; createdTotal += created;
// //
if (!p_CopyOverwriteAcct) if (!p_CopyOverwriteAcct)
{ {
sql = "INSERT INTO C_BP_Customer_Acct " sql = new StringBuilder("INSERT INTO C_BP_Customer_Acct ")
+ "(C_BPartner_ID, C_AcctSchema_ID," .append("(C_BPartner_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " C_Receivable_Acct, C_Receivable_Services_Acct, C_PrePayment_Acct) " .append(" C_Receivable_Acct, C_Receivable_Services_Acct, C_PrePayment_Acct) ")
+ "SELECT p.C_BPartner_ID, acct.C_AcctSchema_ID," .append("SELECT p.C_BPartner_ID, acct.C_AcctSchema_ID,")
+ " p.AD_Client_ID, p.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" p.AD_Client_ID, p.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.C_Receivable_Acct, acct.C_Receivable_Services_Acct, acct.C_PrePayment_Acct " .append(" acct.C_Receivable_Acct, acct.C_Receivable_Services_Acct, acct.C_PrePayment_Acct ")
+ "FROM C_BPartner p" .append("FROM C_BPartner p")
+ " INNER JOIN C_BP_Group_Acct acct ON (acct.C_BP_Group_ID=p.C_BP_Group_ID)" .append(" INNER JOIN C_BP_Group_Acct acct ON (acct.C_BP_Group_ID=p.C_BP_Group_ID)")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID // # .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID) // #
+ " AND p.C_BP_Group_ID=acct.C_BP_Group_ID" .append(" AND p.C_BP_Group_ID=acct.C_BP_Group_ID")
+ " AND NOT EXISTS (SELECT * FROM C_BP_Customer_Acct ca " .append(" AND NOT EXISTS (SELECT * FROM C_BP_Customer_Acct ca ")
+ "WHERE ca.C_BPartner_ID=p.C_BPartner_ID" .append("WHERE ca.C_BPartner_ID=p.C_BPartner_ID")
+ " AND ca.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND ca.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_BPartner_ID@ @IsCustomer@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_BPartner_ID@ @IsCustomer@");
createdTotal += created; createdTotal += created;
// //
sql = "INSERT INTO C_BP_Vendor_Acct " sql = new StringBuilder("INSERT INTO C_BP_Vendor_Acct ")
+ "(C_BPartner_ID, C_AcctSchema_ID," .append("(C_BPartner_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " V_Liability_Acct, V_Liability_Services_Acct, V_PrePayment_Acct) " .append(" V_Liability_Acct, V_Liability_Services_Acct, V_PrePayment_Acct) ")
+ "SELECT p.C_BPartner_ID, acct.C_AcctSchema_ID," .append("SELECT p.C_BPartner_ID, acct.C_AcctSchema_ID,")
+ " p.AD_Client_ID, p.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" p.AD_Client_ID, p.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.V_Liability_Acct, acct.V_Liability_Services_Acct, acct.V_PrePayment_Acct " .append(" acct.V_Liability_Acct, acct.V_Liability_Services_Acct, acct.V_PrePayment_Acct ")
+ "FROM C_BPartner p" .append("FROM C_BPartner p")
+ " INNER JOIN C_BP_Group_Acct acct ON (acct.C_BP_Group_ID=p.C_BP_Group_ID)" .append(" INNER JOIN C_BP_Group_Acct acct ON (acct.C_BP_Group_ID=p.C_BP_Group_ID)")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID // # .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID) // #
+ " AND p.C_BP_Group_ID=acct.C_BP_Group_ID" .append(" AND p.C_BP_Group_ID=acct.C_BP_Group_ID")
+ " AND NOT EXISTS (SELECT * FROM C_BP_Vendor_Acct va " .append(" AND NOT EXISTS (SELECT * FROM C_BP_Vendor_Acct va ")
+ "WHERE va.C_BPartner_ID=p.C_BPartner_ID AND va.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append("WHERE va.C_BPartner_ID=p.C_BPartner_ID AND va.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_BPartner_ID@ @IsVendor@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_BPartner_ID@ @IsVendor@");
createdTotal += created; createdTotal += created;
} }
@ -297,34 +297,34 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update Warehouse // Update Warehouse
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE M_Warehouse_Acct a " sql = new StringBuilder("UPDATE M_Warehouse_Acct a ")
+ "SET W_Inventory_Acct=" + acct.getW_Inventory_Acct() .append("SET W_Inventory_Acct=").append(acct.getW_Inventory_Acct())
+ ", W_Differences_Acct=" + acct.getW_Differences_Acct() .append(", W_Differences_Acct=").append(acct.getW_Differences_Acct())
+ ", W_Revaluation_Acct=" + acct.getW_Revaluation_Acct() .append(", W_Revaluation_Acct=").append(acct.getW_Revaluation_Acct())
+ ", W_InvActualAdjust_Acct=" + acct.getW_InvActualAdjust_Acct() .append(", W_InvActualAdjust_Acct=").append(acct.getW_InvActualAdjust_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE a.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE a.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM M_Warehouse_Acct x " .append(" AND EXISTS (SELECT * FROM M_Warehouse_Acct x ")
+ "WHERE x.M_Warehouse_ID=a.M_Warehouse_ID)"; .append("WHERE x.M_Warehouse_ID=a.M_Warehouse_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @M_Warehouse_ID@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @M_Warehouse_ID@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert new Warehouse // Insert new Warehouse
sql = "INSERT INTO M_Warehouse_Acct " sql = new StringBuilder("INSERT INTO M_Warehouse_Acct ")
+ "(M_Warehouse_ID, C_AcctSchema_ID," .append("(M_Warehouse_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " W_Inventory_Acct, W_Differences_Acct, W_Revaluation_Acct, W_InvActualAdjust_Acct) " .append(" W_Inventory_Acct, W_Differences_Acct, W_Revaluation_Acct, W_InvActualAdjust_Acct) ")
+ "SELECT x.M_Warehouse_ID, acct.C_AcctSchema_ID," .append("SELECT x.M_Warehouse_ID, acct.C_AcctSchema_ID,")
+ " x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.W_Inventory_Acct, acct.W_Differences_Acct, acct.W_Revaluation_Acct, acct.W_InvActualAdjust_Acct " .append(" acct.W_Inventory_Acct, acct.W_Differences_Acct, acct.W_Revaluation_Acct, acct.W_InvActualAdjust_Acct ")
+ "FROM M_Warehouse x" .append("FROM M_Warehouse x")
+ " INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM M_Warehouse_Acct a " .append(" AND NOT EXISTS (SELECT * FROM M_Warehouse_Acct a ")
+ "WHERE a.M_Warehouse_ID=x.M_Warehouse_ID" .append("WHERE a.M_Warehouse_ID=x.M_Warehouse_ID")
+ " AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @M_Warehouse_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @M_Warehouse_ID@");
createdTotal += created; createdTotal += created;
@ -332,32 +332,32 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update Project // Update Project
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE C_Project_Acct a " sql = new StringBuilder("UPDATE C_Project_Acct a ")
+ "SET PJ_Asset_Acct=" + acct.getPJ_Asset_Acct() .append("SET PJ_Asset_Acct=").append(acct.getPJ_Asset_Acct())
+ ", PJ_WIP_Acct=" + acct.getPJ_Asset_Acct() .append(", PJ_WIP_Acct=").append(acct.getPJ_Asset_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE a.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE a.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM C_Project_Acct x " .append(" AND EXISTS (SELECT * FROM C_Project_Acct x ")
+ "WHERE x.C_Project_ID=a.C_Project_ID)"; .append("WHERE x.C_Project_ID=a.C_Project_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Project_ID@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Project_ID@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert new Projects // Insert new Projects
sql = "INSERT INTO C_Project_Acct " sql = new StringBuilder("INSERT INTO C_Project_Acct ")
+ "(C_Project_ID, C_AcctSchema_ID," .append("(C_Project_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " PJ_Asset_Acct, PJ_WIP_Acct) " .append(" PJ_Asset_Acct, PJ_WIP_Acct) ")
+ "SELECT x.C_Project_ID, acct.C_AcctSchema_ID," .append("SELECT x.C_Project_ID, acct.C_AcctSchema_ID,")
+ " x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.PJ_Asset_Acct, acct.PJ_WIP_Acct " .append(" acct.PJ_Asset_Acct, acct.PJ_WIP_Acct ")
+ "FROM C_Project x" .append("FROM C_Project x")
+ " INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM C_Project_Acct a " .append(" AND NOT EXISTS (SELECT * FROM C_Project_Acct a ")
+ "WHERE a.C_Project_ID=x.C_Project_ID" .append("WHERE a.C_Project_ID=x.C_Project_ID")
+ " AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_Project_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_Project_ID@");
createdTotal += created; createdTotal += created;
@ -365,35 +365,35 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update Tax // Update Tax
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE C_Tax_Acct a " sql = new StringBuilder("UPDATE C_Tax_Acct a ")
+ "SET T_Due_Acct=" + acct.getT_Due_Acct() .append("SET T_Due_Acct=").append(acct.getT_Due_Acct())
+ ", T_Liability_Acct=" + acct.getT_Liability_Acct() .append(", T_Liability_Acct=").append(acct.getT_Liability_Acct())
+ ", T_Credit_Acct=" + acct.getT_Credit_Acct() .append(", T_Credit_Acct=").append(acct.getT_Credit_Acct())
+ ", T_Receivables_Acct=" + acct.getT_Receivables_Acct() .append(", T_Receivables_Acct=").append(acct.getT_Receivables_Acct())
+ ", T_Expense_Acct=" + acct.getT_Expense_Acct() .append(", T_Expense_Acct=").append(acct.getT_Expense_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE a.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE a.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM C_Tax_Acct x " .append(" AND EXISTS (SELECT * FROM C_Tax_Acct x ")
+ "WHERE x.C_Tax_ID=a.C_Tax_ID)"; .append("WHERE x.C_Tax_ID=a.C_Tax_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Tax_ID@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Tax_ID@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert new Tax // Insert new Tax
sql = "INSERT INTO C_Tax_Acct " sql = new StringBuilder("INSERT INTO C_Tax_Acct ")
+ "(C_Tax_ID, C_AcctSchema_ID," .append("(C_Tax_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " T_Due_Acct, T_Liability_Acct, T_Credit_Acct, T_Receivables_Acct, T_Expense_Acct) " .append(" T_Due_Acct, T_Liability_Acct, T_Credit_Acct, T_Receivables_Acct, T_Expense_Acct) ")
+ "SELECT x.C_Tax_ID, acct.C_AcctSchema_ID," .append("SELECT x.C_Tax_ID, acct.C_AcctSchema_ID,")
+ " x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.T_Due_Acct, acct.T_Liability_Acct, acct.T_Credit_Acct, acct.T_Receivables_Acct, acct.T_Expense_Acct " .append(" acct.T_Due_Acct, acct.T_Liability_Acct, acct.T_Credit_Acct, acct.T_Receivables_Acct, acct.T_Expense_Acct ")
+ "FROM C_Tax x" .append("FROM C_Tax x")
+ " INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM C_Tax_Acct a " .append(" AND NOT EXISTS (SELECT * FROM C_Tax_Acct a ")
+ "WHERE a.C_Tax_ID=x.C_Tax_ID" .append("WHERE a.C_Tax_ID=x.C_Tax_ID")
+ " AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_Tax_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_Tax_ID@");
createdTotal += created; createdTotal += created;
@ -401,48 +401,48 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update BankAccount // Update BankAccount
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE C_BankAccount_Acct a " sql = new StringBuilder("UPDATE C_BankAccount_Acct a ")
+ "SET B_InTransit_Acct=" + acct.getB_InTransit_Acct() .append("SET B_InTransit_Acct=").append(acct.getB_InTransit_Acct())
+ ", B_Asset_Acct=" + acct.getB_Asset_Acct() .append(", B_Asset_Acct=").append(acct.getB_Asset_Acct())
+ ", B_Expense_Acct=" + acct.getB_Expense_Acct() .append(", B_Expense_Acct=").append(acct.getB_Expense_Acct())
+ ", B_InterestRev_Acct=" + acct.getB_InterestRev_Acct() .append(", B_InterestRev_Acct=").append(acct.getB_InterestRev_Acct())
+ ", B_InterestExp_Acct=" + acct.getB_InterestExp_Acct() .append(", B_InterestExp_Acct=").append(acct.getB_InterestExp_Acct())
+ ", B_Unidentified_Acct=" + acct.getB_Unidentified_Acct() .append(", B_Unidentified_Acct=").append(acct.getB_Unidentified_Acct())
+ ", B_UnallocatedCash_Acct=" + acct.getB_UnallocatedCash_Acct() .append(", B_UnallocatedCash_Acct=").append(acct.getB_UnallocatedCash_Acct())
+ ", B_PaymentSelect_Acct=" + acct.getB_PaymentSelect_Acct() .append(", B_PaymentSelect_Acct=").append(acct.getB_PaymentSelect_Acct())
+ ", B_SettlementGain_Acct=" + acct.getB_SettlementGain_Acct() .append(", B_SettlementGain_Acct=").append(acct.getB_SettlementGain_Acct())
+ ", B_SettlementLoss_Acct=" + acct.getB_SettlementLoss_Acct() .append(", B_SettlementLoss_Acct=").append(acct.getB_SettlementLoss_Acct())
+ ", B_RevaluationGain_Acct=" + acct.getB_RevaluationGain_Acct() .append(", B_RevaluationGain_Acct=").append(acct.getB_RevaluationGain_Acct())
+ ", B_RevaluationLoss_Acct=" + acct.getB_RevaluationLoss_Acct() .append(", B_RevaluationLoss_Acct=").append(acct.getB_RevaluationLoss_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE a.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE a.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM C_BankAccount_Acct x " .append(" AND EXISTS (SELECT * FROM C_BankAccount_Acct x ")
+ "WHERE x.C_BankAccount_ID=a.C_BankAccount_ID)"; .append("WHERE x.C_BankAccount_ID=a.C_BankAccount_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @C_BankAccount_ID@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @C_BankAccount_ID@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert new BankAccount // Insert new BankAccount
sql = "INSERT INTO C_BankAccount_Acct " sql = new StringBuilder("INSERT INTO C_BankAccount_Acct ")
+ "(C_BankAccount_ID, C_AcctSchema_ID," .append("(C_BankAccount_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " B_InTransit_Acct, B_Asset_Acct, B_Expense_Acct, B_InterestRev_Acct, B_InterestExp_Acct," .append(" B_InTransit_Acct, B_Asset_Acct, B_Expense_Acct, B_InterestRev_Acct, B_InterestExp_Acct,")
+ " B_Unidentified_Acct, B_UnallocatedCash_Acct, B_PaymentSelect_Acct," .append(" B_Unidentified_Acct, B_UnallocatedCash_Acct, B_PaymentSelect_Acct,")
+ " B_SettlementGain_Acct, B_SettlementLoss_Acct," .append(" B_SettlementGain_Acct, B_SettlementLoss_Acct,")
+ " B_RevaluationGain_Acct, B_RevaluationLoss_Acct) " .append(" B_RevaluationGain_Acct, B_RevaluationLoss_Acct) ")
+ "SELECT x.C_BankAccount_ID, acct.C_AcctSchema_ID," .append("SELECT x.C_BankAccount_ID, acct.C_AcctSchema_ID,")
+ " x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.B_InTransit_Acct, acct.B_Asset_Acct, acct.B_Expense_Acct, acct.B_InterestRev_Acct, acct.B_InterestExp_Acct," .append(" acct.B_InTransit_Acct, acct.B_Asset_Acct, acct.B_Expense_Acct, acct.B_InterestRev_Acct, acct.B_InterestExp_Acct,")
+ " acct.B_Unidentified_Acct, acct.B_UnallocatedCash_Acct, acct.B_PaymentSelect_Acct," .append(" acct.B_Unidentified_Acct, acct.B_UnallocatedCash_Acct, acct.B_PaymentSelect_Acct,")
+ " acct.B_SettlementGain_Acct, acct.B_SettlementLoss_Acct," .append(" acct.B_SettlementGain_Acct, acct.B_SettlementLoss_Acct,")
+ " acct.B_RevaluationGain_Acct, acct.B_RevaluationLoss_Acct " .append(" acct.B_RevaluationGain_Acct, acct.B_RevaluationLoss_Acct ")
+ "FROM C_BankAccount x" .append("FROM C_BankAccount x")
+ " INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM C_BankAccount_Acct a " .append(" AND NOT EXISTS (SELECT * FROM C_BankAccount_Acct a ")
+ "WHERE a.C_BankAccount_ID=x.C_BankAccount_ID" .append("WHERE a.C_BankAccount_ID=x.C_BankAccount_ID")
+ " AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_BankAccount_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_BankAccount_ID@");
createdTotal += created; createdTotal += created;
@ -450,31 +450,31 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update Withholding // Update Withholding
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE C_Withholding_Acct a " sql = new StringBuilder("UPDATE C_Withholding_Acct a ")
+ "SET Withholding_Acct=" + acct.getWithholding_Acct() .append("SET Withholding_Acct=").append(acct.getWithholding_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE a.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE a.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM C_Withholding_Acct x " .append(" AND EXISTS (SELECT * FROM C_Withholding_Acct x ")
+ "WHERE x.C_Withholding_ID=a.C_Withholding_ID)"; .append("WHERE x.C_Withholding_ID=a.C_Withholding_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Withholding_ID@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Withholding_ID@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert new Withholding // Insert new Withholding
sql = "INSERT INTO C_Withholding_Acct " sql = new StringBuilder("INSERT INTO C_Withholding_Acct ")
+ "(C_Withholding_ID, C_AcctSchema_ID," .append("(C_Withholding_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " Withholding_Acct) " .append(" Withholding_Acct) ")
+ "SELECT x.C_Withholding_ID, acct.C_AcctSchema_ID," .append("SELECT x.C_Withholding_ID, acct.C_AcctSchema_ID,")
+ " x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.Withholding_Acct " .append(" acct.Withholding_Acct ")
+ "FROM C_Withholding x" .append("FROM C_Withholding x")
+ " INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM C_Withholding_Acct a " .append(" AND NOT EXISTS (SELECT * FROM C_Withholding_Acct a ")
+ "WHERE a.C_Withholding_ID=x.C_Withholding_ID" .append("WHERE a.C_Withholding_ID=x.C_Withholding_ID")
+ " AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_Withholding_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_Withholding_ID@");
createdTotal += created; createdTotal += created;
@ -482,31 +482,31 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update Charge // Update Charge
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE C_Charge_Acct a " sql = new StringBuilder("UPDATE C_Charge_Acct a ")
+ "SET Ch_Expense_Acct=" + acct.getCh_Expense_Acct() .append("SET Ch_Expense_Acct=").append(acct.getCh_Expense_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE a.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE a.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM C_Charge_Acct x " .append(" AND EXISTS (SELECT * FROM C_Charge_Acct x ")
+ "WHERE x.C_Charge_ID=a.C_Charge_ID)"; .append("WHERE x.C_Charge_ID=a.C_Charge_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Charge_ID@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Charge_ID@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert new Charge // Insert new Charge
sql = "INSERT INTO C_Charge_Acct " sql = new StringBuilder("INSERT INTO C_Charge_Acct ")
+ "(C_Charge_ID, C_AcctSchema_ID," .append("(C_Charge_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " Ch_Expense_Acct) " .append(" Ch_Expense_Acct) ")
+ "SELECT x.C_Charge_ID, acct.C_AcctSchema_ID," .append("SELECT x.C_Charge_ID, acct.C_AcctSchema_ID,")
+ " x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.Ch_Expense_Acct " .append(" acct.Ch_Expense_Acct ")
+ "FROM C_Charge x" .append("FROM C_Charge x")
+ " INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM C_Charge_Acct a " .append(" AND NOT EXISTS (SELECT * FROM C_Charge_Acct a ")
+ "WHERE a.C_Charge_ID=x.C_Charge_ID" .append("WHERE a.C_Charge_ID=x.C_Charge_ID")
+ " AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_Charge_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_Charge_ID@");
createdTotal += created; createdTotal += created;
@ -514,41 +514,42 @@ public class AcctSchemaDefaultCopy extends SvrProcess
// Update Cashbook // Update Cashbook
if (p_CopyOverwriteAcct) if (p_CopyOverwriteAcct)
{ {
sql = "UPDATE C_Cashbook_Acct a " sql = new StringBuilder("UPDATE C_Cashbook_Acct a ")
+ "SET CB_Asset_Acct=" + acct.getCB_Asset_Acct() .append("SET CB_Asset_Acct=").append(acct.getCB_Asset_Acct())
+ ", CB_Differences_Acct=" + acct.getCB_Differences_Acct() .append(", CB_Differences_Acct=").append(acct.getCB_Differences_Acct())
+ ", CB_CashTransfer_Acct=" + acct.getCB_CashTransfer_Acct() .append(", CB_CashTransfer_Acct=").append(acct.getCB_CashTransfer_Acct())
+ ", CB_Expense_Acct=" + acct.getCB_Expense_Acct() .append(", CB_Expense_Acct=").append(acct.getCB_Expense_Acct())
+ ", CB_Receipt_Acct=" + acct.getCB_Receipt_Acct() .append(", CB_Receipt_Acct=").append(acct.getCB_Receipt_Acct())
+ ", Updated=SysDate, UpdatedBy=0 " .append(", Updated=SysDate, UpdatedBy=0 ")
+ "WHERE a.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE a.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND EXISTS (SELECT * FROM C_Cashbook_Acct x " .append(" AND EXISTS (SELECT * FROM C_Cashbook_Acct x ")
+ "WHERE x.C_Cashbook_ID=a.C_Cashbook_ID)"; .append("WHERE x.C_Cashbook_ID=a.C_Cashbook_ID)");
updated = DB.executeUpdate(sql, get_TrxName()); updated = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Cashbook_ID@"); addLog(0, null, new BigDecimal(updated), "@Updated@ @C_Cashbook_ID@");
updatedTotal += updated; updatedTotal += updated;
} }
// Insert new Cashbook // Insert new Cashbook
sql = "INSERT INTO C_Cashbook_Acct " sql = new StringBuilder("INSERT INTO C_Cashbook_Acct ")
+ "(C_Cashbook_ID, C_AcctSchema_ID," .append("(C_Cashbook_ID, C_AcctSchema_ID,")
+ " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," .append(" AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,")
+ " CB_Asset_Acct, CB_Differences_Acct, CB_CashTransfer_Acct," .append(" CB_Asset_Acct, CB_Differences_Acct, CB_CashTransfer_Acct,")
+ " CB_Expense_Acct, CB_Receipt_Acct) " .append(" CB_Expense_Acct, CB_Receipt_Acct) ")
+ "SELECT x.C_Cashbook_ID, acct.C_AcctSchema_ID," .append("SELECT x.C_Cashbook_ID, acct.C_AcctSchema_ID,")
+ " x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," .append(" x.AD_Client_ID, x.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0,")
+ " acct.CB_Asset_Acct, acct.CB_Differences_Acct, acct.CB_CashTransfer_Acct," .append(" acct.CB_Asset_Acct, acct.CB_Differences_Acct, acct.CB_CashTransfer_Acct,")
+ " acct.CB_Expense_Acct, acct.CB_Receipt_Acct " .append(" acct.CB_Expense_Acct, acct.CB_Receipt_Acct ")
+ "FROM C_Cashbook x" .append("FROM C_Cashbook x")
+ " INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) " .append(" INNER JOIN C_AcctSchema_Default acct ON (x.AD_Client_ID=acct.AD_Client_ID) ")
+ "WHERE acct.C_AcctSchema_ID=" + p_C_AcctSchema_ID .append("WHERE acct.C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
+ " AND NOT EXISTS (SELECT * FROM C_Cashbook_Acct a " .append(" AND NOT EXISTS (SELECT * FROM C_Cashbook_Acct a ")
+ "WHERE a.C_Cashbook_ID=x.C_Cashbook_ID" .append("WHERE a.C_Cashbook_ID=x.C_Cashbook_ID")
+ " AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)"; .append(" AND a.C_AcctSchema_ID=acct.C_AcctSchema_ID)");
created = DB.executeUpdate(sql, get_TrxName()); created = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@ @C_Cashbook_ID@"); addLog(0, null, new BigDecimal(created), "@Created@ @C_Cashbook_ID@");
createdTotal += created; createdTotal += created;
return "@Created@=" + createdTotal + ", @Updated@=" + updatedTotal; StringBuilder msgreturn = new StringBuilder("@Created@=").append(createdTotal).append(", @Updated@=").append(updatedTotal);
return msgreturn.toString();
} // doIt } // doIt
} // AcctSchemaDefaultCopy } // AcctSchemaDefaultCopy

View File

@ -170,7 +170,8 @@ public class AllocationAuto extends SvrProcess
} }
} }
// //
return "@Created@ #" + countBP + "/" + countAlloc; StringBuilder msgreturn = new StringBuilder("@Created@ #").append(countBP).append("/").append(countAlloc);
return msgreturn.toString();
} // doIt } // doIt
/** /**
@ -258,19 +259,19 @@ public class AllocationAuto extends SvrProcess
private MPayment[] getPayments (int C_BPartner_ID) private MPayment[] getPayments (int C_BPartner_ID)
{ {
ArrayList<MPayment> list = new ArrayList<MPayment>(); ArrayList<MPayment> list = new ArrayList<MPayment>();
String sql = "SELECT * FROM C_Payment " StringBuilder sql = new StringBuilder("SELECT * FROM C_Payment ")
+ "WHERE IsAllocated='N' AND Processed='Y' AND C_BPartner_ID=?" .append("WHERE IsAllocated='N' AND Processed='Y' AND C_BPartner_ID=?")
+ " AND IsPrepayment='N' AND C_Charge_ID IS NULL "; .append(" AND IsPrepayment='N' AND C_Charge_ID IS NULL ");
if (ONLY_AP.equals(p_APAR)) if (ONLY_AP.equals(p_APAR))
sql += "AND IsReceipt='N' "; sql.append("AND IsReceipt='N' ");
else if (ONLY_AR.equals(p_APAR)) else if (ONLY_AR.equals(p_APAR))
sql += "AND IsReceipt='Y' "; sql.append("AND IsReceipt='Y' ");
sql += "ORDER BY DateTrx"; sql.append("ORDER BY DateTrx");
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, C_BPartner_ID); pstmt.setInt (1, C_BPartner_ID);
rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
@ -288,7 +289,7 @@ public class AllocationAuto extends SvrProcess
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql.toString(), e);
} }
finally finally
{ {
@ -308,18 +309,18 @@ public class AllocationAuto extends SvrProcess
private MInvoice[] getInvoices (int C_BPartner_ID) private MInvoice[] getInvoices (int C_BPartner_ID)
{ {
ArrayList<MInvoice> list = new ArrayList<MInvoice>(); ArrayList<MInvoice> list = new ArrayList<MInvoice>();
String sql = "SELECT * FROM C_Invoice " StringBuilder sql = new StringBuilder("SELECT * FROM C_Invoice ")
+ "WHERE IsPaid='N' AND Processed='Y' AND C_BPartner_ID=? "; .append("WHERE IsPaid='N' AND Processed='Y' AND C_BPartner_ID=? ");
if (ONLY_AP.equals(p_APAR)) if (ONLY_AP.equals(p_APAR))
sql += "AND IsSOTrx='N' "; sql.append("AND IsSOTrx='N' ");
else if (ONLY_AR.equals(p_APAR)) else if (ONLY_AR.equals(p_APAR))
sql += "AND IsSOTrx='Y' "; sql.append("AND IsSOTrx='Y' ");
sql += "ORDER BY DateInvoiced"; sql.append("ORDER BY DateInvoiced");
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, C_BPartner_ID); pstmt.setInt (1, C_BPartner_ID);
rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
@ -336,7 +337,7 @@ public class AllocationAuto extends SvrProcess
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql.toString(), e);
} }
finally finally
{ {
@ -768,8 +769,9 @@ public class AllocationAuto extends SvrProcess
if (allocatedPayments.compareTo(allocatedInvoices) != 0) if (allocatedPayments.compareTo(allocatedInvoices) != 0)
{ {
throw new AdempiereSystemError("Allocated Payments=" + allocatedPayments StringBuilder msg = new StringBuilder("Allocated Payments=").append(allocatedPayments)
+ " <> Invoices=" + allocatedInvoices); .append(" <> Invoices=").append(allocatedInvoices);
throw new AdempiereSystemError(msg.toString());
} }
processAllocation(); processAllocation();
return 1; return 1;
@ -828,9 +830,11 @@ public class AllocationAuto extends SvrProcess
if (m_allocation == null) if (m_allocation == null)
return true; return true;
boolean success = m_allocation.processIt(MAllocationHdr.DOCACTION_Complete); boolean success = m_allocation.processIt(MAllocationHdr.DOCACTION_Complete);
if (!success) if (!success){
throw new IllegalStateException("Allocation Process Failed "+ m_allocation.getDocumentNo() + StringBuilder msg = new StringBuilder("Allocation Process Failed ").append(m_allocation.getDocumentNo())
" " + m_allocation.getProcessMsg()); .append(" ").append( m_allocation.getProcessMsg());
throw new IllegalStateException(msg.toString());
}
else else
m_allocation.saveEx(); m_allocation.saveEx();
addLog(0, m_allocation.getDateAcct(), null, m_allocation.getDescription()); addLog(0, m_allocation.getDateAcct(), null, m_allocation.getDescription());

View File

@ -115,14 +115,14 @@ public class AllocationReset extends SvrProcess
} }
// Selection // Selection
StringBuffer sql = new StringBuffer("SELECT * FROM C_AllocationHdr ah " StringBuilder sql = new StringBuilder("SELECT * FROM C_AllocationHdr ah ")
+ "WHERE EXISTS (SELECT * FROM C_AllocationLine al " .append("WHERE EXISTS (SELECT * FROM C_AllocationLine al ")
+ "WHERE ah.C_AllocationHdr_ID=al.C_AllocationHdr_ID"); .append("WHERE ah.C_AllocationHdr_ID=al.C_AllocationHdr_ID");
if (p_C_BPartner_ID != 0) if (p_C_BPartner_ID != 0)
sql.append(" AND al.C_BPartner_ID=?"); sql.append(" AND al.C_BPartner_ID=?");
else if (p_C_BP_Group_ID != 0) else if (p_C_BP_Group_ID != 0)
sql.append(" AND EXISTS (SELECT * FROM C_BPartner bp " sql.append(" AND EXISTS (SELECT * FROM C_BPartner bp ")
+ "WHERE bp.C_BPartner_ID=al.C_BPartner_ID AND bp.C_BP_Group_ID=?)"); .append("WHERE bp.C_BPartner_ID=al.C_BPartner_ID AND bp.C_BP_Group_ID=?)");
else else
sql.append(" AND AD_Client_ID=?"); sql.append(" AND AD_Client_ID=?");
if (p_DateAcct_From != null) if (p_DateAcct_From != null)
@ -132,9 +132,9 @@ public class AllocationReset extends SvrProcess
// Do not delete Cash Trx // Do not delete Cash Trx
sql.append(" AND al.C_CashLine_ID IS NULL)"); sql.append(" AND al.C_CashLine_ID IS NULL)");
// Open Period // Open Period
sql.append(" AND EXISTS (SELECT * FROM C_Period p" sql.append(" AND EXISTS (SELECT * FROM C_Period p")
+ " INNER JOIN C_PeriodControl pc ON (p.C_Period_ID=pc.C_Period_ID AND pc.DocBaseType='CMA') " .append(" INNER JOIN C_PeriodControl pc ON (p.C_Period_ID=pc.C_Period_ID AND pc.DocBaseType='CMA') ")
+ "WHERE ah.DateAcct BETWEEN p.StartDate AND p.EndDate)"); .append("WHERE ah.DateAcct BETWEEN p.StartDate AND p.EndDate)");
// //
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;

View File

@ -112,10 +112,10 @@ public class AssetDelivery extends SvrProcess
return msg; return msg;
} }
// //
StringBuffer sql = new StringBuffer ("SELECT A_Asset_ID, GuaranteeDate " StringBuilder sql = new StringBuilder("SELECT A_Asset_ID, GuaranteeDate ")
+ "FROM A_Asset a" .append("FROM A_Asset a")
+ " INNER JOIN M_Product p ON (a.M_Product_ID=p.M_Product_ID) " .append(" INNER JOIN M_Product p ON (a.M_Product_ID=p.M_Product_ID) ")
+ "WHERE "); .append("WHERE ");
if (m_A_Asset_Group_ID != 0) if (m_A_Asset_Group_ID != 0)
sql.append("a.A_Asset_Group_ID=").append(m_A_Asset_Group_ID).append(" AND "); sql.append("a.A_Asset_Group_ID=").append(m_A_Asset_Group_ID).append(" AND ");
if (m_M_Product_ID != 0) if (m_M_Product_ID != 0)

View File

@ -44,17 +44,17 @@ public class BOMFlagValidate extends SvrProcess {
{ {
//Select Products where there's a BOM, and there are no lines //Select Products where there's a BOM, and there are no lines
String sql = "SELECT Name, M_Product_ID FROM M_Product WHERE IsBOM = 'Y' AND " + StringBuilder sql = new StringBuilder("SELECT Name, M_Product_ID FROM M_Product WHERE IsBOM = 'Y' AND ")
"M_Product_ID NOT IN (SELECT M_Product_ID FROM M_Product_BOM ) AND "; .append("M_Product_ID NOT IN (SELECT M_Product_ID FROM M_Product_BOM ) AND ");
if (p_M_Product_Category_ID == 0) if (p_M_Product_Category_ID == 0)
sql += "AD_Client_ID= ?"; sql.append("AD_Client_ID= ?");
else else
sql += "M_Product_Category_ID= ?"; sql.append("M_Product_Category_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());
if (p_M_Product_Category_ID == 0) if (p_M_Product_Category_ID == 0)
pstmt.setInt (1, Env.getAD_Client_ID(getCtx())); pstmt.setInt (1, Env.getAD_Client_ID(getCtx()));
else else
@ -63,7 +63,8 @@ public class BOMFlagValidate extends SvrProcess {
while (rs.next()) while (rs.next())
{ {
addLog(0, null, null, rs.getString(1) + " BOM without BOM lines", MProduct.Table_ID, rs.getInt(2)); StringBuilder msglog=new StringBuilder(rs.getString(1)).append(" BOM without BOM lines");
addLog(0, null, null, msglog.toString(), MProduct.Table_ID, rs.getInt(2));
} }
} catch (SQLException e) { } catch (SQLException e) {
throw e; throw e;
@ -74,13 +75,13 @@ public class BOMFlagValidate extends SvrProcess {
PreparedStatement upstmt = null; PreparedStatement upstmt = null;
try { try {
String update = "UPDATE M_Product SET IsBOM = 'N' WHERE IsBOM = 'Y' AND M_Product_ID NOT IN " + StringBuilder update = new StringBuilder("UPDATE M_Product SET IsBOM = 'N' WHERE IsBOM = 'Y' AND M_Product_ID NOT IN ")
"(SELECT M_Product_ID FROM M_Product_BOM ) AND "; .append("(SELECT M_Product_ID FROM M_Product_BOM ) AND ");
if (p_M_Product_Category_ID == 0) if (p_M_Product_Category_ID == 0)
update += "AD_Client_ID= ?"; update.append("AD_Client_ID= ?");
else else
update += "M_Product_Category_ID= ?"; update.append("M_Product_Category_ID= ?");
upstmt = DB.prepareStatement (update, get_TrxName()); upstmt = DB.prepareStatement (update.toString(), get_TrxName());
if (p_M_Product_Category_ID == 0) if (p_M_Product_Category_ID == 0)
upstmt.setInt (1, Env.getAD_Client_ID(getCtx())); upstmt.setInt (1, Env.getAD_Client_ID(getCtx()));
else else
@ -99,17 +100,17 @@ public class BOMFlagValidate extends SvrProcess {
{ {
//Select Products where there's a BOM, and there are no lines //Select Products where there's a BOM, and there are no lines
String sql = "SELECT Name, M_Product_ID FROM M_Product WHERE IsBOM = 'N' AND " + StringBuilder sql = new StringBuilder("SELECT Name, M_Product_ID FROM M_Product WHERE IsBOM = 'N' AND ")
"M_Product_ID IN (SELECT M_Product_ID FROM M_Product_BOM ) AND "; .append("M_Product_ID IN (SELECT M_Product_ID FROM M_Product_BOM ) AND ");
if (p_M_Product_Category_ID == 0) if (p_M_Product_Category_ID == 0)
sql += "AD_Client_ID= ?"; sql.append("AD_Client_ID= ?");
else else
sql += "M_Product_Category_ID= ?"; sql.append("M_Product_Category_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());
if (p_M_Product_Category_ID == 0) if (p_M_Product_Category_ID == 0)
pstmt.setInt (1, Env.getAD_Client_ID(getCtx())); pstmt.setInt (1, Env.getAD_Client_ID(getCtx()));
else else
@ -118,7 +119,8 @@ public class BOMFlagValidate extends SvrProcess {
while (rs.next()) while (rs.next())
{ {
addLog(0, null, null, rs.getString(1) + " not BOM with BOM lines", MProduct.Table_ID, rs.getInt(2)); StringBuilder msglog = new StringBuilder(rs.getString(1)).append(" not BOM with BOM lines");
addLog(0, null, null, msglog.toString(), MProduct.Table_ID, rs.getInt(2));
} }
} catch (SQLException e) { } catch (SQLException e) {
throw e; throw e;
@ -127,15 +129,15 @@ public class BOMFlagValidate extends SvrProcess {
rs = null; pstmt = null; rs = null; pstmt = null;
} }
String update = "UPDATE M_Product SET ISBOM = 'Y' WHERE IsBOM = 'N' AND M_Product_ID IN " + StringBuilder update = new StringBuilder("UPDATE M_Product SET ISBOM = 'Y' WHERE IsBOM = 'N' AND M_Product_ID IN ")
"(SELECT M_Product_ID FROM M_Product_BOM ) AND "; .append("(SELECT M_Product_ID FROM M_Product_BOM ) AND ");
if (p_M_Product_Category_ID == 0) if (p_M_Product_Category_ID == 0)
update += "AD_Client_ID= ?"; update.append("AD_Client_ID= ?");
else else
update += "M_Product_Category_ID= ?"; update.append("M_Product_Category_ID= ?");
PreparedStatement upstmt = null; PreparedStatement upstmt = null;
try { try {
upstmt = DB.prepareStatement (update, get_TrxName()); upstmt = DB.prepareStatement (update.toString(), get_TrxName());
if (p_M_Product_Category_ID == 0) if (p_M_Product_Category_ID == 0)
upstmt.setInt (1, Env.getAD_Client_ID(getCtx())); upstmt.setInt (1, Env.getAD_Client_ID(getCtx()));
else else

View File

@ -101,10 +101,10 @@ public class BankStatementPayment extends SvrProcess
ibs.setTrxAmt(payment.getPayAmt(true)); ibs.setTrxAmt(payment.getPayAmt(true));
ibs.saveEx(); ibs.saveEx();
// //
String retString = "@C_Payment_ID@ = " + payment.getDocumentNo(); StringBuilder retString = new StringBuilder("@C_Payment_ID@ = ").append(payment.getDocumentNo());
if (payment.getOverUnderAmt().signum() != 0) if (payment.getOverUnderAmt().signum() != 0)
retString += " - @OverUnderAmt@=" + payment.getOverUnderAmt(); retString.append(" - @OverUnderAmt@=").append(payment.getOverUnderAmt());
return retString; return retString.toString();
} // createPayment - Import } // createPayment - Import
/** /**
@ -133,10 +133,10 @@ public class BankStatementPayment extends SvrProcess
bsl.setPayment(payment); bsl.setPayment(payment);
bsl.saveEx(); bsl.saveEx();
// //
String retString = "@C_Payment_ID@ = " + payment.getDocumentNo(); StringBuilder retString = new StringBuilder("@C_Payment_ID@ = ").append(payment.getDocumentNo());
if (payment.getOverUnderAmt().signum() != 0) if (payment.getOverUnderAmt().signum() != 0)
retString += " - @OverUnderAmt@=" + payment.getOverUnderAmt(); retString.append(" - @OverUnderAmt@=").append(payment.getOverUnderAmt());
return retString; return retString.toString();
} // createPayment } // createPayment

View File

@ -146,8 +146,8 @@ public class ChangeLogProcess extends SvrProcess
} }
// final call // final call
executeStatement(); executeStatement();
StringBuilder msgreturn = new StringBuilder("@OK@: ").append(m_ok).append(" - @Errors@: ").append(m_errors).append(" - @Failed@: ").append(m_checkFailed);
return "@OK@: " + m_ok + " - @Errors@: " + m_errors + " - @Failed@: " + m_checkFailed; return msgreturn.toString();
} // doIt } // doIt
@ -369,7 +369,7 @@ public class ChangeLogProcess extends SvrProcess
// Changed Tables // Changed Tables
+ " AND EXISTS (SELECT * FROM AD_ChangeLog l " + " AND EXISTS (SELECT * FROM AD_ChangeLog l "
+ "WHERE t.AD_Table_ID=l.AD_Table_ID)"; + "WHERE t.AD_Table_ID=l.AD_Table_ID)";
StringBuffer update = null; StringBuilder update = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
@ -384,14 +384,15 @@ public class ChangeLogProcess extends SvrProcess
String columnName = tableName + "_ID"; String columnName = tableName + "_ID";
if (tableName.equals("AD_Ref_Table")) if (tableName.equals("AD_Ref_Table"))
columnName = "AD_Reference_ID"; columnName = "AD_Reference_ID";
update = new StringBuffer ("UPDATE AD_ChangeLog SET IsCustomization='Y' " update = new StringBuilder ("UPDATE AD_ChangeLog SET IsCustomization='Y' ")
+ "WHERE AD_Table_ID=").append(table.getAD_Table_ID()); .append("WHERE AD_Table_ID=").append(table.getAD_Table_ID());
update.append (" AND Record_ID IN (SELECT ") update.append (" AND Record_ID IN (SELECT ")
.append (columnName) .append (columnName)
.append (" FROM ").append(tableName) .append (" FROM ").append(tableName)
.append (" WHERE EntityType IN ('D','C'))"); .append (" WHERE EntityType IN ('D','C'))");
int no = DB.executeUpdate(update.toString(), get_TrxName()); int no = DB.executeUpdate(update.toString(), get_TrxName());
log.config(table.getTableName() + " = " + no); StringBuilder msglog = new StringBuilder(table.getTableName()).append(" = ").append(no);
log.config(msglog.toString());
updateNo += no; updateNo += no;
} }

View File

@ -129,33 +129,42 @@ public class ColumnEncryption extends SvrProcess {
} }
// Start // Start
addLog(0, null, null, "Encryption Class = " StringBuilder msglog = new StringBuilder("Encryption Class = ")
+ SecureEngine.getClassName()); .append(SecureEngine.getClassName());
addLog(0, null, null, msglog.toString());
boolean error = false; boolean error = false;
// Test Value // Test Value
if (p_TestValue != null && p_TestValue.length() > 0) { if (p_TestValue != null && p_TestValue.length() > 0) {
String encString = SecureEngine.encrypt(p_TestValue); String encString = SecureEngine.encrypt(p_TestValue);
addLog(0, null, null, "Encrypted Test Value=" + encString); msglog = new StringBuilder("Encrypted Test Value=").append(encString);
addLog(0, null, null, msglog.toString());
String clearString = SecureEngine.decrypt(encString); String clearString = SecureEngine.decrypt(encString);
if (p_TestValue.equals(clearString)) if (p_TestValue.equals(clearString)){
addLog(0, null, null, "Decrypted=" + clearString msglog = new StringBuilder("Decrypted=").append(clearString)
+ " (same as test value)"); .append(" (same as test value)");
addLog(0, null, null, msglog.toString());
}
else { else {
addLog(0, null, null, "Decrypted=" + clearString msglog = new StringBuilder("Decrypted=").append(clearString)
+ " (NOT the same as test value - check algorithm)"); .append(" (NOT the same as test value - check algorithm)");
addLog(0, null, null, msglog.toString());
error = true; error = true;
} }
int encLength = encString.length(); int encLength = encString.length();
addLog(0, null, null, "Test Length=" + p_TestValue.length() msglog = new StringBuilder("Test Length=").append(p_TestValue.length())
+ " -> " + encLength); .append(" -> ").append(encLength);
if (encLength <= column.getFieldLength()) addLog(0, null, null, msglog.toString());
addLog(0, null, null, "Encrypted Length (" + encLength if (encLength <= column.getFieldLength()){
+ ") fits into field (" + column.getFieldLength() + ")"); msglog = new StringBuilder("Encrypted Length (").append(encLength)
.append(") fits into field (").append(column.getFieldLength()).append(")");
addLog(0, null, null, msglog.toString());
}
else { else {
addLog(0, null, null, "Encrypted Length (" + encLength msglog = new StringBuilder("Encrypted Length (").append(encLength)
+ ") does NOT fit into field (" .append(") does NOT fit into field (")
+ column.getFieldLength() + ") - resize field"); .append(column.getFieldLength()).append(") - resize field");
addLog(0, null, null, msglog.toString());
error = true; error = true;
} }
} }
@ -167,22 +176,25 @@ public class ColumnEncryption extends SvrProcess {
while (testClear.length() < p_MaxLength) while (testClear.length() < p_MaxLength)
testClear.append(testClear); testClear.append(testClear);
testClear.delete(p_MaxLength,testClear.length()); testClear.delete(p_MaxLength,testClear.length());
StringBuilder msglog = new StringBuilder() msglog = new StringBuilder()
.append("Test=").append(testClear.toString()).append(" (").append(p_MaxLength).append(")"); .append("Test=").append(testClear.toString()).append(" (").append(p_MaxLength).append(")");
log.config(msglog.toString()); log.config(msglog.toString());
// //
String encString = SecureEngine.encrypt(testClear.toString()); String encString = SecureEngine.encrypt(testClear.toString());
int encLength = encString.length(); int encLength = encString.length();
msglog = new StringBuilder("Test Max Length=").append(testClear.length())
addLog(0, null, null, "Test Max Length=" + testClear.length() .append(" -> ").append(encLength);
+ " -> " + encLength); addLog(0, null, null, msglog.toString());
if (encLength <= column.getFieldLength()) if (encLength <= column.getFieldLength()){
addLog(0, null, null, "Encrypted Max Length (" + encLength msglog = new StringBuilder("Encrypted Max Length (").append(encLength)
+ ") fits into field (" + column.getFieldLength() + ")"); .append(") fits into field (").append(column.getFieldLength()).append(")");
addLog(0, null, null, msglog.toString());
}
else { else {
addLog(0, null, null, "Encrypted Max Length (" + encLength msglog = new StringBuilder("Encrypted Max Length (").append(encLength)
+ ") does NOT fit into field (" .append(") does NOT fit into field (")
+ column.getFieldLength() + ") - resize field"); .append(column.getFieldLength()).append(") - resize field");
addLog(0, null, null, msglog.toString());
error = true; error = true;
} }
} }
@ -227,14 +239,18 @@ public class ColumnEncryption extends SvrProcess {
} }
if (p_IsEncrypted != column.isEncrypted()) { if (p_IsEncrypted != column.isEncrypted()) {
if (error || !p_ChangeSetting) if (error || !p_ChangeSetting){
addLog(0, null, null, "Encryption NOT changed - Encryption=" msglog = new StringBuilder("Encryption NOT changed - Encryption=")
+ column.isEncrypted()); .append(column.isEncrypted());
addLog(0, null, null, msglog.toString());
}
else { else {
column.setIsEncrypted(p_IsEncrypted); column.setIsEncrypted(p_IsEncrypted);
if (column.save()) if (column.save()){
addLog(0, null, null, "Encryption CHANGED - Encryption=" msglog = new StringBuilder("Encryption CHANGED - Encryption=")
+ column.isEncrypted()); .append(column.isEncrypted());
addLog(0, null, null, msglog.toString());
}
else else
addLog(0, null, null, "Save Error"); addLog(0, null, null, "Save Error");
} }
@ -274,17 +290,17 @@ public class ColumnEncryption extends SvrProcess {
private int encryptColumnContents(String columnName, String tableName) private int encryptColumnContents(String columnName, String tableName)
throws Exception { throws Exception {
int recordsEncrypted = 0; int recordsEncrypted = 0;
String idColumnName = tableName + "_ID"; StringBuilder idColumnName = new StringBuilder(tableName).append("_ID");
StringBuilder selectSql = new StringBuilder(); StringBuilder selectSql = new StringBuilder();
selectSql.append("SELECT " + idColumnName + "," + columnName); selectSql.append("SELECT ").append(idColumnName).append(",").append(columnName);
selectSql.append(" FROM " + tableName); selectSql.append(" FROM ").append(tableName);
selectSql.append(" ORDER BY " + idColumnName); selectSql.append(" ORDER BY ").append(idColumnName);
StringBuilder updateSql = new StringBuilder(); StringBuilder updateSql = new StringBuilder();
updateSql.append("UPDATE " + tableName); updateSql.append("UPDATE ").append(tableName);
updateSql.append(" SET " + columnName + "=?"); updateSql.append(" SET ").append(columnName).append("=?");
updateSql.append(" WHERE " + idColumnName + "=?"); updateSql.append(" WHERE ").append(idColumnName).append("=?");
PreparedStatement selectStmt = null; PreparedStatement selectStmt = null;
PreparedStatement updateStmt = null; PreparedStatement updateStmt = null;
@ -357,16 +373,16 @@ public class ColumnEncryption extends SvrProcess {
// Alter SQL // Alter SQL
StringBuffer alterSql = new StringBuffer(); StringBuffer alterSql = new StringBuffer();
alterSql.append("ALTER TABLE " + tableName); alterSql.append("ALTER TABLE ").append(tableName);
alterSql.append(" MODIFY " + columnName); alterSql.append(" MODIFY ").append(columnName);
alterSql.append(" NVARCHAR2("); alterSql.append(" NVARCHAR2(");
alterSql.append(length + ") "); alterSql.append(length).append(") ");
// Update SQL // Update SQL
StringBuffer updateSql = new StringBuffer(); StringBuffer updateSql = new StringBuffer();
updateSql.append("UPDATE AD_Column"); updateSql.append("UPDATE AD_Column");
updateSql.append(" SET FieldLength=" + length); updateSql.append(" SET FieldLength=").append(length);
updateSql.append(" WHERE AD_Column_ID=" + columnID); updateSql.append(" WHERE AD_Column_ID=").append(columnID);
PreparedStatement selectStmt = null; PreparedStatement selectStmt = null;

View File

@ -140,12 +140,12 @@ public class ColumnSync extends SvrProcess
if (no == -1) if (no == -1)
{ {
String msg = "@Error@ "; StringBuilder msg = new StringBuilder("@Error@ ");
ValueNamePair pp = CLogger.retrieveError(); ValueNamePair pp = CLogger.retrieveError();
if (pp != null) if (pp != null)
msg = pp.getName() + " - "; msg = new StringBuilder(pp.getName()).append(" - ");
msg += sql; msg.append(sql);
throw new AdempiereUserError (msg); throw new AdempiereUserError (msg.toString());
} }
return sql; return sql;
} finally { } finally {

View File

@ -89,10 +89,10 @@ public class CommissionCalc extends SvrProcess
comRun.setStartDate(p_StartDate); comRun.setStartDate(p_StartDate);
// 01-Jan-2000 - 31-Jan-2001 - USD // 01-Jan-2000 - 31-Jan-2001 - USD
SimpleDateFormat format = DisplayType.getDateFormat(DisplayType.Date); SimpleDateFormat format = DisplayType.getDateFormat(DisplayType.Date);
String description = format.format(p_StartDate) StringBuilder description = new StringBuilder(format.format(p_StartDate))
+ " - " + format.format(m_EndDate) .append(" - ").append(format.format(m_EndDate))
+ " - " + MCurrency.getISO_Code(getCtx(), m_com.getC_Currency_ID()); .append(" - ").append(MCurrency.getISO_Code(getCtx(), m_com.getC_Currency_ID()));
comRun.setDescription(description); comRun.setDescription(description.toString());
if (!comRun.save()) if (!comRun.save())
throw new AdempiereSystemError ("Could not save Commission Run"); throw new AdempiereSystemError ("Could not save Commission Run");
@ -104,94 +104,94 @@ public class CommissionCalc extends SvrProcess
if (!comAmt.save()) if (!comAmt.save())
throw new AdempiereSystemError ("Could not save Commission Amt"); throw new AdempiereSystemError ("Could not save Commission Amt");
// //
StringBuffer sql = new StringBuffer(); StringBuilder sql = new StringBuilder();
if (MCommission.DOCBASISTYPE_Receipt.equals(m_com.getDocBasisType())) if (MCommission.DOCBASISTYPE_Receipt.equals(m_com.getDocBasisType()))
{ {
if (m_com.isListDetails()) if (m_com.isListDetails())
{ {
sql.append("SELECT h.C_Currency_ID, (l.LineNetAmt*al.Amount/h.GrandTotal) AS Amt," sql.append("SELECT h.C_Currency_ID, (l.LineNetAmt*al.Amount/h.GrandTotal) AS Amt,")
+ " (l.QtyInvoiced*al.Amount/h.GrandTotal) AS Qty," .append(" (l.QtyInvoiced*al.Amount/h.GrandTotal) AS Qty,")
+ " NULL, l.C_InvoiceLine_ID, p.DocumentNo||'_'||h.DocumentNo," .append(" NULL, l.C_InvoiceLine_ID, p.DocumentNo||'_'||h.DocumentNo,")
+ " COALESCE(prd.Value,l.Description), h.DateInvoiced " .append(" COALESCE(prd.Value,l.Description), h.DateInvoiced ")
+ "FROM C_Payment p" .append("FROM C_Payment p")
+ " INNER JOIN C_AllocationLine al ON (p.C_Payment_ID=al.C_Payment_ID)" .append(" INNER JOIN C_AllocationLine al ON (p.C_Payment_ID=al.C_Payment_ID)")
+ " INNER JOIN C_Invoice h ON (al.C_Invoice_ID = h.C_Invoice_ID)" .append(" INNER JOIN C_Invoice h ON (al.C_Invoice_ID = h.C_Invoice_ID)")
+ " INNER JOIN C_InvoiceLine l ON (h.C_Invoice_ID = l.C_Invoice_ID) " .append(" INNER JOIN C_InvoiceLine l ON (h.C_Invoice_ID = l.C_Invoice_ID) ")
+ " LEFT OUTER JOIN M_Product prd ON (l.M_Product_ID = prd.M_Product_ID) " .append(" LEFT OUTER JOIN M_Product prd ON (l.M_Product_ID = prd.M_Product_ID) ")
+ "WHERE p.DocStatus IN ('CL','CO','RE')" .append("WHERE p.DocStatus IN ('CL','CO','RE')")
+ " AND h.IsSOTrx='Y'" .append(" AND h.IsSOTrx='Y'")
+ " AND p.AD_Client_ID = ?" .append(" AND p.AD_Client_ID = ?")
+ " AND p.DateTrx BETWEEN ? AND ?"); .append(" AND p.DateTrx BETWEEN ? AND ?");
} }
else else
{ {
sql.append("SELECT h.C_Currency_ID, SUM(l.LineNetAmt*al.Amount/h.GrandTotal) AS Amt," sql.append("SELECT h.C_Currency_ID, SUM(l.LineNetAmt*al.Amount/h.GrandTotal) AS Amt,")
+ " SUM(l.QtyInvoiced*al.Amount/h.GrandTotal) AS Qty," .append(" SUM(l.QtyInvoiced*al.Amount/h.GrandTotal) AS Qty,")
+ " NULL, NULL, NULL, NULL, MAX(h.DateInvoiced) " .append(" NULL, NULL, NULL, NULL, MAX(h.DateInvoiced) ")
+ "FROM C_Payment p" .append("FROM C_Payment p")
+ " INNER JOIN C_AllocationLine al ON (p.C_Payment_ID=al.C_Payment_ID)" .append(" INNER JOIN C_AllocationLine al ON (p.C_Payment_ID=al.C_Payment_ID)")
+ " INNER JOIN C_Invoice h ON (al.C_Invoice_ID = h.C_Invoice_ID)" .append(" INNER JOIN C_Invoice h ON (al.C_Invoice_ID = h.C_Invoice_ID)")
+ " INNER JOIN C_InvoiceLine l ON (h.C_Invoice_ID = l.C_Invoice_ID) " .append(" INNER JOIN C_InvoiceLine l ON (h.C_Invoice_ID = l.C_Invoice_ID) ")
+ "WHERE p.DocStatus IN ('CL','CO','RE')" .append("WHERE p.DocStatus IN ('CL','CO','RE')")
+ " AND h.IsSOTrx='Y'" .append(" AND h.IsSOTrx='Y'")
+ " AND p.AD_Client_ID = ?" .append(" AND p.AD_Client_ID = ?")
+ " AND p.DateTrx BETWEEN ? AND ?"); .append(" AND p.DateTrx BETWEEN ? AND ?");
} }
} }
else if (MCommission.DOCBASISTYPE_Order.equals(m_com.getDocBasisType())) else if (MCommission.DOCBASISTYPE_Order.equals(m_com.getDocBasisType()))
{ {
if (m_com.isListDetails()) if (m_com.isListDetails())
{ {
sql.append("SELECT h.C_Currency_ID, l.LineNetAmt, l.QtyOrdered, " sql.append("SELECT h.C_Currency_ID, l.LineNetAmt, l.QtyOrdered, ")
+ "l.C_OrderLine_ID, NULL, h.DocumentNo," .append("l.C_OrderLine_ID, NULL, h.DocumentNo,")
+ " COALESCE(prd.Value,l.Description),h.DateOrdered " .append(" COALESCE(prd.Value,l.Description),h.DateOrdered ")
+ "FROM C_Order h" .append("FROM C_Order h")
+ " INNER JOIN C_OrderLine l ON (h.C_Order_ID = l.C_Order_ID)" .append(" INNER JOIN C_OrderLine l ON (h.C_Order_ID = l.C_Order_ID)")
+ " LEFT OUTER JOIN M_Product prd ON (l.M_Product_ID = prd.M_Product_ID) " .append(" LEFT OUTER JOIN M_Product prd ON (l.M_Product_ID = prd.M_Product_ID) ")
+ "WHERE h.DocStatus IN ('CL','CO')" .append("WHERE h.DocStatus IN ('CL','CO')")
+ " AND h.IsSOTrx='Y'" .append(" AND h.IsSOTrx='Y'")
+ " AND h.AD_Client_ID = ?" .append(" AND h.AD_Client_ID = ?")
+ " AND h.DateOrdered BETWEEN ? AND ?"); .append(" AND h.DateOrdered BETWEEN ? AND ?");
} }
else else
{ {
sql.append("SELECT h.C_Currency_ID, SUM(l.LineNetAmt) AS Amt," sql.append("SELECT h.C_Currency_ID, SUM(l.LineNetAmt) AS Amt,")
+ " SUM(l.QtyOrdered) AS Qty, " .append(" SUM(l.QtyOrdered) AS Qty, ")
+ "NULL, NULL, NULL, NULL, MAX(h.DateOrdered) " .append("NULL, NULL, NULL, NULL, MAX(h.DateOrdered) ")
+ "FROM C_Order h" .append("FROM C_Order h")
+ " INNER JOIN C_OrderLine l ON (h.C_Order_ID = l.C_Order_ID) " .append(" INNER JOIN C_OrderLine l ON (h.C_Order_ID = l.C_Order_ID) ")
+ "WHERE h.DocStatus IN ('CL','CO')" .append("WHERE h.DocStatus IN ('CL','CO')")
+ " AND h.IsSOTrx='Y'" .append(" AND h.IsSOTrx='Y'")
+ " AND h.AD_Client_ID = ?" .append(" AND h.AD_Client_ID = ?")
+ " AND h.DateOrdered BETWEEN ? AND ?"); .append(" AND h.DateOrdered BETWEEN ? AND ?");
} }
} }
else // Invoice Basis else // Invoice Basis
{ {
if (m_com.isListDetails()) if (m_com.isListDetails())
{ {
sql.append("SELECT h.C_Currency_ID, l.LineNetAmt, l.QtyInvoiced, " sql.append("SELECT h.C_Currency_ID, l.LineNetAmt, l.QtyInvoiced, ")
+ "NULL, l.C_InvoiceLine_ID, h.DocumentNo," .append("NULL, l.C_InvoiceLine_ID, h.DocumentNo,")
+ " COALESCE(prd.Value,l.Description),h.DateInvoiced " .append(" COALESCE(prd.Value,l.Description),h.DateInvoiced ")
+ "FROM C_Invoice h" .append("FROM C_Invoice h")
+ " INNER JOIN C_InvoiceLine l ON (h.C_Invoice_ID = l.C_Invoice_ID)" .append(" INNER JOIN C_InvoiceLine l ON (h.C_Invoice_ID = l.C_Invoice_ID)")
+ " LEFT OUTER JOIN M_Product prd ON (l.M_Product_ID = prd.M_Product_ID) " .append(" LEFT OUTER JOIN M_Product prd ON (l.M_Product_ID = prd.M_Product_ID) ")
+ "WHERE h.DocStatus IN ('CL','CO','RE')" .append("WHERE h.DocStatus IN ('CL','CO','RE')")
+ " AND h.IsSOTrx='Y'" .append(" AND h.IsSOTrx='Y'")
+ " AND h.AD_Client_ID = ?" .append(" AND h.AD_Client_ID = ?")
+ " AND h.DateInvoiced BETWEEN ? AND ?"); .append(" AND h.DateInvoiced BETWEEN ? AND ?");
} }
else else
{ {
sql.append("SELECT h.C_Currency_ID, SUM(l.LineNetAmt) AS Amt," sql.append("SELECT h.C_Currency_ID, SUM(l.LineNetAmt) AS Amt,")
+ " SUM(l.QtyInvoiced) AS Qty, " .append(" SUM(l.QtyInvoiced) AS Qty, ")
+ "NULL, NULL, NULL, NULL, MAX(h.DateInvoiced) " .append("NULL, NULL, NULL, NULL, MAX(h.DateInvoiced) ")
+ "FROM C_Invoice h" .append("FROM C_Invoice h")
+ " INNER JOIN C_InvoiceLine l ON (h.C_Invoice_ID = l.C_Invoice_ID) " .append(" INNER JOIN C_InvoiceLine l ON (h.C_Invoice_ID = l.C_Invoice_ID) ")
+ "WHERE h.DocStatus IN ('CL','CO','RE')" .append("WHERE h.DocStatus IN ('CL','CO','RE')")
+ " AND h.IsSOTrx='Y'" .append(" AND h.IsSOTrx='Y'")
+ " AND h.AD_Client_ID = ?" .append(" AND h.AD_Client_ID = ?")
+ " AND h.DateInvoiced BETWEEN ? AND ?"); .append(" AND h.DateInvoiced BETWEEN ? AND ?");
} }
} }
// CommissionOrders/Invoices // CommissionOrders/Invoices
@ -221,19 +221,19 @@ public class CommissionCalc extends SvrProcess
sql.append(" AND h.C_BPartner_ID=").append(lines[i].getC_BPartner_ID()); sql.append(" AND h.C_BPartner_ID=").append(lines[i].getC_BPartner_ID());
// BPartner Group // BPartner Group
if (lines[i].getC_BP_Group_ID() != 0) if (lines[i].getC_BP_Group_ID() != 0)
sql.append(" AND h.C_BPartner_ID IN " sql.append(" AND h.C_BPartner_ID IN ")
+ "(SELECT C_BPartner_ID FROM C_BPartner WHERE C_BP_Group_ID=").append(lines[i].getC_BP_Group_ID()).append(")"); .append("(SELECT C_BPartner_ID FROM C_BPartner WHERE C_BP_Group_ID=").append(lines[i].getC_BP_Group_ID()).append(")");
// Sales Region // Sales Region
if (lines[i].getC_SalesRegion_ID() != 0) if (lines[i].getC_SalesRegion_ID() != 0)
sql.append(" AND h.C_BPartner_Location_ID IN " sql.append(" AND h.C_BPartner_Location_ID IN ")
+ "(SELECT C_BPartner_Location_ID FROM C_BPartner_Location WHERE C_SalesRegion_ID=").append(lines[i].getC_SalesRegion_ID()).append(")"); .append("(SELECT C_BPartner_Location_ID FROM C_BPartner_Location WHERE C_SalesRegion_ID=").append(lines[i].getC_SalesRegion_ID()).append(")");
// Product // Product
if (lines[i].getM_Product_ID() != 0) if (lines[i].getM_Product_ID() != 0)
sql.append(" AND l.M_Product_ID=").append(lines[i].getM_Product_ID()); sql.append(" AND l.M_Product_ID=").append(lines[i].getM_Product_ID());
// Product Category // Product Category
if (lines[i].getM_Product_Category_ID() != 0) if (lines[i].getM_Product_Category_ID() != 0)
sql.append(" AND l.M_Product_ID IN " sql.append(" AND l.M_Product_ID IN ")
+ "(SELECT M_Product_ID FROM M_Product WHERE M_Product_Category_ID=").append(lines[i].getM_Product_Category_ID()).append(")"); .append("(SELECT M_Product_ID FROM M_Product WHERE M_Product_Category_ID=").append(lines[i].getM_Product_Category_ID()).append(")");
// Payment Rule // Payment Rule
if (lines[i].getPaymentRule() != null) if (lines[i].getPaymentRule() != null)
sql.append(" AND h.PaymentRule='").append(lines[i].getPaymentRule()).append("'"); sql.append(" AND h.PaymentRule='").append(lines[i].getPaymentRule()).append("'");
@ -254,9 +254,9 @@ public class CommissionCalc extends SvrProcess
// Save Last Run // Save Last Run
m_com.setDateLastRun (p_StartDate); m_com.setDateLastRun (p_StartDate);
m_com.saveEx(); m_com.saveEx();
StringBuilder msgreturn = new StringBuilder("@C_CommissionRun_ID@ = ").append(comRun.getDocumentNo())
return "@C_CommissionRun_ID@ = " + comRun.getDocumentNo() .append(" - ").append(comRun.getDescription());
+ " - " + comRun.getDescription(); return msgreturn.toString();
} // doIt } // doIt
/** /**