Merge bug fixes from release to trunk

merge 12009, 12011, 12014, 12015

Revision: 12009
Fix [2927581] Financial Report parameter does not display in Report
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2927581

Revision: 12011
Fix [2926732] Query.setParameters has wrong argument type - thanks to Tobi
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2926732

Revision: 12014
Fix [2927102] Big Decimal exception calling setScale()
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2927102

Revision: 12015
Fix [2920052] print format Cache Image
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2920052

Regards,
Tony
This commit is contained in:
tspc 2010-04-15 08:38:52 +00:00
parent b2701b39b7
commit eb2dd63503
13 changed files with 34 additions and 47 deletions

View File

@ -132,8 +132,8 @@
<classpathentry exported="true" kind="lib" path="posterita/posterita/web/WEB-INF/lib/log4j-1.2.13.jar"/> <classpathentry exported="true" kind="lib" path="posterita/posterita/web/WEB-INF/lib/log4j-1.2.13.jar"/>
<classpathentry exported="true" kind="lib" path="posterita/posterita/web/WEB-INF/lib/poi-3.0-FINAL.jar"/> <classpathentry exported="true" kind="lib" path="posterita/posterita/web/WEB-INF/lib/poi-3.0-FINAL.jar"/>
<classpathentry exported="true" kind="lib" path="posterita/posterita/web/WEB-INF/lib/servlet.jar"/> <classpathentry exported="true" kind="lib" path="posterita/posterita/web/WEB-INF/lib/servlet.jar"/>
<classpathentry exported="true" kind="lib" path="packages/liberoHR.jar"/> <classpathentry exported="true" kind="lib" path="packages/liberoHR.jar" sourcepath="/adempiereLiberoHR"/>
<classpathentry exported="true" kind="lib" path="packages/liberoMFG.jar"/> <classpathentry exported="true" kind="lib" path="packages/liberoMFG.jar" sourcepath="/adempiereLibero"/>
<classpathentry exported="true" kind="lib" path="tools/lib/iText-2.1.7.jar"/> <classpathentry exported="true" kind="lib" path="tools/lib/iText-2.1.7.jar"/>
<classpathentry exported="true" kind="lib" path="tools/lib/miglayout-3.7.1-swing.jar"/> <classpathentry exported="true" kind="lib" path="tools/lib/miglayout-3.7.1-swing.jar"/>
<classpathentry exported="true" kind="lib" path="tools/lib/payflow.jar"/> <classpathentry exported="true" kind="lib" path="tools/lib/payflow.jar"/>

View File

@ -106,7 +106,7 @@ public class AssetSplit extends SvrProcess
v_ManDep_Org =v_ManDep_Org.subtract(v_ManDep_New); v_ManDep_Org =v_ManDep_Org.subtract(v_ManDep_New);
} }
else if (AssetSplit.getA_Split_Type().compareTo("QTY")==0) { else if (AssetSplit.getA_Split_Type().compareTo("QTY")==0) {
v_multiplier_New = AssetSplit.getA_QTY_Split().setScale(5).divide(v_QTY_Org.setScale(5), 0); v_multiplier_New = AssetSplit.getA_QTY_Split().setScale(5, BigDecimal.ROUND_HALF_UP).divide(v_QTY_Org.setScale(5, BigDecimal.ROUND_HALF_UP), 0);
v_AccumBalance_New = v_AccumBalance_Org .multiply(v_multiplier_New); v_AccumBalance_New = v_AccumBalance_Org .multiply(v_multiplier_New);
v_CostBalance_New = v_CostBalance_Org .multiply(v_multiplier_New); v_CostBalance_New = v_CostBalance_Org .multiply(v_multiplier_New);
v_QTY_New = AssetSplit.getA_QTY_Split(); v_QTY_New = AssetSplit.getA_QTY_Split();
@ -119,7 +119,7 @@ public class AssetSplit extends SvrProcess
v_ManDep_Org =v_ManDep_Org.subtract(v_ManDep_New); v_ManDep_Org =v_ManDep_Org.subtract(v_ManDep_New);
} }
else if (AssetSplit.getA_Split_Type().compareTo("AMT")==0) { else if (AssetSplit.getA_Split_Type().compareTo("AMT")==0) {
v_multiplier_New = AssetSplit.getA_Amount_Split().setScale(5).divide(v_CostBalance_Org.setScale(5), 0); v_multiplier_New = AssetSplit.getA_Amount_Split().setScale(5, BigDecimal.ROUND_HALF_UP).divide(v_CostBalance_Org.setScale(5, BigDecimal.ROUND_HALF_UP), 0);
v_AccumBalance_New = v_AccumBalance_Org .multiply(v_multiplier_New); v_AccumBalance_New = v_AccumBalance_Org .multiply(v_multiplier_New);
v_CostBalance_New = AssetSplit.getA_Amount_Split(); v_CostBalance_New = AssetSplit.getA_Amount_Split();
v_QTY_New = v_QTY_Org .multiply(v_multiplier_New); v_QTY_New = v_QTY_Org .multiply(v_multiplier_New);

View File

@ -864,7 +864,7 @@ public class MCost extends X_M_Cost
BigDecimal averageCurrent = oldStockQty.multiply(oldAverageAmt); BigDecimal averageCurrent = oldStockQty.multiply(oldAverageAmt);
BigDecimal averageIncrease = matchQty.multiply(cost); BigDecimal averageIncrease = matchQty.multiply(cost);
BigDecimal newAmt = averageCurrent.add(averageIncrease); BigDecimal newAmt = averageCurrent.add(averageIncrease);
newAmt = newAmt.setScale(as.getCostingPrecision()); newAmt = newAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty
+ ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt); + ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt);
@ -960,7 +960,7 @@ public class MCost extends X_M_Cost
BigDecimal averageCurrent = oldStockQty.multiply(oldAverageAmt); BigDecimal averageCurrent = oldStockQty.multiply(oldAverageAmt);
BigDecimal averageIncrease = matchQty.multiply(cost); BigDecimal averageIncrease = matchQty.multiply(cost);
BigDecimal newAmt = averageCurrent.add(averageIncrease); BigDecimal newAmt = averageCurrent.add(averageIncrease);
newAmt = newAmt.setScale(as.getCostingPrecision()); newAmt = newAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty
+ ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt); + ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt);

View File

@ -65,6 +65,7 @@ public class MQuery implements Serializable
isTemporaryTable = true; isTemporaryTable = true;
table = MTable.get(ctx, TableName); table = MTable.get(ctx, TableName);
} }
boolean isFinancialReport = ("T_Report".equals(TableName) || "T_ReportStatement".equals(TableName));
query.m_AD_PInstance_ID = AD_PInstance_ID; query.m_AD_PInstance_ID = AD_PInstance_ID;
// How many rows do we have? // How many rows do we have?
@ -144,7 +145,7 @@ public class MQuery implements Serializable
// //
// Check if the parameter exists as column in our table. // Check if the parameter exists as column in our table.
// This condition applies only to temporary tables - teo_sarca [ 2860022 ] // This condition applies only to temporary tables - teo_sarca [ 2860022 ]
if(isTemporaryTable && table != null && table.getColumn(ParameterName) == null) if (isTemporaryTable && !isFinancialReport && table != null && table.getColumn(ParameterName) == null)
{ {
s_log.info("Skip parameter "+ParameterName+" because there is no column in table "+TableName); s_log.info("Skip parameter "+ParameterName+" because there is no column in table "+TableName);
continue; continue;

View File

@ -25,7 +25,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -138,7 +137,7 @@ public class Query
* Set query parameters * Set query parameters
* @param parameters collection of parameters * @param parameters collection of parameters
*/ */
public Query setParameters(Collection<Object> parameters) public Query setParameters(List<Object> parameters)
{ {
if (parameters == null) { if (parameters == null) {
this.parameters = null; this.parameters = null;

View File

@ -141,7 +141,7 @@ public class ImageElement extends PrintElement
URL imageURL = getURL(imageURLstring); URL imageURL = getURL(imageURLstring);
if (imageURL != null) if (imageURL != null)
{ {
m_image = Toolkit.getDefaultToolkit().getImage(imageURL); m_image = Toolkit.getDefaultToolkit().createImage(imageURL);
if (m_image != null) if (m_image != null)
log.fine("URL=" + imageURL); log.fine("URL=" + imageURL);
else else
@ -159,7 +159,7 @@ public class ImageElement extends PrintElement
{ {
if (imageURL != null) if (imageURL != null)
{ {
m_image = Toolkit.getDefaultToolkit().getImage(imageURL); m_image = Toolkit.getDefaultToolkit().createImage(imageURL);
if (m_image != null) if (m_image != null)
log.fine("URL=" + imageURL); log.fine("URL=" + imageURL);
else else

View File

@ -1281,7 +1281,7 @@ public final class DB
* @return first value or -1 * @return first value or -1
* @throws DBException if there is any SQLException * @throws DBException if there is any SQLException
*/ */
public static int getSQLValueEx (String trxName, String sql, Collection<Object> params) public static int getSQLValueEx (String trxName, String sql, List<Object> params)
{ {
return getSQLValueEx(trxName, sql, params.toArray(new Object[params.size()])); return getSQLValueEx(trxName, sql, params.toArray(new Object[params.size()]));
} }
@ -1314,7 +1314,7 @@ public final class DB
* @param params collection of parameters * @param params collection of parameters
* @return first value or null * @return first value or null
*/ */
public static int getSQLValue (String trxName, String sql, Collection<Object> params) public static int getSQLValue (String trxName, String sql, List<Object> params)
{ {
return getSQLValue(trxName, sql, params.toArray(new Object[params.size()])); return getSQLValue(trxName, sql, params.toArray(new Object[params.size()]));
} }
@ -1362,7 +1362,7 @@ public final class DB
* @return first value or null * @return first value or null
* @throws DBException if there is any SQLException * @throws DBException if there is any SQLException
*/ */
public static String getSQLValueStringEx (String trxName, String sql, Collection<Object> params) public static String getSQLValueStringEx (String trxName, String sql, List<Object> params)
{ {
return getSQLValueStringEx(trxName, sql, params.toArray(new Object[params.size()])); return getSQLValueStringEx(trxName, sql, params.toArray(new Object[params.size()]));
} }
@ -1395,7 +1395,7 @@ public final class DB
* @param params collection of parameters * @param params collection of parameters
* @return first value or null * @return first value or null
*/ */
public static String getSQLValueString (String trxName, String sql, Collection<Object> params) public static String getSQLValueString (String trxName, String sql, List<Object> params)
{ {
return getSQLValueString(trxName, sql, params.toArray(new Object[params.size()])); return getSQLValueString(trxName, sql, params.toArray(new Object[params.size()]));
} }
@ -1444,7 +1444,7 @@ public final class DB
* @return first value or null if not found * @return first value or null if not found
* @throws DBException if there is any SQLException * @throws DBException if there is any SQLException
*/ */
public static BigDecimal getSQLValueBDEx (String trxName, String sql, Collection<Object> params) throws DBException public static BigDecimal getSQLValueBDEx (String trxName, String sql, List<Object> params) throws DBException
{ {
return getSQLValueBDEx(trxName, sql, params.toArray(new Object[params.size()])); return getSQLValueBDEx(trxName, sql, params.toArray(new Object[params.size()]));
} }
@ -1478,7 +1478,7 @@ public final class DB
* @param params collection of parameters * @param params collection of parameters
* @return first value or null * @return first value or null
*/ */
public static BigDecimal getSQLValueBD (String trxName, String sql, Collection<Object> params) public static BigDecimal getSQLValueBD (String trxName, String sql, List<Object> params)
{ {
return getSQLValueBD(trxName, sql, params.toArray(new Object[params.size()])); return getSQLValueBD(trxName, sql, params.toArray(new Object[params.size()]));
} }
@ -1526,7 +1526,7 @@ public final class DB
* @return first value or null if not found * @return first value or null if not found
* @throws DBException if there is any SQLException * @throws DBException if there is any SQLException
*/ */
public static Timestamp getSQLValueTSEx (String trxName, String sql, Collection<Object> params) throws DBException public static Timestamp getSQLValueTSEx (String trxName, String sql, List<Object> params) throws DBException
{ {
return getSQLValueTSEx(trxName, sql, params.toArray(new Object[params.size()])); return getSQLValueTSEx(trxName, sql, params.toArray(new Object[params.size()]));
} }
@ -1558,7 +1558,7 @@ public final class DB
* @param params collection of parameters * @param params collection of parameters
* @return first value or null * @return first value or null
*/ */
public static Timestamp getSQLValueTS (String trxName, String sql, Collection<Object> params) public static Timestamp getSQLValueTS (String trxName, String sql, List<Object> params)
{ {
Object[] arr = new Object[params.size()]; Object[] arr = new Object[params.size()];
params.toArray(arr); params.toArray(arr);
@ -1577,19 +1577,6 @@ public final class DB
return getKeyNamePairs(sql, optional, (Object[])null); return getKeyNamePairs(sql, optional, (Object[])null);
} }
/**
* Get Array of Key Name Pairs
* @param sql select with id / name as first / second column
* @param optional if true (-1,"") is added
* @param params query parameters
* @return array of {@link KeyNamePair}
* @see #getKeyNamePairs(String, boolean, Object...)
*/
public static KeyNamePair[] getKeyNamePairs(String sql, boolean optional, Collection<Object> params)
{
return getKeyNamePairs(sql, optional, params.toArray(new Object[params.size()]));
}
/** /**
* Get Array of Key Name Pairs * Get Array of Key Name Pairs
* @param sql select with id / name as first / second column * @param sql select with id / name as first / second column

View File

@ -43,12 +43,12 @@ public class MStorageTest extends AdempiereTestCase
loc.setXYZ("X"+locatorValue, "Y"+locatorValue, "Z"+locatorValue); loc.setXYZ("X"+locatorValue, "Y"+locatorValue, "Z"+locatorValue);
loc.saveEx(); loc.saveEx();
// //
BigDecimal targetQty = BigDecimal.valueOf(qtyOnHand).setScale(12); BigDecimal targetQty = BigDecimal.valueOf(qtyOnHand).setScale(12, BigDecimal.ROUND_HALF_UP);
MStorage s1 = MStorage.getCreate(getCtx(), loc.get_ID(), product_id, 0, getTrxName()); MStorage s1 = MStorage.getCreate(getCtx(), loc.get_ID(), product_id, 0, getTrxName());
s1.setQtyOnHand(targetQty); s1.setQtyOnHand(targetQty);
s1.saveEx(); s1.saveEx();
// //
BigDecimal qty = MStorage.getQtyAvailable(wh.get_ID(), loc.get_ID(), product_id, 0, getTrxName()).setScale(12); BigDecimal qty = MStorage.getQtyAvailable(wh.get_ID(), loc.get_ID(), product_id, 0, getTrxName()).setScale(12, BigDecimal.ROUND_HALF_UP);
assertEquals("Error on locator "+locatorValue, targetQty, qty); assertEquals("Error on locator "+locatorValue, targetQty, qty);
// //
return loc; return loc;
@ -56,8 +56,8 @@ public class MStorageTest extends AdempiereTestCase
private void assertWarehouseQty(MWarehouse wh, BigDecimal targetQty) private void assertWarehouseQty(MWarehouse wh, BigDecimal targetQty)
{ {
BigDecimal qty = MStorage.getQtyAvailable(wh.get_ID(), 0, product_id, 0, getTrxName()); BigDecimal qty = MStorage.getQtyAvailable(wh.get_ID(), 0, product_id, 0, getTrxName());
qty = qty.setScale(12); qty = qty.setScale(12, BigDecimal.ROUND_HALF_UP);
targetQty = targetQty.setScale(12); targetQty = targetQty.setScale(12, BigDecimal.ROUND_HALF_UP);
assertEquals(targetQty, qty); assertEquals(targetQty, qty);
} }

View File

@ -715,7 +715,7 @@ public class POSManager
} }
orderLineBean.setLineTotalAmt(lineTotalAmount); orderLineBean.setLineTotalAmt(lineTotalAmount);
orderLineBean.setUnitPrice(line.getPriceList().setScale(2)); orderLineBean.setUnitPrice(line.getPriceList().setScale(2, BigDecimal.ROUND_HALF_UP));
orderLineBean.setPriceActual(line.getPriceActual()); orderLineBean.setPriceActual(line.getPriceActual());
orderLineBean.setProductId(Integer.valueOf(line.getM_Product_ID())); orderLineBean.setProductId(Integer.valueOf(line.getM_Product_ID()));
orderLineBean.setUom(product.getUOMSymbol()); orderLineBean.setUom(product.getUOMSymbol());
@ -843,7 +843,7 @@ public class POSManager
{ {
totalGrossProfitPercentage = Env.ZERO; totalGrossProfitPercentage = Env.ZERO;
} }
orderLineBean.setTotalGrossProfitPercentage(totalGrossProfitPercentage.setScale(2)); orderLineBean.setTotalGrossProfitPercentage(totalGrossProfitPercentage.setScale(2, BigDecimal.ROUND_HALF_UP));
} }
orderLineBean.setDiscountAmt(discountAmt); orderLineBean.setDiscountAmt(discountAmt);
@ -2686,14 +2686,14 @@ public class POSManager
throw new OperationException("DISCOUNT ERROR!! CANNOT PROCESS YOUR REQUEST!!!"); throw new OperationException("DISCOUNT ERROR!! CANNOT PROCESS YOUR REQUEST!!!");
} }
bean.setInclPrice(price.setScale(2)); bean.setInclPrice(price.setScale(2, BigDecimal.ROUND_HALF_UP));
BigDecimal incPriceExcVat = ((price.multiply(qty)).subtract(newTaxAmt)).divide(qty, 2, BigDecimal.ROUND_HALF_UP); BigDecimal incPriceExcVat = ((price.multiply(qty)).subtract(newTaxAmt)).divide(qty, 2, BigDecimal.ROUND_HALF_UP);
bean.setDiscountedLinePrice(incPriceExcVat.setScale(2)); bean.setDiscountedLinePrice(incPriceExcVat.setScale(2, BigDecimal.ROUND_HALF_UP));
bean.setDiscountedInclUnitPrice(incPriceExcVat); bean.setDiscountedInclUnitPrice(incPriceExcVat);
bean.setUnitPrice(incPriceExcVat.setScale(2)); bean.setUnitPrice(incPriceExcVat.setScale(2, BigDecimal.ROUND_HALF_UP));
bean.setTaxAmt(newTaxAmt.setScale(2)); bean.setTaxAmt(newTaxAmt.setScale(2, BigDecimal.ROUND_HALF_UP));
bean.setIsDiscountOnInclUnitPrice(isDiscOnInclUnitPrices[0]); bean.setIsDiscountOnInclUnitPrice(isDiscOnInclUnitPrices[0]);
bean.setIsDiscountOnPercentage(isDiscountsOnPerc[0]); bean.setIsDiscountOnPercentage(isDiscountsOnPerc[0]);
bean.setIsDiscountOnTotal(isDiscountsOnTotal[0]); bean.setIsDiscountOnTotal(isDiscountsOnTotal[0]);

View File

@ -512,7 +512,7 @@ public class POSStockManager
String uom = product.getUOMSymbol(); String uom = product.getUOMSymbol();
bean= new AttributeBean(); bean= new AttributeBean();
bean.setProductName(rs.getString(1)); bean.setProductName(rs.getString(1));
bean.setQuantity(quantity.setScale(uomPrecision)); bean.setQuantity(quantity.setScale(uomPrecision, BigDecimal.ROUND_HALF_UP));
bean.setBarCode(rs.getString(3)); bean.setBarCode(rs.getString(3));
totalCost = quantity.multiply(price); totalCost = quantity.multiply(price);

View File

@ -453,7 +453,7 @@ public class StockManager
itemBean.setBarCode(barcode); itemBean.setBarCode(barcode);
itemBean.setPriceListId(orderLineBean.getPriceListId()); itemBean.setPriceListId(orderLineBean.getPriceListId());
itemBean.setDescription(description); itemBean.setDescription(description);
itemBean.setQty(orderLineBean.getQuantity().setScale(uomPrecision)); itemBean.setQty(orderLineBean.getQuantity().setScale(uomPrecision, BigDecimal.ROUND_HALF_UP));
itemBean.setIsDiscountOnInclUnitPrice(false); itemBean.setIsDiscountOnInclUnitPrice(false);
itemBean.setIsDiscountOnPercentage(false); itemBean.setIsDiscountOnPercentage(false);
itemBean.setIsDiscountOnTotal(false); itemBean.setIsDiscountOnTotal(false);
@ -1058,7 +1058,7 @@ public class StockManager
itemBean.setBarCode(barcode); itemBean.setBarCode(barcode);
itemBean.setPriceListId(bean.getPriceListId()); itemBean.setPriceListId(bean.getPriceListId());
itemBean.setDescription(description); itemBean.setDescription(description);
itemBean.setQtyCount((bean.getQtyCount().setScale(uomPrecision))); itemBean.setQtyCount((bean.getQtyCount().setScale(uomPrecision, BigDecimal.ROUND_HALF_UP)));
itemBean.setQtyBook(pBean.getQtyOnHand()); itemBean.setQtyBook(pBean.getQtyOnHand());
itemBean.setQtyCsv(bean.getQtyCsv()); itemBean.setQtyCsv(bean.getQtyCsv());

View File

@ -602,7 +602,7 @@ public class Product
// Get Rounding Precision // Get Rounding Precision
int StdPrecision = getUOMPrecision(M_ProductBOM_ID); int StdPrecision = getUOMPrecision(M_ProductBOM_ID);
// How much can we make with this product // How much can we make with this product
productQuantity = productQuantity.setScale(StdPrecision) productQuantity = productQuantity.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP)
.divide(bomQty, BigDecimal.ROUND_HALF_UP); .divide(bomQty, BigDecimal.ROUND_HALF_UP);
// How much can we make overall // How much can we make overall
if (productQuantity.compareTo(quantity) < 0) if (productQuantity.compareTo(quantity) < 0)

View File

@ -794,7 +794,7 @@ public class WPAttributeDialog extends Window implements EventListener
mandatory += " - " + attributes[i].getName(); mandatory += " - " + attributes[i].getName();
//setMAttributeInstance doesn't work without decimal point //setMAttributeInstance doesn't work without decimal point
if (value != null && value.scale() == 0) if (value != null && value.scale() == 0)
value = value.setScale(1); value = value.setScale(1, BigDecimal.ROUND_HALF_UP);
attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value); attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value);
} }
else else