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

This commit is contained in:
Carlos Ruiz 2012-09-26 18:35:53 -05:00
parent 27bc656e22
commit 2defc00efb
19 changed files with 401 additions and 384 deletions

View File

@ -94,23 +94,23 @@ public class InventoryValue extends SvrProcess
MAcctSchema as = c.getAcctSchema(); MAcctSchema as = c.getAcctSchema();
// Delete (just to be sure) // Delete (just to be sure)
StringBuffer sql = new StringBuffer ("DELETE T_InventoryValue WHERE AD_PInstance_ID="); StringBuilder sql = new StringBuilder ("DELETE T_InventoryValue WHERE AD_PInstance_ID=");
sql.append(getAD_PInstance_ID()); sql.append(getAD_PInstance_ID());
int no = DB.executeUpdateEx(sql.toString(), get_TrxName()); int no = DB.executeUpdateEx(sql.toString(), get_TrxName());
// Insert Standard Costs // Insert Standard Costs
sql = new StringBuffer ("INSERT INTO T_InventoryValue " sql = new StringBuilder ("INSERT INTO T_InventoryValue ")
+ "(AD_PInstance_ID, M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID," .append("(AD_PInstance_ID, M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID,")
+ " AD_Client_ID, AD_Org_ID, CostStandard) " .append(" AD_Client_ID, AD_Org_ID, CostStandard) ")
+ "SELECT ").append(getAD_PInstance_ID()) .append("SELECT ").append(getAD_PInstance_ID())
.append(", w.M_Warehouse_ID, c.M_Product_ID, c.M_AttributeSetInstance_ID," .append(", w.M_Warehouse_ID, c.M_Product_ID, c.M_AttributeSetInstance_ID,")
+ " w.AD_Client_ID, w.AD_Org_ID, c.CurrentCostPrice " .append(" w.AD_Client_ID, w.AD_Org_ID, c.CurrentCostPrice ")
+ "FROM M_Warehouse w" .append("FROM M_Warehouse w")
+ " INNER JOIN AD_ClientInfo ci ON (w.AD_Client_ID=ci.AD_Client_ID)" .append(" INNER JOIN AD_ClientInfo ci ON (w.AD_Client_ID=ci.AD_Client_ID)")
+ " INNER JOIN C_AcctSchema acs ON (ci.C_AcctSchema1_ID=acs.C_AcctSchema_ID)" .append(" INNER JOIN C_AcctSchema acs ON (ci.C_AcctSchema1_ID=acs.C_AcctSchema_ID)")
+ " INNER JOIN M_Cost c ON (acs.C_AcctSchema_ID=c.C_AcctSchema_ID AND acs.M_CostType_ID=c.M_CostType_ID AND c.AD_Org_ID IN (0, w.AD_Org_ID))" .append(" INNER JOIN M_Cost c ON (acs.C_AcctSchema_ID=c.C_AcctSchema_ID AND acs.M_CostType_ID=c.M_CostType_ID AND c.AD_Org_ID IN (0, w.AD_Org_ID))")
+ " INNER JOIN M_CostElement ce ON (c.M_CostElement_ID=ce.M_CostElement_ID AND ce.CostingMethod='S' AND ce.CostElementType='M') " .append(" INNER JOIN M_CostElement ce ON (c.M_CostElement_ID=ce.M_CostElement_ID AND ce.CostingMethod='S' AND ce.CostElementType='M') ")
+ "WHERE w.M_Warehouse_ID=").append(p_M_Warehouse_ID); .append("WHERE w.M_Warehouse_ID=").append(p_M_Warehouse_ID);
int noInsertStd = DB.executeUpdateEx(sql.toString(), get_TrxName()); int noInsertStd = DB.executeUpdateEx(sql.toString(), get_TrxName());
log.fine("Inserted Std=" + noInsertStd); log.fine("Inserted Std=" + noInsertStd);
if (noInsertStd == 0) if (noInsertStd == 0)
@ -120,41 +120,41 @@ public class InventoryValue extends SvrProcess
int noInsertCost = 0; int noInsertCost = 0;
if (p_M_CostElement_ID != 0) if (p_M_CostElement_ID != 0)
{ {
sql = new StringBuffer ("INSERT INTO T_InventoryValue " sql = new StringBuilder ("INSERT INTO T_InventoryValue ")
+ "(AD_PInstance_ID, M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID," .append("(AD_PInstance_ID, M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID,")
+ " AD_Client_ID, AD_Org_ID, CostStandard, Cost, M_CostElement_ID) " .append(" AD_Client_ID, AD_Org_ID, CostStandard, Cost, M_CostElement_ID) ")
+ "SELECT ").append(getAD_PInstance_ID()) .append("SELECT ").append(getAD_PInstance_ID())
.append(", w.M_Warehouse_ID, c.M_Product_ID, c.M_AttributeSetInstance_ID," .append(", w.M_Warehouse_ID, c.M_Product_ID, c.M_AttributeSetInstance_ID,")
+ " w.AD_Client_ID, w.AD_Org_ID, 0, c.CurrentCostPrice, c.M_CostElement_ID " .append(" w.AD_Client_ID, w.AD_Org_ID, 0, c.CurrentCostPrice, c.M_CostElement_ID ")
+ "FROM M_Warehouse w" .append("FROM M_Warehouse w")
+ " INNER JOIN AD_ClientInfo ci ON (w.AD_Client_ID=ci.AD_Client_ID)" .append(" INNER JOIN AD_ClientInfo ci ON (w.AD_Client_ID=ci.AD_Client_ID)")
+ " INNER JOIN C_AcctSchema acs ON (ci.C_AcctSchema1_ID=acs.C_AcctSchema_ID)" .append(" INNER JOIN C_AcctSchema acs ON (ci.C_AcctSchema1_ID=acs.C_AcctSchema_ID)")
+ " INNER JOIN M_Cost c ON (acs.C_AcctSchema_ID=c.C_AcctSchema_ID AND acs.M_CostType_ID=c.M_CostType_ID AND c.AD_Org_ID IN (0, w.AD_Org_ID)) " .append(" INNER JOIN M_Cost c ON (acs.C_AcctSchema_ID=c.C_AcctSchema_ID AND acs.M_CostType_ID=c.M_CostType_ID AND c.AD_Org_ID IN (0, w.AD_Org_ID)) ")
+ "WHERE w.M_Warehouse_ID=").append(p_M_Warehouse_ID) .append("WHERE w.M_Warehouse_ID=").append(p_M_Warehouse_ID)
.append(" AND c.M_CostElement_ID=").append(p_M_CostElement_ID) .append(" AND c.M_CostElement_ID=").append(p_M_CostElement_ID)
.append(" AND NOT EXISTS (SELECT * FROM T_InventoryValue iv " .append(" AND NOT EXISTS (SELECT * FROM T_InventoryValue iv ")
+ "WHERE iv.AD_PInstance_ID=").append(getAD_PInstance_ID()) .append("WHERE iv.AD_PInstance_ID=").append(getAD_PInstance_ID())
.append(" AND iv.M_Warehouse_ID=w.M_Warehouse_ID" .append(" AND iv.M_Warehouse_ID=w.M_Warehouse_ID")
+ " AND iv.M_Product_ID=c.M_Product_ID" .append(" AND iv.M_Product_ID=c.M_Product_ID")
+ " AND iv.M_AttributeSetInstance_ID=c.M_AttributeSetInstance_ID)"); .append(" AND iv.M_AttributeSetInstance_ID=c.M_AttributeSetInstance_ID)");
noInsertCost = DB.executeUpdateEx(sql.toString(), get_TrxName()); noInsertCost = DB.executeUpdateEx(sql.toString(), get_TrxName());
log.fine("Inserted Cost=" + noInsertCost); log.fine("Inserted Cost=" + noInsertCost);
// Update Std Cost Records // Update Std Cost Records
sql = new StringBuffer ("UPDATE T_InventoryValue iv " sql = new StringBuilder ("UPDATE T_InventoryValue iv ")
+ "SET (Cost, M_CostElement_ID)=" .append("SET (Cost, M_CostElement_ID)=")
+ "(SELECT c.CurrentCostPrice, c.M_CostElement_ID " .append("(SELECT c.CurrentCostPrice, c.M_CostElement_ID ")
+ "FROM M_Warehouse w" .append("FROM M_Warehouse w")
+ " INNER JOIN AD_ClientInfo ci ON (w.AD_Client_ID=ci.AD_Client_ID)" .append(" INNER JOIN AD_ClientInfo ci ON (w.AD_Client_ID=ci.AD_Client_ID)")
+ " INNER JOIN C_AcctSchema acs ON (ci.C_AcctSchema1_ID=acs.C_AcctSchema_ID)" .append(" INNER JOIN C_AcctSchema acs ON (ci.C_AcctSchema1_ID=acs.C_AcctSchema_ID)")
+ " INNER JOIN M_Cost c ON (acs.C_AcctSchema_ID=c.C_AcctSchema_ID" .append(" INNER JOIN M_Cost c ON (acs.C_AcctSchema_ID=c.C_AcctSchema_ID")
+ " AND acs.M_CostType_ID=c.M_CostType_ID AND c.AD_Org_ID IN (0, w.AD_Org_ID)) " .append(" AND acs.M_CostType_ID=c.M_CostType_ID AND c.AD_Org_ID IN (0, w.AD_Org_ID)) ")
+ "WHERE c.M_CostElement_ID=" + p_M_CostElement_ID .append("WHERE c.M_CostElement_ID=").append(p_M_CostElement_ID)
+ " AND iv.M_Warehouse_ID=w.M_Warehouse_ID" .append(" AND iv.M_Warehouse_ID=w.M_Warehouse_ID")
+ " AND iv.M_Product_ID=c.M_Product_ID" .append(" AND iv.M_Product_ID=c.M_Product_ID")
+ " AND iv.M_AttributeSetInstance_ID=c.M_AttributeSetInstance_ID) " .append(" AND iv.M_AttributeSetInstance_ID=c.M_AttributeSetInstance_ID) ")
+ "WHERE EXISTS (SELECT * FROM T_InventoryValue ivv " .append("WHERE EXISTS (SELECT * FROM T_InventoryValue ivv ")
+ "WHERE ivv.AD_PInstance_ID=" + getAD_PInstance_ID() .append("WHERE ivv.AD_PInstance_ID=").append(getAD_PInstance_ID())
+ " AND ivv.M_CostElement_ID IS NULL)"); .append(" AND ivv.M_CostElement_ID IS NULL)");
int noUpdatedCost = DB.executeUpdateEx(sql.toString(), get_TrxName()); int noUpdatedCost = DB.executeUpdateEx(sql.toString(), get_TrxName());
log.fine("Updated Cost=" + noUpdatedCost); log.fine("Updated Cost=" + noUpdatedCost);
} }
@ -164,97 +164,97 @@ public class InventoryValue extends SvrProcess
// Update Constants // Update Constants
// YYYY-MM-DD HH24:MI:SS.mmmm JDBC Timestamp format // YYYY-MM-DD HH24:MI:SS.mmmm JDBC Timestamp format
String myDate = p_DateValue.toString(); String myDate = p_DateValue.toString();
sql = new StringBuffer ("UPDATE T_InventoryValue SET ") sql = new StringBuilder ("UPDATE T_InventoryValue SET ")
.append("DateValue=TO_DATE('").append(myDate.substring(0,10)) .append("DateValue=TO_DATE('").append(myDate.substring(0,10))
.append(" 23:59:59','YYYY-MM-DD HH24:MI:SS'),") .append(" 23:59:59','YYYY-MM-DD HH24:MI:SS'),")
.append("M_PriceList_Version_ID=").append(p_M_PriceList_Version_ID).append(",") .append("M_PriceList_Version_ID=").append(p_M_PriceList_Version_ID).append(",")
.append("C_Currency_ID=").append(p_C_Currency_ID) .append("C_Currency_ID=").append(p_C_Currency_ID)
.append(" WHERE AD_PInstance_ID=" + getAD_PInstance_ID()); .append(" WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdateEx(sql.toString(), get_TrxName()); no = DB.executeUpdateEx(sql.toString(), get_TrxName());
log.fine("Constants=" + no); log.fine("Constants=" + no);
// Get current QtyOnHand with ASI // Get current QtyOnHand with ASI
sql = new StringBuffer ("UPDATE T_InventoryValue iv SET QtyOnHand = " sql = new StringBuilder ("UPDATE T_InventoryValue iv SET QtyOnHand = ")
+ "(SELECT SUM(QtyOnHand) FROM M_Storage s" .append("(SELECT SUM(QtyOnHand) FROM M_Storage s")
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) " .append(" INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) ")
+ "WHERE iv.M_Product_ID=s.M_Product_ID" .append("WHERE iv.M_Product_ID=s.M_Product_ID")
+ " AND iv.M_Warehouse_ID=l.M_Warehouse_ID" .append(" AND iv.M_Warehouse_ID=l.M_Warehouse_ID")
+ " AND iv.M_AttributeSetInstance_ID=s.M_AttributeSetInstance_ID) " .append(" AND iv.M_AttributeSetInstance_ID=s.M_AttributeSetInstance_ID) ")
+ "WHERE AD_PInstance_ID=").append(getAD_PInstance_ID()) .append("WHERE AD_PInstance_ID=").append(getAD_PInstance_ID())
.append(" AND iv.M_AttributeSetInstance_ID<>0"); .append(" AND iv.M_AttributeSetInstance_ID<>0");
no = DB.executeUpdateEx(sql.toString(), get_TrxName()); no = DB.executeUpdateEx(sql.toString(), get_TrxName());
log.fine("QtHand with ASI=" + no); log.fine("QtHand with ASI=" + no);
// Get current QtyOnHand without ASI // Get current QtyOnHand without ASI
sql = new StringBuffer ("UPDATE T_InventoryValue iv SET QtyOnHand = " sql = new StringBuilder ("UPDATE T_InventoryValue iv SET QtyOnHand = ")
+ "(SELECT SUM(QtyOnHand) FROM M_Storage s" .append("(SELECT SUM(QtyOnHand) FROM M_Storage s")
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) " .append(" INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) ")
+ "WHERE iv.M_Product_ID=s.M_Product_ID" .append("WHERE iv.M_Product_ID=s.M_Product_ID")
+ " AND iv.M_Warehouse_ID=l.M_Warehouse_ID) " .append(" AND iv.M_Warehouse_ID=l.M_Warehouse_ID) ")
+ "WHERE iv.AD_PInstance_ID=").append(getAD_PInstance_ID()) .append("WHERE iv.AD_PInstance_ID=").append(getAD_PInstance_ID())
.append(" AND iv.M_AttributeSetInstance_ID=0"); .append(" AND iv.M_AttributeSetInstance_ID=0");
no = DB.executeUpdateEx(sql.toString(), get_TrxName()); no = DB.executeUpdateEx(sql.toString(), get_TrxName());
log.fine("QtHand w/o ASI=" + no); log.fine("QtHand w/o ASI=" + no);
// Adjust for Valuation Date // Adjust for Valuation Date
sql = new StringBuffer("UPDATE T_InventoryValue iv " sql = new StringBuilder("UPDATE T_InventoryValue iv ")
+ "SET QtyOnHand=" .append("SET QtyOnHand=")
+ "(SELECT iv.QtyOnHand - NVL(SUM(t.MovementQty), 0) " .append("(SELECT iv.QtyOnHand - NVL(SUM(t.MovementQty), 0) ")
+ "FROM M_Transaction t" .append("FROM M_Transaction t")
+ " INNER JOIN M_Locator l ON (t.M_Locator_ID=l.M_Locator_ID) " .append(" INNER JOIN M_Locator l ON (t.M_Locator_ID=l.M_Locator_ID) ")
+ "WHERE t.M_Product_ID=iv.M_Product_ID" .append("WHERE t.M_Product_ID=iv.M_Product_ID")
+ " AND t.M_AttributeSetInstance_ID=iv.M_AttributeSetInstance_ID" .append(" AND t.M_AttributeSetInstance_ID=iv.M_AttributeSetInstance_ID")
+ " AND t.MovementDate > iv.DateValue" .append(" AND t.MovementDate > iv.DateValue")
+ " AND l.M_Warehouse_ID=iv.M_Warehouse_ID) " .append(" AND l.M_Warehouse_ID=iv.M_Warehouse_ID) ")
+ "WHERE iv.M_AttributeSetInstance_ID<>0" .append("WHERE iv.M_AttributeSetInstance_ID<>0" )
+ " AND iv.AD_PInstance_ID=").append(getAD_PInstance_ID()); .append(" AND iv.AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdateEx(sql.toString(), get_TrxName()); no = DB.executeUpdateEx(sql.toString(), get_TrxName());
log.fine("Update with ASI=" + no); log.fine("Update with ASI=" + no);
// //
sql = new StringBuffer("UPDATE T_InventoryValue iv " sql = new StringBuilder("UPDATE T_InventoryValue iv ")
+ "SET QtyOnHand=" .append("SET QtyOnHand=")
+ "(SELECT iv.QtyOnHand - NVL(SUM(t.MovementQty), 0) " .append("(SELECT iv.QtyOnHand - NVL(SUM(t.MovementQty), 0) ")
+ "FROM M_Transaction t" .append("FROM M_Transaction t")
+ " INNER JOIN M_Locator l ON (t.M_Locator_ID=l.M_Locator_ID) " .append(" INNER JOIN M_Locator l ON (t.M_Locator_ID=l.M_Locator_ID) ")
+ "WHERE t.M_Product_ID=iv.M_Product_ID" .append("WHERE t.M_Product_ID=iv.M_Product_ID")
+ " AND t.MovementDate > iv.DateValue" .append(" AND t.MovementDate > iv.DateValue")
+ " AND l.M_Warehouse_ID=iv.M_Warehouse_ID) " .append(" AND l.M_Warehouse_ID=iv.M_Warehouse_ID) ")
+ "WHERE iv.M_AttributeSetInstance_ID=0 " .append("WHERE iv.M_AttributeSetInstance_ID=0 ")
+ "AND iv.AD_PInstance_ID=").append(getAD_PInstance_ID()); .append("AND iv.AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdateEx(sql.toString(), get_TrxName()); no = DB.executeUpdateEx(sql.toString(), get_TrxName());
log.fine("Update w/o ASI=" + no); log.fine("Update w/o ASI=" + no);
// Delete Records w/o OnHand Qty // Delete Records w/o OnHand Qty
sql = new StringBuffer("DELETE T_InventoryValue " sql = new StringBuilder("DELETE T_InventoryValue ")
+ "WHERE (QtyOnHand=0 OR QtyOnHand IS NULL) AND AD_PInstance_ID=").append(getAD_PInstance_ID()); .append("WHERE (QtyOnHand=0 OR QtyOnHand IS NULL) AND AD_PInstance_ID=").append(getAD_PInstance_ID());
int noQty = DB.executeUpdateEx (sql.toString(), get_TrxName()); int noQty = DB.executeUpdateEx (sql.toString(), get_TrxName());
log.fine("NoQty Deleted=" + noQty); log.fine("NoQty Deleted=" + noQty);
// Update Prices // Update Prices
sql = new StringBuffer("UPDATE T_InventoryValue iv " sql = new StringBuilder("UPDATE T_InventoryValue iv ")
+ "SET PricePO = " .append("SET PricePO = ")
+ "(SELECT MAX(currencyConvert (po.PriceList,po.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, po.AD_Client_ID,po.AD_Org_ID))" .append("(SELECT MAX(currencyConvert (po.PriceList,po.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, po.AD_Client_ID,po.AD_Org_ID))")
+ " FROM M_Product_PO po WHERE po.M_Product_ID=iv.M_Product_ID" .append(" FROM M_Product_PO po WHERE po.M_Product_ID=iv.M_Product_ID")
+ " AND po.IsCurrentVendor='Y'), " .append(" AND po.IsCurrentVendor='Y'), ")
+ "PriceList = " .append("PriceList = ")
+ "(SELECT currencyConvert(pp.PriceList,pl.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID)" .append("(SELECT currencyConvert(pp.PriceList,pl.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID)")
+ " FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp" .append(" FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp")
+ " WHERE pp.M_Product_ID=iv.M_Product_ID AND pp.M_PriceList_Version_ID=iv.M_PriceList_Version_ID" .append(" WHERE pp.M_Product_ID=iv.M_Product_ID AND pp.M_PriceList_Version_ID=iv.M_PriceList_Version_ID")
+ " AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID" .append(" AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID")
+ " AND plv.M_PriceList_ID=pl.M_PriceList_ID), " .append(" AND plv.M_PriceList_ID=pl.M_PriceList_ID), ")
+ "PriceStd = " .append("PriceStd = ")
+ "(SELECT currencyConvert(pp.PriceStd,pl.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID)" .append("(SELECT currencyConvert(pp.PriceStd,pl.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID)")
+ " FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp" .append(" FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp")
+ " WHERE pp.M_Product_ID=iv.M_Product_ID AND pp.M_PriceList_Version_ID=iv.M_PriceList_Version_ID" .append(" WHERE pp.M_Product_ID=iv.M_Product_ID AND pp.M_PriceList_Version_ID=iv.M_PriceList_Version_ID")
+ " AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID" .append(" AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID")
+ " AND plv.M_PriceList_ID=pl.M_PriceList_ID), " .append(" AND plv.M_PriceList_ID=pl.M_PriceList_ID), ")
+ "PriceLimit = " .append("PriceLimit = ")
+ "(SELECT currencyConvert(pp.PriceLimit,pl.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID)" .append("(SELECT currencyConvert(pp.PriceLimit,pl.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID)")
+ " FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp" .append(" FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp")
+ " WHERE pp.M_Product_ID=iv.M_Product_ID AND pp.M_PriceList_Version_ID=iv.M_PriceList_Version_ID" .append(" WHERE pp.M_Product_ID=iv.M_Product_ID AND pp.M_PriceList_Version_ID=iv.M_PriceList_Version_ID")
+ " AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID" .append(" AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID")
+ " AND plv.M_PriceList_ID=pl.M_PriceList_ID)" .append(" AND plv.M_PriceList_ID=pl.M_PriceList_ID)")
+ " WHERE iv.AD_PInstance_ID=").append(getAD_PInstance_ID()); .append(" WHERE iv.AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdateEx (sql.toString(), get_TrxName()); no = DB.executeUpdateEx (sql.toString(), get_TrxName());
String msg = ""; String msg = "";
@ -264,28 +264,29 @@ public class InventoryValue extends SvrProcess
// Convert if different Currency // Convert if different Currency
if (as.getC_Currency_ID() != p_C_Currency_ID) if (as.getC_Currency_ID() != p_C_Currency_ID)
{ {
sql = new StringBuffer ("UPDATE T_InventoryValue iv " sql = new StringBuilder ("UPDATE T_InventoryValue iv ")
+ "SET CostStandard= " .append("SET CostStandard= ")
+ "(SELECT currencyConvert(iv.CostStandard,acs.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, iv.AD_Client_ID,iv.AD_Org_ID) " .append("(SELECT currencyConvert(iv.CostStandard,acs.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, iv.AD_Client_ID,iv.AD_Org_ID) ")
+ "FROM C_AcctSchema acs WHERE acs.C_AcctSchema_ID=" + as.getC_AcctSchema_ID() + ")," .append("FROM C_AcctSchema acs WHERE acs.C_AcctSchema_ID=").append(as.getC_AcctSchema_ID()).append("),")
+ " Cost= " .append(" Cost= ")
+ "(SELECT currencyConvert(iv.Cost,acs.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, iv.AD_Client_ID,iv.AD_Org_ID) " .append("(SELECT currencyConvert(iv.Cost,acs.C_Currency_ID,iv.C_Currency_ID,iv.DateValue,null, iv.AD_Client_ID,iv.AD_Org_ID) ")
+ "FROM C_AcctSchema acs WHERE acs.C_AcctSchema_ID=" + as.getC_AcctSchema_ID() + ") " .append("FROM C_AcctSchema acs WHERE acs.C_AcctSchema_ID=").append(as.getC_AcctSchema_ID()).append(") ")
+ "WHERE iv.AD_PInstance_ID=" + getAD_PInstance_ID()); .append("WHERE iv.AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdateEx (sql.toString(), get_TrxName()); no = DB.executeUpdateEx (sql.toString(), get_TrxName());
log.fine("Converted=" + no); log.fine("Converted=" + no);
} }
// Update Values // Update Values
no = DB.executeUpdateEx("UPDATE T_InventoryValue SET " StringBuilder dbeux = new StringBuilder("UPDATE T_InventoryValue SET ")
+ "PricePOAmt = QtyOnHand * PricePO, " .append("PricePOAmt = QtyOnHand * PricePO, ")
+ "PriceListAmt = QtyOnHand * PriceList, " .append("PriceListAmt = QtyOnHand * PriceList, ")
+ "PriceStdAmt = QtyOnHand * PriceStd, " .append("PriceStdAmt = QtyOnHand * PriceStd, ")
+ "PriceLimitAmt = QtyOnHand * PriceLimit, " .append("PriceLimitAmt = QtyOnHand * PriceLimit, ")
+ "CostStandardAmt = QtyOnHand * CostStandard, " .append("CostStandardAmt = QtyOnHand * CostStandard, ")
+ "CostAmt = QtyOnHand * Cost " .append("CostAmt = QtyOnHand * Cost ")
+ "WHERE AD_PInstance_ID=" + getAD_PInstance_ID() .append("WHERE AD_PInstance_ID=").append(getAD_PInstance_ID()
, get_TrxName()); );
no = DB.executeUpdateEx(dbeux.toString(), get_TrxName());
log.fine("Calculation=" + no); log.fine("Calculation=" + no);
// //
return msg; return msg;

View File

@ -142,7 +142,8 @@ public class InvoiceBatchProcess extends SvrProcess
batch.setProcessed(true); batch.setProcessed(true);
batch.saveEx(); batch.saveEx();
return "#" + m_count; StringBuilder msgreturn = new StringBuilder("#").append(m_count);
return msgreturn.toString();
} // doIt } // doIt

View File

@ -129,38 +129,38 @@ public class InvoiceGenerate extends SvrProcess
+ ", C_Order_ID=" + p_C_Order_ID + ", DocAction=" + p_docAction + ", C_Order_ID=" + p_C_Order_ID + ", DocAction=" + p_docAction
+ ", Consolidate=" + p_ConsolidateDocument); + ", Consolidate=" + p_ConsolidateDocument);
// //
String sql = null; StringBuilder sql = null;
if (p_Selection) // VInvoiceGen if (p_Selection) // VInvoiceGen
{ {
sql = "SELECT C_Order.* FROM C_Order, T_Selection " sql = new StringBuilder("SELECT C_Order.* FROM C_Order, T_Selection ")
+ "WHERE C_Order.DocStatus='CO' AND C_Order.IsSOTrx='Y' " .append("WHERE C_Order.DocStatus='CO' AND C_Order.IsSOTrx='Y' ")
+ "AND C_Order.C_Order_ID = T_Selection.T_Selection_ID " .append("AND C_Order.C_Order_ID = T_Selection.T_Selection_ID ")
+ "AND T_Selection.AD_PInstance_ID=? " .append("AND T_Selection.AD_PInstance_ID=? ")
+ "ORDER BY C_Order.M_Warehouse_ID, C_Order.PriorityRule, C_Order.C_BPartner_ID, C_Order.Bill_Location_ID, C_Order.C_Order_ID"; .append("ORDER BY C_Order.M_Warehouse_ID, C_Order.PriorityRule, C_Order.C_BPartner_ID, C_Order.Bill_Location_ID, C_Order.C_Order_ID");
} }
else else
{ {
sql = "SELECT * FROM C_Order o " sql = new StringBuilder("SELECT * FROM C_Order o ")
+ "WHERE DocStatus IN('CO','CL') AND IsSOTrx='Y'"; .append("WHERE DocStatus IN('CO','CL') AND IsSOTrx='Y'");
if (p_AD_Org_ID != 0) if (p_AD_Org_ID != 0)
sql += " AND AD_Org_ID=?"; sql.append(" AND AD_Org_ID=?");
if (p_C_BPartner_ID != 0) if (p_C_BPartner_ID != 0)
sql += " AND C_BPartner_ID=?"; sql.append(" AND C_BPartner_ID=?");
if (p_C_Order_ID != 0) if (p_C_Order_ID != 0)
sql += " AND C_Order_ID=?"; sql.append(" AND C_Order_ID=?");
// //
sql += " AND EXISTS (SELECT * FROM C_OrderLine ol " sql.append(" AND EXISTS (SELECT * FROM C_OrderLine ol ")
+ "WHERE o.C_Order_ID=ol.C_Order_ID AND ol.QtyOrdered<>ol.QtyInvoiced) " .append("WHERE o.C_Order_ID=ol.C_Order_ID AND ol.QtyOrdered<>ol.QtyInvoiced) ")
+ "AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType " .append("AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType ")
+ "WHERE DocBaseType='SOO' AND DocSubTypeSO NOT IN ('ON','OB','WR')) " .append("WHERE DocBaseType='SOO' AND DocSubTypeSO NOT IN ('ON','OB','WR')) ")
+ "ORDER BY M_Warehouse_ID, PriorityRule, C_BPartner_ID, Bill_Location_ID, C_Order_ID"; .append("ORDER BY M_Warehouse_ID, PriorityRule, C_BPartner_ID, Bill_Location_ID, C_Order_ID");
} }
// sql += " FOR UPDATE"; // sql += " FOR UPDATE";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
{ {
pstmt = DB.prepareStatement (sql, get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
int index = 1; int index = 1;
if (p_Selection) if (p_Selection)
{ {
@ -178,7 +178,7 @@ public class InvoiceGenerate extends SvrProcess
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql.toString(), e);
} }
return generate(pstmt); return generate(pstmt);
} // doIt } // doIt
@ -197,7 +197,8 @@ public class InvoiceGenerate extends SvrProcess
while (rs.next ()) while (rs.next ())
{ {
MOrder order = new MOrder (getCtx(), rs, get_TrxName()); MOrder order = new MOrder (getCtx(), rs, get_TrxName());
statusUpdate(Msg.getMsg(getCtx(), "Processing") + " " + order.getDocumentInfo()); StringBuilder msgsup = new StringBuilder(Msg.getMsg(getCtx(), "Processing")).append(" ").append(order.getDocumentInfo());
statusUpdate(msgsup.toString());
// New Invoice Location // New Invoice Location
if (!p_ConsolidateDocument if (!p_ConsolidateDocument
@ -337,7 +338,8 @@ public class InvoiceGenerate extends SvrProcess
pstmt = null; pstmt = null;
} }
completeInvoice(); completeInvoice();
return "@Created@ = " + m_created; StringBuilder msgreturn = new StringBuilder("@Created@ = ").append(m_created);
return msgreturn.toString();
} // generate } // generate
@ -400,14 +402,14 @@ public class InvoiceGenerate extends SvrProcess
AD_Language = Language.getBaseAD_Language(); AD_Language = Language.getBaseAD_Language();
java.text.SimpleDateFormat format = DisplayType.getDateFormat java.text.SimpleDateFormat format = DisplayType.getDateFormat
(DisplayType.Date, Language.getLanguage(AD_Language)); (DisplayType.Date, Language.getLanguage(AD_Language));
String reference = dt.getPrintName(m_bp.getAD_Language()) StringBuilder reference = new StringBuilder(dt.getPrintName(m_bp.getAD_Language()))
+ ": " + ship.getDocumentNo() .append(": ").append(ship.getDocumentNo())
+ " - " + format.format(ship.getMovementDate()); .append(" - ").append(format.format(ship.getMovementDate()));
m_ship = ship; m_ship = ship;
// //
MInvoiceLine line = new MInvoiceLine (m_invoice); MInvoiceLine line = new MInvoiceLine (m_invoice);
line.setIsDescription(true); line.setIsDescription(true);
line.setDescription(reference); line.setDescription(reference.toString());
line.setLine(m_line + sLine.getLine() - 2); line.setLine(m_line + sLine.getLine() - 2);
if (!line.save()) if (!line.save())
throw new IllegalStateException("Could not create Invoice Comment Line (sh)"); throw new IllegalStateException("Could not create Invoice Comment Line (sh)");

View File

@ -117,47 +117,47 @@ public class InvoiceNGL extends SvrProcess
p_DateReval = new Timestamp(System.currentTimeMillis()); p_DateReval = new Timestamp(System.currentTimeMillis());
// Delete - just to be sure // Delete - just to be sure
String sql = "DELETE T_InvoiceGL WHERE AD_PInstance_ID=" + getAD_PInstance_ID(); StringBuilder sql = new StringBuilder("DELETE T_InvoiceGL WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());
int no = DB.executeUpdate(sql, get_TrxName()); int no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no > 0) if (no > 0)
log.info("Deleted #" + no); log.info("Deleted #" + no);
// Insert Trx // Insert Trx
String dateStr = DB.TO_DATE(p_DateReval, true); String dateStr = DB.TO_DATE(p_DateReval, true);
sql = "INSERT INTO T_InvoiceGL (AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy," sql = new StringBuilder("INSERT INTO T_InvoiceGL (AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,")
+ " AD_PInstance_ID, C_Invoice_ID, GrandTotal, OpenAmt, " .append(" AD_PInstance_ID, C_Invoice_ID, GrandTotal, OpenAmt, ")
+ " Fact_Acct_ID, AmtSourceBalance, AmtAcctBalance, " .append(" Fact_Acct_ID, AmtSourceBalance, AmtAcctBalance, ")
+ " AmtRevalDr, AmtRevalCr, C_DocTypeReval_ID, IsAllCurrencies, " .append(" AmtRevalDr, AmtRevalCr, C_DocTypeReval_ID, IsAllCurrencies, ")
+ " DateReval, C_ConversionTypeReval_ID, AmtRevalDrDiff, AmtRevalCrDiff, APAR) " .append(" DateReval, C_ConversionTypeReval_ID, AmtRevalDrDiff, AmtRevalCrDiff, APAR) ")
// -- // --
+ "SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy," .append("SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy,")
+ getAD_PInstance_ID() + ", i.C_Invoice_ID, i.GrandTotal, invoiceOpen(i.C_Invoice_ID, 0), " .append( getAD_PInstance_ID()).append(", i.C_Invoice_ID, i.GrandTotal, invoiceOpen(i.C_Invoice_ID, 0), ")
+ " fa.Fact_Acct_ID, fa.AmtSourceDr-fa.AmtSourceCr, fa.AmtAcctDr-fa.AmtAcctCr, " .append(" fa.Fact_Acct_ID, fa.AmtSourceDr-fa.AmtSourceCr, fa.AmtAcctDr-fa.AmtAcctCr, ")
// AmtRevalDr, AmtRevalCr, // AmtRevalDr, AmtRevalCr,
+ " currencyConvert(fa.AmtSourceDr, i.C_Currency_ID, a.C_Currency_ID, " + dateStr + ", " + p_C_ConversionTypeReval_ID + ", i.AD_Client_ID, i.AD_Org_ID)," .append(" currencyConvert(fa.AmtSourceDr, i.C_Currency_ID, a.C_Currency_ID, ").append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", i.AD_Client_ID, i.AD_Org_ID),")
+ " currencyConvert(fa.AmtSourceCr, i.C_Currency_ID, a.C_Currency_ID, " + dateStr + ", " + p_C_ConversionTypeReval_ID + ", i.AD_Client_ID, i.AD_Org_ID)," .append(" currencyConvert(fa.AmtSourceCr, i.C_Currency_ID, a.C_Currency_ID, ").append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", i.AD_Client_ID, i.AD_Org_ID),")
+ (p_C_DocTypeReval_ID==0 ? "NULL" : String.valueOf(p_C_DocTypeReval_ID)) + ", " .append((p_C_DocTypeReval_ID==0 ? "NULL" : String.valueOf(p_C_DocTypeReval_ID))).append(", ")
+ (p_IsAllCurrencies ? "'Y'," : "'N',") .append((p_IsAllCurrencies ? "'Y'," : "'N',"))
+ dateStr + ", " + p_C_ConversionTypeReval_ID + ", 0, 0, '" + p_APAR + "' " .append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", 0, 0, '").append(p_APAR).append("' ")
// //
+ "FROM C_Invoice_v i" .append("FROM C_Invoice_v i")
+ " INNER JOIN Fact_Acct fa ON (fa.AD_Table_ID=318 AND fa.Record_ID=i.C_Invoice_ID" .append(" INNER JOIN Fact_Acct fa ON (fa.AD_Table_ID=318 AND fa.Record_ID=i.C_Invoice_ID")
+ " AND (i.GrandTotal=fa.AmtSourceDr OR i.GrandTotal=fa.AmtSourceCr))" .append(" AND (i.GrandTotal=fa.AmtSourceDr OR i.GrandTotal=fa.AmtSourceCr))")
+ " INNER JOIN C_AcctSchema a ON (fa.C_AcctSchema_ID=a.C_AcctSchema_ID) " .append(" INNER JOIN C_AcctSchema a ON (fa.C_AcctSchema_ID=a.C_AcctSchema_ID) ")
+ "WHERE i.IsPaid='N'" .append("WHERE i.IsPaid='N'")
+ " AND EXISTS (SELECT * FROM C_ElementValue ev " .append(" AND EXISTS (SELECT * FROM C_ElementValue ev ")
+ "WHERE ev.C_ElementValue_ID=fa.Account_ID AND (ev.AccountType='A' OR ev.AccountType='L'))" .append("WHERE ev.C_ElementValue_ID=fa.Account_ID AND (ev.AccountType='A' OR ev.AccountType='L'))")
+ " AND fa.C_AcctSchema_ID=" + p_C_AcctSchema_ID; .append(" AND fa.C_AcctSchema_ID=").append(p_C_AcctSchema_ID);
if (!p_IsAllCurrencies) if (!p_IsAllCurrencies)
sql += " AND i.C_Currency_ID<>a.C_Currency_ID"; sql.append(" AND i.C_Currency_ID<>a.C_Currency_ID");
if (ONLY_AR.equals(p_APAR)) if (ONLY_AR.equals(p_APAR))
sql += " AND i.IsSOTrx='Y'"; sql.append(" AND i.IsSOTrx='Y'");
else if (ONLY_AP.equals(p_APAR)) else if (ONLY_AP.equals(p_APAR))
sql += " AND i.IsSOTrx='N'"; sql.append(" AND i.IsSOTrx='N'");
if (!p_IsAllCurrencies && p_C_Currency_ID != 0) if (!p_IsAllCurrencies && p_C_Currency_ID != 0)
sql += " AND i.C_Currency_ID=" + p_C_Currency_ID; sql.append(" AND i.C_Currency_ID=").append(p_C_Currency_ID);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.info("Inserted #" + no); log.info("Inserted #" + no);
else if (CLogMgt.isLevelFiner()) else if (CLogMgt.isLevelFiner())
@ -166,35 +166,35 @@ public class InvoiceNGL extends SvrProcess
log.warning("Inserted #" + no); log.warning("Inserted #" + no);
// Calculate Difference // Calculate Difference
sql = "UPDATE T_InvoiceGL gl " sql = new StringBuilder("UPDATE T_InvoiceGL gl ")
+ "SET (AmtRevalDrDiff,AmtRevalCrDiff)=" .append("SET (AmtRevalDrDiff,AmtRevalCrDiff)=")
+ "(SELECT gl.AmtRevalDr-fa.AmtAcctDr, gl.AmtRevalCr-fa.AmtAcctCr " .append("(SELECT gl.AmtRevalDr-fa.AmtAcctDr, gl.AmtRevalCr-fa.AmtAcctCr ")
+ "FROM Fact_Acct fa " .append("FROM Fact_Acct fa ")
+ "WHERE gl.Fact_Acct_ID=fa.Fact_Acct_ID) " .append("WHERE gl.Fact_Acct_ID=fa.Fact_Acct_ID) ")
+ "WHERE AD_PInstance_ID=" + getAD_PInstance_ID(); .append("WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());
int noT = DB.executeUpdate(sql, get_TrxName()); int noT = DB.executeUpdate(sql.toString(), get_TrxName());
if (noT > 0) if (noT > 0)
log.config("Difference #" + noT); log.config("Difference #" + noT);
// Percentage // Percentage
sql = "UPDATE T_InvoiceGL SET Percent = 100 " sql = new StringBuilder("UPDATE T_InvoiceGL SET Percent = 100 ")
+ "WHERE GrandTotal=OpenAmt AND AD_PInstance_ID=" + getAD_PInstance_ID(); .append("WHERE GrandTotal=OpenAmt AND AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no > 0) if (no > 0)
log.info("Not Paid #" + no); log.info("Not Paid #" + no);
sql = "UPDATE T_InvoiceGL SET Percent = ROUND(OpenAmt*100/GrandTotal,6) " sql = new StringBuilder("UPDATE T_InvoiceGL SET Percent = ROUND(OpenAmt*100/GrandTotal,6) ")
+ "WHERE GrandTotal<>OpenAmt AND GrandTotal <> 0 AND AD_PInstance_ID=" + getAD_PInstance_ID(); .append("WHERE GrandTotal<>OpenAmt AND GrandTotal <> 0 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no > 0) if (no > 0)
log.info("Partial Paid #" + no); log.info("Partial Paid #" + no);
sql = "UPDATE T_InvoiceGL SET AmtRevalDr = AmtRevalDr * Percent/100," sql = new StringBuilder("UPDATE T_InvoiceGL SET AmtRevalDr = AmtRevalDr * Percent/100,")
+ " AmtRevalCr = AmtRevalCr * Percent/100," .append(" AmtRevalCr = AmtRevalCr * Percent/100,")
+ " AmtRevalDrDiff = AmtRevalDrDiff * Percent/100," .append(" AmtRevalDrDiff = AmtRevalDrDiff * Percent/100,")
+ " AmtRevalCrDiff = AmtRevalCrDiff * Percent/100 " .append(" AmtRevalCrDiff = AmtRevalCrDiff * Percent/100 ")
+ "WHERE Percent <> 100 AND AD_PInstance_ID=" + getAD_PInstance_ID(); .append("WHERE Percent <> 100 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no > 0) if (no > 0)
log.config("Partial Calc #" + no); log.config("Partial Calc #" + no);
@ -206,8 +206,9 @@ public class InvoiceNGL extends SvrProcess
log.warning("Can create Journal only for all currencies"); log.warning("Can create Journal only for all currencies");
else else
info = createGLJournal(); info = createGLJournal();
} }
return "#" + noT + info; StringBuilder msgreturn = new StringBuilder("#").append(noT).append(info);
return msgreturn.toString();
} // doIt } // doIt
/** /**
@ -302,8 +303,9 @@ public class InvoiceNGL extends SvrProcess
} }
} }
createBalancing (asDefaultAccts, journal, drTotal, crTotal, AD_Org_ID, (list.size()+1) * 10); createBalancing (asDefaultAccts, journal, drTotal, crTotal, AD_Org_ID, (list.size()+1) * 10);
return " - " + batch.getDocumentNo() + " #" + list.size(); StringBuilder msgreturn = new StringBuilder(" - ").append(batch.getDocumentNo()).append(" #").append(list.size());
return msgreturn.toString();
} // createGLJournal } // createGLJournal
/** /**

View File

@ -84,12 +84,12 @@ public class InvoicePayScheduleValidate extends SvrProcess
schedule[i].saveEx(); schedule[i].saveEx();
} }
} }
String msg = "@OK@"; StringBuilder msg = new StringBuilder("@OK@");
if (!valid) if (!valid)
msg = "@GrandTotal@ = " + invoice.getGrandTotal() msg = new StringBuilder("@GrandTotal@ = ").append(invoice.getGrandTotal())
+ " <> @Total@ = " + total .append(" <> @Total@ = ").append(total)
+ " - @Difference@ = " + invoice.getGrandTotal().subtract(total); .append(" - @Difference@ = ").append(invoice.getGrandTotal().subtract(total));
return Msg.parseTranslation(getCtx(), msg); return Msg.parseTranslation(getCtx(), msg.toString());
} // doIt } // doIt
} // InvoicePayScheduleValidate } // InvoicePayScheduleValidate

View File

@ -130,21 +130,20 @@ public class InvoicePrint extends SvrProcess
MClient client = MClient.get(getCtx()); MClient client = MClient.get(getCtx());
// Get Info // Get Info
StringBuffer sql = new StringBuffer ( StringBuilder sql = new StringBuilder ("SELECT i.C_Invoice_ID,bp.AD_Language,c.IsMultiLingualDocument,") // 1..3
"SELECT i.C_Invoice_ID,bp.AD_Language,c.IsMultiLingualDocument," // 1..3
// Prio: 1. BPartner 2. DocType, 3. PrintFormat (Org) // see ReportCtl+MInvoice // Prio: 1. BPartner 2. DocType, 3. PrintFormat (Org) // see ReportCtl+MInvoice
+ " COALESCE(bp.Invoice_PrintFormat_ID, dt.AD_PrintFormat_ID, pf.Invoice_PrintFormat_ID)," // 4 .append(" COALESCE(bp.Invoice_PrintFormat_ID, dt.AD_PrintFormat_ID, pf.Invoice_PrintFormat_ID),") // 4
+ " dt.DocumentCopies+bp.DocumentCopies," // 5 .append(" dt.DocumentCopies+bp.DocumentCopies,") // 5
+ " bpc.AD_User_ID, i.DocumentNo," // 6..7 .append(" bpc.AD_User_ID, i.DocumentNo,") // 6..7
+ " bp.C_BPartner_ID " // 8 .append(" bp.C_BPartner_ID ") // 8
+ "FROM C_Invoice i" .append("FROM C_Invoice i")
+ " INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID)" .append(" INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID)")
+ " LEFT OUTER JOIN AD_User bpc ON (i.AD_User_ID=bpc.AD_User_ID)" .append(" LEFT OUTER JOIN AD_User bpc ON (i.AD_User_ID=bpc.AD_User_ID)")
+ " INNER JOIN AD_Client c ON (i.AD_Client_ID=c.AD_Client_ID)" .append(" INNER JOIN AD_Client c ON (i.AD_Client_ID=c.AD_Client_ID)")
+ " INNER JOIN AD_PrintForm pf ON (i.AD_Client_ID=pf.AD_Client_ID)" .append(" INNER JOIN AD_PrintForm pf ON (i.AD_Client_ID=pf.AD_Client_ID)")
+ " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)" .append(" INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)")
+ " WHERE i.AD_Client_ID=? AND i.AD_Org_ID=? AND i.isSOTrx='Y' AND " .append(" WHERE i.AD_Client_ID=? AND i.AD_Org_ID=? AND i.isSOTrx='Y' AND ")
+ " pf.AD_Org_ID IN (0,i.AD_Org_ID) AND " ); // more them 1 PF .append(" pf.AD_Org_ID IN (0,i.AD_Org_ID) AND " ); // more them 1 PF
boolean needAnd = false; boolean needAnd = false;
if (m_C_Invoice_ID != 0) if (m_C_Invoice_ID != 0)
sql.append("i.C_Invoice_ID=").append(m_C_Invoice_ID); sql.append("i.C_Invoice_ID=").append(m_C_Invoice_ID);
@ -289,8 +288,8 @@ public class InvoicePrint extends SvrProcess
boolean printed = false; boolean printed = false;
if (p_EMailPDF) if (p_EMailPDF)
{ {
String subject = mText.getMailHeader() + " - " + DocumentNo; StringBuilder subject =new StringBuilder(mText.getMailHeader()).append(" - ").append(DocumentNo);
EMail email = client.createEMail(to.getEMail(), subject, null); EMail email = client.createEMail(to.getEMail(), subject.toString(), null);
if (!email.isValid()) if (!email.isValid())
{ {
addLog (C_Invoice_ID, null, null, addLog (C_Invoice_ID, null, null,
@ -303,10 +302,10 @@ public class InvoicePrint extends SvrProcess
mText.setPO(new MInvoice(getCtx(), C_Invoice_ID, get_TrxName())); mText.setPO(new MInvoice(getCtx(), C_Invoice_ID, get_TrxName()));
String message = mText.getMailText(true); String message = mText.getMailText(true);
if (mText.isHtml()) if (mText.isHtml())
email.setMessageHTML(subject, message); email.setMessageHTML(subject.toString(), message);
else else
{ {
email.setSubject (subject); email.setSubject (subject.toString());
email.setMessageText (message); email.setMessageText (message);
} }
// //
@ -348,8 +347,8 @@ public class InvoicePrint extends SvrProcess
// Print Confirm // Print Confirm
if (printed) if (printed)
{ {
StringBuffer sb = new StringBuffer ("UPDATE C_Invoice " StringBuilder sb = new StringBuilder ("UPDATE C_Invoice ")
+ "SET DatePrinted=SysDate, IsPrinted='Y' WHERE C_Invoice_ID=") .append("SET DatePrinted=SysDate, IsPrinted='Y' WHERE C_Invoice_ID=")
.append (C_Invoice_ID); .append (C_Invoice_ID);
int no = DB.executeUpdate(sb.toString(), get_TrxName()); int no = DB.executeUpdate(sb.toString(), get_TrxName());
} }
@ -364,9 +363,12 @@ public class InvoicePrint extends SvrProcess
DB.close(rs, pstmt); DB.close(rs, pstmt);
} }
// //
if (p_EMailPDF) if (p_EMailPDF){
return "@Sent@=" + count + " - @Errors@=" + errors; StringBuilder msgreturn = new StringBuilder("@Sent@=").append(count).append(" - @Errors@=").append(errors);
return "@Printed@=" + count; return msgreturn.toString();
}
StringBuilder msgreturn = new StringBuilder("@Printed@=").append(count);
return msgreturn.toString();
} // doIt } // doIt
} // InvoicePrint } // InvoicePrint

View File

@ -134,10 +134,10 @@ public class InvoiceWriteOff extends SvrProcess
if (p_CreatePayment && p_C_BankAccount_ID == 0) if (p_CreatePayment && p_C_BankAccount_ID == 0)
throw new AdempiereUserError ("@FillMandatory@ @C_BankAccount_ID@"); throw new AdempiereUserError ("@FillMandatory@ @C_BankAccount_ID@");
// //
StringBuffer sql = new StringBuffer( StringBuilder sql = new StringBuilder(
"SELECT C_Invoice_ID,DocumentNo,DateInvoiced," "SELECT C_Invoice_ID,DocumentNo,DateInvoiced,")
+ " C_Currency_ID,GrandTotal, invoiceOpen(C_Invoice_ID, 0) AS OpenAmt " .append(" C_Currency_ID,GrandTotal, invoiceOpen(C_Invoice_ID, 0) AS OpenAmt ")
+ "FROM C_Invoice WHERE "); .append("FROM C_Invoice WHERE ");
if (p_C_Invoice_ID != 0) if (p_C_Invoice_ID != 0)
sql.append("C_Invoice_ID=").append(p_C_Invoice_ID); sql.append("C_Invoice_ID=").append(p_C_Invoice_ID);
else else
@ -201,7 +201,8 @@ public class InvoiceWriteOff extends SvrProcess
// final // final
processPayment(); processPayment();
processAllocation(); processAllocation();
return "#" + counter; StringBuilder msgreturn = new StringBuilder("#").append(counter);
return msgreturn.toString();
} // doIt } // doIt
/** /**

View File

@ -51,14 +51,18 @@ public class IssueReport extends SvrProcess
return "NOT reported - Enable Error Reporting in Window System"; return "NOT reported - Enable Error Reporting in Window System";
// //
MIssue issue = new MIssue(getCtx(), m_AD_Issue_ID, get_TrxName()); MIssue issue = new MIssue(getCtx(), m_AD_Issue_ID, get_TrxName());
if (issue.get_ID() == 0) if (issue.get_ID() == 0){
return "No Issue to report - ID=" + m_AD_Issue_ID; StringBuilder msgreturn = new StringBuilder("No Issue to report - ID=").append(m_AD_Issue_ID);
return msgreturn.toString();
}
// //
String error = issue.report(); String error = issue.report();
if (error != null) if (error != null)
throw new AdempiereSystemError(error); throw new AdempiereSystemError(error);
if (issue.save()) if (issue.save()){
return "Issue Reported: " + issue.getRequestDocumentNo(); StringBuilder msgreturn = new StringBuilder("Issue Reported: ").append(issue.getRequestDocumentNo());
return msgreturn.toString();
}
throw new AdempiereSystemError("Issue Not Saved"); throw new AdempiereSystemError("Issue Not Saved");
} // doIt } // doIt

View File

@ -91,7 +91,7 @@ public class M_PriceList_Create extends SvrProcess {
int totd = 0; int totd = 0;
int V_temp; int V_temp;
int v_NextNo = 0; int v_NextNo = 0;
String Message = " "; StringBuilder Message = new StringBuilder();
// //
//Checking Prerequisites //Checking Prerequisites
//PO Prices must exists //PO Prices must exists
@ -225,7 +225,7 @@ public class M_PriceList_Create extends SvrProcess {
if (cntd == -1) if (cntd == -1)
raiseError(" DELETE M_ProductPrice ", sqldel.toString()); raiseError(" DELETE M_ProductPrice ", sqldel.toString());
totd += cntd; totd += cntd;
Message = "@Deleted@=" + cntd + " - "; Message = new StringBuilder("@Deleted@=").append(cntd).append(" - ");
log.fine("Deleted " + cntd); log.fine("Deleted " + cntd);
} }
// //
@ -375,7 +375,7 @@ public class M_PriceList_Create extends SvrProcess {
} }
Message = Message + "@Selected@=" + cnti; Message.append("@Selected@=").append(cnti);
// //
//Delete Prices in Selection, so that we can insert //Delete Prices in Selection, so that we can insert
@ -393,7 +393,7 @@ public class M_PriceList_Create extends SvrProcess {
if (cntd == -1) if (cntd == -1)
raiseError(" DELETE M_ProductPrice ", sqldel.toString()); raiseError(" DELETE M_ProductPrice ", sqldel.toString());
totd += cntd; totd += cntd;
Message = Message + ", @Deleted@=" + cntd; Message.append(", @Deleted@=").append(cntd);
log.fine("Deleted " + cntd); log.fine("Deleted " + cntd);
} }
@ -564,7 +564,7 @@ public class M_PriceList_Create extends SvrProcess {
log.fine("Inserted " + cnti); log.fine("Inserted " + cnti);
} }
Message = Message + ", @Inserted@=" + cnti; Message.append(", @Inserted@=").append(cnti);
// //
// Calculation // Calculation
// //
@ -656,7 +656,7 @@ public class M_PriceList_Create extends SvrProcess {
totu += cntu; totu += cntu;
log.fine("Updated " + cntu); log.fine("Updated " + cntu);
Message = Message + ", @Updated@=" + cntu; Message.append(", @Updated@=").append(cntu);
// //
//Fixed Price overwrite //Fixed Price overwrite
// //
@ -683,8 +683,8 @@ public class M_PriceList_Create extends SvrProcess {
log.fine("Updated " + cntu); log.fine("Updated " + cntu);
v_NextNo = v_NextNo + 1; v_NextNo = v_NextNo + 1;
addLog(0, null, null, Message); addLog(0, null, null, Message.toString());
Message = ""; Message = new StringBuilder();
} }
dl.close(); dl.close();
Cur_DiscountLine.close(); Cur_DiscountLine.close();
@ -718,12 +718,12 @@ public class M_PriceList_Create extends SvrProcess {
private void raiseError(String string, String sql) throws Exception { private void raiseError(String string, String sql) throws Exception {
// DB.rollback(false, get_TrxName()); // DB.rollback(false, get_TrxName());
String msg = string; StringBuilder msg = new StringBuilder(string);
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());
} }
/** /**
@ -735,7 +735,7 @@ public class M_PriceList_Create extends SvrProcess {
private String getSubCategoryWhereClause(int productCategoryId) throws SQLException, AdempiereSystemError{ private String getSubCategoryWhereClause(int productCategoryId) throws SQLException, AdempiereSystemError{
//if a node with this id is found later in the search we have a loop in the tree //if a node with this id is found later in the search we have a loop in the tree
int subTreeRootParentId = 0; int subTreeRootParentId = 0;
String retString = " "; StringBuilder retString = new StringBuilder();
String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category"; String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category";
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100); final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
Statement stmt = DB.createStatement(); Statement stmt = DB.createStatement();
@ -746,10 +746,10 @@ public class M_PriceList_Create extends SvrProcess {
} }
categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2))); categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2)));
} }
retString += getSubCategoriesString(productCategoryId, categories, subTreeRootParentId); retString.append(getSubCategoriesString(productCategoryId, categories, subTreeRootParentId));
rs.close(); rs.close();
stmt.close(); stmt.close();
return retString; return retString.toString();
} }
/** /**

View File

@ -73,7 +73,7 @@ public class M_Product_BOM_Check extends SvrProcess
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
StringBuffer sql1 = null; StringBuilder sql1 = null;
int no = 0; int no = 0;
log.info("Check BOM Structure"); log.info("Check BOM Structure");
@ -90,20 +90,20 @@ public class M_Product_BOM_Check extends SvrProcess
} }
// Table to put all BOMs - duplicate will cause exception // Table to put all BOMs - duplicate will cause exception
sql1 = new StringBuffer("DELETE FROM T_Selection2 WHERE Query_ID = 0 AND AD_PInstance_ID="+ m_AD_PInstance_ID); sql1 = new StringBuilder("DELETE FROM T_Selection2 WHERE Query_ID = 0 AND AD_PInstance_ID=").append(m_AD_PInstance_ID);
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
sql1 = new StringBuffer("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) VALUES (" sql1 = new StringBuilder("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) VALUES (")
+ m_AD_PInstance_ID .append(m_AD_PInstance_ID)
+ ", 0, " .append(", 0, ")
+ p_Record_ID + ")"); .append(p_Record_ID).append(")");
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
// Table of root modes // Table of root modes
sql1 = new StringBuffer("DELETE FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID); sql1 = new StringBuilder("DELETE FROM T_Selection WHERE AD_PInstance_ID=").append(m_AD_PInstance_ID);
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
sql1 = new StringBuffer("INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) VALUES (" sql1 = new StringBuilder("INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) VALUES (")
+ m_AD_PInstance_ID .append(m_AD_PInstance_ID)
+ ", " .append(", ")
+ p_Record_ID + ")"); .append(p_Record_ID).append(")");
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
while (true) { while (true) {
@ -112,8 +112,8 @@ public class M_Product_BOM_Check extends SvrProcess
int countno = 0; int countno = 0;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement StringBuilder dbpst = new StringBuilder("SELECT COUNT(*) FROM T_Selection WHERE AD_PInstance_ID=").append(m_AD_PInstance_ID);
("SELECT COUNT(*) FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID, get_TrxName()); PreparedStatement pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
countno = rs.getInt(1); countno = rs.getInt(1);
@ -133,31 +133,31 @@ public class M_Product_BOM_Check extends SvrProcess
{ {
// if any command fails (no==-1) break and inform failure // if any command fails (no==-1) break and inform failure
// Insert BOM Nodes into "All" table // Insert BOM Nodes into "All" table
sql1 = new StringBuffer("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) " sql1 = new StringBuilder("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) ")
+ "SELECT " + m_AD_PInstance_ID + ", 0, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS " .append("SELECT ").append(m_AD_PInstance_ID).append(", 0, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS ")
//+ "(SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND b.M_Product_ID IN " //+ "(SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND b.M_Product_ID IN "
+ "(SELECT * FROM PP_Product_BOM b WHERE p.M_Product_ID=b.M_Product_ID AND b.M_Product_ID IN " .append("(SELECT * FROM PP_Product_BOM b WHERE p.M_Product_ID=b.M_Product_ID AND b.M_Product_ID IN ")
+ "(SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID + "))"); .append("(SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID=").append(m_AD_PInstance_ID).append("))");
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString()); if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
// Insert BOM Nodes into temporary table // Insert BOM Nodes into temporary table
sql1 = new StringBuffer("DELETE FROM T_Selection2 WHERE Query_ID = 1 AND AD_PInstance_ID="+ m_AD_PInstance_ID); sql1 = new StringBuilder("DELETE FROM T_Selection2 WHERE Query_ID = 1 AND AD_PInstance_ID=").append(m_AD_PInstance_ID);
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString()); if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
sql1 = new StringBuffer("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) " sql1 = new StringBuilder("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) ")
+ "SELECT " + m_AD_PInstance_ID + ", 1, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS " .append("SELECT ").append(m_AD_PInstance_ID).append(", 1, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS ")
//+ "(SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND b.M_Product_ID IN " //+ "(SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND b.M_Product_ID IN "
+ "(SELECT * FROM PP_Product_BOM b WHERE p.M_Product_ID=b.M_Product_ID AND b.M_Product_ID IN " .append("(SELECT * FROM PP_Product_BOM b WHERE p.M_Product_ID=b.M_Product_ID AND b.M_Product_ID IN ")
+ "(SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID + "))"); .append("(SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID=").append(m_AD_PInstance_ID).append("))");
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString()); if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
// Copy into root table // Copy into root table
sql1 = new StringBuffer("DELETE FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID); sql1 = new StringBuilder("DELETE FROM T_Selection WHERE AD_PInstance_ID=").append(m_AD_PInstance_ID);
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString()); if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
sql1 = new StringBuffer("INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) " sql1 = new StringBuilder("INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) ")
+ "SELECT " + m_AD_PInstance_ID + ", T_Selection_ID " .append("SELECT ").append(m_AD_PInstance_ID).append(", T_Selection_ID ")
+ "FROM T_Selection2 WHERE Query_ID = 1 AND AD_PInstance_ID="+ m_AD_PInstance_ID); .append("FROM T_Selection2 WHERE Query_ID = 1 AND AD_PInstance_ID=").append(m_AD_PInstance_ID);
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString()); if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
} }
@ -176,12 +176,12 @@ public class M_Product_BOM_Check extends SvrProcess
private void raiseError(String string, String sql) throws Exception { private void raiseError(String string, String sql) throws Exception {
DB.rollback(false, get_TrxName()); DB.rollback(false, get_TrxName());
String msg = string; StringBuilder msg = new StringBuilder(string);
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());
} }
} // M_Product_BOM_Check } // M_Product_BOM_Check

View File

@ -256,11 +256,11 @@ public class M_Production_Run extends SvrProcess {
} }
private void raiseError(String string, String sql) throws Exception { private void raiseError(String string, String sql) throws Exception {
String msg = string; StringBuilder msg = new StringBuilder(string);
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());
} }
} // M_Production_Run } // M_Production_Run

View File

@ -66,14 +66,15 @@ public class NoteDelete extends SvrProcess
{ {
log.info("doIt - AD_User_ID=" + p_AD_User_ID); log.info("doIt - AD_User_ID=" + p_AD_User_ID);
String sql = "DELETE FROM AD_Note WHERE AD_Client_ID=" + getAD_Client_ID(); StringBuilder sql = new StringBuilder("DELETE FROM AD_Note WHERE AD_Client_ID=").append(getAD_Client_ID());
if (p_AD_User_ID > 0) if (p_AD_User_ID > 0)
sql += " AND AD_User_ID=" + p_AD_User_ID; sql.append(" AND AD_User_ID=").append(p_AD_User_ID);
if (p_KeepLogDays > 0) if (p_KeepLogDays > 0)
sql += " AND (Created+" + p_KeepLogDays + ") < SysDate"; sql.append(" AND (Created+").append(p_KeepLogDays).append(") < SysDate");
// //
int no = DB.executeUpdate(sql, get_TrxName()); int no = DB.executeUpdate(sql.toString(), get_TrxName());
return "@Deleted@ = " + no; StringBuilder msgreturn = new StringBuilder("@Deleted@ = ").append(no);
return msgreturn.toString();
} // doIt } // doIt
} // NoteDelete } // NoteDelete

View File

@ -102,8 +102,8 @@ public class OrderBatchProcess extends SvrProcess
throw new AdempiereUserError("@NotFound@: @DocAction@"); throw new AdempiereUserError("@NotFound@: @DocAction@");
// //
StringBuffer sql = new StringBuffer("SELECT * FROM C_Order o " StringBuilder sql = new StringBuilder("SELECT * FROM C_Order o ")
+ " WHERE o.C_DocTypeTarget_ID=? AND o.DocStatus=? "); .append(" WHERE o.C_DocTypeTarget_ID=? AND o.DocStatus=? ");
if (p_IsSelfService != null && p_IsSelfService.length() == 1) if (p_IsSelfService != null && p_IsSelfService.length() == 1)
sql.append(" AND o.IsSelfService='").append(p_IsSelfService).append("'"); sql.append(" AND o.IsSelfService='").append(p_IsSelfService).append("'");
if (p_C_BPartner_ID != 0) if (p_C_BPartner_ID != 0)
@ -159,7 +159,8 @@ public class OrderBatchProcess extends SvrProcess
{ {
pstmt = null; pstmt = null;
} }
return "@Updated@=" + counter + ", @Errors@=" + errCounter; StringBuilder msgreturn = new StringBuilder("@Updated@=").append(counter).append(", @Errors@=").append(errCounter);
return msgreturn.toString();
} // doIt } // doIt
/** /**

View File

@ -131,7 +131,8 @@ public class OrderLineCreateProduction extends SvrProcess
production.setIsCreated("Y"); production.setIsCreated("Y");
production.saveEx(); production.saveEx();
return "Production created -- " + production.get_ValueAsString("DocumentNo"); StringBuilder msgreturn = new StringBuilder("Production created -- ").append(production.get_ValueAsString("DocumentNo"));
return msgreturn.toString();
} // OrderLineCreateShipment } // OrderLineCreateShipment
} // OrderLineCreateShipment } // OrderLineCreateShipment

View File

@ -102,35 +102,34 @@ public class OrderPOCreate extends SvrProcess
&& p_C_BPartner_ID == 0 && p_Vendor_ID == 0) && p_C_BPartner_ID == 0 && p_Vendor_ID == 0)
throw new AdempiereUserError("You need to restrict selection"); throw new AdempiereUserError("You need to restrict selection");
// //
String sql = "SELECT * FROM C_Order o " StringBuilder sql = new StringBuilder("SELECT * FROM C_Order o ")
+ "WHERE o.IsSOTrx='Y'" .append("WHERE o.IsSOTrx='Y'")
// No Duplicates // No Duplicates
// " AND o.Link_Order_ID IS NULL" // " AND o.Link_Order_ID IS NULL"
+ " AND NOT EXISTS (SELECT * FROM C_OrderLine ol WHERE o.C_Order_ID=ol.C_Order_ID AND ol.Link_OrderLine_ID IS NOT NULL)" .append(" AND NOT EXISTS (SELECT * FROM C_OrderLine ol WHERE o.C_Order_ID=ol.C_Order_ID AND ol.Link_OrderLine_ID IS NOT NULL)");
;
if (p_C_Order_ID != 0) if (p_C_Order_ID != 0)
sql += " AND o.C_Order_ID=?"; sql.append(" AND o.C_Order_ID=?");
else else
{ {
if (p_C_BPartner_ID != 0) if (p_C_BPartner_ID != 0)
sql += " AND o.C_BPartner_ID=?"; sql.append(" AND o.C_BPartner_ID=?");
if (p_Vendor_ID != 0) if (p_Vendor_ID != 0)
sql += " AND EXISTS (SELECT * FROM C_OrderLine ol" sql.append(" AND EXISTS (SELECT * FROM C_OrderLine ol")
+ " INNER JOIN M_Product_PO po ON (ol.M_Product_ID=po.M_Product_ID) " .append(" INNER JOIN M_Product_PO po ON (ol.M_Product_ID=po.M_Product_ID) ")
+ "WHERE o.C_Order_ID=ol.C_Order_ID AND po.C_BPartner_ID=?)"; .append("WHERE o.C_Order_ID=ol.C_Order_ID AND po.C_BPartner_ID=?)");
if (p_DateOrdered_From != null && p_DateOrdered_To != null) if (p_DateOrdered_From != null && p_DateOrdered_To != null)
sql += "AND TRUNC(o.DateOrdered) BETWEEN ? AND ?"; sql.append("AND TRUNC(o.DateOrdered) BETWEEN ? AND ?");
else if (p_DateOrdered_From != null && p_DateOrdered_To == null) else if (p_DateOrdered_From != null && p_DateOrdered_To == null)
sql += "AND TRUNC(o.DateOrdered) >= ?"; sql.append("AND TRUNC(o.DateOrdered) >= ?");
else if (p_DateOrdered_From == null && p_DateOrdered_To != null) else if (p_DateOrdered_From == null && p_DateOrdered_To != null)
sql += "AND TRUNC(o.DateOrdered) <= ?"; sql.append("AND TRUNC(o.DateOrdered) <= ?");
} }
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
int counter = 0; int counter = 0;
try try
{ {
pstmt = DB.prepareStatement (sql, get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
if (p_C_Order_ID != 0) if (p_C_Order_ID != 0)
pstmt.setInt (1, p_C_Order_ID); pstmt.setInt (1, p_C_Order_ID);
else else
@ -162,8 +161,9 @@ public class OrderPOCreate extends SvrProcess
rs = null; pstmt = null; rs = null; pstmt = null;
} }
if (counter == 0) if (counter == 0)
log.fine(sql); log.fine(sql.toString());
return "@Created@ " + counter; StringBuilder msgreturn = new StringBuilder("@Created@ ").append(counter);
return msgreturn.toString();
} // doIt } // doIt
/** /**

View File

@ -83,12 +83,12 @@ public class OrderPayScheduleValidate extends SvrProcess
schedule[i].saveEx(); schedule[i].saveEx();
} }
} }
String msg = "@OK@"; StringBuilder msg = new StringBuilder("@OK@");
if (!valid) if (!valid)
msg = "@GrandTotal@ = " + order.getGrandTotal() msg = new StringBuilder("@GrandTotal@ = ") .append(order.getGrandTotal())
+ " <> @Total@ = " + total .append(" <> @Total@ = ").append(total)
+ " - @Difference@ = " + order.getGrandTotal().subtract(total); .append(" - @Difference@ = ").append(order.getGrandTotal().subtract(total));
return Msg.parseTranslation(getCtx(), msg); return Msg.parseTranslation(getCtx(), msg.toString());
} // doIt } // doIt
} // OrderPayScheduleValidate } // OrderPayScheduleValidate

View File

@ -69,7 +69,7 @@ public class OrderRePrice extends SvrProcess
if (p_C_Order_ID == 0 && p_C_Invoice_ID == 0) if (p_C_Order_ID == 0 && p_C_Invoice_ID == 0)
throw new IllegalArgumentException("Nothing to do"); throw new IllegalArgumentException("Nothing to do");
String retValue = ""; StringBuilder retValue = new StringBuilder();
if (p_C_Order_ID != 0) if (p_C_Order_ID != 0)
{ {
MOrder order = new MOrder (getCtx(), p_C_Order_ID, get_TrxName()); MOrder order = new MOrder (getCtx(), p_C_Order_ID, get_TrxName());
@ -82,7 +82,7 @@ public class OrderRePrice extends SvrProcess
} }
order = new MOrder (getCtx(), p_C_Order_ID, get_TrxName()); order = new MOrder (getCtx(), p_C_Order_ID, get_TrxName());
BigDecimal newPrice = order.getGrandTotal(); BigDecimal newPrice = order.getGrandTotal();
retValue = order.getDocumentNo() + ": " + oldPrice + " -> " + newPrice; retValue = new StringBuilder(order.getDocumentNo()).append(": ").append(oldPrice).append(" -> ").append(newPrice);
} }
if (p_C_Invoice_ID != 0) if (p_C_Invoice_ID != 0)
{ {
@ -97,11 +97,11 @@ public class OrderRePrice extends SvrProcess
invoice = new MInvoice (getCtx(), p_C_Invoice_ID, null); invoice = new MInvoice (getCtx(), p_C_Invoice_ID, null);
BigDecimal newPrice = invoice.getGrandTotal(); BigDecimal newPrice = invoice.getGrandTotal();
if (retValue.length() > 0) if (retValue.length() > 0)
retValue += Env.NL; retValue.append(Env.NL);
retValue += invoice.getDocumentNo() + ": " + oldPrice + " -> " + newPrice; retValue.append(invoice.getDocumentNo()).append(": ").append(oldPrice).append(" -> ").append(newPrice);
} }
// //
return retValue; return retValue.toString();
} // doIt } // doIt
} // OrderRePrice } // OrderRePrice

View File

@ -109,9 +109,9 @@ public class OrgOwnership extends SvrProcess
throw new IllegalArgumentException ("Warehouse - Org cannot be * (0)"); throw new IllegalArgumentException ("Warehouse - Org cannot be * (0)");
// Set Warehouse // Set Warehouse
StringBuffer sql = new StringBuffer(); StringBuilder sql = new StringBuilder();
sql.append("UPDATE M_Warehouse " sql.append("UPDATE M_Warehouse ")
+ "SET AD_Org_ID=").append(p_AD_Org_ID) .append("SET AD_Org_ID=").append(p_AD_Org_ID)
.append(" WHERE M_Warehouse_ID=").append(p_M_Warehouse_ID) .append(" WHERE M_Warehouse_ID=").append(p_M_Warehouse_ID)
.append(" AND AD_Client_ID=").append(getAD_Client_ID()) .append(" AND AD_Client_ID=").append(getAD_Client_ID())
.append(" AND AD_Org_ID<>").append(p_AD_Org_ID); .append(" AND AD_Org_ID<>").append(p_AD_Org_ID);
@ -119,9 +119,9 @@ public class OrgOwnership extends SvrProcess
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "M_Warehouse_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "M_Warehouse_ID"));
// Set Accounts // Set Accounts
sql = new StringBuffer(); sql = new StringBuilder();
sql.append("UPDATE M_Warehouse_Acct " sql.append("UPDATE M_Warehouse_Acct ")
+ "SET AD_Org_ID=").append(p_AD_Org_ID) .append("SET AD_Org_ID=").append(p_AD_Org_ID)
.append(" WHERE M_Warehouse_ID=").append(p_M_Warehouse_ID) .append(" WHERE M_Warehouse_ID=").append(p_M_Warehouse_ID)
.append(" AND AD_Client_ID=").append(getAD_Client_ID()) .append(" AND AD_Client_ID=").append(getAD_Client_ID())
.append(" AND AD_Org_ID<>").append(p_AD_Org_ID); .append(" AND AD_Org_ID<>").append(p_AD_Org_ID);
@ -129,9 +129,9 @@ public class OrgOwnership extends SvrProcess
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID"));
// Set Locators // Set Locators
sql = new StringBuffer(); sql = new StringBuilder();
sql.append("UPDATE M_Locator " sql.append("UPDATE M_Locator ")
+ "SET AD_Org_ID=").append(p_AD_Org_ID) .append("SET AD_Org_ID=").append(p_AD_Org_ID)
.append(" WHERE M_Warehouse_ID=").append(p_M_Warehouse_ID) .append(" WHERE M_Warehouse_ID=").append(p_M_Warehouse_ID)
.append(" AND AD_Client_ID=").append(getAD_Client_ID()) .append(" AND AD_Client_ID=").append(getAD_Client_ID())
.append(" AND AD_Org_ID<>").append(p_AD_Org_ID); .append(" AND AD_Org_ID<>").append(p_AD_Org_ID);
@ -139,12 +139,12 @@ public class OrgOwnership extends SvrProcess
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "M_Locator_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "M_Locator_ID"));
// Set Storage // Set Storage
sql = new StringBuffer(); sql = new StringBuilder();
sql.append("UPDATE M_Storage s " sql.append("UPDATE M_Storage s ")
+ "SET AD_Org_ID=").append(p_AD_Org_ID) .append("SET AD_Org_ID=").append(p_AD_Org_ID)
.append(" WHERE EXISTS " .append(" WHERE EXISTS ")
+ "(SELECT * FROM M_Locator l WHERE l.M_Locator_ID=s.M_Locator_ID" .append("(SELECT * FROM M_Locator l WHERE l.M_Locator_ID=s.M_Locator_ID")
+ " AND l.M_Warehouse_ID=").append(p_M_Warehouse_ID) .append(" AND l.M_Warehouse_ID=").append(p_M_Warehouse_ID)
.append(") AND AD_Client_ID=").append(getAD_Client_ID()) .append(") AND AD_Client_ID=").append(getAD_Client_ID())
.append(" AND AD_Org_ID<>").append(p_AD_Org_ID); .append(" AND AD_Org_ID<>").append(p_AD_Org_ID);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
@ -162,39 +162,39 @@ public class OrgOwnership extends SvrProcess
log.info ("productOwnership - M_Product_Category_ID=" + p_M_Product_Category_ID log.info ("productOwnership - M_Product_Category_ID=" + p_M_Product_Category_ID
+ ", M_Product_ID=" + p_M_Product_ID); + ", M_Product_ID=" + p_M_Product_ID);
String set = " SET AD_Org_ID=" + p_AD_Org_ID; StringBuilder set = new StringBuilder(" SET AD_Org_ID=").append(p_AD_Org_ID);
if (p_M_Product_Category_ID > 0) if (p_M_Product_Category_ID > 0)
set += " WHERE EXISTS (SELECT * FROM M_Product p" set.append(" WHERE EXISTS (SELECT * FROM M_Product p")
+ " WHERE p.M_Product_ID=x.M_Product_ID AND p.M_Product_Category_ID=" .append(" WHERE p.M_Product_ID=x.M_Product_ID AND p.M_Product_Category_ID=")
+ p_M_Product_Category_ID + ")"; .append(p_M_Product_Category_ID).append(")");
else else
set += " WHERE M_Product_ID=" + p_M_Product_ID; set.append(" WHERE M_Product_ID=").append(p_M_Product_ID);
set += " AND AD_Client_ID=" + getAD_Client_ID() + " AND AD_Org_ID<>" + p_AD_Org_ID; set.append(" AND AD_Client_ID=").append(getAD_Client_ID()).append(" AND AD_Org_ID<>").append(p_AD_Org_ID);
log.fine("productOwnership - " + set); log.fine("productOwnership - " + set);
// Product // Product
String sql = "UPDATE M_Product x " + set; StringBuilder sql = new StringBuilder("UPDATE M_Product x ").append(set);
int no = DB.executeUpdate(sql, get_TrxName()); int no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "M_Product_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "M_Product_ID"));
// Acct // Acct
sql = "UPDATE M_Product_Acct x " + set; sql = new StringBuilder("UPDATE M_Product_Acct x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID"));
// BOM // BOM
sql = "UPDATE M_Product_BOM x " + set; sql = new StringBuilder("UPDATE M_Product_BOM x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "M_Product_BOM_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "M_Product_BOM_ID"));
// PO // PO
sql = "UPDATE M_Product_PO x " + set; sql = new StringBuilder("UPDATE M_Product_PO x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "PO")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "PO"));
// Trl // Trl
sql = "UPDATE M_Product_Trl x " + set; sql = new StringBuilder("UPDATE M_Product_Trl x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "AD_Language")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "AD_Language"));
return ""; return "";
@ -209,43 +209,43 @@ public class OrgOwnership extends SvrProcess
log.info ("bPartnerOwnership - C_BP_Group_ID=" + p_C_BP_Group_ID log.info ("bPartnerOwnership - C_BP_Group_ID=" + p_C_BP_Group_ID
+ ", C_BPartner_ID=" + p_C_BPartner_ID); + ", C_BPartner_ID=" + p_C_BPartner_ID);
String set = " SET AD_Org_ID=" + p_AD_Org_ID; StringBuilder set = new StringBuilder(" SET AD_Org_ID=").append(p_AD_Org_ID);
if (p_C_BP_Group_ID > 0) if (p_C_BP_Group_ID > 0)
set += " WHERE EXISTS (SELECT * FROM C_BPartner bp WHERE bp.C_BPartner_ID=x.C_BPartner_ID AND bp.C_BP_Group_ID=" + p_C_BP_Group_ID + ")"; set.append(" WHERE EXISTS (SELECT * FROM C_BPartner bp WHERE bp.C_BPartner_ID=x.C_BPartner_ID AND bp.C_BP_Group_ID=").append(p_C_BP_Group_ID).append(")");
else else
set += " WHERE C_BPartner_ID=" + p_C_BPartner_ID; set.append(" WHERE C_BPartner_ID=").append(p_C_BPartner_ID);
set += " AND AD_Client_ID=" + getAD_Client_ID() + " AND AD_Org_ID<>" + p_AD_Org_ID; set.append(" AND AD_Client_ID=").append(getAD_Client_ID()).append(" AND AD_Org_ID<>").append(p_AD_Org_ID);
log.fine("bPartnerOwnership - " + set); log.fine("bPartnerOwnership - " + set.toString());
// BPartner // BPartner
String sql = "UPDATE C_BPartner x " + set; StringBuilder sql = new StringBuilder("UPDATE C_BPartner x ").append(set);
int no = DB.executeUpdate(sql, get_TrxName()); int no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_BPartner_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_BPartner_ID"));
// Acct xxx // Acct xxx
sql = "UPDATE C_BP_Customer_Acct x " + set; sql = new StringBuilder("UPDATE C_BP_Customer_Acct x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID"));
sql = "UPDATE C_BP_Employee_Acct x " + set; sql = new StringBuilder("UPDATE C_BP_Employee_Acct x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID"));
sql = "UPDATE C_BP_Vendor_Acct x " + set; sql = new StringBuilder("UPDATE C_BP_Vendor_Acct x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_AcctSchema_ID"));
// Location // Location
sql = "UPDATE C_BPartner_Location x " + set; sql = new StringBuilder("UPDATE C_BPartner_Location x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_BPartner_Location_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_BPartner_Location_ID"));
// Contcat/User // Contcat/User
sql = "UPDATE AD_User x " + set; sql = new StringBuilder("UPDATE AD_User x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "AD_User_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "AD_User_ID"));
// BankAcct // BankAcct
sql = "UPDATE C_BP_BankAccount x " + set; sql = new StringBuilder("UPDATE C_BP_BankAccount x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_BP_BankAccount_ID")); addLog (0,null, new BigDecimal(no), Msg.translate(getCtx(), "C_BP_BankAccount_ID"));
return ""; return "";
@ -257,36 +257,36 @@ public class OrgOwnership extends SvrProcess
*/ */
private void generalOwnership () private void generalOwnership ()
{ {
String set = "SET AD_Org_ID=0 WHERE AD_Client_ID=" + getAD_Client_ID() StringBuilder set = new StringBuilder("SET AD_Org_ID=0 WHERE AD_Client_ID=").append(getAD_Client_ID())
+ " AND AD_Org_ID<>0"; .append(" AND AD_Org_ID<>0");
// R_ContactInterest // R_ContactInterest
String sql = "UPDATE R_ContactInterest " + set; StringBuilder sql = new StringBuilder("UPDATE R_ContactInterest ").append(set);
int no = DB.executeUpdate(sql, get_TrxName()); int no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.fine("generalOwnership - R_ContactInterest=" + no); log.fine("generalOwnership - R_ContactInterest=" + no);
// AD_User_Roles // AD_User_Roles
sql = "UPDATE AD_User_Roles " + set; sql = new StringBuilder("UPDATE AD_User_Roles ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.fine("generalOwnership - AD_User_Roles=" + no); log.fine("generalOwnership - AD_User_Roles=" + no);
// C_BPartner_Product // C_BPartner_Product
sql = "UPDATE C_BPartner_Product " + set; sql = new StringBuilder("UPDATE C_BPartner_Product ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.fine("generalOwnership - C_BPartner_Product=" + no); log.fine("generalOwnership - C_BPartner_Product=" + no);
// Withholding // Withholding
sql = "UPDATE C_BP_Withholding x " + set; sql = new StringBuilder("UPDATE C_BP_Withholding x ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.fine("generalOwnership - C_BP_Withholding=" + no); log.fine("generalOwnership - C_BP_Withholding=" + no);
// Replenish // Replenish
sql = "UPDATE M_Replenish " + set; sql = new StringBuilder("UPDATE M_Replenish ").append(set);
no = DB.executeUpdate(sql, get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.fine("generalOwnership - M_Replenish=" + no); log.fine("generalOwnership - M_Replenish=" + no);

View File

@ -91,7 +91,8 @@ public class PaySelectionCreateCheck extends SvrProcess
psel.setProcessed(true); psel.setProcessed(true);
psel.saveEx(); psel.saveEx();
return "@C_PaySelectionCheck_ID@ - #" + m_list.size(); StringBuilder msgreturn = new StringBuilder("@C_PaySelectionCheck_ID@ - #").append(m_list.size());
return msgreturn.toString();
} // doIt } // doIt
/** /**
@ -130,8 +131,8 @@ public class PaySelectionCreateCheck extends SvrProcess
{ {
int C_BPartner_ID = check.getC_BPartner_ID(); int C_BPartner_ID = check.getC_BPartner_ID();
MBPartner bp = MBPartner.get(getCtx(), C_BPartner_ID); MBPartner bp = MBPartner.get(getCtx(), C_BPartner_ID);
String msg = "@NotFound@ @C_BP_BankAccount@: " + bp.getName(); StringBuilder msg = new StringBuilder("@NotFound@ @C_BP_BankAccount@: ").append(bp.getName());
throw new AdempiereUserError(msg); throw new AdempiereUserError(msg.toString());
} }
if (!check.save()) if (!check.save())
throw new IllegalStateException("Cannot save MPaySelectionCheck"); throw new IllegalStateException("Cannot save MPaySelectionCheck");