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

View File

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

View File

@ -129,38 +129,38 @@ public class InvoiceGenerate extends SvrProcess
+ ", C_Order_ID=" + p_C_Order_ID + ", DocAction=" + p_docAction
+ ", Consolidate=" + p_ConsolidateDocument);
//
String sql = null;
StringBuilder sql = null;
if (p_Selection) // VInvoiceGen
{
sql = "SELECT C_Order.* FROM C_Order, T_Selection "
+ "WHERE C_Order.DocStatus='CO' AND C_Order.IsSOTrx='Y' "
+ "AND C_Order.C_Order_ID = T_Selection.T_Selection_ID "
+ "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";
sql = new StringBuilder("SELECT C_Order.* FROM C_Order, T_Selection ")
.append("WHERE C_Order.DocStatus='CO' AND C_Order.IsSOTrx='Y' ")
.append("AND C_Order.C_Order_ID = T_Selection.T_Selection_ID ")
.append("AND T_Selection.AD_PInstance_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
{
sql = "SELECT * FROM C_Order o "
+ "WHERE DocStatus IN('CO','CL') AND IsSOTrx='Y'";
sql = new StringBuilder("SELECT * FROM C_Order o ")
.append("WHERE DocStatus IN('CO','CL') AND IsSOTrx='Y'");
if (p_AD_Org_ID != 0)
sql += " AND AD_Org_ID=?";
sql.append(" AND AD_Org_ID=?");
if (p_C_BPartner_ID != 0)
sql += " AND C_BPartner_ID=?";
sql.append(" AND C_BPartner_ID=?");
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 "
+ "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 "
+ "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";
sql.append(" AND EXISTS (SELECT * FROM C_OrderLine ol ")
.append("WHERE o.C_Order_ID=ol.C_Order_ID AND ol.QtyOrdered<>ol.QtyInvoiced) ")
.append("AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType ")
.append("WHERE DocBaseType='SOO' AND DocSubTypeSO NOT IN ('ON','OB','WR')) ")
.append("ORDER BY M_Warehouse_ID, PriorityRule, C_BPartner_ID, Bill_Location_ID, C_Order_ID");
}
// sql += " FOR UPDATE";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
int index = 1;
if (p_Selection)
{
@ -178,7 +178,7 @@ public class InvoiceGenerate extends SvrProcess
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
log.log(Level.SEVERE, sql.toString(), e);
}
return generate(pstmt);
} // doIt
@ -197,7 +197,8 @@ public class InvoiceGenerate extends SvrProcess
while (rs.next ())
{
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
if (!p_ConsolidateDocument
@ -337,7 +338,8 @@ public class InvoiceGenerate extends SvrProcess
pstmt = null;
}
completeInvoice();
return "@Created@ = " + m_created;
StringBuilder msgreturn = new StringBuilder("@Created@ = ").append(m_created);
return msgreturn.toString();
} // generate
@ -400,14 +402,14 @@ public class InvoiceGenerate extends SvrProcess
AD_Language = Language.getBaseAD_Language();
java.text.SimpleDateFormat format = DisplayType.getDateFormat
(DisplayType.Date, Language.getLanguage(AD_Language));
String reference = dt.getPrintName(m_bp.getAD_Language())
+ ": " + ship.getDocumentNo()
+ " - " + format.format(ship.getMovementDate());
StringBuilder reference = new StringBuilder(dt.getPrintName(m_bp.getAD_Language()))
.append(": ").append(ship.getDocumentNo())
.append(" - ").append(format.format(ship.getMovementDate()));
m_ship = ship;
//
MInvoiceLine line = new MInvoiceLine (m_invoice);
line.setIsDescription(true);
line.setDescription(reference);
line.setDescription(reference.toString());
line.setLine(m_line + sLine.getLine() - 2);
if (!line.save())
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());
// Delete - just to be sure
String sql = "DELETE T_InvoiceGL WHERE AD_PInstance_ID=" + getAD_PInstance_ID();
int no = DB.executeUpdate(sql, get_TrxName());
StringBuilder sql = new StringBuilder("DELETE T_InvoiceGL WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());
int no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no > 0)
log.info("Deleted #" + no);
// Insert Trx
String dateStr = DB.TO_DATE(p_DateReval, true);
sql = "INSERT INTO T_InvoiceGL (AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,"
+ " AD_PInstance_ID, C_Invoice_ID, GrandTotal, OpenAmt, "
+ " Fact_Acct_ID, AmtSourceBalance, AmtAcctBalance, "
+ " AmtRevalDr, AmtRevalCr, C_DocTypeReval_ID, IsAllCurrencies, "
+ " DateReval, C_ConversionTypeReval_ID, AmtRevalDrDiff, AmtRevalCrDiff, APAR) "
sql = new StringBuilder("INSERT INTO T_InvoiceGL (AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,")
.append(" AD_PInstance_ID, C_Invoice_ID, GrandTotal, OpenAmt, ")
.append(" Fact_Acct_ID, AmtSourceBalance, AmtAcctBalance, ")
.append(" AmtRevalDr, AmtRevalCr, C_DocTypeReval_ID, IsAllCurrencies, ")
.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,"
+ getAD_PInstance_ID() + ", 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("SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy,")
.append( getAD_PInstance_ID()).append(", i.C_Invoice_ID, i.GrandTotal, invoiceOpen(i.C_Invoice_ID, 0), ")
.append(" fa.Fact_Acct_ID, fa.AmtSourceDr-fa.AmtSourceCr, fa.AmtAcctDr-fa.AmtAcctCr, ")
// 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),"
+ " currencyConvert(fa.AmtSourceCr, i.C_Currency_ID, a.C_Currency_ID, " + dateStr + ", " + p_C_ConversionTypeReval_ID + ", i.AD_Client_ID, i.AD_Org_ID),"
+ (p_C_DocTypeReval_ID==0 ? "NULL" : String.valueOf(p_C_DocTypeReval_ID)) + ", "
+ (p_IsAllCurrencies ? "'Y'," : "'N',")
+ dateStr + ", " + p_C_ConversionTypeReval_ID + ", 0, 0, '" + p_APAR + "' "
.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),")
.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),")
.append((p_C_DocTypeReval_ID==0 ? "NULL" : String.valueOf(p_C_DocTypeReval_ID))).append(", ")
.append((p_IsAllCurrencies ? "'Y'," : "'N',"))
.append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", 0, 0, '").append(p_APAR).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"
+ " AND (i.GrandTotal=fa.AmtSourceDr OR i.GrandTotal=fa.AmtSourceCr))"
+ " INNER JOIN C_AcctSchema a ON (fa.C_AcctSchema_ID=a.C_AcctSchema_ID) "
+ "WHERE i.IsPaid='N'"
+ " AND EXISTS (SELECT * FROM C_ElementValue ev "
+ "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("FROM C_Invoice_v i")
.append(" INNER JOIN Fact_Acct fa ON (fa.AD_Table_ID=318 AND fa.Record_ID=i.C_Invoice_ID")
.append(" AND (i.GrandTotal=fa.AmtSourceDr OR i.GrandTotal=fa.AmtSourceCr))")
.append(" INNER JOIN C_AcctSchema a ON (fa.C_AcctSchema_ID=a.C_AcctSchema_ID) ")
.append("WHERE i.IsPaid='N'")
.append(" AND EXISTS (SELECT * FROM C_ElementValue ev ")
.append("WHERE ev.C_ElementValue_ID=fa.Account_ID AND (ev.AccountType='A' OR ev.AccountType='L'))")
.append(" AND fa.C_AcctSchema_ID=").append(p_C_AcctSchema_ID);
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))
sql += " AND i.IsSOTrx='Y'";
sql.append(" AND i.IsSOTrx='Y'");
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)
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)
log.info("Inserted #" + no);
else if (CLogMgt.isLevelFiner())
@ -166,35 +166,35 @@ public class InvoiceNGL extends SvrProcess
log.warning("Inserted #" + no);
// Calculate Difference
sql = "UPDATE T_InvoiceGL gl "
+ "SET (AmtRevalDrDiff,AmtRevalCrDiff)="
+ "(SELECT gl.AmtRevalDr-fa.AmtAcctDr, gl.AmtRevalCr-fa.AmtAcctCr "
+ "FROM Fact_Acct fa "
+ "WHERE gl.Fact_Acct_ID=fa.Fact_Acct_ID) "
+ "WHERE AD_PInstance_ID=" + getAD_PInstance_ID();
int noT = DB.executeUpdate(sql, get_TrxName());
sql = new StringBuilder("UPDATE T_InvoiceGL gl ")
.append("SET (AmtRevalDrDiff,AmtRevalCrDiff)=")
.append("(SELECT gl.AmtRevalDr-fa.AmtAcctDr, gl.AmtRevalCr-fa.AmtAcctCr ")
.append("FROM Fact_Acct fa ")
.append("WHERE gl.Fact_Acct_ID=fa.Fact_Acct_ID) ")
.append("WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());
int noT = DB.executeUpdate(sql.toString(), get_TrxName());
if (noT > 0)
log.config("Difference #" + noT);
// Percentage
sql = "UPDATE T_InvoiceGL SET Percent = 100 "
+ "WHERE GrandTotal=OpenAmt AND AD_PInstance_ID=" + getAD_PInstance_ID();
no = DB.executeUpdate(sql, get_TrxName());
sql = new StringBuilder("UPDATE T_InvoiceGL SET Percent = 100 ")
.append("WHERE GrandTotal=OpenAmt AND AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no > 0)
log.info("Not Paid #" + no);
sql = "UPDATE T_InvoiceGL SET Percent = ROUND(OpenAmt*100/GrandTotal,6) "
+ "WHERE GrandTotal<>OpenAmt AND GrandTotal <> 0 AND AD_PInstance_ID=" + getAD_PInstance_ID();
no = DB.executeUpdate(sql, get_TrxName());
sql = new StringBuilder("UPDATE T_InvoiceGL SET Percent = ROUND(OpenAmt*100/GrandTotal,6) ")
.append("WHERE GrandTotal<>OpenAmt AND GrandTotal <> 0 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no > 0)
log.info("Partial Paid #" + no);
sql = "UPDATE T_InvoiceGL SET AmtRevalDr = AmtRevalDr * Percent/100,"
+ " AmtRevalCr = AmtRevalCr * Percent/100,"
+ " AmtRevalDrDiff = AmtRevalDrDiff * Percent/100,"
+ " AmtRevalCrDiff = AmtRevalCrDiff * Percent/100 "
+ "WHERE Percent <> 100 AND AD_PInstance_ID=" + getAD_PInstance_ID();
no = DB.executeUpdate(sql, get_TrxName());
sql = new StringBuilder("UPDATE T_InvoiceGL SET AmtRevalDr = AmtRevalDr * Percent/100,")
.append(" AmtRevalCr = AmtRevalCr * Percent/100,")
.append(" AmtRevalDrDiff = AmtRevalDrDiff * Percent/100,")
.append(" AmtRevalCrDiff = AmtRevalCrDiff * Percent/100 ")
.append("WHERE Percent <> 100 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no > 0)
log.config("Partial Calc #" + no);
@ -206,8 +206,9 @@ public class InvoiceNGL extends SvrProcess
log.warning("Can create Journal only for all currencies");
else
info = createGLJournal();
}
return "#" + noT + info;
}
StringBuilder msgreturn = new StringBuilder("#").append(noT).append(info);
return msgreturn.toString();
} // doIt
/**
@ -302,8 +303,9 @@ public class InvoiceNGL extends SvrProcess
}
}
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
/**

View File

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

View File

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

View File

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

View File

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

View File

@ -91,7 +91,7 @@ public class M_PriceList_Create extends SvrProcess {
int totd = 0;
int V_temp;
int v_NextNo = 0;
String Message = " ";
StringBuilder Message = new StringBuilder();
//
//Checking Prerequisites
//PO Prices must exists
@ -225,7 +225,7 @@ public class M_PriceList_Create extends SvrProcess {
if (cntd == -1)
raiseError(" DELETE M_ProductPrice ", sqldel.toString());
totd += cntd;
Message = "@Deleted@=" + cntd + " - ";
Message = new StringBuilder("@Deleted@=").append(cntd).append(" - ");
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
@ -393,7 +393,7 @@ public class M_PriceList_Create extends SvrProcess {
if (cntd == -1)
raiseError(" DELETE M_ProductPrice ", sqldel.toString());
totd += cntd;
Message = Message + ", @Deleted@=" + cntd;
Message.append(", @Deleted@=").append(cntd);
log.fine("Deleted " + cntd);
}
@ -564,7 +564,7 @@ public class M_PriceList_Create extends SvrProcess {
log.fine("Inserted " + cnti);
}
Message = Message + ", @Inserted@=" + cnti;
Message.append(", @Inserted@=").append(cnti);
//
// Calculation
//
@ -656,7 +656,7 @@ public class M_PriceList_Create extends SvrProcess {
totu += cntu;
log.fine("Updated " + cntu);
Message = Message + ", @Updated@=" + cntu;
Message.append(", @Updated@=").append(cntu);
//
//Fixed Price overwrite
//
@ -683,8 +683,8 @@ public class M_PriceList_Create extends SvrProcess {
log.fine("Updated " + cntu);
v_NextNo = v_NextNo + 1;
addLog(0, null, null, Message);
Message = "";
addLog(0, null, null, Message.toString());
Message = new StringBuilder();
}
dl.close();
Cur_DiscountLine.close();
@ -718,12 +718,12 @@ public class M_PriceList_Create extends SvrProcess {
private void raiseError(String string, String sql) throws Exception {
// DB.rollback(false, get_TrxName());
String msg = string;
StringBuilder msg = new StringBuilder(string);
ValueNamePair pp = CLogger.retrieveError();
if (pp != null)
msg = pp.getName() + " - ";
msg += sql;
throw new AdempiereUserError(msg);
msg = new StringBuilder(pp.getName()).append(" - ");
msg.append(sql);
throw new AdempiereUserError(msg.toString());
}
/**
@ -735,7 +735,7 @@ public class M_PriceList_Create extends SvrProcess {
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
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";
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
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)));
}
retString += getSubCategoriesString(productCategoryId, categories, subTreeRootParentId);
retString.append(getSubCategoriesString(productCategoryId, categories, subTreeRootParentId));
rs.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
{
StringBuffer sql1 = null;
StringBuilder sql1 = null;
int no = 0;
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
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());
sql1 = new StringBuffer("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) VALUES ("
+ m_AD_PInstance_ID
+ ", 0, "
+ p_Record_ID + ")");
sql1 = new StringBuilder("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) VALUES (")
.append(m_AD_PInstance_ID)
.append(", 0, ")
.append(p_Record_ID).append(")");
no = DB.executeUpdate(sql1.toString(), get_TrxName());
// 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());
sql1 = new StringBuffer("INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) VALUES ("
+ m_AD_PInstance_ID
+ ", "
+ p_Record_ID + ")");
sql1 = new StringBuilder("INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) VALUES (")
.append(m_AD_PInstance_ID)
.append(", ")
.append(p_Record_ID).append(")");
no = DB.executeUpdate(sql1.toString(), get_TrxName());
while (true) {
@ -112,8 +112,8 @@ public class M_Product_BOM_Check extends SvrProcess
int countno = 0;
try
{
PreparedStatement pstmt = DB.prepareStatement
("SELECT COUNT(*) FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID, get_TrxName());
StringBuilder dbpst = new StringBuilder("SELECT COUNT(*) FROM T_Selection WHERE AD_PInstance_ID=").append(m_AD_PInstance_ID);
PreparedStatement pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
if (rs.next())
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
// Insert BOM Nodes into "All" table
sql1 = new StringBuffer("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 "
sql1 = new StringBuilder("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) ")
.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 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 * FROM PP_Product_BOM b WHERE p.M_Product_ID=b.M_Product_ID AND b.M_Product_ID IN ")
.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());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
// 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());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
sql1 = new StringBuffer("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 "
sql1 = new StringBuilder("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) ")
.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 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 * FROM PP_Product_BOM b WHERE p.M_Product_ID=b.M_Product_ID AND b.M_Product_ID IN ")
.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());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
// 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());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
sql1 = new StringBuffer("INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) "
+ "SELECT " + m_AD_PInstance_ID + ", T_Selection_ID "
+ "FROM T_Selection2 WHERE Query_ID = 1 AND AD_PInstance_ID="+ m_AD_PInstance_ID);
sql1 = new StringBuilder("INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) ")
.append("SELECT ").append(m_AD_PInstance_ID).append(", T_Selection_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());
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 {
DB.rollback(false, get_TrxName());
String msg = string;
StringBuilder msg = new StringBuilder(string);
ValueNamePair pp = CLogger.retrieveError();
if (pp != null)
msg = pp.getName() + " - ";
msg += sql;
throw new AdempiereUserError (msg);
msg = new StringBuilder(pp.getName()).append(" - ");
msg.append(sql);
throw new AdempiereUserError (msg.toString());
}
} // 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 {
String msg = string;
StringBuilder msg = new StringBuilder(string);
ValueNamePair pp = CLogger.retrieveError();
if (pp != null)
msg = pp.getName() + " - ";
msg += sql;
throw new AdempiereUserError (msg);
msg = new StringBuilder(pp.getName()).append(" - ");
msg.append(sql);
throw new AdempiereUserError (msg.toString());
}
} // M_Production_Run

View File

@ -66,14 +66,15 @@ public class NoteDelete extends SvrProcess
{
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)
sql += " AND AD_User_ID=" + p_AD_User_ID;
sql.append(" AND AD_User_ID=").append(p_AD_User_ID);
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());
return "@Deleted@ = " + no;
int no = DB.executeUpdate(sql.toString(), get_TrxName());
StringBuilder msgreturn = new StringBuilder("@Deleted@ = ").append(no);
return msgreturn.toString();
} // doIt
} // NoteDelete

View File

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

View File

@ -131,7 +131,8 @@ public class OrderLineCreateProduction extends SvrProcess
production.setIsCreated("Y");
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

View File

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

View File

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

View File

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

View File

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

View File

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