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++)