From 01a9897cc11436a1f4c78da66da5f17085ec3ba5 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 9 Apr 2013 18:09:44 -0500 Subject: [PATCH] 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++)