From e4476ec95cd6451fdc113028cfef102c71d1351e Mon Sep 17 00:00:00 2001 From: Richard Morales Date: Tue, 9 Apr 2013 15:49:25 -0500 Subject: [PATCH 1/6] IDEMPIERE-455 Discover and fix FindBugs problems / DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE --- .../org/compiere/model/CalloutInvoice.java | 2 +- .../src/org/compiere/model/CalloutOrder.java | 6 +-- .../process/SalesOrderRateInquiryProcess.java | 6 +-- org.adempiere.base/src/org/compiere/Base.java | 4 +- .../org/compiere/acct/Doc_AllocationHdr.java | 6 +-- .../org/compiere/acct/Doc_Requisition.java | 2 +- .../src/org/compiere/impexp/ImpFormatRow.java | 2 +- .../src/org/compiere/model/CalloutEngine.java | 2 +- .../org/compiere/model/MConversionRate.java | 4 +- .../src/org/compiere/model/MCost.java | 2 +- .../src/org/compiere/model/MDepreciation.java | 2 +- .../src/org/compiere/model/MGoal.java | 40 +++++++++---------- .../src/org/compiere/model/MJournalLine.java | 4 +- .../compiere/model/MLandedCostAllocation.java | 2 +- .../org/compiere/model/MProductPricing.java | 2 +- .../compiere/model/MResourceAssignment.java | 2 +- .../src/org/compiere/model/PO.java | 2 +- .../org/compiere/print/MPrintTableFormat.java | 6 +-- .../org/compiere/print/PrintDataElement.java | 2 +- .../org/compiere/print/PrintDataFunction.java | 2 +- .../org/compiere/report/core/RModelData.java | 2 +- .../src/org/compiere/util/AmtInWords_HR.java | 2 +- .../src/org/compiere/util/Env.java | 6 +-- .../src/org/compiere/util/WebUtil.java | 2 +- .../globalqss/process/GLJournalGenerate.java | 2 +- .../model/CalloutA_Depreciation_Workfile.java | 8 ++-- .../src/org/compiere/apps/AMenu.java | 4 +- .../org/compiere/apps/form/VAllocation.java | 4 +- .../compiere/apps/form/VFactReconcile.java | 2 +- .../src/org/compiere/apps/form/VMatch.java | 4 +- .../compiere/apps/search/InvoiceHistory.java | 2 +- .../src/org/compiere/grid/ed/Calculator.java | 14 +++---- .../src/org/compiere/grid/ed/MDocNumber.java | 4 +- .../src/org/compiere/grid/ed/VColor.java | 2 +- .../src/org/compiere/grid/ed/VNumber.java | 6 +-- .../webui/apps/form/WAllocation.java | 4 +- .../webui/apps/form/WFactReconcile.java | 2 +- .../org/adempiere/webui/apps/form/WMatch.java | 4 +- .../adempiere/webui/apps/graph/WGraph.java | 2 +- .../adempiere/webui/component/NumberBox.java | 2 +- .../adempiere/webui/editor/WNumberEditor.java | 2 +- .../adempiere/webui/panel/InvoiceHistory.java | 2 +- .../adempiere/webui/window/InfoSchedule.java | 4 +- .../org/compiere/apps/form/Allocation.java | 10 ++--- .../src/org/compiere/apps/form/Match.java | 2 +- .../src/org/compiere/apps/form/PaySelect.java | 4 +- 46 files changed, 101 insertions(+), 101 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java index ff97b34e6d..0f6c48b1a8 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java @@ -638,7 +638,7 @@ public class CalloutInvoice extends CalloutEngine // Repeat Discount calc if (PriceList.intValue() != 0) { - Discount = new BigDecimal ((PriceList.doubleValue () - PriceActual.doubleValue ()) / PriceList.doubleValue () * 100.0); + Discount = BigDecimal.valueOf((PriceList.doubleValue () - PriceActual.doubleValue ()) / PriceList.doubleValue () * 100.0); if (Discount.scale () > 2) Discount = Discount.setScale (2, BigDecimal.ROUND_HALF_UP); // mTab.setValue ("Discount", Discount); diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java index 39f7c9a029..241b8c4858 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -1111,7 +1111,7 @@ public class CalloutOrder extends CalloutEngine if (mField.getColumnName().equals("Discount")) { if ( PriceList.doubleValue() != 0 ) - PriceActual = new BigDecimal ((100.0 - Discount.doubleValue()) / 100.0 * PriceList.doubleValue()); + PriceActual = BigDecimal.valueOf((100.0 - Discount.doubleValue()) / 100.0 * PriceList.doubleValue()); if (PriceActual.scale() > StdPrecision) PriceActual = PriceActual.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, @@ -1127,7 +1127,7 @@ public class CalloutOrder extends CalloutEngine if (PriceList.intValue() == 0) Discount = Env.ZERO; else - Discount = new BigDecimal ((PriceList.doubleValue() - PriceActual.doubleValue()) / PriceList.doubleValue() * 100.0); + Discount = BigDecimal.valueOf((PriceList.doubleValue() - PriceActual.doubleValue()) / PriceList.doubleValue() * 100.0); if (Discount.scale() > 2) Discount = Discount.setScale(2, BigDecimal.ROUND_HALF_UP); mTab.setValue("Discount", Discount); @@ -1155,7 +1155,7 @@ public class CalloutOrder extends CalloutEngine // Repeat Discount calc if (PriceList.intValue() != 0) { - Discount = new BigDecimal ((PriceList.doubleValue () - PriceActual.doubleValue ()) / PriceList.doubleValue () * 100.0); + Discount = BigDecimal.valueOf((PriceList.doubleValue () - PriceActual.doubleValue ()) / PriceList.doubleValue () * 100.0); if (Discount.scale () > 2) Discount = Discount.setScale (2, BigDecimal.ROUND_HALF_UP); mTab.setValue ("Discount", Discount); diff --git a/org.adempiere.base/src/org/adempiere/process/SalesOrderRateInquiryProcess.java b/org.adempiere.base/src/org/adempiere/process/SalesOrderRateInquiryProcess.java index 96a976f252..e732b3964e 100644 --- a/org.adempiere.base/src/org/adempiere/process/SalesOrderRateInquiryProcess.java +++ b/org.adempiere.base/src/org/adempiere/process/SalesOrderRateInquiryProcess.java @@ -222,12 +222,12 @@ public class SalesOrderRateInquiryProcess extends SvrProcess } MShipperPackaging sp = new MShipperPackaging(ctx, M_ShipperPackaging_ID, trxName); - BigDecimal WeightPerPackage = sp.getWeight().multiply(isPound ? new BigDecimal(2.20462) : BigDecimal.ONE); + BigDecimal WeightPerPackage = sp.getWeight().multiply(isPound ? BigDecimal.valueOf(2.20462) : BigDecimal.ONE); if (WeightPerPackage == null || WeightPerPackage.compareTo(BigDecimal.ZERO) == 0) { - BigDecimal defaultWeightPerPackage = new BigDecimal(MSysConfig.getDoubleValue(MSysConfig.SHIPPING_DEFAULT_WEIGHT_PER_PACKAGE, 30)); - WeightPerPackage = defaultWeightPerPackage.multiply(isPound ? new BigDecimal(2.20462) : BigDecimal.ONE); + BigDecimal defaultWeightPerPackage = BigDecimal.valueOf(MSysConfig.getDoubleValue(MSysConfig.SHIPPING_DEFAULT_WEIGHT_PER_PACKAGE, 30)); + WeightPerPackage = defaultWeightPerPackage.multiply(isPound ? BigDecimal.valueOf(2.20462) : BigDecimal.ONE); } BigDecimal CODAmount = m_order.getGrandTotal(); diff --git a/org.adempiere.base/src/org/compiere/Base.java b/org.adempiere.base/src/org/compiere/Base.java index e0c8f41798..0b85858b11 100644 --- a/org.adempiere.base/src/org/compiere/Base.java +++ b/org.adempiere.base/src/org/compiere/Base.java @@ -97,9 +97,9 @@ class Base listThreads(); // System.out.println("API Test"); - System.out.println("64.72=" + MConversionRate.convert(ctx, new BigDecimal(100.0), 116, 100,0,0)); + System.out.println("64.72=" + MConversionRate.convert(ctx, BigDecimal.valueOf(100.0), 116, 100,0,0)); System.out.println("0.647169=" + MConversionRate.getRate(116, 100, null, 0,0,0)); - System.out.println("12.5=" + MUOMConversion.convert(101, 102, new BigDecimal(100.0), true)); + System.out.println("12.5=" + MUOMConversion.convert(101, 102, BigDecimal.valueOf(100.0), true)); } // Base diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java b/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java index f475d95b8d..278921afa8 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java @@ -594,7 +594,7 @@ public class Doc_AllocationHdr extends Doc Doc_Invoice docInvoice = (Doc_Invoice)Doc.get(as, MInvoice.Table_ID, invoice.getC_Invoice_ID(), getTrxName()); docInvoice.loadDocumentDetails(); - allocationAccounted = docInvoice.createFactCash(as, fact, new BigDecimal(percent)); + allocationAccounted = docInvoice.createFactCash(as, fact, BigDecimal.valueOf(percent)); if (log.isLoggable(Level.CONFIG)) log.config("Allocation Accounted=" + allocationAccounted); // Cash Based Commitment Release @@ -604,7 +604,7 @@ public class Doc_AllocationHdr extends Doc for (int i = 0; i < lines.length; i++) { Fact factC = Doc_Order.getCommitmentRelease(as, this, - lines[i].getQtyInvoiced(), lines[i].getC_InvoiceLine_ID(), new BigDecimal(percent)); + lines[i].getQtyInvoiced(), lines[i].getC_InvoiceLine_ID(), BigDecimal.valueOf(percent)); if (factC == null) return null; m_facts.add(factC); @@ -780,7 +780,7 @@ public class Doc_AllocationHdr extends Doc // percent of total payment double multiplier = allocationSource.doubleValue() / invoiceSource.doubleValue(); // Reduce Orig Invoice Accounted - invoiceAccounted = invoiceAccounted.multiply(new BigDecimal(multiplier)); + invoiceAccounted = invoiceAccounted.multiply(BigDecimal.valueOf(multiplier)); // Difference based on percentage of Orig Invoice acctDifference = invoiceAccounted.subtract(allocationAccounted); // gain is negative // ignore Tolerance diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_Requisition.java b/org.adempiere.base/src/org/compiere/acct/Doc_Requisition.java index 1337f51995..51bfe3d185 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_Requisition.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_Requisition.java @@ -105,7 +105,7 @@ public class Doc_Requisition extends Doc */ public BigDecimal getBalance () { - BigDecimal retValue = new BigDecimal (0.0); + BigDecimal retValue = BigDecimal.valueOf(0.0); return retValue; } // getBalance diff --git a/org.adempiere.base/src/org/compiere/impexp/ImpFormatRow.java b/org.adempiere.base/src/org/compiere/impexp/ImpFormatRow.java index 9317e2870f..eabbed49b6 100644 --- a/org.adempiere.base/src/org/compiere/impexp/ImpFormatRow.java +++ b/org.adempiere.base/src/org/compiere/impexp/ImpFormatRow.java @@ -486,7 +486,7 @@ public final class ImpFormatRow return "0"; BigDecimal bd = new BigDecimal(sb.toString()); if (m_divideBy100) // assumed two decimal scale - bd = bd.divide(new BigDecimal(100.0), 2, BigDecimal.ROUND_HALF_UP); + bd = bd.divide(BigDecimal.valueOf(100.0), 2, BigDecimal.ROUND_HALF_UP); return bd.toString(); } // parseNumber diff --git a/org.adempiere.base/src/org/compiere/model/CalloutEngine.java b/org.adempiere.base/src/org/compiere/model/CalloutEngine.java index 4feb07b283..766b26127a 100644 --- a/org.adempiere.base/src/org/compiere/model/CalloutEngine.java +++ b/org.adempiere.base/src/org/compiere/model/CalloutEngine.java @@ -250,7 +250,7 @@ public class CalloutEngine implements Callout BigDecimal rate1 = (BigDecimal)value; BigDecimal rate2 = Env.ZERO; - BigDecimal one = new BigDecimal(1.0); + BigDecimal one = BigDecimal.valueOf(1.0); if (rate1.doubleValue() != 0.0) // no divide by zero rate2 = one.divide(rate1, 12, BigDecimal.ROUND_HALF_UP); diff --git a/org.adempiere.base/src/org/compiere/model/MConversionRate.java b/org.adempiere.base/src/org/compiere/model/MConversionRate.java index 6b4d0d1120..fda74dc6b9 100644 --- a/org.adempiere.base/src/org/compiere/model/MConversionRate.java +++ b/org.adempiere.base/src/org/compiere/model/MConversionRate.java @@ -334,7 +334,7 @@ public class MConversionRate extends X_C_Conversion_Rate { super.setMultiplyRate(MultiplyRate); double dd = 1 / MultiplyRate.doubleValue(); - super.setDivideRate(new BigDecimal(dd)); + super.setDivideRate(BigDecimal.valueOf(dd)); } } // setMultiplyRate @@ -356,7 +356,7 @@ public class MConversionRate extends X_C_Conversion_Rate { super.setDivideRate(DivideRate); double dd = 1 / DivideRate.doubleValue(); - super.setMultiplyRate(new BigDecimal(dd)); + super.setMultiplyRate(BigDecimal.valueOf(dd)); } } // setDivideRate diff --git a/org.adempiere.base/src/org/compiere/model/MCost.java b/org.adempiere.base/src/org/compiere/model/MCost.java index 72ff4c727b..86c4ac84a4 100644 --- a/org.adempiere.base/src/org/compiere/model/MCost.java +++ b/org.adempiere.base/src/org/compiere/model/MCost.java @@ -1482,7 +1482,7 @@ public class MCost extends X_M_Cost //amount must follow the sign of qty if (amt.signum() != 0 && amt.signum() != qty.signum()) { - amt = amt.multiply(new BigDecimal(-1.00d)); + amt = amt.multiply(BigDecimal.valueOf(-1.00d)); } if (getCurrentQty().add(qty).signum() < 0) diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciation.java b/org.adempiere.base/src/org/compiere/model/MDepreciation.java index 5e99ed0200..d471de738d 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepreciation.java +++ b/org.adempiere.base/src/org/compiere/model/MDepreciation.java @@ -337,7 +337,7 @@ public class MDepreciation extends X_A_Depreciation BigDecimal coef_sl = BigDecimal.ONE.divide(new BigDecimal(A_Life_Year), getPrecision() + 2, RoundingMode.DOWN); /** Degressive damping coefficient for one year = one-year linear depreciation * coeficient K */ //BigDecimal coef_ad1 = coef_sl.multiply(coef_K); //commented by @win - BigDecimal coef_ad1 = coef_sl.multiply(new BigDecimal(2.0)); //added by @win + BigDecimal coef_ad1 = coef_sl.multiply(BigDecimal.valueOf(2.0)); //added by @win /** AD2 */ //~ BigDecimal DUR = BD_100.multiply( diff --git a/org.adempiere.base/src/org/compiere/model/MGoal.java b/org.adempiere.base/src/org/compiere/model/MGoal.java index 061a02bb4a..e12f40a120 100644 --- a/org.adempiere.base/src/org/compiere/model/MGoal.java +++ b/org.adempiere.base/src/org/compiere/model/MGoal.java @@ -195,57 +195,57 @@ public class MGoal extends X_PA_Goal if (MeasureScope.equals(MEASURESCOPE_Year)) { if (MeasureDisplay.equals(MEASUREDISPLAY_Quarter)) - Multiplier = new BigDecimal(1.0/4.0); + Multiplier = BigDecimal.valueOf(1.0/4.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Month)) - Multiplier = new BigDecimal(1.0/12.0); + Multiplier = BigDecimal.valueOf(1.0/12.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Week)) - Multiplier = new BigDecimal(1.0/52.0); + Multiplier = BigDecimal.valueOf(1.0/52.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Day)) - Multiplier = new BigDecimal(1.0/364.0); + Multiplier = BigDecimal.valueOf(1.0/364.0); } else if (MeasureScope.equals(MEASURESCOPE_Quarter)) { if (MeasureDisplay.equals(MEASUREDISPLAY_Year)) - Multiplier = new BigDecimal(4.0); + Multiplier = BigDecimal.valueOf(4.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Month)) - Multiplier = new BigDecimal(1.0/3.0); + Multiplier = BigDecimal.valueOf(1.0/3.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Week)) - Multiplier = new BigDecimal(1.0/13.0); + Multiplier = BigDecimal.valueOf(1.0/13.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Day)) - Multiplier = new BigDecimal(1.0/91.0); + Multiplier = BigDecimal.valueOf(1.0/91.0); } else if (MeasureScope.equals(MEASURESCOPE_Month)) { if (MeasureDisplay.equals(MEASUREDISPLAY_Year)) - Multiplier = new BigDecimal(12.0); + Multiplier = BigDecimal.valueOf(12.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Quarter)) - Multiplier = new BigDecimal(3.0); + Multiplier = BigDecimal.valueOf(3.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Week)) - Multiplier = new BigDecimal(1.0/4.0); + Multiplier = BigDecimal.valueOf(1.0/4.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Day)) - Multiplier = new BigDecimal(1.0/30.0); + Multiplier = BigDecimal.valueOf(1.0/30.0); } else if (MeasureScope.equals(MEASURESCOPE_Week)) { if (MeasureDisplay.equals(MEASUREDISPLAY_Year)) - Multiplier = new BigDecimal(52.0); + Multiplier = BigDecimal.valueOf(52.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Quarter)) - Multiplier = new BigDecimal(13.0); + Multiplier = BigDecimal.valueOf(13.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Month)) - Multiplier = new BigDecimal(4.0); + Multiplier = BigDecimal.valueOf(4.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Day)) - Multiplier = new BigDecimal(1.0/7.0); + Multiplier = BigDecimal.valueOf(1.0/7.0); } else if (MeasureScope.equals(MEASURESCOPE_Day)) { if (MeasureDisplay.equals(MEASUREDISPLAY_Year)) - Multiplier = new BigDecimal(364.0); + Multiplier = BigDecimal.valueOf(364.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Quarter)) - Multiplier = new BigDecimal(91.0); + Multiplier = BigDecimal.valueOf(91.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Month)) - Multiplier = new BigDecimal(30.0); + Multiplier = BigDecimal.valueOf(30.0); else if (MeasureDisplay.equals(MEASUREDISPLAY_Week)) - Multiplier = new BigDecimal(7.0); + Multiplier = BigDecimal.valueOf(7.0); } return Multiplier; } // getMultiplier diff --git a/org.adempiere.base/src/org/compiere/model/MJournalLine.java b/org.adempiere.base/src/org/compiere/model/MJournalLine.java index 84b7ff4b11..10352f3f92 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalLine.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalLine.java @@ -210,9 +210,9 @@ public class MJournalLine extends X_GL_JournalLine } if (rateDR != 0) - setCurrencyRate(new BigDecimal(rateDR)); + setCurrencyRate(BigDecimal.valueOf(rateDR)); if (rateCR != 0) - setCurrencyRate(new BigDecimal(rateCR)); + setCurrencyRate(BigDecimal.valueOf(rateCR)); } // setAmtAcct diff --git a/org.adempiere.base/src/org/compiere/model/MLandedCostAllocation.java b/org.adempiere.base/src/org/compiere/model/MLandedCostAllocation.java index ff4495cfa2..c882bc9f0e 100644 --- a/org.adempiere.base/src/org/compiere/model/MLandedCostAllocation.java +++ b/org.adempiere.base/src/org/compiere/model/MLandedCostAllocation.java @@ -131,7 +131,7 @@ public class MLandedCostAllocation extends X_C_LandedCostAllocation */ public void setAmt (double Amt, int precision) { - BigDecimal bd = new BigDecimal(Amt); + BigDecimal bd = BigDecimal.valueOf(Amt); if (bd.scale() > precision) bd = bd.setScale(precision, BigDecimal.ROUND_HALF_UP); super.setAmt(bd); diff --git a/org.adempiere.base/src/org/compiere/model/MProductPricing.java b/org.adempiere.base/src/org/compiere/model/MProductPricing.java index 76e8345aeb..0f740c8fac 100644 --- a/org.adempiere.base/src/org/compiere/model/MProductPricing.java +++ b/org.adempiere.base/src/org/compiere/model/MProductPricing.java @@ -799,7 +799,7 @@ public class MProductPricing { BigDecimal Discount = Env.ZERO; if (m_PriceList.intValue() != 0) - Discount = new BigDecimal ((m_PriceList.doubleValue() - m_PriceStd.doubleValue()) + Discount = BigDecimal.valueOf((m_PriceList.doubleValue() - m_PriceStd.doubleValue()) / m_PriceList.doubleValue() * 100.0); if (Discount.scale() > 2) Discount = Discount.setScale(2, BigDecimal.ROUND_HALF_UP); diff --git a/org.adempiere.base/src/org/compiere/model/MResourceAssignment.java b/org.adempiere.base/src/org/compiere/model/MResourceAssignment.java index 799b3d7f9f..0212f2f519 100644 --- a/org.adempiere.base/src/org/compiere/model/MResourceAssignment.java +++ b/org.adempiere.base/src/org/compiere/model/MResourceAssignment.java @@ -48,7 +48,7 @@ public class MResourceAssignment extends X_S_ResourceAssignment if (S_ResourceAssignment_ID == 0) { setAssignDateFrom(new Timestamp(System.currentTimeMillis())); - setQty(new BigDecimal(1.0)); + setQty(BigDecimal.valueOf(1.0)); setName("."); setIsConfirmed(false); } diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index 2b8042402f..1117783c2d 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -909,7 +909,7 @@ public abstract class PO long mili = ts.getTime(); int nano = ts.getNanos(); double doublets = Double.parseDouble(Long.toString(mili) + "." + Integer.toString(nano)); - BigDecimal bdtimestamp = new BigDecimal(doublets); + BigDecimal bdtimestamp = BigDecimal.valueOf(doublets); set_Value("ProcessedOn", bdtimestamp); } } diff --git a/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java b/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java index dd3a0f345b..1e9f758c9a 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java @@ -238,7 +238,7 @@ public class MPrintTableFormat extends X_AD_PrintTableFormat { BigDecimal retValue = super.getHdrStroke(); if (retValue == null || Env.ZERO.compareTo(retValue) <= 0) - retValue = new BigDecimal (2.0); + retValue = BigDecimal.valueOf(2.0); return retValue; } // getHdrStroke @@ -486,7 +486,7 @@ public class MPrintTableFormat extends X_AD_PrintTableFormat { BigDecimal retValue = super.getLineStroke(); if (retValue == null || Env.ZERO.compareTo(retValue) <= 0) - retValue = new BigDecimal (1.0); + retValue = BigDecimal.valueOf(1.0); return retValue; } // getLineStroke @@ -498,7 +498,7 @@ public class MPrintTableFormat extends X_AD_PrintTableFormat { BigDecimal retValue = super.getLineStroke(); if (retValue == null || Env.ZERO.compareTo(retValue) <= 0) - retValue = new BigDecimal (1.0); + retValue = BigDecimal.valueOf(1.0); return retValue; } // getVLineStroke diff --git a/org.adempiere.base/src/org/compiere/print/PrintDataElement.java b/org.adempiere.base/src/org/compiere/print/PrintDataElement.java index 3b2d4a202e..62b0a081af 100644 --- a/org.adempiere.base/src/org/compiere/print/PrintDataElement.java +++ b/org.adempiere.base/src/org/compiere/print/PrintDataElement.java @@ -126,7 +126,7 @@ public class PrintDataElement implements Serializable if (m_value instanceof BigDecimal) return (BigDecimal)m_value; if (m_value instanceof Number) - return new BigDecimal(((Number)m_value).doubleValue()); + return BigDecimal.valueOf(((Number)m_value).doubleValue()); // Boolean - return 1 for true 0 for false if (m_value instanceof Boolean) diff --git a/org.adempiere.base/src/org/compiere/print/PrintDataFunction.java b/org.adempiere.base/src/org/compiere/print/PrintDataFunction.java index 0e29710a55..0a331ebdae 100644 --- a/org.adempiere.base/src/org/compiere/print/PrintDataFunction.java +++ b/org.adempiere.base/src/org/compiere/print/PrintDataFunction.java @@ -148,7 +148,7 @@ public class PrintDataFunction return variance; } // Standard Deviation - BigDecimal deviation = new BigDecimal(Math.sqrt(variance.doubleValue())); + BigDecimal deviation = BigDecimal.valueOf(Math.sqrt(variance.doubleValue())); if (deviation.scale() > 4) deviation = deviation.setScale(4, BigDecimal.ROUND_HALF_UP); return deviation; diff --git a/org.adempiere.base/src/org/compiere/report/core/RModelData.java b/org.adempiere.base/src/org/compiere/report/core/RModelData.java index 6f5291e61b..921eec1b09 100644 --- a/org.adempiere.base/src/org/compiere/report/core/RModelData.java +++ b/org.adempiere.base/src/org/compiere/report/core/RModelData.java @@ -76,7 +76,7 @@ public class RModelData private ArrayList m_groupRowsIndicator = null; /** Constant 1 */ - private static final BigDecimal ONE = new BigDecimal(1.0); + private static final BigDecimal ONE = BigDecimal.valueOf(1.0); /** Logger */ private static CLogger log = CLogger.getCLogger(RModelData.class); diff --git a/org.adempiere.base/src/org/compiere/util/AmtInWords_HR.java b/org.adempiere.base/src/org/compiere/util/AmtInWords_HR.java index 7e464f45a1..76b5513bf9 100644 --- a/org.adempiere.base/src/org/compiere/util/AmtInWords_HR.java +++ b/org.adempiere.base/src/org/compiere/util/AmtInWords_HR.java @@ -475,7 +475,7 @@ boolean jedinceBezBroja) { amount = amount.replaceAll (",", ""); Double iznos = Double.parseDouble(amount); - sb.append (slovimaUValuti (new BigDecimal(Double.valueOf(iznos)))); + sb.append (slovimaUValuti (BigDecimal.valueOf(Double.valueOf(iznos)))); return sb.toString (); } // getAmtInWords diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index b6a0609934..a52687b1b1 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -1777,11 +1777,11 @@ public final class Env */ /** Big Decimal 0 */ - static final public BigDecimal ZERO = new BigDecimal(0.0); + static final public BigDecimal ZERO = BigDecimal.valueOf(0.0); /** Big Decimal 1 */ - static final public BigDecimal ONE = new BigDecimal(1.0); + static final public BigDecimal ONE = BigDecimal.valueOf(1.0); /** Big Decimal 100 */ - static final public BigDecimal ONEHUNDRED = new BigDecimal(100.0); + static final public BigDecimal ONEHUNDRED = BigDecimal.valueOf(100.0); /** New Line */ public static final String NL = System.getProperty("line.separator"); diff --git a/org.adempiere.base/src/org/compiere/util/WebUtil.java b/org.adempiere.base/src/org/compiere/util/WebUtil.java index 76cf6d5317..12f1a756d0 100644 --- a/org.adempiere.base/src/org/compiere/util/WebUtil.java +++ b/org.adempiere.base/src/org/compiere/util/WebUtil.java @@ -375,7 +375,7 @@ public final class WebUtil if (oo instanceof BigDecimal) return (BigDecimal)oo; else if (oo instanceof Number) - return new BigDecimal (((Number)oo).doubleValue()); + return BigDecimal.valueOf(((Number)oo).doubleValue()); return new BigDecimal (oo.toString()); } catch (Exception e) diff --git a/org.adempiere.base/src/org/globalqss/process/GLJournalGenerate.java b/org.adempiere.base/src/org/globalqss/process/GLJournalGenerate.java index 20626e0c48..f764ce2beb 100644 --- a/org.adempiere.base/src/org/globalqss/process/GLJournalGenerate.java +++ b/org.adempiere.base/src/org/globalqss/process/GLJournalGenerate.java @@ -534,7 +534,7 @@ public class GLJournalGenerate extends SvrProcess sourceAmt = sourceAmt.multiply(amtMultiplier, MathContext.UNLIMITED); if (roundFactor < 0) { - BigDecimal divisor = new BigDecimal(Math.pow(10, -roundFactor)); + BigDecimal divisor = BigDecimal.valueOf(Math.pow(10, -roundFactor)); sourceAmt = sourceAmt.divide(divisor, MathContext.UNLIMITED); sourceAmt = sourceAmt.setScale(0, BigDecimal.ROUND_HALF_UP); sourceAmt = sourceAmt.multiply(divisor, MathContext.UNLIMITED); diff --git a/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Depreciation_Workfile.java b/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Depreciation_Workfile.java index 8a14e107ff..307ed988a0 100644 --- a/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Depreciation_Workfile.java +++ b/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Depreciation_Workfile.java @@ -28,26 +28,26 @@ public class CalloutA_Depreciation_Workfile extends CalloutEngine BigDecimal uselife = null; if (MDepreciationWorkfile.COLUMNNAME_UseLifeYears.equals(mField.getColumnName())) { - uselife = new BigDecimal(value.toString()).multiply(new BigDecimal(12.0)); + uselife = new BigDecimal(value.toString()).multiply(BigDecimal.valueOf(12.0)); mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeYears_F, value); mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeMonths, uselife); mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeMonths_F, uselife); } else if (MDepreciationWorkfile.COLUMNNAME_UseLifeMonths.equals(mField.getColumnName())) { - uselife = new BigDecimal(value.toString()).divide(new BigDecimal(12.0)); + uselife = new BigDecimal(value.toString()).divide(BigDecimal.valueOf(12.0)); mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeYears, uselife); mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeYears_F, uselife); mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeMonths_F, value); } else if (MDepreciationWorkfile.COLUMNNAME_UseLifeYears_F.equals(mField.getColumnName())) { - uselife = new BigDecimal(value.toString()).multiply(new BigDecimal(12.0)); + uselife = new BigDecimal(value.toString()).multiply(BigDecimal.valueOf(12.0)); mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeMonths_F, uselife); } else if (MDepreciationWorkfile.COLUMNNAME_UseLifeMonths_F.equals(mField.getColumnName())) { - uselife = new BigDecimal(value.toString()).divide(new BigDecimal(12.0)); + uselife = new BigDecimal(value.toString()).divide(BigDecimal.valueOf(12.0)); mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeYears_F, uselife); } diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AMenu.java b/org.adempiere.ui.swing/src/org/compiere/apps/AMenu.java index 8b64707421..a63241cb0f 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AMenu.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/AMenu.java @@ -710,12 +710,12 @@ public final class AMenu extends CFrame memoryBar.setMaximum((int)total); memoryBar.setValue((int)used); String msg = MessageFormat.format("{0,number,integer} MB - {1,number,integer}%", - new Object[] {new BigDecimal(total / 1024), new BigDecimal(percent)}); + new Object[] {BigDecimal.valueOf(total / 1024), BigDecimal.valueOf(percent)}); memoryBar.setString(msg); // // msg = MessageFormat.format("Total Memory {0,number,integer} kB - Free {1,number,integer} kB", msg = Msg.getMsg(m_ctx, "MemoryInfo", - new Object[] {new BigDecimal(total), new BigDecimal(free)}); + new Object[] {BigDecimal.valueOf(total), BigDecimal.valueOf(free)}); memoryBar.setToolTipText(msg); // progressBar.repaint(); diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java index 207317cc60..04fec3666e 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java @@ -394,7 +394,7 @@ public class VAllocation extends Allocation private void setAllocateButton() { - if (totalDiff.compareTo(new BigDecimal(0.0)) == 0 ^ m_C_Charge_ID > 0 ) + if (totalDiff.compareTo(BigDecimal.valueOf(0.0)) == 0 ^ m_C_Charge_ID > 0 ) { allocateButton.setEnabled(true); // chargePick.setValue(m_C_Charge_ID); @@ -404,7 +404,7 @@ public class VAllocation extends Allocation allocateButton.setEnabled(false); } - if ( totalDiff.compareTo(new BigDecimal(0.0)) == 0 ) + if ( totalDiff.compareTo(BigDecimal.valueOf(0.0)) == 0 ) { chargePick.setValue(null); m_C_Charge_ID = 0; diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java index 84f230a3b9..8c1b2728a2 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java @@ -320,7 +320,7 @@ implements FormPanel, ActionListener, TableModelListener, VetoableChangeListener public void calculateSelection() { m_noSelected = 0; - BigDecimal selectedAmt = new BigDecimal(0.0); + BigDecimal selectedAmt = BigDecimal.valueOf(0.0); int rows = miniTable.getRowCount(); for (int i = 0; i < rows; i++) diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VMatch.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VMatch.java index 72d8cfd12e..916d950a19 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VMatch.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VMatch.java @@ -442,7 +442,7 @@ public class VMatch extends Match } // Display To be Matched Qty - m_xMatched = new BigDecimal (qty); + m_xMatched = BigDecimal.valueOf(qty); xMatched.setValue(m_xMatched); xMatchedTo.setValue(Env.ZERO); difference.setValue(m_xMatched); @@ -494,7 +494,7 @@ public class VMatch extends Match } } // update quantities - m_xMatchedTo = new BigDecimal(qty); + m_xMatchedTo = BigDecimal.valueOf(qty); xMatchedTo.setValue(m_xMatchedTo); difference.setValue(m_xMatched.subtract(m_xMatchedTo)); bProcess.setEnabled(noRows != 0); diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java index 4e0783c17d..e4410396fd 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java @@ -282,7 +282,7 @@ public class InvoiceHistory extends CDialog double priceList = rs.getDouble(3); double priceActual = rs.getDouble(2); if (priceList != 0) { - discountBD = new BigDecimal((priceList - priceActual)/priceList * 100); + discountBD = BigDecimal.valueOf((priceList - priceActual)/priceList * 100); // Rounding: int precision = MPriceList.getStandardPrecision(Env.getCtx(), rs.getInt(9)); if (discountBD.scale() > precision) diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java index 8b8efece30..806e26ea71 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java @@ -96,7 +96,7 @@ public final class Calculator extends CDialog // m_number = number; if (m_number == null) - m_number = new BigDecimal(0.0); + m_number = BigDecimal.valueOf(0.0); // try { @@ -433,7 +433,7 @@ public final class Calculator extends CDialog // nothing or zero if (m_display == null || m_display.equals("") || m_display.equals("0")) { - m_number = new BigDecimal(0.0); + m_number = BigDecimal.valueOf(0.0); return m_number; } @@ -448,7 +448,7 @@ public final class Calculator extends CDialog token += st.nextToken(); else { - m_number = new BigDecimal(0.0); + m_number = BigDecimal.valueOf(0.0); return m_number; } } @@ -462,7 +462,7 @@ public final class Calculator extends CDialog catch (ParseException pe1) { log.log(Level.SEVERE, "Calculator.evaluate - token: " + token, pe1); - m_number = new BigDecimal(0.0); + m_number = BigDecimal.valueOf(0.0); return m_number; } BigDecimal firstNo = new BigDecimal(firstNumber.toString()); @@ -485,7 +485,7 @@ public final class Calculator extends CDialog char op = token.charAt(0); if (op == '%') { - firstNo = firstNo.divide(new BigDecimal(100.0), m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); + firstNo = firstNo.divide(BigDecimal.valueOf(100.0), m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); m_number = firstNo; } @@ -502,7 +502,7 @@ public final class Calculator extends CDialog catch (ParseException pe2) { log.log(Level.SEVERE, "Calculator.evaluate - token: " + token, pe2); - m_number = new BigDecimal(0.0); + m_number = BigDecimal.valueOf(0.0); return m_number; } BigDecimal secondNo = new BigDecimal(secondNumber.toString()); @@ -523,7 +523,7 @@ public final class Calculator extends CDialog // Percent operation if (op2 == '%') - secondNo = secondNo.divide(new BigDecimal(100.0), m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); + secondNo = secondNo.divide(BigDecimal.valueOf(100.0), m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); switch (op) { diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java index 05a244ad7f..b267d31541 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java @@ -220,14 +220,14 @@ public final class MDocNumber extends PlainDocument else { String value = getText(); - BigDecimal percentValue = new BigDecimal(0.0); + BigDecimal percentValue = BigDecimal.valueOf(0.0); try { if (value != null && value.length() > 0) { Number number = m_format.parse(value); percentValue = new BigDecimal (number.toString()); - percentValue = percentValue.divide(new BigDecimal(100.0), m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); + percentValue = percentValue.divide(BigDecimal.valueOf(100.0), m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); m_tc.setText(m_format.format(percentValue)); } } diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VColor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VColor.java index 579fbdfc3a..21611aced6 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VColor.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VColor.java @@ -340,7 +340,7 @@ public class VColor extends CButton setColor (cc.getTextureTaintColor(), true); // URL url = cc.getTextureURL(); // m_mTab.setValue("AD_Image_ID"); - m_mTab.setValue("ImageAlpha", new BigDecimal(cc.getTextureCompositeAlpha())); + m_mTab.setValue("ImageAlpha", BigDecimal.valueOf(cc.getTextureCompositeAlpha())); } m_cc = cc; } // actionPerformed diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java index c7669b2a22..4991112692 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java @@ -667,12 +667,12 @@ public final class VNumber extends JComponent if (bd.doubleValue() < m_minValue) { error = oo + " < " + m_minValue; - oo = new BigDecimal(m_minValue); + oo = BigDecimal.valueOf(m_minValue); } else if (bd.doubleValue() > m_maxValue) { error = oo + " > " + m_maxValue; - oo = new BigDecimal(m_maxValue); + oo = BigDecimal.valueOf(m_maxValue); } } if (error != null) @@ -717,7 +717,7 @@ public final class VNumber extends JComponent DecimalFormat format, int displayType, String title, char operator) { if (log.isLoggable(Level.CONFIG)) log.config("Value=" + value); - BigDecimal startValue = new BigDecimal(0.0); + BigDecimal startValue = BigDecimal.valueOf(0.0); try { if (value != null && value.length() > 0) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java index e7175aada9..fc8372e0a1 100755 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java @@ -485,7 +485,7 @@ public class WAllocation extends Allocation } // vetoableChange private void setAllocateButton() { - if (totalDiff.compareTo(new BigDecimal(0.0)) == 0 ^ m_C_Charge_ID > 0 ) + if (totalDiff.compareTo(BigDecimal.valueOf(0.0)) == 0 ^ m_C_Charge_ID > 0 ) { allocateButton.setEnabled(true); // chargePick.setValue(m_C_Charge_ID); @@ -495,7 +495,7 @@ public class WAllocation extends Allocation allocateButton.setEnabled(false); } - if ( totalDiff.compareTo(new BigDecimal(0.0)) == 0 ) + if ( totalDiff.compareTo(BigDecimal.valueOf(0.0)) == 0 ) { chargePick.setValue(null); m_C_Charge_ID = 0; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFactReconcile.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFactReconcile.java index 1f1a953948..ff98e25105 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFactReconcile.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFactReconcile.java @@ -334,7 +334,7 @@ implements IFormController, EventListener, WTableModelListener, ValueChan public void calculateSelection() { m_noSelected = 0; - BigDecimal selectedAmt = new BigDecimal(0.0); + BigDecimal selectedAmt = BigDecimal.valueOf(0.0); int rows = miniTable.getRowCount(); for (int i = 0; i < rows; i++) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java index 0e93bf7740..267379fe1e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java @@ -472,7 +472,7 @@ public class WMatch extends Match xMatchedToTable = (WListbox) cmd_searchTo(xMatchedTable, xMatchedToTable, displayString, matchToType, sameBPartner.isSelected(), sameProduct.isSelected(), sameQty.isSelected(), matchMode.getSelectedIndex() == MODE_MATCHED); } // Display To be Matched Qty - m_xMatched = new BigDecimal (qty); + m_xMatched = BigDecimal.valueOf(qty); xMatched.setValue(m_xMatched); xMatchedTo.setValue(Env.ZERO); difference.setValue(m_xMatched); @@ -528,7 +528,7 @@ public class WMatch extends Match } } // update qualtities - m_xMatchedTo = new BigDecimal(qty); + m_xMatchedTo = BigDecimal.valueOf(qty); xMatchedTo.setValue(m_xMatchedTo); difference.setValue(m_xMatched.subtract(m_xMatchedTo)); bProcess.setEnabled(noRows != 0); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WGraph.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WGraph.java index cf2861bae6..d245567ac4 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WGraph.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WGraph.java @@ -530,7 +530,7 @@ public class WGraph extends Div implements IdSpace { td = new Td(); td.setSclass("pa-tdvalue"); tr.appendChild(td); - BigDecimal value = new BigDecimal(bgc.getValue()); + BigDecimal value = BigDecimal.valueOf(bgc.getValue()); if (bgc.getMQuery(builder.getMGoal()) != null) { A a = new A(); a.setSclass("pa-hrefNode"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java index f981eb4403..d3f57e0549 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java @@ -123,7 +123,7 @@ public class NumberBox extends Div else if (value instanceof BigDecimal) decimalBox.setValue((BigDecimal) value); else if (value instanceof Number) - decimalBox.setValue(new BigDecimal(((Number)value).doubleValue())); + decimalBox.setValue(BigDecimal.valueOf(((Number)value).doubleValue())); else decimalBox.setValue(new BigDecimal(value.toString())); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java index 7061741371..cd213fe197 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java @@ -209,7 +209,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener else if (value instanceof BigDecimal) oldValue = (BigDecimal) value; else if (value instanceof Number) - oldValue = new BigDecimal(((Number)value).doubleValue()); + oldValue = BigDecimal.valueOf(((Number)value).doubleValue()); else oldValue = new BigDecimal(value.toString()); getComponent().setValue(oldValue); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InvoiceHistory.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InvoiceHistory.java index dd011a7ec8..8981171dd6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InvoiceHistory.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InvoiceHistory.java @@ -316,7 +316,7 @@ public class InvoiceHistory extends Window implements EventListener double priceList = rs.getDouble(3); double priceActual = rs.getDouble(2); if (priceList != 0) { - discountBD = new BigDecimal((priceList - priceActual)/priceList * 100); + discountBD = BigDecimal.valueOf((priceList - priceActual)/priceList * 100); // Rounding: int precision = MPriceList.getStandardPrecision(Env.getCtx(), rs.getInt(9)); if (discountBD.scale() > precision) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java index f23a4dd916..d3cfd90ac3 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java @@ -524,7 +524,7 @@ public class InfoSchedule extends Window implements EventListener ma.setS_Resource_ID(S_Resource_ID); ma.setAssignDateFrom(start); - ma.setQty(new BigDecimal(hours)); + ma.setQty(BigDecimal.valueOf(hours)); if (m_parent == null || m_callback == null) { final boolean createNew = true; if (vad != null && vad.getPage() != null) @@ -569,7 +569,7 @@ public class InfoSchedule extends Window implements EventListener MResourceAssignment ma = slot.getMAssignment(); ma.setAssignDateFrom(start); - ma.setQty(new BigDecimal(hours)); + ma.setQty(BigDecimal.valueOf(hours)); if (m_parent == null || m_callback == null) { if (event.getBeginDate() != null && event.getEndDate() != null) { diff --git a/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java b/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java index 534d752844..160f637acb 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java @@ -53,9 +53,9 @@ public class Allocation public int m_C_BPartner_ID = 0; private int m_noInvoices = 0; private int m_noPayments = 0; - public BigDecimal totalInv = new BigDecimal(0.0); - public BigDecimal totalPay = new BigDecimal(0.0); - public BigDecimal totalDiff = new BigDecimal(0.0); + public BigDecimal totalInv = BigDecimal.valueOf(0.0); + public BigDecimal totalPay = BigDecimal.valueOf(0.0); + public BigDecimal totalDiff = BigDecimal.valueOf(0.0); public Timestamp allocDate = null; @@ -548,7 +548,7 @@ public class Allocation log.config(""); // Payment - totalPay = new BigDecimal(0.0); + totalPay = BigDecimal.valueOf(0.0); int rows = payment.getRowCount(); m_noPayments = 0; for (int i = 0; i < rows; i++) @@ -571,7 +571,7 @@ public class Allocation public String calculateInvoice(IMiniTable invoice, boolean isMultiCurrency) { // Invoices - totalInv = new BigDecimal(0.0); + totalInv = BigDecimal.valueOf(0.0); int rows = invoice.getRowCount(); m_noInvoices = 0; diff --git a/org.adempiere.ui/src/org/compiere/apps/form/Match.java b/org.adempiere.ui/src/org/compiere/apps/form/Match.java index 4ff7de16e3..3d0de136ba 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/Match.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/Match.java @@ -206,7 +206,7 @@ public class Match // Create it String innerTrxName = Trx.createTrxName("Match"); Trx innerTrx = Trx.get(innerTrxName, true); - if (createMatchRecord(invoice, M_InOutLine_ID, Line_ID, new BigDecimal(qty), innerTrxName)) + if (createMatchRecord(invoice, M_InOutLine_ID, Line_ID, BigDecimal.valueOf(qty), innerTrxName)) innerTrx.commit(); else innerTrx.rollback(); diff --git a/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java b/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java index b9327f53a6..7c6305452d 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java @@ -61,7 +61,7 @@ public class PaySelect /** Format */ public DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount); /** Bank Balance */ - private BigDecimal m_bankBalance = new BigDecimal(0.0); + private BigDecimal m_bankBalance = BigDecimal.valueOf(0.0); /** SQL for Query */ private String m_sql; /** Number of selected rows */ @@ -379,7 +379,7 @@ public class PaySelect public String calculateSelection(IMiniTable miniTable) { m_noSelected = 0; - BigDecimal invoiceAmt = new BigDecimal(0.0); + BigDecimal invoiceAmt = BigDecimal.valueOf(0.0); int rows = miniTable.getRowCount(); for (int i = 0; i < rows; i++) From 6b108cff550c4b2eb7250fb2cc8a8379252574b0 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 9 Apr 2013 17:48:34 -0500 Subject: [PATCH 2/6] IDEMPIERE-455 Discover and fix FindBugs problems / DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE / Improve some calculations for BigDecimal --- .../src/org/adempiere/model/PromotionRule.java | 10 +++++----- org.adempiere.base/src/org/compiere/Base.java | 8 ++++---- .../src/org/compiere/acct/Doc_Requisition.java | 2 +- .../src/org/compiere/impexp/ImpFormatRow.java | 3 ++- .../src/org/compiere/model/CalloutEngine.java | 5 ++--- .../org/compiere/model/MResourceAssignment.java | 5 +++-- .../src/org/compiere/print/MPrintTableFormat.java | 4 ++-- .../src/org/compiere/report/core/RModelData.java | 5 +---- .../src/org/compiere/apps/form/VAllocation.java | 10 ++++++---- .../src/org/compiere/apps/form/VFactReconcile.java | 2 +- .../src/org/compiere/grid/ed/Calculator.java | 14 +++++++------- .../src/org/compiere/grid/ed/MDocNumber.java | 5 +++-- .../org/adempiere/webui/apps/form/WAllocation.java | 5 ++--- .../adempiere/webui/apps/form/WFactReconcile.java | 2 +- .../src/org/compiere/apps/form/Allocation.java | 10 +++++----- .../src/org/compiere/apps/form/PaySelect.java | 4 ++-- 16 files changed, 47 insertions(+), 47 deletions(-) diff --git a/org.adempiere.base/src/org/adempiere/model/PromotionRule.java b/org.adempiere.base/src/org/adempiere/model/PromotionRule.java index bbb505b252..0822141809 100644 --- a/org.adempiere.base/src/org/adempiere/model/PromotionRule.java +++ b/org.adempiere.base/src/org/adempiere/model/PromotionRule.java @@ -193,10 +193,10 @@ public class PromotionRule { } else if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_FlatDiscount)) { discount = pr.getAmount(); } else if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_Percentage)) { - discount = pr.getAmount().divide(BigDecimal.valueOf(100.00)).multiply(totalPrice); + discount = pr.getAmount().divide(Env.ONEHUNDRED).multiply(totalPrice); } if (discount.signum() > 0) { - addDiscountLine(order, null, discount, BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion()); + addDiscountLine(order, null, discount, Env.ONE, pr.getC_Charge_ID(), pr.getM_Promotion()); } } else { int M_PromotionDistribution_ID = pr.getM_PromotionDistribution_ID(); @@ -260,10 +260,10 @@ public class PromotionRule { if (ol.getC_OrderLine_ID() == C_OrderLine_ID) { if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_Percentage)) { BigDecimal priceActual = ol.getPriceActual(); - BigDecimal discount = priceActual.multiply(pr.getAmount().divide(BigDecimal.valueOf(100.00))); + BigDecimal discount = priceActual.multiply(pr.getAmount().divide(Env.ONEHUNDRED)); addDiscountLine(order, ol, discount, qty, pr.getC_Charge_ID(), pr.getM_Promotion()); } else if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_FlatDiscount)) { - addDiscountLine(order, ol, pr.getAmount(), BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion()); + addDiscountLine(order, ol, pr.getAmount(), Env.ONE, pr.getC_Charge_ID(), pr.getM_Promotion()); } else if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_AbsoluteAmount)) { BigDecimal priceActual = ol.getPriceActual(); totalPrice = totalPrice.add(priceActual.multiply(qty)); @@ -278,7 +278,7 @@ public class PromotionRule { } if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_AbsoluteAmount)) { if (pr.getAmount().compareTo(totalPrice) < 0) { - addDiscountLine(order, null, totalPrice.subtract(pr.getAmount()), BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion()); + addDiscountLine(order, null, totalPrice.subtract(pr.getAmount()), Env.ONE, pr.getC_Charge_ID(), pr.getM_Promotion()); } } } diff --git a/org.adempiere.base/src/org/compiere/Base.java b/org.adempiere.base/src/org/compiere/Base.java index 0b85858b11..91eed9965e 100644 --- a/org.adempiere.base/src/org/compiere/Base.java +++ b/org.adempiere.base/src/org/compiere/Base.java @@ -16,14 +16,14 @@ *****************************************************************************/ package org.compiere; -import java.math.BigDecimal; +import static org.compiere.model.SystemIDs.WINDOW_WINDOW_TAB_FIELD; + import java.util.Properties; import org.compiere.model.GridWindow; import org.compiere.model.GridWindowVO; import org.compiere.model.MConversionRate; import org.compiere.model.MUOMConversion; -import static org.compiere.model.SystemIDs.*; import org.compiere.util.Env; import org.compiere.util.Login; @@ -97,9 +97,9 @@ class Base listThreads(); // System.out.println("API Test"); - System.out.println("64.72=" + MConversionRate.convert(ctx, BigDecimal.valueOf(100.0), 116, 100,0,0)); + System.out.println("64.72=" + MConversionRate.convert(ctx, Env.ONEHUNDRED, 116, 100,0,0)); System.out.println("0.647169=" + MConversionRate.getRate(116, 100, null, 0,0,0)); - System.out.println("12.5=" + MUOMConversion.convert(101, 102, BigDecimal.valueOf(100.0), true)); + System.out.println("12.5=" + MUOMConversion.convert(101, 102, Env.ONEHUNDRED, true)); } // Base diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_Requisition.java b/org.adempiere.base/src/org/compiere/acct/Doc_Requisition.java index 51bfe3d185..5af23115cd 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_Requisition.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_Requisition.java @@ -105,7 +105,7 @@ public class Doc_Requisition extends Doc */ public BigDecimal getBalance () { - BigDecimal retValue = BigDecimal.valueOf(0.0); + BigDecimal retValue = Env.ZERO; return retValue; } // getBalance diff --git a/org.adempiere.base/src/org/compiere/impexp/ImpFormatRow.java b/org.adempiere.base/src/org/compiere/impexp/ImpFormatRow.java index eabbed49b6..a77e26fff7 100644 --- a/org.adempiere.base/src/org/compiere/impexp/ImpFormatRow.java +++ b/org.adempiere.base/src/org/compiere/impexp/ImpFormatRow.java @@ -27,6 +27,7 @@ import java.util.logging.Level; import org.compiere.model.Callout; import org.compiere.model.X_AD_ImpFormat_Row; import org.compiere.util.CLogger; +import org.compiere.util.Env; /** * Import Format Row with parsing capability @@ -486,7 +487,7 @@ public final class ImpFormatRow return "0"; BigDecimal bd = new BigDecimal(sb.toString()); if (m_divideBy100) // assumed two decimal scale - bd = bd.divide(BigDecimal.valueOf(100.0), 2, BigDecimal.ROUND_HALF_UP); + bd = bd.divide(Env.ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); return bd.toString(); } // parseNumber diff --git a/org.adempiere.base/src/org/compiere/model/CalloutEngine.java b/org.adempiere.base/src/org/compiere/model/CalloutEngine.java index 766b26127a..006a88eaaa 100644 --- a/org.adempiere.base/src/org/compiere/model/CalloutEngine.java +++ b/org.adempiere.base/src/org/compiere/model/CalloutEngine.java @@ -250,10 +250,9 @@ public class CalloutEngine implements Callout BigDecimal rate1 = (BigDecimal)value; BigDecimal rate2 = Env.ZERO; - BigDecimal one = BigDecimal.valueOf(1.0); - if (rate1.doubleValue() != 0.0) // no divide by zero - rate2 = one.divide(rate1, 12, BigDecimal.ROUND_HALF_UP); + if (rate1.signum() != 0.0) // no divide by zero + rate2 = Env.ONE.divide(rate1, 12, BigDecimal.ROUND_HALF_UP); // if (mField.getColumnName().equals("MultiplyRate")) mTab.setValue("DivideRate", rate2); diff --git a/org.adempiere.base/src/org/compiere/model/MResourceAssignment.java b/org.adempiere.base/src/org/compiere/model/MResourceAssignment.java index 0212f2f519..ea4c182df5 100644 --- a/org.adempiere.base/src/org/compiere/model/MResourceAssignment.java +++ b/org.adempiere.base/src/org/compiere/model/MResourceAssignment.java @@ -16,11 +16,12 @@ *****************************************************************************/ package org.compiere.model; -import java.math.BigDecimal; import java.sql.ResultSet; import java.sql.Timestamp; import java.util.Properties; +import org.compiere.util.Env; + /** * Resource Assignment Model @@ -48,7 +49,7 @@ public class MResourceAssignment extends X_S_ResourceAssignment if (S_ResourceAssignment_ID == 0) { setAssignDateFrom(new Timestamp(System.currentTimeMillis())); - setQty(BigDecimal.valueOf(1.0)); + setQty(Env.ONE); setName("."); setIsConfirmed(false); } diff --git a/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java b/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java index 1e9f758c9a..4cd288399d 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java @@ -486,7 +486,7 @@ public class MPrintTableFormat extends X_AD_PrintTableFormat { BigDecimal retValue = super.getLineStroke(); if (retValue == null || Env.ZERO.compareTo(retValue) <= 0) - retValue = BigDecimal.valueOf(1.0); + retValue = Env.ONE; return retValue; } // getLineStroke @@ -498,7 +498,7 @@ public class MPrintTableFormat extends X_AD_PrintTableFormat { BigDecimal retValue = super.getLineStroke(); if (retValue == null || Env.ZERO.compareTo(retValue) <= 0) - retValue = BigDecimal.valueOf(1.0); + retValue = Env.ONE; return retValue; } // getVLineStroke diff --git a/org.adempiere.base/src/org/compiere/report/core/RModelData.java b/org.adempiere.base/src/org/compiere/report/core/RModelData.java index 921eec1b09..0d65821ca8 100644 --- a/org.adempiere.base/src/org/compiere/report/core/RModelData.java +++ b/org.adempiere.base/src/org/compiere/report/core/RModelData.java @@ -75,9 +75,6 @@ public class RModelData private ArrayList m_groupRows = new ArrayList(); private ArrayList m_groupRowsIndicator = null; - /** Constant 1 */ - private static final BigDecimal ONE = BigDecimal.valueOf(1.0); - /** Logger */ private static CLogger log = CLogger.getCLogger(RModelData.class); @@ -322,7 +319,7 @@ public class RModelData if (funcFuns[fc].equals(RModel.FUNCTION_SUM)) funcVals[fc][level] = funcVals[fc][level].add(bd); else if (funcFuns[fc].equals(RModel.FUNCTION_COUNT)) - funcVals[fc][level] = funcVals[fc][level].add(ONE); + funcVals[fc][level] = funcVals[fc][level].add(Env.ONE); } // for all group levels } // for all functions diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java index 04fec3666e..cead1dfac2 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java @@ -13,6 +13,10 @@ *****************************************************************************/ package org.compiere.apps.form; +import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID; +import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_CURRENCY_ID; +import static org.compiere.model.SystemIDs.COLUMN_C_PERIOD_AD_ORG_ID; + import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridBagConstraints; @@ -22,7 +26,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.VetoableChangeListener; -import java.math.BigDecimal; import java.util.Vector; import java.util.logging.Level; @@ -46,7 +49,6 @@ import org.compiere.minigrid.MiniTable; import org.compiere.model.MAllocationHdr; import org.compiere.model.MLookup; import org.compiere.model.MLookupFactory; -import static org.compiere.model.SystemIDs.*; import org.compiere.plaf.CompiereColor; import org.compiere.swing.CPanel; import org.compiere.swing.CTextField; @@ -394,7 +396,7 @@ public class VAllocation extends Allocation private void setAllocateButton() { - if (totalDiff.compareTo(BigDecimal.valueOf(0.0)) == 0 ^ m_C_Charge_ID > 0 ) + if (totalDiff.signum() == 0 ^ m_C_Charge_ID > 0 ) { allocateButton.setEnabled(true); // chargePick.setValue(m_C_Charge_ID); @@ -404,7 +406,7 @@ public class VAllocation extends Allocation allocateButton.setEnabled(false); } - if ( totalDiff.compareTo(BigDecimal.valueOf(0.0)) == 0 ) + if ( totalDiff.signum() == 0 ) { chargePick.setValue(null); m_C_Charge_ID = 0; diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java index 8c1b2728a2..bd4cd398d1 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java @@ -320,7 +320,7 @@ implements FormPanel, ActionListener, TableModelListener, VetoableChangeListener public void calculateSelection() { m_noSelected = 0; - BigDecimal selectedAmt = BigDecimal.valueOf(0.0); + BigDecimal selectedAmt = Env.ZERO; int rows = miniTable.getRowCount(); for (int i = 0; i < rows; i++) diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java index 806e26ea71..a1c48b5f42 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java @@ -96,7 +96,7 @@ public final class Calculator extends CDialog // m_number = number; if (m_number == null) - m_number = BigDecimal.valueOf(0.0); + m_number = Env.ZERO; // try { @@ -433,7 +433,7 @@ public final class Calculator extends CDialog // nothing or zero if (m_display == null || m_display.equals("") || m_display.equals("0")) { - m_number = BigDecimal.valueOf(0.0); + m_number = Env.ZERO; return m_number; } @@ -448,7 +448,7 @@ public final class Calculator extends CDialog token += st.nextToken(); else { - m_number = BigDecimal.valueOf(0.0); + m_number = Env.ZERO; return m_number; } } @@ -462,7 +462,7 @@ public final class Calculator extends CDialog catch (ParseException pe1) { log.log(Level.SEVERE, "Calculator.evaluate - token: " + token, pe1); - m_number = BigDecimal.valueOf(0.0); + m_number = Env.ZERO; return m_number; } BigDecimal firstNo = new BigDecimal(firstNumber.toString()); @@ -485,7 +485,7 @@ public final class Calculator extends CDialog char op = token.charAt(0); if (op == '%') { - firstNo = firstNo.divide(BigDecimal.valueOf(100.0), m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); + firstNo = firstNo.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); m_number = firstNo; } @@ -502,7 +502,7 @@ public final class Calculator extends CDialog catch (ParseException pe2) { log.log(Level.SEVERE, "Calculator.evaluate - token: " + token, pe2); - m_number = BigDecimal.valueOf(0.0); + m_number = Env.ZERO; return m_number; } BigDecimal secondNo = new BigDecimal(secondNumber.toString()); @@ -523,7 +523,7 @@ public final class Calculator extends CDialog // Percent operation if (op2 == '%') - secondNo = secondNo.divide(BigDecimal.valueOf(100.0), m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); + secondNo = secondNo.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); switch (op) { diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java index b267d31541..d3c567beb6 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java @@ -30,6 +30,7 @@ import javax.swing.text.PlainDocument; import org.compiere.apps.ADialog; import org.compiere.util.CLogger; import org.compiere.util.DisplayType; +import org.compiere.util.Env; /** * Number Document Model. @@ -220,14 +221,14 @@ public final class MDocNumber extends PlainDocument else { String value = getText(); - BigDecimal percentValue = BigDecimal.valueOf(0.0); + BigDecimal percentValue = Env.ZERO; try { if (value != null && value.length() > 0) { Number number = m_format.parse(value); percentValue = new BigDecimal (number.toString()); - percentValue = percentValue.divide(BigDecimal.valueOf(100.0), m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); + percentValue = percentValue.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); m_tc.setText(m_format.format(percentValue)); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java index fc8372e0a1..63fefa2b78 100755 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java @@ -20,7 +20,6 @@ import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID; import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_CURRENCY_ID; import static org.compiere.model.SystemIDs.COLUMN_C_PERIOD_AD_ORG_ID; -import java.math.BigDecimal; import java.util.Vector; import java.util.logging.Level; @@ -485,7 +484,7 @@ public class WAllocation extends Allocation } // vetoableChange private void setAllocateButton() { - if (totalDiff.compareTo(BigDecimal.valueOf(0.0)) == 0 ^ m_C_Charge_ID > 0 ) + if (totalDiff.signum() == 0 ^ m_C_Charge_ID > 0 ) { allocateButton.setEnabled(true); // chargePick.setValue(m_C_Charge_ID); @@ -495,7 +494,7 @@ public class WAllocation extends Allocation allocateButton.setEnabled(false); } - if ( totalDiff.compareTo(BigDecimal.valueOf(0.0)) == 0 ) + if ( totalDiff.signum() == 0 ) { chargePick.setValue(null); m_C_Charge_ID = 0; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFactReconcile.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFactReconcile.java index ff98e25105..a86e3e05d6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFactReconcile.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFactReconcile.java @@ -334,7 +334,7 @@ implements IFormController, EventListener, WTableModelListener, ValueChan public void calculateSelection() { m_noSelected = 0; - BigDecimal selectedAmt = BigDecimal.valueOf(0.0); + BigDecimal selectedAmt = Env.ZERO; int rows = miniTable.getRowCount(); for (int i = 0; i < rows; i++) diff --git a/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java b/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java index 160f637acb..7bb72f5ae4 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java @@ -53,9 +53,9 @@ public class Allocation public int m_C_BPartner_ID = 0; private int m_noInvoices = 0; private int m_noPayments = 0; - public BigDecimal totalInv = BigDecimal.valueOf(0.0); - public BigDecimal totalPay = BigDecimal.valueOf(0.0); - public BigDecimal totalDiff = BigDecimal.valueOf(0.0); + public BigDecimal totalInv = Env.ZERO; + public BigDecimal totalPay = Env.ZERO; + public BigDecimal totalDiff = Env.ZERO; public Timestamp allocDate = null; @@ -548,7 +548,7 @@ public class Allocation log.config(""); // Payment - totalPay = BigDecimal.valueOf(0.0); + totalPay = Env.ZERO; int rows = payment.getRowCount(); m_noPayments = 0; for (int i = 0; i < rows; i++) @@ -571,7 +571,7 @@ public class Allocation public String calculateInvoice(IMiniTable invoice, boolean isMultiCurrency) { // Invoices - totalInv = BigDecimal.valueOf(0.0); + totalInv = Env.ZERO; int rows = invoice.getRowCount(); m_noInvoices = 0; diff --git a/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java b/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java index 7c6305452d..636d6d6727 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java @@ -61,7 +61,7 @@ public class PaySelect /** Format */ public DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount); /** Bank Balance */ - private BigDecimal m_bankBalance = BigDecimal.valueOf(0.0); + private BigDecimal m_bankBalance = Env.ZERO; /** SQL for Query */ private String m_sql; /** Number of selected rows */ @@ -379,7 +379,7 @@ public class PaySelect public String calculateSelection(IMiniTable miniTable) { m_noSelected = 0; - BigDecimal invoiceAmt = BigDecimal.valueOf(0.0); + BigDecimal invoiceAmt = Env.ZERO; int rows = miniTable.getRowCount(); for (int i = 0; i < rows; i++) From 16094d84d546c07ca0af413273f0d86a88aebb50 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 9 Apr 2013 17:52:50 -0500 Subject: [PATCH 3/6] IDEMPIERE-455 Discover and fix FindBugs problems / DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE --- org.adempiere.base/src/org/compiere/model/MAllocationHdr.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java index 17c17b148e..bbfc21cd22 100644 --- a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java +++ b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java @@ -57,7 +57,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction private static final long serialVersionUID = 8726957992840702609L; /** Tolerance Gain and Loss */ - private static final BigDecimal TOLERANCE = new BigDecimal (0.02); + private static final BigDecimal TOLERANCE = BigDecimal.valueOf(0.02); /** * Get Allocations of Payment @@ -1045,7 +1045,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction // allocation as a percentage of the invoice double multiplier = allocAmt.doubleValue() / invoice.getGrandTotal().doubleValue(); // Reduce Orig Invoice Accounted - invAmtAccted = invAmtAccted.multiply(new BigDecimal(multiplier)); + invAmtAccted = invAmtAccted.multiply(BigDecimal.valueOf(multiplier)); // Difference based on percentage of Orig Invoice openBalanceDiff = openBalanceDiff.add(invAmtAccted).subtract(allocAmtAccted); // gain is negative // ignore Tolerance From 01a9897cc11436a1f4c78da66da5f17085ec3ba5 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 9 Apr 2013 18:09:44 -0500 Subject: [PATCH 4/6] IDEMPIERE-455 Discover and fix FindBugs problems / DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE / Improve some calculations for BigDecimal --- .../src/org/compiere/model/CalloutInventory.java | 4 ++-- .../src/org/adempiere/process/ImmediateBankTransfer.java | 4 ++-- .../src/org/compiere/process/DunningRunCreate.java | 4 ++-- .../src/org/compiere/process/RfQCreateSO.java | 7 ++----- .../src/org/adempiere/process/UUIDGenerator.java | 3 ++- .../src/org/compiere/acct/Doc_Production.java | 2 +- .../src/org/compiere/model/MDepositBatch.java | 3 ++- .../src/org/compiere/model/MDiscountSchema.java | 2 +- .../src/org/compiere/model/MInvoicePaySchedule.java | 8 ++------ org.adempiere.base/src/org/compiere/model/MOrderLine.java | 2 +- .../src/org/compiere/model/MOrderPaySchedule.java | 8 ++------ .../src/org/compiere/model/MPaymentTerm.java | 7 ++----- .../src/org/compiere/model/MRfQResponseLineQty.java | 8 +++----- org.adempiere.base/src/org/compiere/model/MTax.java | 4 +--- .../src/org/eevolution/process/BankTransfer.java | 4 ++-- .../src/test/functional/MProductTest.java | 3 ++- .../src/org/compiere/apps/form/VTreeBOM.java | 4 ++-- .../src/org/compiere/apps/search/VSchedulePanel.java | 3 +-- .../src/org/compiere/grid/ed/VNumber.java | 2 +- org.adempiere.ui.swing/src/org/compiere/pos/SubOrder.java | 2 +- .../src/org/adempiere/webui/apps/form/WBOMDrop.java | 2 +- .../src/org/adempiere/webui/apps/form/WTreeBOM.java | 6 +++--- .../org/compiere/apps/form/StatementCreateFromBatch.java | 2 +- .../src/org/compiere/grid/CreateFromBatch.java | 2 +- 24 files changed, 40 insertions(+), 56 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java index 6e6ab12249..213dbdcc82 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java @@ -186,7 +186,7 @@ public class CalloutInventory extends CalloutEngine } else { // gwu: 1719401: clear Booked Quantity to zero first in case the query returns no rows, // for example when the locator has never stored a particular product. - return new BigDecimal(0); + return Env.ZERO; } } catch (SQLException e) @@ -201,7 +201,7 @@ public class CalloutInventory extends CalloutEngine pstmt = null; } - return new BigDecimal(0); + return Env.ZERO; } diff --git a/org.adempiere.base.process/src/org/adempiere/process/ImmediateBankTransfer.java b/org.adempiere.base.process/src/org/adempiere/process/ImmediateBankTransfer.java index fcf56da70d..00c2c88ef5 100644 --- a/org.adempiere.base.process/src/org/adempiere/process/ImmediateBankTransfer.java +++ b/org.adempiere.base.process/src/org/adempiere/process/ImmediateBankTransfer.java @@ -70,7 +70,7 @@ public class ImmediateBankTransfer extends SvrProcess private String p_Name = ""; // Name private String p_Description= ""; // Description private int p_C_CashBook_ID = 0; // CashBook to be used as bridge - private BigDecimal p_Amount = new BigDecimal(0); // Amount to be transfered between the accounts + private BigDecimal p_Amount = Env.ZERO; // Amount to be transfered between the accounts private int p_From_C_BankAccount_ID = 0; // Bank Account From private int p_To_C_BankAccount_ID= 0; // Bank Account To private Timestamp p_StatementDate = null; // Date Statement @@ -134,7 +134,7 @@ public class ImmediateBankTransfer extends SvrProcess if (!isSameCurrency()) throw new AdempiereUserError ("Banks and CashBook must have same currency"); - if (p_Amount.compareTo(new BigDecimal(0)) == 0) + if (p_Amount.signum() == 0) throw new AdempiereUserError ("Amount required"); // Login Date diff --git a/org.adempiere.base.process/src/org/compiere/process/DunningRunCreate.java b/org.adempiere.base.process/src/org/compiere/process/DunningRunCreate.java index 3cd5aeb1c8..d4a7043f73 100644 --- a/org.adempiere.base.process/src/org/compiere/process/DunningRunCreate.java +++ b/org.adempiere.base.process/src/org/compiere/process/DunningRunCreate.java @@ -348,7 +348,7 @@ public class DunningRunCreate extends SvrProcess // MDunningRunLine line = new MDunningRunLine (entry); line.setInvoice(C_Invoice_ID, C_Currency_ID, GrandTotal, Open, - new BigDecimal(0), DaysDue, IsInDispute, TimesDunned, + Env.ZERO, DaysDue, IsInDispute, TimesDunned, DaysAfterLast); line.setC_InvoicePaySchedule_ID(C_InvoicePaySchedule_ID); if (!line.save()) @@ -497,7 +497,7 @@ public class DunningRunCreate extends SvrProcess line.setFee (p_C_Currency_ID, level.getFeeAmt()); if (!line.save()) throw new IllegalStateException("Cannot save MDunningRunLine"); - element.setQty (element.getQty ().subtract (new BigDecimal(1))); + element.setQty (element.getQty ().subtract (Env.ONE)); } } } // addFees diff --git a/org.adempiere.base.process/src/org/compiere/process/RfQCreateSO.java b/org.adempiere.base.process/src/org/compiere/process/RfQCreateSO.java index 1b3f69f812..f7c9ff976b 100644 --- a/org.adempiere.base.process/src/org/compiere/process/RfQCreateSO.java +++ b/org.adempiere.base.process/src/org/compiere/process/RfQCreateSO.java @@ -40,9 +40,6 @@ public class RfQCreateSO extends SvrProcess private int p_C_RfQ_ID = 0; private int p_C_DocType_ID = 0; - /** 100 */ - private static BigDecimal ONEHUNDRED = new BigDecimal (100); - /** * Prepare */ @@ -130,9 +127,9 @@ public class RfQCreateSO extends SvrProcess margin = rfq.getMargin(); if (margin != null && margin.signum() != 0) { - margin = margin.add(ONEHUNDRED); + margin = margin.add(Env.ONEHUNDRED); price = price.multiply(margin) - .divide(ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); + .divide(Env.ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); } } } // price diff --git a/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java b/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java index 50f2048d5c..2ccc945bd8 100644 --- a/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java +++ b/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java @@ -36,6 +36,7 @@ import org.compiere.util.AdempiereUserError; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.DisplayType; +import org.compiere.util.Env; import org.compiere.util.Trx; import org.compiere.util.ValueNamePair; @@ -119,7 +120,7 @@ public class UUIDGenerator extends SvrProcess { mColumn.setEntityType("U"); mColumn.setFieldLength(36); mColumn.setName(columnName); - mColumn.setVersion(new BigDecimal("1.00")); + mColumn.setVersion(Env.ONE); mColumn.saveEx(); syncColumn(mColumn); diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_Production.java b/org.adempiere.base/src/org/compiere/acct/Doc_Production.java index 0f0e2b9a98..7ca1f8c905 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_Production.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_Production.java @@ -193,7 +193,7 @@ public class Doc_Production extends Doc as.get_ID(), base.getAccount_ID(), 0,0,0,0,0,0,0,0,0,0,0,0,0,0); // // only post variance if it's not zero - if (variance.compareTo(new BigDecimal("0.00")) != 0) + if (variance.signum() != 0) { //post variance fl = fact.createLine(line, diff --git a/org.adempiere.base/src/org/compiere/model/MDepositBatch.java b/org.adempiere.base/src/org/compiere/model/MDepositBatch.java index 25f98965ff..5893e7511e 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepositBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MDepositBatch.java @@ -41,6 +41,7 @@ import java.util.Properties; import java.util.logging.Level; import org.compiere.util.DB; +import org.compiere.util.Env; /** * Deposit Batch Model @@ -69,7 +70,7 @@ public class MDepositBatch extends X_C_DepositBatch setDocStatus (DOCSTATUS_Drafted); setProcessed (false); setProcessing (false); - setDepositAmt(new BigDecimal(0)); + setDepositAmt(Env.ZERO); } } // MDepositBatch diff --git a/org.adempiere.base/src/org/compiere/model/MDiscountSchema.java b/org.adempiere.base/src/org/compiere/model/MDiscountSchema.java index fc92c73ca8..292baccabf 100644 --- a/org.adempiere.base/src/org/compiere/model/MDiscountSchema.java +++ b/org.adempiere.base/src/org/compiere/model/MDiscountSchema.java @@ -201,7 +201,7 @@ public class MDiscountSchema extends X_M_DiscountSchema if (discount == null || discount.signum() == 0) return Price; // - BigDecimal onehundred = new BigDecimal(100); + BigDecimal onehundred = Env.ONEHUNDRED; BigDecimal multiplier = (onehundred).subtract(discount); multiplier = multiplier.divide(onehundred, 6, BigDecimal.ROUND_HALF_UP); BigDecimal newPrice = Price.multiply(multiplier); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java b/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java index f8ee35109f..2006a6a74c 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java @@ -96,10 +96,6 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MInvoicePaySchedule.class); - /** 100 */ - private final static BigDecimal HUNDRED = new BigDecimal(100); - - /************************************************************************** * Standard Constructor * @param ctx context @@ -156,10 +152,10 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule else { due = due.multiply(paySchedule.getPercentage()) - .divide(HUNDRED, scale, BigDecimal.ROUND_HALF_UP); + .divide(Env.ONEHUNDRED, scale, BigDecimal.ROUND_HALF_UP); setDueAmt (due); BigDecimal discount = due.multiply(paySchedule.getDiscount()) - .divide(HUNDRED, scale, BigDecimal.ROUND_HALF_UP); + .divide(Env.ONEHUNDRED, scale, BigDecimal.ROUND_HALF_UP); setDiscountAmt (discount); setIsValid(true); } diff --git a/org.adempiere.base/src/org/compiere/model/MOrderLine.java b/org.adempiere.base/src/org/compiere/model/MOrderLine.java index 33104db73d..561125ab46 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrderLine.java +++ b/org.adempiere.base/src/org/compiere/model/MOrderLine.java @@ -720,7 +720,7 @@ public class MOrderLine extends X_C_OrderLine if (Env.ZERO.compareTo(list) == 0) return; BigDecimal discount = list.subtract(getPriceActual()) - .multiply(new BigDecimal(100)) + .multiply(Env.ONEHUNDRED) .divide(list, getPrecision(), BigDecimal.ROUND_HALF_UP); setDiscount(discount); } // setDiscount diff --git a/org.adempiere.base/src/org/compiere/model/MOrderPaySchedule.java b/org.adempiere.base/src/org/compiere/model/MOrderPaySchedule.java index ca029cec63..c02a527aa2 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrderPaySchedule.java +++ b/org.adempiere.base/src/org/compiere/model/MOrderPaySchedule.java @@ -96,10 +96,6 @@ public class MOrderPaySchedule extends X_C_OrderPaySchedule /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MOrderPaySchedule.class); - /** 100 */ - private final static BigDecimal HUNDRED = new BigDecimal(100); - - /************************************************************************** * Standard Constructor * @param ctx context @@ -156,10 +152,10 @@ public class MOrderPaySchedule extends X_C_OrderPaySchedule else { due = due.multiply(paySchedule.getPercentage()) - .divide(HUNDRED, scale, BigDecimal.ROUND_HALF_UP); + .divide(Env.ONEHUNDRED, scale, BigDecimal.ROUND_HALF_UP); setDueAmt (due); BigDecimal discount = due.multiply(paySchedule.getDiscount()) - .divide(HUNDRED, scale, BigDecimal.ROUND_HALF_UP); + .divide(Env.ONEHUNDRED, scale, BigDecimal.ROUND_HALF_UP); setDiscountAmt (discount); setIsValid(true); } diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java b/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java index 03ae3347ff..2f2da9ca9f 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java @@ -78,9 +78,6 @@ public class MPaymentTerm extends X_C_PaymentTerm super(ctx, rs, trxName); } // MPaymentTerm - /** 100 */ - private final static BigDecimal HUNDRED = new BigDecimal(100); - /** Payment Schedule children */ private MPaySchedule[] m_schedule; @@ -159,7 +156,7 @@ public class MPaymentTerm extends X_C_PaymentTerm if (percent != null) total = total.add(percent); } - boolean valid = total.compareTo(HUNDRED) == 0; + boolean valid = total.compareTo(Env.ONEHUNDRED) == 0; if (isValid() != valid) setIsValid (valid); for (int i = 0; i < m_schedule.length; i++) @@ -172,7 +169,7 @@ public class MPaymentTerm extends X_C_PaymentTerm } if (valid) return validMsg; - return "@Total@ = " + total + " - @Difference@ = " + HUNDRED.subtract(total); + return "@Total@ = " + total + " - @Difference@ = " + Env.ONEHUNDRED.subtract(total); } // validate diff --git a/org.adempiere.base/src/org/compiere/model/MRfQResponseLineQty.java b/org.adempiere.base/src/org/compiere/model/MRfQResponseLineQty.java index 28ea7556f4..57e1560c00 100644 --- a/org.adempiere.base/src/org/compiere/model/MRfQResponseLineQty.java +++ b/org.adempiere.base/src/org/compiere/model/MRfQResponseLineQty.java @@ -84,8 +84,6 @@ public class MRfQResponseLineQty extends X_C_RfQResponseLineQty implements Compa /** RfQ Line Qty */ private MRfQLineQty m_rfqQty = null; - /** 100 */ - private static BigDecimal ONEHUNDRED = new BigDecimal (100); /** * Get RfQ Line Qty @@ -114,7 +112,7 @@ public class MRfQResponseLineQty extends X_C_RfQResponseLineQty implements Compa BigDecimal discount = getDiscount(); if (discount != null) { - if (discount.abs().compareTo(ONEHUNDRED) > 0) + if (discount.abs().compareTo(Env.ONEHUNDRED) > 0) { log.warning("Discount > 100 - " + discount); return false; @@ -149,8 +147,8 @@ public class MRfQResponseLineQty extends X_C_RfQResponseLineQty implements Compa return price; // Calculate // double result = price.doubleValue() * (100.0 - discount.doubleValue()) / 100.0; - BigDecimal factor = ONEHUNDRED.subtract(discount); - return price.multiply(factor).divide(ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); + BigDecimal factor = Env.ONEHUNDRED.subtract(discount); + return price.multiply(factor).divide(Env.ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); } // getNetAmt diff --git a/org.adempiere.base/src/org/compiere/model/MTax.java b/org.adempiere.base/src/org/compiere/model/MTax.java index f3209da83d..2121ee92f6 100644 --- a/org.adempiere.base/src/org/compiere/model/MTax.java +++ b/org.adempiere.base/src/org/compiere/model/MTax.java @@ -48,8 +48,6 @@ public class MTax extends X_C_Tax /** Cache of Client */ private static CCache s_cacheAll = new CCache(Table_Name, Table_Name+"_Of_Client", 5); - /** 100 */ - private static BigDecimal ONEHUNDRED = new BigDecimal(100); /** Child Taxes */ private MTax[] m_childTaxes = null; /** Postal Codes */ @@ -258,7 +256,7 @@ public class MTax extends X_C_Tax if (isZeroTax()) return Env.ZERO; - BigDecimal multiplier = getRate().divide(ONEHUNDRED, 12, BigDecimal.ROUND_HALF_UP); + BigDecimal multiplier = getRate().divide(Env.ONEHUNDRED, 12, BigDecimal.ROUND_HALF_UP); BigDecimal tax = null; if (!taxIncluded) // $100 * 6 / 100 == $6 == $100 * 0.06 diff --git a/org.adempiere.base/src/org/eevolution/process/BankTransfer.java b/org.adempiere.base/src/org/eevolution/process/BankTransfer.java index c85a9f2374..88364f1ef7 100644 --- a/org.adempiere.base/src/org/eevolution/process/BankTransfer.java +++ b/org.adempiere.base/src/org/eevolution/process/BankTransfer.java @@ -44,7 +44,7 @@ public class BankTransfer extends SvrProcess private int p_C_ConversionType_ID = 0; // Payment Conversion Type private int p_C_Charge_ID = 0; // Charge to be used as bridge - private BigDecimal p_Amount = new BigDecimal(0); // Amount to be transfered between the accounts + private BigDecimal p_Amount = Env.ZERO; // Amount to be transfered between the accounts private int p_From_C_BankAccount_ID = 0; // Bank Account From private int p_To_C_BankAccount_ID= 0; // Bank Account To private Timestamp p_StatementDate = null; // Date Statement @@ -116,7 +116,7 @@ public class BankTransfer extends SvrProcess if (p_C_Charge_ID == 0) throw new AdempiereUserError ("Business Partner required"); - if (p_Amount.compareTo(new BigDecimal(0)) == 0) + if (p_Amount.signum() == 0) throw new AdempiereUserError ("Amount required"); // Login Date diff --git a/org.adempiere.extend/src/test/functional/MProductTest.java b/org.adempiere.extend/src/test/functional/MProductTest.java index e8331be2fb..0d16e87601 100644 --- a/org.adempiere.extend/src/test/functional/MProductTest.java +++ b/org.adempiere.extend/src/test/functional/MProductTest.java @@ -2,6 +2,7 @@ package test.functional; import org.compiere.model.MProductPrice; + import test.AdempiereTestCase; public class MProductTest extends AdempiereTestCase { @@ -86,7 +87,7 @@ public class MProductTest extends AdempiereTestCase { } public void testSetBaseInfo() { - MProductPricing prodprice = new MProductPricing(122,100, new BigDecimal (100),true); + MProductPricing prodprice = new MProductPricing(122,100, Env.ONEHUNDRED,true); int uom = 0; uom = prodprice.getC_UOM_ID(); assertTrue("UOM must be correct", uom == 100); diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeBOM.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeBOM.java index 31fdc58873..b6ca42300c 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeBOM.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeBOM.java @@ -567,7 +567,7 @@ public class VTreeBOM extends CPanel implements FormPanel, ActionListener, TreeS MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName()); KeyNamePair uom = new KeyNamePair(u.get_ID(), u.getUOMSymbol()); line.add(uom); // 3 C_UOM_ID - line.add((BigDecimal) ((bomline.getBOMQty()!=null) ? bomline.getBOMQty() : new BigDecimal(0))); // 4 QtyBOM + line.add((BigDecimal) ((bomline.getBOMQty()!=null) ? bomline.getBOMQty() : Env.ZERO)); // 4 QtyBOM DefaultMutableTreeNode child = new DefaultMutableTreeNode(line); parent.add(child); @@ -595,7 +595,7 @@ public class VTreeBOM extends CPanel implements FormPanel, ActionListener, TreeS MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName()); KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol()); line.add(uom); // 3 C_UOM_ID - line.add((BigDecimal) ((bom.getBOMQty()!=null) ? bom.getBOMQty() : new BigDecimal(0))); // 4 QtyBOM + line.add((BigDecimal) ((bom.getBOMQty()!=null) ? bom.getBOMQty() : Env.ZERO)); // 4 QtyBOM if(m_selected_id == bom.getM_ProductBOM_ID() || getM_Product_ID() == bom.getM_ProductBOM_ID()) dataBOM.add(line); diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedulePanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedulePanel.java index 3dec6b4dd6..f8fa7484d0 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedulePanel.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedulePanel.java @@ -27,7 +27,6 @@ import java.awt.event.MouseListener; import java.awt.font.LineBreakMeasurer; import java.awt.font.TextAttribute; import java.awt.font.TextLayout; -import java.math.BigDecimal; import java.sql.Timestamp; import java.text.AttributedCharacterIterator; import java.text.AttributedString; @@ -391,7 +390,7 @@ public class VSchedulePanel extends JComponent implements MouseListener ma.setS_Resource_ID(m_S_Resource_ID); ma.setAssignDateFrom(TimeUtil.getDayTime(TimeUtil.addDays(m_startDate, dayIndex), m_timePanel.getTimeSlot(timeIndex).getStartTime())); - ma.setQty(new BigDecimal(1)); + ma.setQty(Env.ONE); VAssignmentDialog vad = new VAssignmentDialog (AEnv.getFrame(this), ma, false, m_createNew); m_infoSchedule.mAssignmentCallback(vad.getMResourceAssignment()); return; diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java index 4991112692..d20864addf 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java @@ -717,7 +717,7 @@ public final class VNumber extends JComponent DecimalFormat format, int displayType, String title, char operator) { if (log.isLoggable(Level.CONFIG)) log.config("Value=" + value); - BigDecimal startValue = BigDecimal.valueOf(0.0); + BigDecimal startValue = Env.ZERO; try { if (value != null && value.length() > 0) diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/SubOrder.java b/org.adempiere.ui.swing/src/org/compiere/pos/SubOrder.java index 19dc73c1bc..9f9657c29f 100644 --- a/org.adempiere.ui.swing/src/org/compiere/pos/SubOrder.java +++ b/org.adempiere.ui.swing/src/org/compiere/pos/SubOrder.java @@ -569,7 +569,7 @@ public class SubOrder extends PosSubPanel if (p_posPanel != null && p_posPanel.f_curLine != null) { MOrder order = p_posPanel.f_curLine.getOrder(); - BigDecimal total = new BigDecimal(0); + BigDecimal total = Env.ZERO; if (order != null) total = order.getGrandTotal(); paid = given.doubleValue() >= total.doubleValue(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WBOMDrop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WBOMDrop.java index 01ba67c4d1..e0bc8b2f1f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WBOMDrop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WBOMDrop.java @@ -207,7 +207,7 @@ public class WBOMDrop extends ADForm implements EventListener Label lblProduct = new Label(Msg.translate(Env.getCtx(), "M_Product_ID")); Label lblQty = new Label(Msg.translate(Env.getCtx(), "Qty")); - productQty.setValue(new BigDecimal(1)); + productQty.setValue(Env.ONE); productField.addEventListener(Events.ON_SELECT, this); productQty.addEventListener(Events.ON_CHANGE, this); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeBOM.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeBOM.java index 13d96a936b..35020df4c9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeBOM.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeBOM.java @@ -319,7 +319,7 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener< MUOM u = new MUOM(product.getCtx(), product.getC_UOM_ID(), product.get_TrxName()); KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol()); line.add(uom); // 3 C_UOM_ID - line.add((BigDecimal) (new BigDecimal(1)).setScale(4, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); // 4 QtyBOM + line.add((BigDecimal) (Env.ONE).setScale(4, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); // 4 QtyBOM // dummy root node, as first node is not displayed in tree mySimpleTreeNode parent = new mySimpleTreeNode("Root",new ArrayList>()); @@ -441,7 +441,7 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener< MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName()); KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol()); line.add(uom); // 3 C_UOM_ID - line.add((BigDecimal) ((bomline.getBOMQty()!=null) ? bomline.getBOMQty() : new BigDecimal(0)).setScale(4, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); // 4 QtyBOM + line.add((BigDecimal) ((bomline.getBOMQty()!=null) ? bomline.getBOMQty() : Env.ZERO).setScale(4, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); // 4 QtyBOM mySimpleTreeNode child = new mySimpleTreeNode(line,new ArrayList>()); if (!reload) @@ -470,7 +470,7 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener< MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName()); KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol()); line.add(uom); // 3 C_UOM_ID - line.add((BigDecimal) ((bom.getBOMQty()!=null) ? bom.getBOMQty() : new BigDecimal(0)).setScale(4, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); // 4 QtyBOM + line.add((BigDecimal) ((bom.getBOMQty()!=null) ? bom.getBOMQty() : Env.ZERO).setScale(4, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); // 4 QtyBOM if(m_selected_id == bom.getM_ProductBOM_ID() || getM_Product_ID() == bom.getM_ProductBOM_ID()) dataBOM.add(line); diff --git a/org.adempiere.ui/src/org/compiere/apps/form/StatementCreateFromBatch.java b/org.adempiere.ui/src/org/compiere/apps/form/StatementCreateFromBatch.java index dd73dbef06..e47c5cb615 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/StatementCreateFromBatch.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/StatementCreateFromBatch.java @@ -341,7 +341,7 @@ public abstract class StatementCreateFromBatch extends CreateFromForm public void info(IMiniTable miniTable, IStatusBar statusBar) { DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount); - BigDecimal total = new BigDecimal(0); + BigDecimal total = Env.ZERO; int rows = miniTable.getRowCount(); int count = 0; for(int i = 0; i < rows; i++) diff --git a/org.adempiere.ui/src/org/compiere/grid/CreateFromBatch.java b/org.adempiere.ui/src/org/compiere/grid/CreateFromBatch.java index eddc7cf373..882bdc884e 100644 --- a/org.adempiere.ui/src/org/compiere/grid/CreateFromBatch.java +++ b/org.adempiere.ui/src/org/compiere/grid/CreateFromBatch.java @@ -166,7 +166,7 @@ public abstract class CreateFromBatch extends CreateFrom public void info(IMiniTable miniTable, IStatusBar statusBar) { DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount); - BigDecimal total = new BigDecimal(0); + BigDecimal total = Env.ZERO; int rows = miniTable.getRowCount(); int count = 0; for(int i = 0; i < rows; i++) From 8ec9d58deb55ec4416eb3d35007d5916e0495758 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 9 Apr 2013 21:08:31 -0500 Subject: [PATCH 5/6] IDEMPIERE-843 Negative values are not evaluated in Tab Editor --- .../oracle/201304092105_IDEMPIERE-843.sql | 16 +++++ .../postgresql/201304092105_IDEMPIERE-843.sql | 16 +++++ .../src/org/compiere/model/PO.java | 59 ++++++++++++------- .../adempiere/webui/apps/form/WTabEditor.java | 4 +- 4 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 migration/i1.0a-release/oracle/201304092105_IDEMPIERE-843.sql create mode 100644 migration/i1.0a-release/postgresql/201304092105_IDEMPIERE-843.sql diff --git a/migration/i1.0a-release/oracle/201304092105_IDEMPIERE-843.sql b/migration/i1.0a-release/oracle/201304092105_IDEMPIERE-843.sql new file mode 100644 index 0000000000..a44454f2aa --- /dev/null +++ b/migration/i1.0a-release/oracle/201304092105_IDEMPIERE-843.sql @@ -0,0 +1,16 @@ +-- Apr 9, 2013 8:52:09 PM COT +-- IDEMPIERE-843 Negative values are not evaluated in Tab Editor +UPDATE AD_Column SET ValueMin='1',Updated=TO_DATE('2013-04-09 20:52:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200351 +; + +-- Apr 9, 2013 8:52:37 PM COT +UPDATE AD_Column SET ValueMin='1',Updated=TO_DATE('2013-04-09 20:52:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200352 +; + +-- Apr 9, 2013 8:53:07 PM COT +UPDATE AD_Column SET ValueMin='1',Updated=TO_DATE('2013-04-09 20:53:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200354 +; + +SELECT register_migration_script('201304092105_IDEMPIERE-843.sql') FROM dual +; + diff --git a/migration/i1.0a-release/postgresql/201304092105_IDEMPIERE-843.sql b/migration/i1.0a-release/postgresql/201304092105_IDEMPIERE-843.sql new file mode 100644 index 0000000000..d49596bc66 --- /dev/null +++ b/migration/i1.0a-release/postgresql/201304092105_IDEMPIERE-843.sql @@ -0,0 +1,16 @@ +-- Apr 9, 2013 8:52:09 PM COT +-- IDEMPIERE-843 Negative values are not evaluated in Tab Editor +UPDATE AD_Column SET ValueMin='1',Updated=TO_TIMESTAMP('2013-04-09 20:52:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200351 +; + +-- Apr 9, 2013 8:52:37 PM COT +UPDATE AD_Column SET ValueMin='1',Updated=TO_TIMESTAMP('2013-04-09 20:52:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200352 +; + +-- Apr 9, 2013 8:53:07 PM COT +UPDATE AD_Column SET ValueMin='1',Updated=TO_TIMESTAMP('2013-04-09 20:53:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200354 +; + +SELECT register_migration_script('201304092105_IDEMPIERE-843.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index 1117783c2d..32079e01e3 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -102,12 +102,12 @@ import org.w3c.dom.Element; public abstract class PO implements Serializable, Comparator, Evaluatee, Cloneable { - public static final String LOCAL_TRX_PREFIX = "POSave"; - /** - * + * */ - private static final long serialVersionUID = 6604764467216189092L; + private static final long serialVersionUID = 8742545079591136114L; + + public static final String LOCAL_TRX_PREFIX = "POSave"; private static final String USE_TIMEOUT_FOR_UPDATE = "org.adempiere.po.useTimeoutForUpdate"; @@ -196,6 +196,7 @@ public abstract class PO int size = p_info.getColumnCount(); m_oldValues = new Object[size]; m_newValues = new Object[size]; + m_setErrors = new ValueNamePair[size]; if (rs != null) load(rs); // will not have virtual columns @@ -235,6 +236,8 @@ public abstract class PO private Object[] m_oldValues = null; /** New Values */ private Object[] m_newValues = null; + /** Errors when setting */ + private ValueNamePair[] m_setErrors = null; /** Record_IDs */ private Object[] m_IDs = new Object[] {I_ZERO}; @@ -763,12 +766,14 @@ public abstract class PO String ColumnName = p_info.getColumnName(index); String colInfo = " - " + ColumnName; // + m_setErrors[index] = null; if (checkWritable) { if (p_info.isVirtualColumn(index)) { log.log(Level.WARNING, "Virtual Column" + colInfo); log.saveError("VirtualColumn", "Virtual Column" + colInfo); + m_setErrors[index] = new ValueNamePair("VirtualColumn", "Virtual Column" + colInfo); return false; } @@ -780,6 +785,7 @@ public abstract class PO colInfo += " - NewValue=" + value + " - OldValue=" + get_Value(index); log.log(Level.WARNING, "Column not updateable" + colInfo); log.saveError("ColumnReadonly", "Column not updateable" + colInfo); + m_setErrors[index] = new ValueNamePair("ColumnReadonly", "Column not updateable" + colInfo); return false; } } @@ -789,7 +795,8 @@ public abstract class PO if (checkWritable && p_info.isColumnMandatory(index)) { log.saveError("FillMandatory", ColumnName + " is mandatory."); - throw new IllegalArgumentException (ColumnName + " is mandatory."); + m_setErrors[index] = new ValueNamePair("FillMandatory", ColumnName + " is mandatory."); + return false; } m_newValues[index] = Null.NULL; // correct if (log.isLoggable(Level.FINER)) log.finer(ColumnName + " = null"); @@ -823,22 +830,22 @@ public abstract class PO } catch (NumberFormatException e) { - log.log(Level.SEVERE, ColumnName - + " - Class invalid: " + value.getClass().toString() - + ", Should be " + p_info.getColumnClass(index).toString() + ": " + value); - log.saveError("WrongDataType", ColumnName + String errmsg = ColumnName + " - Class invalid: " + value.getClass().toString() - + ", Should be " + p_info.getColumnClass(index).toString() + ": " + value); + + ", Should be " + p_info.getColumnClass(index).toString() + ": " + value; + log.log(Level.SEVERE, errmsg); + log.saveError("WrongDataType", errmsg); + m_setErrors[index] = new ValueNamePair("WrongDataType", errmsg); return false; } else { - log.log(Level.SEVERE, ColumnName - + " - Class invalid: " + value.getClass().toString() - + ", Should be " + p_info.getColumnClass(index).toString() + ": " + value); - log.saveError("WrongDataType", ColumnName + String errmsg = ColumnName + " - Class invalid: " + value.getClass().toString() - + ", Should be " + p_info.getColumnClass(index).toString() + ": " + value); + + ", Should be " + p_info.getColumnClass(index).toString() + ": " + value; + log.log(Level.SEVERE, errmsg); + log.saveError("WrongDataType", errmsg); + m_setErrors[index] = new ValueNamePair("WrongDataType", errmsg); return false; } // Validate (Min/Max) @@ -849,8 +856,10 @@ public abstract class PO int separatorIndex = error.indexOf(";"); if (separatorIndex > 0) { log.saveError(error.substring(0,separatorIndex), error.substring(separatorIndex+1)); + m_setErrors[index] = new ValueNamePair(error.substring(0,separatorIndex), error.substring(separatorIndex+1)); } else { log.saveError(error, ColumnName); + m_setErrors[index] = new ValueNamePair(error, ColumnName); } return false; } @@ -876,10 +885,11 @@ public abstract class PO StringBuilder validValues = new StringBuilder(); for (ValueNamePair vp : MRefList.getList(getCtx(), p_info.getColumn(index).AD_Reference_Value_ID, false)) validValues.append(" - ").append(vp.getValue()); - log.saveError("Validate", ColumnName + " Invalid value - " - + value + " - Reference_ID=" + p_info.getColumn(index).AD_Reference_Value_ID + validValues.toString()); - throw new IllegalArgumentException(ColumnName + " Invalid value - " - + value + " - Reference_ID=" + p_info.getColumn(index).AD_Reference_Value_ID + validValues.toString()); + String errmsg = ColumnName + " Invalid value - " + + value + " - Reference_ID=" + p_info.getColumn(index).AD_Reference_Value_ID + validValues.toString(); + log.saveError("Validate", errmsg); + m_setErrors[index] = new ValueNamePair("Validate", errmsg); + return false; } } if (log.isLoggable(Level.FINEST)) log.finest(ColumnName + " = " + m_newValues[index] + " (OldValue="+m_oldValues[index]+")"); @@ -1952,6 +1962,14 @@ public abstract class PO if (log.isLoggable(Level.FINE)) log.fine("Nothing changed - " + p_info.getTableName()); return true; } + + for (int i = 0; i < m_setErrors.length; i++) { + ValueNamePair setError = m_setErrors[i]; + if (setError != null) { + log.saveError(setError.getValue(), Msg.getElement(getCtx(), p_info.getColumnName(i)) + " - " + setError.getName()); + return false; + } + } // Organization Check if (getAD_Org_ID() == 0 @@ -2156,8 +2174,9 @@ public abstract class PO if (!save()) { String msg = null; ValueNamePair err = CLogger.retrieveError(); + String val = Msg.translate(getCtx(), err.getValue()); if (err != null) - msg = err.getName(); + msg = (val != null ? val + ": " : "") + err.getName(); if (msg == null || msg.length() == 0) msg = "SaveError"; throw new AdempiereException(msg); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTabEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTabEditor.java index ef824a5336..c99066a10b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTabEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTabEditor.java @@ -810,7 +810,9 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe } else if (MField.COLUMNNAME_XPosition.equals(propertyName)) { field.setXPosition(intvalue); } else if (MField.COLUMNNAME_ColumnSpan.equals(propertyName)) { - field.setColumnSpan(intvalue); + int prevcolspan = field.getColumnSpan(); + if (!field.set_ValueOfColumnReturningBoolean(MField.COLUMNNAME_ColumnSpan, intvalue)) + field.setColumnSpan(prevcolspan); } else if (MField.COLUMNNAME_NumLines.equals(propertyName)) { field.setNumLines(intvalue); } From 019dc77fc59d2d483b7e92643b1211b1cd7348fb Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 9 Apr 2013 21:45:24 -0500 Subject: [PATCH 6/6] IDEMPIERE-845 Reference List not allowing to clear --- .../WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java index 4fe8993911..a84906432f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java @@ -244,6 +244,8 @@ ContextMenuListener, IZoomableEditor retVal = selItem.getValue(); if ((retVal instanceof Integer) && (Integer)retVal == -1) retVal = null; + else if ((retVal instanceof String) && "".equals(retVal)) + retVal = null; } return retVal; }