IDEMPIERE-3798:Move iDempiere default branch to openjdk 10 (warning deprecated of constructer)

constance of BigDecimal move to RoundingMode
This commit is contained in:
hieplq 2018-10-24 09:48:52 +07:00
parent cfa2705b25
commit 61a5fd1c21
87 changed files with 285 additions and 200 deletions

View File

@ -18,6 +18,7 @@
package org.adempiere.model; package org.adempiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Properties; import java.util.Properties;
import org.adempiere.base.Core; import org.adempiere.base.Core;
@ -101,7 +102,7 @@ public class CalloutRMA extends CalloutEngine {
BigDecimal lineNetAmt = invoiceLine.getQtyEntered().multiply(invoiceLine.getPriceEntered()); BigDecimal lineNetAmt = invoiceLine.getQtyEntered().multiply(invoiceLine.getPriceEntered());
int precision = invoiceLine.getPrecision(); int precision = invoiceLine.getPrecision();
if (lineNetAmt.scale() > precision) if (lineNetAmt.scale() > precision)
lineNetAmt = lineNetAmt.setScale(precision, BigDecimal.ROUND_HALF_UP); lineNetAmt = lineNetAmt.setScale(precision, RoundingMode.HALF_UP);
mTab.setValue(MRMALine.COLUMNNAME_LineNetAmt, lineNetAmt); mTab.setValue(MRMALine.COLUMNNAME_LineNetAmt, lineNetAmt);
} }
else if (iol.getC_OrderLine_ID() != 0) else if (iol.getC_OrderLine_ID() != 0)
@ -122,7 +123,7 @@ public class CalloutRMA extends CalloutEngine {
BigDecimal lineNetAmt = orderLine.getQtyEntered().multiply(orderLine.getPriceEntered()); BigDecimal lineNetAmt = orderLine.getQtyEntered().multiply(orderLine.getPriceEntered());
int precision = orderLine.getPrecision(); int precision = orderLine.getPrecision();
if (lineNetAmt.scale() > precision) if (lineNetAmt.scale() > precision)
lineNetAmt = lineNetAmt.setScale(precision, BigDecimal.ROUND_HALF_UP); lineNetAmt = lineNetAmt.setScale(precision, RoundingMode.HALF_UP);
mTab.setValue(MRMALine.COLUMNNAME_LineNetAmt, lineNetAmt); mTab.setValue(MRMALine.COLUMNNAME_LineNetAmt, lineNetAmt);
} }
@ -193,7 +194,7 @@ public class CalloutRMA extends CalloutEngine {
BigDecimal lineNetAmt = Env.ONE.multiply(pp.getPriceStd()); BigDecimal lineNetAmt = Env.ONE.multiply(pp.getPriceStd());
if (lineNetAmt.scale() > precision) if (lineNetAmt.scale() > precision)
lineNetAmt = lineNetAmt.setScale(precision, BigDecimal.ROUND_HALF_UP); lineNetAmt = lineNetAmt.setScale(precision, RoundingMode.HALF_UP);
mTab.setValue(MRMALine.COLUMNNAME_LineNetAmt, lineNetAmt); mTab.setValue(MRMALine.COLUMNNAME_LineNetAmt, lineNetAmt);
return ""; return "";
@ -246,7 +247,7 @@ public class CalloutRMA extends CalloutEngine {
BigDecimal lineNetAmt = Env.ONE.multiply(charge.getChargeAmt()); BigDecimal lineNetAmt = Env.ONE.multiply(charge.getChargeAmt());
if (lineNetAmt.scale() > precision) if (lineNetAmt.scale() > precision)
lineNetAmt = lineNetAmt.setScale(precision, BigDecimal.ROUND_HALF_UP); lineNetAmt = lineNetAmt.setScale(precision, RoundingMode.HALF_UP);
mTab.setValue(MRMALine.COLUMNNAME_LineNetAmt, lineNetAmt); mTab.setValue(MRMALine.COLUMNNAME_LineNetAmt, lineNetAmt);
return ""; return "";

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -222,10 +223,10 @@ public class CalloutGLJournal extends CalloutEngine
AmtSourceCr = Env.ZERO; AmtSourceCr = Env.ZERO;
BigDecimal AmtAcctDr = AmtSourceDr.multiply(CurrencyRate); BigDecimal AmtAcctDr = AmtSourceDr.multiply(CurrencyRate);
AmtAcctDr = AmtAcctDr.setScale(Precision, BigDecimal.ROUND_HALF_UP); AmtAcctDr = AmtAcctDr.setScale(Precision, RoundingMode.HALF_UP);
mTab.setValue("AmtAcctDr", AmtAcctDr); mTab.setValue("AmtAcctDr", AmtAcctDr);
BigDecimal AmtAcctCr = AmtSourceCr.multiply(CurrencyRate); BigDecimal AmtAcctCr = AmtSourceCr.multiply(CurrencyRate);
AmtAcctCr = AmtAcctCr.setScale(Precision, BigDecimal.ROUND_HALF_UP); AmtAcctCr = AmtAcctCr.setScale(Precision, RoundingMode.HALF_UP);
mTab.setValue("AmtAcctCr", AmtAcctCr); mTab.setValue("AmtAcctCr", AmtAcctCr);
return ""; return "";

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -439,7 +440,7 @@ public class CalloutInOut extends CalloutEngine
BigDecimal QtyEntered = MovementQty; BigDecimal QtyEntered = MovementQty;
if (ol.getQtyEntered().compareTo(ol.getQtyOrdered()) != 0) if (ol.getQtyEntered().compareTo(ol.getQtyOrdered()) != 0)
QtyEntered = QtyEntered.multiply(ol.getQtyEntered()) QtyEntered = QtyEntered.multiply(ol.getQtyEntered())
.divide(ol.getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP); .divide(ol.getQtyOrdered(), 12, RoundingMode.HALF_UP);
mTab.setValue("QtyEntered", QtyEntered); mTab.setValue("QtyEntered", QtyEntered);
// //
mTab.setValue("C_Activity_ID", Integer.valueOf(ol.getC_Activity_ID())); mTab.setValue("C_Activity_ID", Integer.valueOf(ol.getC_Activity_ID()));
@ -591,7 +592,7 @@ public class CalloutInOut extends CalloutEngine
{ {
int C_UOM_To_ID = ((Integer)value).intValue(); int C_UOM_To_ID = ((Integer)value).intValue();
QtyEntered = (BigDecimal)mTab.getValue("QtyEntered"); QtyEntered = (BigDecimal)mTab.getValue("QtyEntered");
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP); BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), RoundingMode.HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0) if (QtyEntered.compareTo(QtyEntered1) != 0)
{ {
if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
@ -622,7 +623,7 @@ public class CalloutInOut extends CalloutEngine
{ {
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID"); int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID");
QtyEntered = (BigDecimal)value; QtyEntered = (BigDecimal)value;
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP); BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), RoundingMode.HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0) if (QtyEntered.compareTo(QtyEntered1) != 0)
{ {
if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
@ -648,7 +649,7 @@ public class CalloutInOut extends CalloutEngine
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID"); int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID");
MovementQty = (BigDecimal)value; MovementQty = (BigDecimal)value;
int precision = MProduct.get(ctx, M_Product_ID).getUOMPrecision(); int precision = MProduct.get(ctx, M_Product_ID).getUOMPrecision();
BigDecimal MovementQty1 = MovementQty.setScale(precision, BigDecimal.ROUND_HALF_UP); BigDecimal MovementQty1 = MovementQty.setScale(precision, RoundingMode.HALF_UP);
if (MovementQty.compareTo(MovementQty1) != 0) if (MovementQty.compareTo(MovementQty1) != 0)
{ {
if (log.isLoggable(Level.FINE)) log.fine("Corrected MovementQty " if (log.isLoggable(Level.FINE)) log.fine("Corrected MovementQty "

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -618,7 +619,7 @@ public class CalloutInvoice extends CalloutEngine
{ {
PriceActual = new BigDecimal ((100.0 - Discount.doubleValue()) / 100.0 * PriceList.doubleValue()); PriceActual = new BigDecimal ((100.0 - Discount.doubleValue()) / 100.0 * PriceList.doubleValue());
if (PriceActual.scale() > StdPrecision) if (PriceActual.scale() > StdPrecision)
PriceActual = PriceActual.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); PriceActual = PriceActual.setScale(StdPrecision, RoundingMode.HALF_UP);
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, PriceActual); C_UOM_To_ID, PriceActual);
if (PriceEntered == null) if (PriceEntered == null)
@ -634,7 +635,7 @@ public class CalloutInvoice extends CalloutEngine
else else
Discount = new BigDecimal ((PriceList.doubleValue() - PriceActual.doubleValue()) / PriceList.doubleValue() * 100.0); Discount = new BigDecimal ((PriceList.doubleValue() - PriceActual.doubleValue()) / PriceList.doubleValue() * 100.0);
if (Discount.scale() > 2) if (Discount.scale() > 2)
Discount = Discount.setScale(2, BigDecimal.ROUND_HALF_UP); Discount = Discount.setScale(2, RoundingMode.HALF_UP);
mTab.setValue("Discount", Discount); mTab.setValue("Discount", Discount);
} }
log.fine("amt = PriceEntered=" + PriceEntered + ", Actual" + PriceActual + ", Discount=" + Discount); log.fine("amt = PriceEntered=" + PriceEntered + ", Actual" + PriceActual + ", Discount=" + Discount);
@ -663,7 +664,7 @@ public class CalloutInvoice extends CalloutEngine
{ {
Discount = BigDecimal.valueOf((PriceList.doubleValue () - PriceActual.doubleValue ()) / PriceList.doubleValue () * 100.0); Discount = BigDecimal.valueOf((PriceList.doubleValue () - PriceActual.doubleValue ()) / PriceList.doubleValue () * 100.0);
if (Discount.scale () > 2) if (Discount.scale () > 2)
Discount = Discount.setScale (2, BigDecimal.ROUND_HALF_UP); Discount = Discount.setScale (2, RoundingMode.HALF_UP);
// mTab.setValue ("Discount", Discount); // mTab.setValue ("Discount", Discount);
} }
} }
@ -671,7 +672,7 @@ public class CalloutInvoice extends CalloutEngine
// Line Net Amt // Line Net Amt
BigDecimal LineNetAmt = QtyInvoiced.multiply(PriceActual); BigDecimal LineNetAmt = QtyInvoiced.multiply(PriceActual);
if (LineNetAmt.scale() > StdPrecision) if (LineNetAmt.scale() > StdPrecision)
LineNetAmt = LineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); LineNetAmt = LineNetAmt.setScale(StdPrecision, RoundingMode.HALF_UP);
if (log.isLoggable(Level.INFO)) log.info("amt = LineNetAmt=" + LineNetAmt); if (log.isLoggable(Level.INFO)) log.info("amt = LineNetAmt=" + LineNetAmt);
mTab.setValue("LineNetAmt", LineNetAmt); mTab.setValue("LineNetAmt", LineNetAmt);
@ -757,7 +758,7 @@ public class CalloutInvoice extends CalloutEngine
{ {
int C_UOM_To_ID = ((Integer)value).intValue(); int C_UOM_To_ID = ((Integer)value).intValue();
QtyEntered = (BigDecimal)mTab.getValue("QtyEntered"); QtyEntered = (BigDecimal)mTab.getValue("QtyEntered");
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP); BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), RoundingMode.HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0) if (QtyEntered.compareTo(QtyEntered1) != 0)
{ {
if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
@ -788,7 +789,7 @@ public class CalloutInvoice extends CalloutEngine
{ {
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID"); int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID");
QtyEntered = (BigDecimal)value; QtyEntered = (BigDecimal)value;
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP); BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), RoundingMode.HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0) if (QtyEntered.compareTo(QtyEntered1) != 0)
{ {
if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
@ -814,7 +815,7 @@ public class CalloutInvoice extends CalloutEngine
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID"); int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID");
QtyInvoiced = (BigDecimal)value; QtyInvoiced = (BigDecimal)value;
int precision = MProduct.get(ctx, M_Product_ID).getUOMPrecision(); int precision = MProduct.get(ctx, M_Product_ID).getUOMPrecision();
BigDecimal QtyInvoiced1 = QtyInvoiced.setScale(precision, BigDecimal.ROUND_HALF_UP); BigDecimal QtyInvoiced1 = QtyInvoiced.setScale(precision, RoundingMode.HALF_UP);
if (QtyInvoiced.compareTo(QtyInvoiced1) != 0) if (QtyInvoiced.compareTo(QtyInvoiced1) != 0)
{ {
if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyInvoiced Scale " if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyInvoiced Scale "

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -360,7 +361,7 @@ public class CalloutInvoiceBatch extends CalloutEngine
// Line Net Amt // Line Net Amt
BigDecimal LineNetAmt = QtyEntered.multiply(PriceEntered); BigDecimal LineNetAmt = QtyEntered.multiply(PriceEntered);
if (LineNetAmt.scale() > StdPrecision) if (LineNetAmt.scale() > StdPrecision)
LineNetAmt = LineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); LineNetAmt = LineNetAmt.setScale(StdPrecision, RoundingMode.HALF_UP);
// Calculate Tax Amount // Calculate Tax Amount
boolean IsTaxIncluded = "Y".equals(Env.getContext(Env.getCtx(), WindowNo, "IsTaxIncluded")); boolean IsTaxIncluded = "Y".equals(Env.getContext(Env.getCtx(), WindowNo, "IsTaxIncluded"));

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -1119,7 +1120,7 @@ public class CalloutOrder extends CalloutEngine
if ( PriceList.doubleValue() != 0 ) if ( PriceList.doubleValue() != 0 )
PriceActual = BigDecimal.valueOf((100.0 - Discount.doubleValue()) / 100.0 * PriceList.doubleValue()); PriceActual = BigDecimal.valueOf((100.0 - Discount.doubleValue()) / 100.0 * PriceList.doubleValue());
if (PriceActual.scale() > StdPrecision) if (PriceActual.scale() > StdPrecision)
PriceActual = PriceActual.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); PriceActual = PriceActual.setScale(StdPrecision, RoundingMode.HALF_UP);
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, PriceActual); C_UOM_To_ID, PriceActual);
if (PriceEntered == null) if (PriceEntered == null)
@ -1135,7 +1136,7 @@ public class CalloutOrder extends CalloutEngine
else else
Discount = BigDecimal.valueOf((PriceList.doubleValue() - PriceActual.doubleValue()) / PriceList.doubleValue() * 100.0); Discount = BigDecimal.valueOf((PriceList.doubleValue() - PriceActual.doubleValue()) / PriceList.doubleValue() * 100.0);
if (Discount.scale() > 2) if (Discount.scale() > 2)
Discount = Discount.setScale(2, BigDecimal.ROUND_HALF_UP); Discount = Discount.setScale(2, RoundingMode.HALF_UP);
mTab.setValue("Discount", Discount); mTab.setValue("Discount", Discount);
} }
if (log.isLoggable(Level.FINE)) log.fine("PriceEntered=" + PriceEntered + ", Actual=" + PriceActual + ", Discount=" + Discount); if (log.isLoggable(Level.FINE)) log.fine("PriceEntered=" + PriceEntered + ", Actual=" + PriceActual + ", Discount=" + Discount);
@ -1163,7 +1164,7 @@ public class CalloutOrder extends CalloutEngine
{ {
Discount = BigDecimal.valueOf((PriceList.doubleValue () - PriceActual.doubleValue ()) / PriceList.doubleValue () * 100.0); Discount = BigDecimal.valueOf((PriceList.doubleValue () - PriceActual.doubleValue ()) / PriceList.doubleValue () * 100.0);
if (Discount.scale () > 2) if (Discount.scale () > 2)
Discount = Discount.setScale (2, BigDecimal.ROUND_HALF_UP); Discount = Discount.setScale (2, RoundingMode.HALF_UP);
mTab.setValue ("Discount", Discount); mTab.setValue ("Discount", Discount);
} }
} }
@ -1171,7 +1172,7 @@ public class CalloutOrder extends CalloutEngine
// Line Net Amt // Line Net Amt
BigDecimal LineNetAmt = QtyOrdered.multiply(PriceActual); BigDecimal LineNetAmt = QtyOrdered.multiply(PriceActual);
if (LineNetAmt.scale() > StdPrecision) if (LineNetAmt.scale() > StdPrecision)
LineNetAmt = LineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); LineNetAmt = LineNetAmt.setScale(StdPrecision, RoundingMode.HALF_UP);
if (log.isLoggable(Level.INFO)) log.info("LineNetAmt=" + LineNetAmt); if (log.isLoggable(Level.INFO)) log.info("LineNetAmt=" + LineNetAmt);
mTab.setValue("LineNetAmt", LineNetAmt); mTab.setValue("LineNetAmt", LineNetAmt);
// //
@ -1210,7 +1211,7 @@ public class CalloutOrder extends CalloutEngine
{ {
int C_UOM_To_ID = ((Integer)value).intValue(); int C_UOM_To_ID = ((Integer)value).intValue();
QtyEntered = (BigDecimal)mTab.getValue("QtyEntered"); QtyEntered = (BigDecimal)mTab.getValue("QtyEntered");
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP); BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), RoundingMode.HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0) if (QtyEntered.compareTo(QtyEntered1) != 0)
{ {
if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
@ -1241,7 +1242,7 @@ public class CalloutOrder extends CalloutEngine
{ {
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID"); int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID");
QtyEntered = (BigDecimal)value; QtyEntered = (BigDecimal)value;
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP); BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), RoundingMode.HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0) if (QtyEntered.compareTo(QtyEntered1) != 0)
{ {
if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
@ -1267,7 +1268,7 @@ public class CalloutOrder extends CalloutEngine
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID"); int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID");
QtyOrdered = (BigDecimal)value; QtyOrdered = (BigDecimal)value;
int precision = MProduct.get(ctx, M_Product_ID).getUOMPrecision(); int precision = MProduct.get(ctx, M_Product_ID).getUOMPrecision();
BigDecimal QtyOrdered1 = QtyOrdered.setScale(precision, BigDecimal.ROUND_HALF_UP); BigDecimal QtyOrdered1 = QtyOrdered.setScale(precision, RoundingMode.HALF_UP);
if (QtyOrdered.compareTo(QtyOrdered1) != 0) if (QtyOrdered.compareTo(QtyOrdered1) != 0)
{ {
if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyOrdered Scale " if (log.isLoggable(Level.FINE)) log.fine("Corrected QtyOrdered Scale "

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -411,7 +412,7 @@ public class CalloutPayment extends CalloutEngine
} }
// //
InvoiceOpenAmt = InvoiceOpenAmt.multiply (CurrencyRate).setScale ( InvoiceOpenAmt = InvoiceOpenAmt.multiply (CurrencyRate).setScale (
currency.getStdPrecision (), BigDecimal.ROUND_HALF_UP); currency.getStdPrecision (), RoundingMode.HALF_UP);
if (log.isLoggable(Level.FINE)) log.fine ("Rate=" + CurrencyRate + ", InvoiceOpenAmt=" if (log.isLoggable(Level.FINE)) log.fine ("Rate=" + CurrencyRate + ", InvoiceOpenAmt="
+ InvoiceOpenAmt); + InvoiceOpenAmt);
} }
@ -420,16 +421,16 @@ public class CalloutPayment extends CalloutEngine
|| colName.equals ("C_ConversionType_ID")) || colName.equals ("C_ConversionType_ID"))
{ {
PayAmt = PayAmt.multiply (CurrencyRate).setScale ( PayAmt = PayAmt.multiply (CurrencyRate).setScale (
currency.getStdPrecision (), BigDecimal.ROUND_HALF_UP); currency.getStdPrecision (), RoundingMode.HALF_UP);
mTab.setValue ("PayAmt", PayAmt); mTab.setValue ("PayAmt", PayAmt);
DiscountAmt = DiscountAmt.multiply (CurrencyRate).setScale ( DiscountAmt = DiscountAmt.multiply (CurrencyRate).setScale (
currency.getStdPrecision (), BigDecimal.ROUND_HALF_UP); currency.getStdPrecision (), RoundingMode.HALF_UP);
mTab.setValue ("DiscountAmt", DiscountAmt); mTab.setValue ("DiscountAmt", DiscountAmt);
WriteOffAmt = WriteOffAmt.multiply (CurrencyRate).setScale ( WriteOffAmt = WriteOffAmt.multiply (CurrencyRate).setScale (
currency.getStdPrecision (), BigDecimal.ROUND_HALF_UP); currency.getStdPrecision (), RoundingMode.HALF_UP);
mTab.setValue ("WriteOffAmt", WriteOffAmt); mTab.setValue ("WriteOffAmt", WriteOffAmt);
OverUnderAmt = OverUnderAmt.multiply (CurrencyRate).setScale ( OverUnderAmt = OverUnderAmt.multiply (CurrencyRate).setScale (
currency.getStdPrecision (), BigDecimal.ROUND_HALF_UP); currency.getStdPrecision (), RoundingMode.HALF_UP);
mTab.setValue ("OverUnderAmt", OverUnderAmt); mTab.setValue ("OverUnderAmt", OverUnderAmt);
} }
// No Invoice - Set Discount, Witeoff, Under/Over to 0 // No Invoice - Set Discount, Witeoff, Under/Over to 0

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -61,7 +62,7 @@ public class CalloutProject extends CalloutEngine
// //
BigDecimal PlannedAmt = PlannedQty.multiply(PlannedPrice); BigDecimal PlannedAmt = PlannedQty.multiply(PlannedPrice);
if (PlannedAmt.scale() > StdPrecision) if (PlannedAmt.scale() > StdPrecision)
PlannedAmt = PlannedAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); PlannedAmt = PlannedAmt.setScale(StdPrecision, RoundingMode.HALF_UP);
// //
if (log.isLoggable(Level.FINE)) log.fine("PlannedQty=" + PlannedQty + " * PlannedPrice=" + PlannedPrice + " -> PlannedAmt=" + PlannedAmt + " (Precision=" + StdPrecision+ ")"); if (log.isLoggable(Level.FINE)) log.fine("PlannedQty=" + PlannedQty + " * PlannedPrice=" + PlannedPrice + " -> PlannedAmt=" + PlannedAmt + " (Precision=" + StdPrecision+ ")");
mTab.setValue("PlannedAmt", PlannedAmt); mTab.setValue("PlannedAmt", PlannedAmt);

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -89,7 +90,7 @@ public class CalloutRequisition extends CalloutEngine
// Multiply // Multiply
BigDecimal LineNetAmt = Qty.multiply(PriceActual); BigDecimal LineNetAmt = Qty.multiply(PriceActual);
if (LineNetAmt.scale() > StdPrecision) if (LineNetAmt.scale() > StdPrecision)
LineNetAmt = LineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); LineNetAmt = LineNetAmt.setScale(StdPrecision, RoundingMode.HALF_UP);
line.setLineNetAmt(LineNetAmt); line.setLineNetAmt(LineNetAmt);
if (log.isLoggable(Level.INFO)) log.info("amt - LineNetAmt=" + LineNetAmt); if (log.isLoggable(Level.INFO)) log.info("amt - LineNetAmt=" + LineNetAmt);
// //

View File

@ -17,6 +17,7 @@
package org.compiere.process; package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MBPartner; import org.compiere.model.MBPartner;
@ -191,7 +192,7 @@ public class DistributionCreate extends SvrProcess
BigDecimal ratio = dll.getRatio(); BigDecimal ratio = dll.getRatio();
BigDecimal qty = p_Qty.multiply(ratio); BigDecimal qty = p_Qty.multiply(ratio);
if (qty.compareTo(Env.ZERO) != 0) if (qty.compareTo(Env.ZERO) != 0)
qty = qty.divide(m_dl.getRatioTotal(), m_product.getUOMPrecision(), BigDecimal.ROUND_HALF_UP); qty = qty.divide(m_dl.getRatioTotal(), m_product.getUOMPrecision(), RoundingMode.HALF_UP);
BigDecimal minQty = dll.getMinQty(); BigDecimal minQty = dll.getMinQty();
if (qty.compareTo(minQty) < 0) if (qty.compareTo(minQty) < 0)
qty = minQty; qty = minQty;

View File

@ -17,6 +17,7 @@
package org.compiere.process; package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -413,7 +414,7 @@ public class DistributionRun extends SvrProcess
if (detail.isCanAdjust()) if (detail.isCanAdjust())
{ {
BigDecimal diffRatio = detail.getRatio().multiply(difference) BigDecimal diffRatio = detail.getRatio().multiply(difference)
.divide(ratioTotal, BigDecimal.ROUND_HALF_UP); // precision from total .divide(ratioTotal, RoundingMode.HALF_UP); // precision from total
if (log.isLoggable(Level.FINE)) log.fine("Detail=" + detail.toString() if (log.isLoggable(Level.FINE)) log.fine("Detail=" + detail.toString()
+ ", Allocation=" + detail.getActualAllocation() + ", Allocation=" + detail.getActualAllocation()
+ ", DiffRatio=" + diffRatio); + ", DiffRatio=" + diffRatio);
@ -646,7 +647,7 @@ public class DistributionRun extends SvrProcess
log.info("Qty Total Available:" + drl.getTotalQty()); log.info("Qty Total Available:" + drl.getTotalQty());
log.info("Qty Total Demand:" + totalration); log.info("Qty Total Demand:" + totalration);
} }
BigDecimal factor = ration.divide(totalration, 12 , BigDecimal.ROUND_HALF_UP); BigDecimal factor = ration.divide(totalration, 12 , RoundingMode.HALF_UP);
record.setQty(drl.getTotalQty().multiply(factor)); record.setQty(drl.getTotalQty().multiply(factor));
record.saveEx(); record.saveEx();
} }
@ -750,7 +751,7 @@ public class DistributionRun extends SvrProcess
, p_M_DistributionRun_ID, record.getM_Product_ID()); , p_M_DistributionRun_ID, record.getM_Product_ID());
MDistributionRunLine drl = (MDistributionRunLine) MTable.get(getCtx(), MDistributionRunLine.Table_ID).getPO(record.getM_DistributionRunLine_ID(), get_TrxName()); MDistributionRunLine drl = (MDistributionRunLine) MTable.get(getCtx(), MDistributionRunLine.Table_ID).getPO(record.getM_DistributionRunLine_ID(), get_TrxName());
BigDecimal ration = record.getRatio(); BigDecimal ration = record.getRatio();
BigDecimal factor = ration.divide(total_ration,BigDecimal.ROUND_HALF_UP); BigDecimal factor = ration.divide(total_ration,RoundingMode.HALF_UP);
record.setQty(factor.multiply(drl.getTotalQty())); record.setQty(factor.multiply(drl.getTotalQty()));
record.saveEx(); record.saveEx();
} }

View File

@ -17,6 +17,7 @@
package org.compiere.process; package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MCurrency; import org.compiere.model.MCurrency;
@ -122,7 +123,7 @@ public class InOutCreateInvoice extends SvrProcess
BigDecimal igt = invoice.getGrandTotal(); BigDecimal igt = invoice.getGrandTotal();
BigDecimal percent = Env.ONE; BigDecimal percent = Env.ONE;
if (ogt.compareTo(igt) != 0) if (ogt.compareTo(igt) != 0)
percent = igt.divide(ogt, 10, BigDecimal.ROUND_HALF_UP); percent = igt.divide(ogt, 10, RoundingMode.HALF_UP);
MCurrency cur = MCurrency.get(order.getCtx(), order.getC_Currency_ID()); MCurrency cur = MCurrency.get(order.getCtx(), order.getC_Currency_ID());
int scale = cur.getStdPrecision(); int scale = cur.getStdPrecision();
@ -132,7 +133,7 @@ public class InOutCreateInvoice extends SvrProcess
if (percent != Env.ONE) { if (percent != Env.ONE) {
BigDecimal propDueAmt = ops.getDueAmt().multiply(percent); BigDecimal propDueAmt = ops.getDueAmt().multiply(percent);
if (propDueAmt.scale() > scale) if (propDueAmt.scale() > scale)
propDueAmt = propDueAmt.setScale(scale, BigDecimal.ROUND_HALF_UP); propDueAmt = propDueAmt.setScale(scale, RoundingMode.HALF_UP);
ips.setDueAmt(propDueAmt); ips.setDueAmt(propDueAmt);
} }
ips.setC_Invoice_ID(invoice.getC_Invoice_ID()); ips.setC_Invoice_ID(invoice.getC_Invoice_ID());

View File

@ -17,6 +17,7 @@
package org.compiere.process; package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -448,7 +449,7 @@ public class InOutGenerate extends SvrProcess
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0) if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
line.setQtyEntered(qty line.setQtyEntered(qty
.multiply(orderLine.getQtyEntered()) .multiply(orderLine.getQtyEntered())
.divide(orderLine.getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP)); .divide(orderLine.getQtyOrdered(), 12, RoundingMode.HALF_UP));
line.setLine(m_line + orderLine.getLine()); line.setLine(m_line + orderLine.getLine());
if (!line.save()) if (!line.save())
throw new IllegalStateException("Could not create Shipment Line"); throw new IllegalStateException("Could not create Shipment Line");
@ -504,7 +505,7 @@ public class InOutGenerate extends SvrProcess
line.setQty(line.getMovementQty().add(deliver)); line.setQty(line.getMovementQty().add(deliver));
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0) if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
line.setQtyEntered(line.getMovementQty().multiply(orderLine.getQtyEntered()) line.setQtyEntered(line.getMovementQty().multiply(orderLine.getQtyEntered())
.divide(orderLine.getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP)); .divide(orderLine.getQtyOrdered(), 12, RoundingMode.HALF_UP));
line.setLine(m_line + orderLine.getLine()); line.setLine(m_line + orderLine.getLine());
if (!line.save()) if (!line.save())
throw new IllegalStateException("Could not create Shipment Line"); throw new IllegalStateException("Could not create Shipment Line");
@ -530,7 +531,7 @@ public class InOutGenerate extends SvrProcess
line.setQty(toDeliver); line.setQty(toDeliver);
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0) if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
line.setQtyEntered(line.getMovementQty().multiply(orderLine.getQtyEntered()) line.setQtyEntered(line.getMovementQty().multiply(orderLine.getQtyEntered())
.divide(orderLine.getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP)); .divide(orderLine.getQtyOrdered(), 12, RoundingMode.HALF_UP));
line.setLine(m_line + orderLine.getLine()); line.setLine(m_line + orderLine.getLine());
if (!line.save()) if (!line.save())
throw new IllegalStateException("Could not create Shipment Line"); throw new IllegalStateException("Could not create Shipment Line");

View File

@ -17,6 +17,7 @@
package org.compiere.process; package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -300,7 +301,7 @@ public class InvoiceGenerate extends SvrProcess
if (oLine.getQtyEntered().compareTo(oLine.getQtyOrdered()) != 0) if (oLine.getQtyEntered().compareTo(oLine.getQtyOrdered()) != 0)
qtyEntered = toInvoice qtyEntered = toInvoice
.multiply(oLine.getQtyEntered()) .multiply(oLine.getQtyEntered())
.divide(oLine.getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP); .divide(oLine.getQtyOrdered(), 12, RoundingMode.HALF_UP);
createLine (order, oLine, toInvoice, qtyEntered); createLine (order, oLine, toInvoice, qtyEntered);
} }
else if (!completeOrder) else if (!completeOrder)
@ -492,7 +493,7 @@ public class InvoiceGenerate extends SvrProcess
BigDecimal igt = m_invoice.getGrandTotal(); BigDecimal igt = m_invoice.getGrandTotal();
BigDecimal percent = Env.ONE; BigDecimal percent = Env.ONE;
if (ogt.compareTo(igt) != 0) if (ogt.compareTo(igt) != 0)
percent = igt.divide(ogt, 10, BigDecimal.ROUND_HALF_UP); percent = igt.divide(ogt, 10, RoundingMode.HALF_UP);
MCurrency cur = MCurrency.get(order.getCtx(), order.getC_Currency_ID()); MCurrency cur = MCurrency.get(order.getCtx(), order.getC_Currency_ID());
int scale = cur.getStdPrecision(); int scale = cur.getStdPrecision();
@ -502,7 +503,7 @@ public class InvoiceGenerate extends SvrProcess
if (percent != Env.ONE) { if (percent != Env.ONE) {
BigDecimal propDueAmt = ops.getDueAmt().multiply(percent); BigDecimal propDueAmt = ops.getDueAmt().multiply(percent);
if (propDueAmt.scale() > scale) if (propDueAmt.scale() > scale)
propDueAmt = propDueAmt.setScale(scale, BigDecimal.ROUND_HALF_UP); propDueAmt = propDueAmt.setScale(scale, RoundingMode.HALF_UP);
ips.setDueAmt(propDueAmt); ips.setDueAmt(propDueAmt);
} }
ips.setC_Invoice_ID(m_invoice.getC_Invoice_ID()); ips.setC_Invoice_ID(m_invoice.getC_Invoice_ID());

View File

@ -20,6 +20,7 @@
package org.compiere.process; package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -544,7 +545,7 @@ public class M_PriceList_Create extends SvrProcess {
} }
if (conversion != null) if (conversion != null)
{ {
price = price.divide(conversion.getDivideRate(), precision, BigDecimal.ROUND_HALF_DOWN); price = price.divide(conversion.getDivideRate(), precision, RoundingMode.HALF_DOWN);
StringBuilder sqlupdate = new StringBuilder(); StringBuilder sqlupdate = new StringBuilder();
sqlupdate.append("UPDATE M_ProductPrice SET PriceList=").append(price).append(" WHERE M_PriceList_Version_ID=").append(p_PriceList_Version_ID) sqlupdate.append("UPDATE M_ProductPrice SET PriceList=").append(price).append(" WHERE M_PriceList_Version_ID=").append(p_PriceList_Version_ID)
.append(" AND M_Product_ID= ").append(product_id); .append(" AND M_Product_ID= ").append(product_id);

View File

@ -17,6 +17,7 @@
package org.compiere.process; package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MProduct; import org.compiere.model.MProduct;
@ -95,8 +96,8 @@ public class ProductUOMConvert extends SvrProcess
throw new AdempiereUserError("@NotFound@: @C_UOM_Conversion_ID@"); throw new AdempiereUserError("@NotFound@: @C_UOM_Conversion_ID@");
MUOM uomTo = MUOM.get(getCtx(), productTo.getC_UOM_ID()); MUOM uomTo = MUOM.get(getCtx(), productTo.getC_UOM_ID());
BigDecimal qtyTo = p_Qty.divide(conversion.getDivideRate(), uomTo.getStdPrecision(), BigDecimal.ROUND_HALF_UP); BigDecimal qtyTo = p_Qty.divide(conversion.getDivideRate(), uomTo.getStdPrecision(), RoundingMode.HALF_UP);
BigDecimal qtyTo6 = p_Qty.divide(conversion.getDivideRate(), 6, BigDecimal.ROUND_HALF_UP); BigDecimal qtyTo6 = p_Qty.divide(conversion.getDivideRate(), 6, RoundingMode.HALF_UP);
if (qtyTo.compareTo(qtyTo6) != 0) if (qtyTo.compareTo(qtyTo6) != 0)
throw new AdempiereUserError("@StdPrecision@: " + qtyTo + " <> " + qtyTo6 throw new AdempiereUserError("@StdPrecision@: " + qtyTo + " <> " + qtyTo6
+ " (" + p_Qty + "/" + conversion.getDivideRate() + ")"); + " (" + p_Qty + "/" + conversion.getDivideRate() + ")");

View File

@ -17,6 +17,7 @@
package org.compiere.process; package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MBPartner; import org.compiere.model.MBPartner;
@ -129,7 +130,7 @@ public class RfQCreateSO extends SvrProcess
{ {
margin = margin.add(Env.ONEHUNDRED); margin = margin.add(Env.ONEHUNDRED);
price = price.multiply(margin) price = price.multiply(margin)
.divide(Env.ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); .divide(Env.ONEHUNDRED, 2, RoundingMode.HALF_UP);
} }
} }
} // price } // price

View File

@ -14,6 +14,7 @@
package org.adempiere.model; package org.adempiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -295,7 +296,7 @@ public class PromotionRule {
nol.setC_Charge_ID(C_Charge_ID); nol.setC_Charge_ID(C_Charge_ID);
nol.setQty(qty); nol.setQty(qty);
if (discount.scale() > 2) if (discount.scale() > 2)
discount = discount.setScale(2, BigDecimal.ROUND_HALF_UP); discount = discount.setScale(2, RoundingMode.HALF_UP);
nol.setPriceEntered(discount.negate()); nol.setPriceEntered(discount.negate());
nol.setPriceActual(discount.negate()); nol.setPriceActual(discount.negate());
if (ol != null && Integer.toString(ol.getLine()).endsWith("0")) { if (ol != null && Integer.toString(ol.getLine()).endsWith("0")) {

View File

@ -17,6 +17,7 @@
package org.compiere.acct; package org.compiere.acct;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
@ -780,7 +781,7 @@ public class Doc_AllocationHdr extends Doc
// Round // Round
int precision = as.getStdPrecision(); int precision = as.getStdPrecision();
if (invoiceDifference.scale() > precision) if (invoiceDifference.scale() > precision)
invoiceDifference = invoiceDifference.setScale(precision, BigDecimal.ROUND_HALF_UP); invoiceDifference = invoiceDifference.setScale(precision, RoundingMode.HALF_UP);
StringBuilder d2 = new StringBuilder("(partial) = ").append(invoiceDifference).append(" - Multiplier=").append(multiplier); StringBuilder d2 = new StringBuilder("(partial) = ").append(invoiceDifference).append(" - Multiplier=").append(multiplier);
if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); if (log.isLoggable(Level.FINE)) log.fine(d2.toString());
descriptionInv.append(" - ").append(d2); descriptionInv.append(" - ").append(d2);
@ -847,7 +848,7 @@ public class Doc_AllocationHdr extends Doc
// Round // Round
int precision = as.getStdPrecision(); int precision = as.getStdPrecision();
if (paymentDifference.scale() > precision) if (paymentDifference.scale() > precision)
paymentDifference = paymentDifference.setScale(precision, BigDecimal.ROUND_HALF_UP); paymentDifference = paymentDifference.setScale(precision, RoundingMode.HALF_UP);
StringBuilder d2 = new StringBuilder("(partial) = ").append(paymentDifference).append(" - Multiplier=").append(multiplier); StringBuilder d2 = new StringBuilder("(partial) = ").append(paymentDifference).append(" - Multiplier=").append(multiplier);
if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); if (log.isLoggable(Level.FINE)) log.fine(d2.toString());
descriptionPay.append(" - ").append(d2); descriptionPay.append(" - ").append(d2);
@ -1193,10 +1194,10 @@ class Doc_AllocationTax
|| amt.signum() == 0) || amt.signum() == 0)
return Env.ZERO; return Env.ZERO;
// //
BigDecimal multiplier = tax.divide(total, 10, BigDecimal.ROUND_HALF_UP); BigDecimal multiplier = tax.divide(total, 10, RoundingMode.HALF_UP);
BigDecimal retValue = multiplier.multiply(amt); BigDecimal retValue = multiplier.multiply(amt);
if (retValue.scale() > precision) if (retValue.scale() > precision)
retValue = retValue.setScale(precision, BigDecimal.ROUND_HALF_UP); retValue = retValue.setScale(precision, RoundingMode.HALF_UP);
if (log.isLoggable(Level.FINE)) log.fine(retValue + " (Mult=" + multiplier + "(Prec=" + precision + ")"); if (log.isLoggable(Level.FINE)) log.fine(retValue + " (Mult=" + multiplier + "(Prec=" + precision + ")");
return retValue; return retValue;
} // calcAmount } // calcAmount

View File

@ -17,6 +17,7 @@
package org.compiere.acct; package org.compiere.acct;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -922,7 +923,7 @@ public class Doc_Invoice extends Doc
BigDecimal qty = allocation.getQty(); BigDecimal qty = allocation.getQty();
if (qty.compareTo(iol.getMovementQty()) != 0) if (qty.compareTo(iol.getMovementQty()) != 0)
{ {
amt = amt.multiply(iol.getMovementQty()).divide(qty, 12, BigDecimal.ROUND_HALF_UP); amt = amt.multiply(iol.getMovementQty()).divide(qty, 12, RoundingMode.HALF_UP);
} }
estimatedAmt = estimatedAmt.add(amt); estimatedAmt = estimatedAmt.add(amt);
} }
@ -931,7 +932,7 @@ public class Doc_Invoice extends Doc
if (estimatedAmt.scale() > as.getCostingPrecision()) if (estimatedAmt.scale() > as.getCostingPrecision())
{ {
estimatedAmt = estimatedAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); estimatedAmt = estimatedAmt.setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
} }
BigDecimal costAdjustmentAmt = allocationAmt; BigDecimal costAdjustmentAmt = allocationAmt;
if (estimatedAmt.signum() > 0) if (estimatedAmt.signum() > 0)
@ -996,7 +997,7 @@ public class Doc_Invoice extends Doc
getDateAcct(), getC_ConversionType_ID(), getDateAcct(), getC_ConversionType_ID(),
getAD_Client_ID(), getAD_Org_ID()); getAD_Client_ID(), getAD_Org_ID());
if (costDetailAmt.scale() > as.getCostingPrecision()) if (costDetailAmt.scale() > as.getCostingPrecision())
costDetailAmt = costDetailAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); costDetailAmt = costDetailAmt.setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
String key = lca.getM_Product_ID()+"_"+lca.getM_AttributeSetInstance_ID(); String key = lca.getM_Product_ID()+"_"+lca.getM_AttributeSetInstance_ID();
BigDecimal prevAmt = costDetailAmtMap.remove(key); BigDecimal prevAmt = costDetailAmtMap.remove(key);
@ -1041,11 +1042,11 @@ public class Doc_Invoice extends Doc
{ {
if (allocationAmt.scale() > as.getStdPrecision()) if (allocationAmt.scale() > as.getStdPrecision())
{ {
allocationAmt = allocationAmt.setScale(as.getStdPrecision(), BigDecimal.ROUND_HALF_UP); allocationAmt = allocationAmt.setScale(as.getStdPrecision(), RoundingMode.HALF_UP);
} }
if (estimatedAmt.scale() > as.getStdPrecision()) if (estimatedAmt.scale() > as.getStdPrecision())
{ {
estimatedAmt = estimatedAmt.setScale(as.getStdPrecision(), BigDecimal.ROUND_HALF_UP); estimatedAmt = estimatedAmt.setScale(as.getStdPrecision(), RoundingMode.HALF_UP);
} }
int compare = allocationAmt.compareTo(estimatedAmt); int compare = allocationAmt.compareTo(estimatedAmt);
if (compare > 0) if (compare > 0)

View File

@ -17,6 +17,7 @@
package org.compiere.acct; package org.compiere.acct;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Savepoint; import java.sql.Savepoint;
@ -167,7 +168,7 @@ public class Doc_MatchInv extends Doc
// NotInvoicedReceipt DR // NotInvoicedReceipt DR
// From Receipt // From Receipt
BigDecimal multiplier = getQty() BigDecimal multiplier = getQty()
.divide(m_receiptLine.getMovementQty(), 12, BigDecimal.ROUND_HALF_UP) .divide(m_receiptLine.getMovementQty(), 12, RoundingMode.HALF_UP)
.abs(); .abs();
FactLine dr = fact.createLine (null, FactLine dr = fact.createLine (null,
getAccount(Doc.ACCTTYPE_NotInvoicedReceipts, as), getAccount(Doc.ACCTTYPE_NotInvoicedReceipts, as),
@ -212,7 +213,7 @@ public class Doc_MatchInv extends Doc
expense = m_pc.getAccount(ProductCost.ACCTTYPE_P_Expense, as); expense = m_pc.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
BigDecimal LineNetAmt = m_invoiceLine.getLineNetAmt(); BigDecimal LineNetAmt = m_invoiceLine.getLineNetAmt();
multiplier = getQty() multiplier = getQty()
.divide(m_invoiceLine.getQtyInvoiced(), 12, BigDecimal.ROUND_HALF_UP) .divide(m_invoiceLine.getQtyInvoiced(), 12, RoundingMode.HALF_UP)
.abs(); .abs();
if (multiplier.compareTo(Env.ONE) != 0) if (multiplier.compareTo(Env.ONE) != 0)
LineNetAmt = LineNetAmt.multiply(multiplier); LineNetAmt = LineNetAmt.multiply(multiplier);
@ -453,7 +454,7 @@ public class Doc_MatchInv extends Doc
BigDecimal LineNetAmt = m_invoiceLine.getLineNetAmt(); BigDecimal LineNetAmt = m_invoiceLine.getLineNetAmt();
BigDecimal multiplier = getQty() BigDecimal multiplier = getQty()
.divide(m_invoiceLine.getQtyInvoiced(), 12, BigDecimal.ROUND_HALF_UP) .divide(m_invoiceLine.getQtyInvoiced(), 12, RoundingMode.HALF_UP)
.abs(); .abs();
if (multiplier.compareTo(Env.ONE) != 0) if (multiplier.compareTo(Env.ONE) != 0)
LineNetAmt = LineNetAmt.multiply(multiplier); LineNetAmt = LineNetAmt.multiply(multiplier);
@ -469,7 +470,7 @@ public class Doc_MatchInv extends Doc
{ {
tQty = tQty.add(mInv[i].getQty()); tQty = tQty.add(mInv[i].getQty());
multiplier = mInv[i].getQty() multiplier = mInv[i].getQty()
.divide(m_invoiceLine.getQtyInvoiced(), 12, BigDecimal.ROUND_HALF_UP).abs(); .divide(m_invoiceLine.getQtyInvoiced(), 12, RoundingMode.HALF_UP).abs();
tAmt = tAmt.add(m_invoiceLine.getLineNetAmt().multiply(multiplier)); tAmt = tAmt.add(m_invoiceLine.getLineNetAmt().multiply(multiplier));
} }
} }
@ -516,7 +517,7 @@ public class Doc_MatchInv extends Doc
{ {
BigDecimal totalAmt = allocation.getAmt(); BigDecimal totalAmt = allocation.getAmt();
BigDecimal totalQty = allocation.getQty(); BigDecimal totalQty = allocation.getQty();
BigDecimal amt = totalAmt.multiply(tQty).divide(totalQty, 12, BigDecimal.ROUND_HALF_UP); BigDecimal amt = totalAmt.multiply(tQty).divide(totalQty, 12, RoundingMode.HALF_UP);
if (orderLine.getC_Currency_ID() != as.getC_Currency_ID()) if (orderLine.getC_Currency_ID() != as.getC_Currency_ID())
{ {
I_C_Order order = orderLine.getC_Order(); I_C_Order order = orderLine.getC_Order();
@ -532,7 +533,7 @@ public class Doc_MatchInv extends Doc
} }
amt = amt.multiply(rate); amt = amt.multiply(rate);
if (amt.scale() > as.getCostingPrecision()) if (amt.scale() > as.getCostingPrecision())
amt = amt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); amt = amt.setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
} }
int elementId = allocation.getC_OrderLandedCost().getM_CostElement_ID(); int elementId = allocation.getC_OrderLandedCost().getM_CostElement_ID();
BigDecimal elementAmt = landedCostMap.get(elementId); BigDecimal elementAmt = landedCostMap.get(elementId);

View File

@ -233,7 +233,7 @@ public class Doc_MatchPO extends Doc
amt = amt.divide(getQty(), 12, RoundingMode.HALF_UP); amt = amt.divide(getQty(), 12, RoundingMode.HALF_UP);
landedCost = landedCost.add(amt); landedCost = landedCost.add(amt);
if (landedCost.scale() > as.getCostingPrecision()) if (landedCost.scale() > as.getCostingPrecision())
landedCost = landedCost.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); landedCost = landedCost.setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
int elementId = allocation.getC_OrderLandedCost().getM_CostElement_ID(); int elementId = allocation.getC_OrderLandedCost().getM_CostElement_ID();
BigDecimal elementAmt = landedCostMap.get(elementId); BigDecimal elementAmt = landedCostMap.get(elementId);
if (elementAmt == null) if (elementAmt == null)
@ -263,7 +263,7 @@ public class Doc_MatchPO extends Doc
} }
poCost = poCost.multiply(rate); poCost = poCost.multiply(rate);
if (poCost.scale() > as.getCostingPrecision()) if (poCost.scale() > as.getCostingPrecision())
poCost = poCost.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); poCost = poCost.setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
} }
String costingError = createMatchPOCostDetail(as, poCost, landedCostMap); String costingError = createMatchPOCostDetail(as, poCost, landedCostMap);
@ -492,7 +492,7 @@ public class Doc_MatchPO extends Doc
} }
if (tAmt.scale() > as.getCostingPrecision()) if (tAmt.scale() > as.getCostingPrecision())
tAmt = tAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); tAmt = tAmt.setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
// Set Total Amount and Total Quantity from Matched PO // Set Total Amount and Total Quantity from Matched PO
if (!MCostDetail.createOrder(as, m_oLine.getAD_Org_ID(), if (!MCostDetail.createOrder(as, m_oLine.getAD_Org_ID(),
getM_Product_ID(), mMatchPO.getM_AttributeSetInstance_ID(), getM_Product_ID(), mMatchPO.getM_AttributeSetInstance_ID(),
@ -523,7 +523,7 @@ public class Doc_MatchPO extends Doc
BigDecimal amt = landedCostMap.get(elementId); BigDecimal amt = landedCostMap.get(elementId);
amt = amt.multiply(tQty); amt = amt.multiply(tQty);
if (amt.scale() > as.getCostingPrecision()) if (amt.scale() > as.getCostingPrecision())
amt = amt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); amt = amt.setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
if (!MCostDetail.createOrder(as, m_oLine.getAD_Org_ID(), if (!MCostDetail.createOrder(as, m_oLine.getAD_Org_ID(),
getM_Product_ID(), mMatchPO.getM_AttributeSetInstance_ID(), getM_Product_ID(), mMatchPO.getM_AttributeSetInstance_ID(),
m_oLine.getC_OrderLine_ID(), elementId, m_oLine.getC_OrderLine_ID(), elementId,

View File

@ -17,6 +17,7 @@
package org.compiere.acct; package org.compiere.acct;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
@ -318,7 +319,7 @@ public class Doc_Production extends Doc
costMap.put(line0.get_ID()+ "_"+ ma.getM_AttributeSetInstance_ID(),maCost); costMap.put(line0.get_ID()+ "_"+ ma.getM_AttributeSetInstance_ID(),maCost);
costs0 = costs0.add(maCost); costs0 = costs0.add(maCost);
} }
bomCost = bomCost.add(costs0.setScale(2,BigDecimal.ROUND_HALF_UP)); bomCost = bomCost.add(costs0.setScale(2,RoundingMode.HALF_UP));
} }
else else
p_Error = "Failed to post - No Attribute Set for line"; p_Error = "Failed to post - No Attribute Set for line";
@ -339,7 +340,7 @@ public class Doc_Production extends Doc
costs0 = line0.getProductCosts(as, line0.getAD_Org_ID(), false); costs0 = line0.getProductCosts(as, line0.getAD_Org_ID(), false);
} }
costMap.put(line0.get_ID()+ "_"+ line0.getM_AttributeSetInstance_ID(),costs0); costMap.put(line0.get_ID()+ "_"+ line0.getM_AttributeSetInstance_ID(),costs0);
bomCost = bomCost.add(costs0.setScale(2,BigDecimal.ROUND_HALF_UP)); bomCost = bomCost.add(costs0.setScale(2,RoundingMode.HALF_UP));
} }
} }
@ -358,7 +359,7 @@ public class Doc_Production extends Doc
costs0 = line0.getProductCosts(as, line0.getAD_Org_ID(), false); costs0 = line0.getProductCosts(as, line0.getAD_Org_ID(), false);
} }
costMap.put(line0.get_ID()+ "_"+ line0.getM_AttributeSetInstance_ID(),costs0); costMap.put(line0.get_ID()+ "_"+ line0.getM_AttributeSetInstance_ID(),costs0);
bomCost = bomCost.add(costs0.setScale(2,BigDecimal.ROUND_HALF_UP)); bomCost = bomCost.add(costs0.setScale(2,RoundingMode.HALF_UP));
} }
} }
} }
@ -366,8 +367,8 @@ public class Doc_Production extends Doc
qtyProduced = manipulateQtyProduced (mQtyProduced, endProLine, prod.isUseProductionPlan(), null); qtyProduced = manipulateQtyProduced (mQtyProduced, endProLine, prod.isUseProductionPlan(), null);
if (line.getQty().compareTo(qtyProduced) != 0) if (line.getQty().compareTo(qtyProduced) != 0)
{ {
BigDecimal factor = line.getQty().divide(qtyProduced, 12, BigDecimal.ROUND_HALF_UP); BigDecimal factor = line.getQty().divide(qtyProduced, 12, RoundingMode.HALF_UP);
bomCost = bomCost.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP); bomCost = bomCost.multiply(factor).setScale(2,RoundingMode.HALF_UP);
} }
if (MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel)) if (MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel))
@ -386,7 +387,7 @@ public class Doc_Production extends Doc
else else
{ {
int precision = as.getStdPrecision(); int precision = as.getStdPrecision();
BigDecimal variance = (costs.setScale(precision, BigDecimal.ROUND_HALF_UP)).subtract(bomCost.negate()); BigDecimal variance = (costs.setScale(precision, RoundingMode.HALF_UP)).subtract(bomCost.negate());
// only post variance if it's not zero // only post variance if it's not zero
if (variance.signum() != 0) if (variance.signum() != 0)
{ {

View File

@ -17,6 +17,7 @@
package org.compiere.acct; package org.compiere.acct;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -252,14 +253,14 @@ public final class FactLine extends X_Fact_Acct
int precision = MCurrency.getStdPrecision(getCtx(), C_Currency_ID); int precision = MCurrency.getStdPrecision(getCtx(), C_Currency_ID);
if (AmtSourceDr != null && AmtSourceDr.scale() > precision) if (AmtSourceDr != null && AmtSourceDr.scale() > precision)
{ {
BigDecimal AmtSourceDr1 = AmtSourceDr.setScale(precision, BigDecimal.ROUND_HALF_UP); BigDecimal AmtSourceDr1 = AmtSourceDr.setScale(precision, RoundingMode.HALF_UP);
if (AmtSourceDr1.compareTo(AmtSourceDr) != 0) if (AmtSourceDr1.compareTo(AmtSourceDr) != 0)
log.warning("Source DR Precision " + AmtSourceDr + " -> " + AmtSourceDr1); log.warning("Source DR Precision " + AmtSourceDr + " -> " + AmtSourceDr1);
setAmtSourceDr(AmtSourceDr1); setAmtSourceDr(AmtSourceDr1);
} }
if (AmtSourceCr != null && AmtSourceCr.scale() > precision) if (AmtSourceCr != null && AmtSourceCr.scale() > precision)
{ {
BigDecimal AmtSourceCr1 = AmtSourceCr.setScale(precision, BigDecimal.ROUND_HALF_UP); BigDecimal AmtSourceCr1 = AmtSourceCr.setScale(precision, RoundingMode.HALF_UP);
if (AmtSourceCr1.compareTo(AmtSourceCr) != 0) if (AmtSourceCr1.compareTo(AmtSourceCr) != 0)
log.warning("Source CR Precision " + AmtSourceCr + " -> " + AmtSourceCr1); log.warning("Source CR Precision " + AmtSourceCr + " -> " + AmtSourceCr1);
setAmtSourceCr(AmtSourceCr1); setAmtSourceCr(AmtSourceCr1);
@ -326,14 +327,14 @@ public final class FactLine extends X_Fact_Acct
int precision = MCurrency.getStdPrecision(getCtx(), C_Currency_ID); int precision = MCurrency.getStdPrecision(getCtx(), C_Currency_ID);
if (AmtAcctDr != null && AmtAcctDr.scale() > precision) if (AmtAcctDr != null && AmtAcctDr.scale() > precision)
{ {
BigDecimal AmtAcctDr1 = AmtAcctDr.setScale(precision, BigDecimal.ROUND_HALF_UP); BigDecimal AmtAcctDr1 = AmtAcctDr.setScale(precision, RoundingMode.HALF_UP);
if (AmtAcctDr1.compareTo(AmtAcctDr) != 0) if (AmtAcctDr1.compareTo(AmtAcctDr) != 0)
log.warning("Accounted DR Precision " + AmtAcctDr + " -> " + AmtAcctDr1); log.warning("Accounted DR Precision " + AmtAcctDr + " -> " + AmtAcctDr1);
setAmtAcctDr(AmtAcctDr1); setAmtAcctDr(AmtAcctDr1);
} }
if (AmtAcctCr != null && AmtAcctCr.scale() > precision) if (AmtAcctCr != null && AmtAcctCr.scale() > precision)
{ {
BigDecimal AmtAcctCr1 = AmtAcctCr.setScale(precision, BigDecimal.ROUND_HALF_UP); BigDecimal AmtAcctCr1 = AmtAcctCr.setScale(precision, RoundingMode.HALF_UP);
if (AmtAcctCr1.compareTo(AmtAcctCr) != 0) if (AmtAcctCr1.compareTo(AmtAcctCr) != 0)
log.warning("Accounted CR Precision " + AmtAcctCr + " -> " + AmtAcctCr1); log.warning("Accounted CR Precision " + AmtAcctCr + " -> " + AmtAcctCr1);
setAmtAcctCr(AmtAcctCr1); setAmtAcctCr(AmtAcctCr1);

View File

@ -18,6 +18,7 @@
package org.compiere.impexp; package org.compiere.impexp;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
@ -525,7 +526,7 @@ public final class ImpFormatRow
bd = BigDecimal.ZERO; bd = BigDecimal.ZERO;
if (m_divideBy100) // assumed two decimal scale if (m_divideBy100) // assumed two decimal scale
bd = bd.divide(Env.ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); bd = bd.divide(Env.ONEHUNDRED, 2, RoundingMode.HALF_UP);
return bd.toString(); return bd.toString();
} // parseNumber } // parseNumber

View File

@ -18,6 +18,7 @@ package org.compiere.model;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -303,7 +304,7 @@ public class CalloutEngine implements Callout
BigDecimal rate2 = Env.ZERO; BigDecimal rate2 = Env.ZERO;
if (rate1.signum() != 0.0) // no divide by zero if (rate1.signum() != 0.0) // no divide by zero
rate2 = Env.ONE.divide(rate1, 12, BigDecimal.ROUND_HALF_UP); rate2 = Env.ONE.divide(rate1, 12, RoundingMode.HALF_UP);
// //
if (mField.getColumnName().equals("MultiplyRate")) if (mField.getColumnName().equals("MultiplyRate"))
mTab.setValue("DivideRate", rate2); mTab.setValue("DivideRate", rate2);

View File

@ -18,6 +18,7 @@ package org.compiere.model;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -1066,7 +1067,7 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
// Round // Round
int precision = MCurrency.getStdPrecision(getCtx(), client.getC_Currency_ID()); int precision = MCurrency.getStdPrecision(getCtx(), client.getC_Currency_ID());
if (openBalanceDiff.scale() > precision) if (openBalanceDiff.scale() > precision)
openBalanceDiff = openBalanceDiff.setScale(precision, BigDecimal.ROUND_HALF_UP); openBalanceDiff = openBalanceDiff.setScale(precision, RoundingMode.HALF_UP);
} }
} }

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
@ -220,7 +221,7 @@ public class MBPGroup extends X_C_BP_Group
{ {
BigDecimal bd = super.getCreditWatchPercent(); BigDecimal bd = super.getCreditWatchPercent();
if (bd.compareTo(Env.ZERO) != 0) if (bd.compareTo(Env.ZERO) != 0)
return bd.divide(Env.ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); return bd.divide(Env.ONEHUNDRED, 2, RoundingMode.HALF_UP);
return BigDecimal.valueOf(0.90); return BigDecimal.valueOf(0.90);
} // getCreditWatchRatio } // getCreditWatchRatio

View File

@ -18,6 +18,7 @@ package org.compiere.model;
import java.awt.Color; import java.awt.Color;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
@ -54,7 +55,7 @@ public class MColorSchema extends X_PA_ColorSchema
&& target != null && target.signum() != 0) && target != null && target.signum() != 0)
{ {
BigDecimal pp = actual.multiply(Env.ONEHUNDRED) BigDecimal pp = actual.multiply(Env.ONEHUNDRED)
.divide(target, 0, BigDecimal.ROUND_HALF_UP); .divide(target, 0, RoundingMode.HALF_UP);
percent = pp.intValue(); percent = pp.intValue();
} }
return getColor(ctx, PA_ColorSchema_ID, percent); return getColor(ctx, PA_ColorSchema_ID, percent);

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -142,7 +143,7 @@ public class MConversionRate extends X_C_Conversion_Rate
int stdPrecision = isCosting ? MCurrency.getCostingPrecision(ctx, CurTo_ID): MCurrency.getStdPrecision(ctx, CurTo_ID); int stdPrecision = isCosting ? MCurrency.getCostingPrecision(ctx, CurTo_ID): MCurrency.getStdPrecision(ctx, CurTo_ID);
if (retValue.scale() > stdPrecision) if (retValue.scale() > stdPrecision)
retValue = retValue.setScale(stdPrecision, BigDecimal.ROUND_HALF_UP); retValue = retValue.setScale(stdPrecision, RoundingMode.HALF_UP);
return retValue; return retValue;
} // convert } // convert

View File

@ -18,6 +18,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -243,15 +244,15 @@ public class MCost extends X_M_Cost
if (percentage.signum() == 0) // no percentages if (percentage.signum() == 0) // no percentages
{ {
if (costs.scale() > precision) if (costs.scale() > precision)
costs = costs.setScale(precision, BigDecimal.ROUND_HALF_UP); costs = costs.setScale(precision, RoundingMode.HALF_UP);
return costs; return costs;
} }
// //
BigDecimal percentCost = costs.multiply(percentage); BigDecimal percentCost = costs.multiply(percentage);
percentCost = percentCost.divide(Env.ONEHUNDRED, precision, BigDecimal.ROUND_HALF_UP); percentCost = percentCost.divide(Env.ONEHUNDRED, precision, RoundingMode.HALF_UP);
costs = costs.add(percentCost); costs = costs.add(percentCost);
if (costs.scale() > precision) if (costs.scale() > precision)
costs = costs.setScale(precision, BigDecimal.ROUND_HALF_UP); costs = costs.setScale(precision, RoundingMode.HALF_UP);
if (s_log.isLoggable(Level.FINER)) s_log.finer("Sum Costs = " + costs + " (Add=" + percentCost + ")"); if (s_log.isLoggable(Level.FINER)) s_log.finer("Sum Costs = " + costs + " (Add=" + percentCost + ")");
return costs; return costs;
} // getCurrentCost } // getCurrentCost
@ -921,8 +922,8 @@ public class MCost extends X_M_Cost
BigDecimal averageCurrent = oldStockQty.multiply(oldAverageAmt); BigDecimal averageCurrent = oldStockQty.multiply(oldAverageAmt);
BigDecimal averageIncrease = matchQty.multiply(cost); BigDecimal averageIncrease = matchQty.multiply(cost);
BigDecimal newAmt = averageCurrent.add(averageIncrease); BigDecimal newAmt = averageCurrent.add(averageIncrease);
newAmt = newAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAmt = newAmt.setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), RoundingMode.HALF_UP);
if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty
+ ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt); + ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt);
} }
@ -1017,8 +1018,8 @@ public class MCost extends X_M_Cost
BigDecimal averageCurrent = oldStockQty.multiply(oldAverageAmt); BigDecimal averageCurrent = oldStockQty.multiply(oldAverageAmt);
BigDecimal averageIncrease = matchQty.multiply(cost); BigDecimal averageIncrease = matchQty.multiply(cost);
BigDecimal newAmt = averageCurrent.add(averageIncrease); BigDecimal newAmt = averageCurrent.add(averageIncrease);
newAmt = newAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAmt = newAmt.setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), RoundingMode.HALF_UP);
if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty
+ ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt); + ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt);
} }
@ -1539,12 +1540,12 @@ public class MCost extends X_M_Cost
if (sumQty.signum() != 0) if (sumQty.signum() != 0)
{ {
BigDecimal oldSum = getCurrentCostPrice().multiply(getCurrentQty()); BigDecimal oldSum = getCurrentCostPrice().multiply(getCurrentQty());
BigDecimal oldCost = oldSum.divide(sumQty, 12, BigDecimal.ROUND_HALF_UP); BigDecimal oldCost = oldSum.divide(sumQty, 12, RoundingMode.HALF_UP);
BigDecimal newCost = amt.divide(sumQty, 12, BigDecimal.ROUND_HALF_UP); //amt is total already BigDecimal newCost = amt.divide(sumQty, 12, RoundingMode.HALF_UP); //amt is total already
BigDecimal cost = oldCost.add(newCost); BigDecimal cost = oldCost.add(newCost);
if (cost.scale() > (getPrecision()*2)) if (cost.scale() > (getPrecision()*2))
{ {
cost = cost.setScale((getPrecision()*2), BigDecimal.ROUND_HALF_UP); cost = cost.setScale((getPrecision()*2), RoundingMode.HALF_UP);
} }
setCurrentCostPrice(cost); setCurrentCostPrice(cost);
} }
@ -1562,7 +1563,7 @@ public class MCost extends X_M_Cost
BigDecimal cost = amtUnit; BigDecimal cost = amtUnit;
if (cost.scale() > (getPrecision()*2)) if (cost.scale() > (getPrecision()*2))
{ {
cost = cost.setScale((getPrecision()*2), BigDecimal.ROUND_HALF_UP); cost = cost.setScale((getPrecision()*2), RoundingMode.HALF_UP);
} }
setCurrentCostPrice(cost); setCurrentCostPrice(cost);
} // setWeightedAverageInitial } // setWeightedAverageInitial
@ -1601,7 +1602,7 @@ public class MCost extends X_M_Cost
if (getCumulatedQty().signum() != 0 if (getCumulatedQty().signum() != 0
&& getCumulatedAmt().signum() != 0) && getCumulatedAmt().signum() != 0)
retValue = getCumulatedAmt() retValue = getCumulatedAmt()
.divide(getCumulatedQty(), getPrecision(), BigDecimal.ROUND_HALF_UP); .divide(getCumulatedQty(), getPrecision(), RoundingMode.HALF_UP);
return retValue; return retValue;
} // getHistoryAverage } // getHistoryAverage

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.List; import java.util.List;
@ -1047,7 +1048,7 @@ public class MCostDetail extends X_M_CostDetail
int precision = as.getCostingPrecision(); int precision = as.getCostingPrecision();
BigDecimal price = amt; BigDecimal price = amt;
if (qty.signum() != 0) if (qty.signum() != 0)
price = amt.divide(qty, precision, BigDecimal.ROUND_HALF_UP); price = amt.divide(qty, precision, RoundingMode.HALF_UP);
/** All Costing Methods /** All Costing Methods
if (ce.isAverageInvoice()) if (ce.isAverageInvoice())

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
@ -381,7 +382,7 @@ public class MCostQueue extends X_M_CostQueue
BigDecimal sumQty = getCurrentQty().add(qty); BigDecimal sumQty = getCurrentQty().add(qty);
if (sumQty.signum() != 0) if (sumQty.signum() != 0)
{ {
BigDecimal cost = sumAmt.divide(sumQty, precision, BigDecimal.ROUND_HALF_UP); BigDecimal cost = sumAmt.divide(sumQty, precision, RoundingMode.HALF_UP);
setCurrentCostPrice(cost); setCurrentCostPrice(cost);
} }
// //

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
@ -203,7 +204,7 @@ public class MDiscountSchema extends X_M_DiscountSchema
// //
BigDecimal onehundred = Env.ONEHUNDRED; BigDecimal onehundred = Env.ONEHUNDRED;
BigDecimal multiplier = (onehundred).subtract(discount); BigDecimal multiplier = (onehundred).subtract(discount);
multiplier = multiplier.divide(onehundred, 6, BigDecimal.ROUND_HALF_UP); multiplier = multiplier.divide(onehundred, 6, RoundingMode.HALF_UP);
BigDecimal newPrice = Price.multiply(multiplier); BigDecimal newPrice = Price.multiply(multiplier);
if (log.isLoggable(Level.FINE)) log.fine("=>" + newPrice); if (log.isLoggable(Level.FINE)) log.fine("=>" + newPrice);
return newPrice; return newPrice;

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
@ -193,7 +194,7 @@ public class MDistributionLine extends X_GL_DistributionLine
public void calculateAmt (BigDecimal amt, int precision) public void calculateAmt (BigDecimal amt, int precision)
{ {
m_amt = amt.multiply(getPercent()); m_amt = amt.multiply(getPercent());
m_amt = m_amt.divide(Env.ONEHUNDRED, precision, BigDecimal.ROUND_HALF_UP); m_amt = m_amt.divide(Env.ONEHUNDRED, precision, RoundingMode.HALF_UP);
} // setAmt } // setAmt
/** /**
@ -203,7 +204,7 @@ public class MDistributionLine extends X_GL_DistributionLine
public void calculateQty (BigDecimal qty) public void calculateQty (BigDecimal qty)
{ {
m_qty = qty.multiply(getPercent()); m_qty = qty.multiply(getPercent());
m_qty = m_qty.divide(Env.ONEHUNDRED, BigDecimal.ROUND_HALF_UP); m_qty = m_qty.divide(Env.ONEHUNDRED, RoundingMode.HALF_UP);
} // setAmt } // setAmt

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
@ -121,13 +122,13 @@ public class MDistributionRunDetail extends X_T_DistributionRunDetail
BigDecimal min = getMinQty(); BigDecimal min = getMinQty();
if (min.scale() > m_precision) if (min.scale() > m_precision)
{ {
setMinQty(min.setScale(m_precision, BigDecimal.ROUND_HALF_UP)); setMinQty(min.setScale(m_precision, RoundingMode.HALF_UP));
dirty = true; dirty = true;
} }
BigDecimal qty = getQty(); BigDecimal qty = getQty();
if (qty.scale() > m_precision) if (qty.scale() > m_precision)
{ {
setQty(qty.setScale(m_precision, BigDecimal.ROUND_HALF_UP)); setQty(qty.setScale(m_precision, RoundingMode.HALF_UP));
dirty = true; dirty = true;
} }
if (dirty) if (dirty)
@ -162,7 +163,7 @@ public class MDistributionRunDetail extends X_T_DistributionRunDetail
*/ */
public BigDecimal adjustQty (BigDecimal difference) public BigDecimal adjustQty (BigDecimal difference)
{ {
BigDecimal diff = difference.setScale(m_precision, BigDecimal.ROUND_HALF_UP); BigDecimal diff = difference.setScale(m_precision, RoundingMode.HALF_UP);
BigDecimal qty = getQty(); BigDecimal qty = getQty();
BigDecimal max = getMinQty().subtract(qty); BigDecimal max = getMinQty().subtract(qty);
BigDecimal remaining = Env.ZERO; BigDecimal remaining = Env.ZERO;

View File

@ -18,6 +18,7 @@ package org.compiere.model;
import java.awt.Color; import java.awt.Color;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -416,7 +417,7 @@ public class MGoal extends X_PA_Goal
BigDecimal MeasureActual = getMeasureActual(); BigDecimal MeasureActual = getMeasureActual();
BigDecimal GoalPerformance = Env.ZERO; BigDecimal GoalPerformance = Env.ZERO;
if (MeasureTarget.signum() != 0) if (MeasureTarget.signum() != 0)
GoalPerformance = MeasureActual.divide(MeasureTarget, 6, BigDecimal.ROUND_HALF_UP); GoalPerformance = MeasureActual.divide(MeasureTarget, 6, RoundingMode.HALF_UP);
super.setGoalPerformance (GoalPerformance); super.setGoalPerformance (GoalPerformance);
m_color = null; m_color = null;
} // setGoalPerformance } // setGoalPerformance

View File

@ -18,6 +18,7 @@ package org.compiere.model;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -151,7 +152,7 @@ public class MInOut extends X_M_InOut implements DocAction
if (oLines[i].getQtyEntered().compareTo(oLines[i].getQtyOrdered()) != 0) if (oLines[i].getQtyEntered().compareTo(oLines[i].getQtyOrdered()) != 0)
line.setQtyEntered(lineQty line.setQtyEntered(lineQty
.multiply(oLines[i].getQtyEntered()) .multiply(oLines[i].getQtyEntered())
.divide(oLines[i].getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP)); .divide(oLines[i].getQtyOrdered(), 12, RoundingMode.HALF_UP));
line.setC_Project_ID(oLines[i].getC_Project_ID()); line.setC_Project_ID(oLines[i].getC_Project_ID());
line.saveEx(trxName); line.saveEx(trxName);
// Delivered everything ? // Delivered everything ?

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -335,7 +336,7 @@ public class MInOutLine extends X_M_InOutLine
if (QtyEntered != null && getC_UOM_ID() != 0) if (QtyEntered != null && getC_UOM_ID() != 0)
{ {
int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID()); int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID());
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_UP); QtyEntered = QtyEntered.setScale(precision, RoundingMode.HALF_UP);
} }
super.setQtyEntered (QtyEntered); super.setQtyEntered (QtyEntered);
} // setQtyEntered } // setQtyEntered
@ -350,7 +351,7 @@ public class MInOutLine extends X_M_InOutLine
if (MovementQty != null && product != null) if (MovementQty != null && product != null)
{ {
int precision = product.getUOMPrecision(); int precision = product.getUOMPrecision();
MovementQty = MovementQty.setScale(precision, BigDecimal.ROUND_HALF_UP); MovementQty = MovementQty.setScale(precision, RoundingMode.HALF_UP);
} }
super.setMovementQty(MovementQty); super.setMovementQty(MovementQty);
} // setMovementQty } // setMovementQty

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
@ -172,7 +173,7 @@ public class MInventoryLine extends X_M_InventoryLine
if (product != null) if (product != null)
{ {
int precision = product.getUOMPrecision(); int precision = product.getUOMPrecision();
QtyCount = QtyCount.setScale(precision, BigDecimal.ROUND_HALF_UP); QtyCount = QtyCount.setScale(precision, RoundingMode.HALF_UP);
} }
} }
super.setQtyCount(QtyCount); super.setQtyCount(QtyCount);
@ -191,7 +192,7 @@ public class MInventoryLine extends X_M_InventoryLine
if (product != null) if (product != null)
{ {
int precision = product.getUOMPrecision(); int precision = product.getUOMPrecision();
QtyInternalUse = QtyInternalUse.setScale(precision, BigDecimal.ROUND_HALF_UP); QtyInternalUse = QtyInternalUse.setScale(precision, RoundingMode.HALF_UP);
} }
} }
super.setQtyInternalUse(QtyInternalUse); super.setQtyInternalUse(QtyInternalUse);

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -387,7 +388,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
setPriceEntered(getPriceActual()); setPriceEntered(getPriceActual());
else else
setPriceEntered(getPriceActual().multiply(getQtyInvoiced() setPriceEntered(getPriceActual().multiply(getQtyInvoiced()
.divide(getQtyEntered(), 6, BigDecimal.ROUND_HALF_UP))); // precision .divide(getQtyEntered(), 6, RoundingMode.HALF_UP))); // precision
// //
if (getC_UOM_ID() == 0) if (getC_UOM_ID() == 0)
setC_UOM_ID(m_productPricing.getC_UOM_ID()); setC_UOM_ID(m_productPricing.getC_UOM_ID());
@ -476,7 +477,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
BigDecimal bd = getPriceActual().multiply(getQtyInvoiced()); BigDecimal bd = getPriceActual().multiply(getQtyInvoiced());
int precision = getPrecision(); int precision = getPrecision();
if (bd.scale() > precision) if (bd.scale() > precision)
bd = bd.setScale(precision, BigDecimal.ROUND_HALF_UP); bd = bd.setScale(precision, RoundingMode.HALF_UP);
super.setLineNetAmt (bd); super.setLineNetAmt (bd);
} // setLineNetAmt } // setLineNetAmt
/** /**
@ -528,7 +529,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
if (QtyEntered != null && getC_UOM_ID() != 0) if (QtyEntered != null && getC_UOM_ID() != 0)
{ {
int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID()); int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID());
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_UP); QtyEntered = QtyEntered.setScale(precision, RoundingMode.HALF_UP);
} }
super.setQtyEntered (QtyEntered); super.setQtyEntered (QtyEntered);
} // setQtyEntered } // setQtyEntered
@ -543,7 +544,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
if (QtyInvoiced != null && product != null) if (QtyInvoiced != null && product != null)
{ {
int precision = product.getUOMPrecision(); int precision = product.getUOMPrecision();
QtyInvoiced = QtyInvoiced.setScale(precision, BigDecimal.ROUND_HALF_UP); QtyInvoiced = QtyInvoiced.setScale(precision, RoundingMode.HALF_UP);
} }
super.setQtyInvoiced(QtyInvoiced); super.setQtyInvoiced(QtyInvoiced);
} // setQtyInvoiced } // setQtyInvoiced

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -152,10 +153,10 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule
else else
{ {
due = due.multiply(paySchedule.getPercentage()) due = due.multiply(paySchedule.getPercentage())
.divide(Env.ONEHUNDRED, scale, BigDecimal.ROUND_HALF_UP); .divide(Env.ONEHUNDRED, scale, RoundingMode.HALF_UP);
setDueAmt (due); setDueAmt (due);
BigDecimal discount = due.multiply(paySchedule.getDiscount()) BigDecimal discount = due.multiply(paySchedule.getDiscount())
.divide(Env.ONEHUNDRED, scale, BigDecimal.ROUND_HALF_UP); .divide(Env.ONEHUNDRED, scale, RoundingMode.HALF_UP);
setDiscountAmt (discount); setDiscountAmt (discount);
setIsValid(true); setIsValid(true);
} }

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Properties; import java.util.Properties;
@ -308,11 +309,11 @@ public class MJournalLine extends X_GL_JournalLine
BigDecimal rate = getCurrencyRate(); BigDecimal rate = getCurrencyRate();
BigDecimal amt = rate.multiply(getAmtSourceDr()); BigDecimal amt = rate.multiply(getAmtSourceDr());
if (amt.scale() > getPrecision()) if (amt.scale() > getPrecision())
amt = amt.setScale(getPrecision(), BigDecimal.ROUND_HALF_UP); amt = amt.setScale(getPrecision(), RoundingMode.HALF_UP);
setAmtAcctDr(amt); setAmtAcctDr(amt);
amt = rate.multiply(getAmtSourceCr()); amt = rate.multiply(getAmtSourceCr());
if (amt.scale() > getPrecision()) if (amt.scale() > getPrecision())
amt = amt.setScale(getPrecision(), BigDecimal.ROUND_HALF_UP); amt = amt.setScale(getPrecision(), RoundingMode.HALF_UP);
setAmtAcctCr(amt); setAmtAcctCr(amt);
// Set Line Org to Doc Org if still not set // Set Line Org to Doc Org if still not set
if(getAD_Org_ID() <= 0) if(getAD_Org_ID() <= 0)

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
@ -133,7 +134,7 @@ public class MLandedCostAllocation extends X_C_LandedCostAllocation
{ {
BigDecimal bd = BigDecimal.valueOf(Amt); BigDecimal bd = BigDecimal.valueOf(Amt);
if (bd.scale() > precision) if (bd.scale() > precision)
bd = bd.setScale(precision, BigDecimal.ROUND_HALF_UP); bd = bd.setScale(precision, RoundingMode.HALF_UP);
super.setAmt(bd); super.setAmt(bd);
} // setAmt } // setAmt

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Savepoint; import java.sql.Savepoint;
@ -948,7 +949,7 @@ public class MMatchPO extends X_M_MatchPO
BigDecimal poAmt = poPrice.multiply(getQty()); BigDecimal poAmt = poPrice.multiply(getQty());
BigDecimal maxTolerance = poAmt.multiply(mt); BigDecimal maxTolerance = poAmt.multiply(mt);
maxTolerance = maxTolerance.abs() maxTolerance = maxTolerance.abs()
.divide(Env.ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); .divide(Env.ONEHUNDRED, 2, RoundingMode.HALF_UP);
difference = difference.abs(); difference = difference.abs();
boolean ok = difference.compareTo(maxTolerance) <= 0; boolean ok = difference.compareTo(maxTolerance) <= 0;
if (log.isLoggable(Level.CONFIG)) log.config("Difference=" + getPriceMatchDifference() if (log.isLoggable(Level.CONFIG)) log.config("Difference=" + getPriceMatchDifference()

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -137,7 +138,7 @@ public class MMovementLine extends X_M_MovementLine
if (product != null) if (product != null)
{ {
int precision = product.getUOMPrecision(); int precision = product.getUOMPrecision();
MovementQty = MovementQty.setScale(precision, BigDecimal.ROUND_HALF_UP); MovementQty = MovementQty.setScale(precision, RoundingMode.HALF_UP);
} }
} }
super.setMovementQty(MovementQty); super.setMovementQty(MovementQty);

View File

@ -18,6 +18,7 @@ package org.compiere.model;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Hashtable; import java.util.Hashtable;
@ -2183,7 +2184,7 @@ public class MOrder extends X_C_Order implements DocAction
if (oLine.getQtyEntered().compareTo(oLine.getQtyOrdered()) != 0) if (oLine.getQtyEntered().compareTo(oLine.getQtyOrdered()) != 0)
ioLine.setQtyEntered(MovementQty ioLine.setQtyEntered(MovementQty
.multiply(oLine.getQtyEntered()) .multiply(oLine.getQtyEntered())
.divide(oLine.getQtyOrdered(), 6, BigDecimal.ROUND_HALF_UP)); .divide(oLine.getQtyOrdered(), 6, RoundingMode.HALF_UP));
if (!ioLine.save(get_TrxName())) if (!ioLine.save(get_TrxName()))
{ {
m_processMsg = "Could not create Shipment Line"; m_processMsg = "Could not create Shipment Line";
@ -2270,7 +2271,7 @@ public class MOrder extends X_C_Order implements DocAction
iLine.setQtyEntered(iLine.getQtyInvoiced()); iLine.setQtyEntered(iLine.getQtyInvoiced());
else else
iLine.setQtyEntered(iLine.getQtyInvoiced().multiply(oLine.getQtyEntered()) iLine.setQtyEntered(iLine.getQtyInvoiced().multiply(oLine.getQtyEntered())
.divide(oLine.getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP)); .divide(oLine.getQtyOrdered(), 12, RoundingMode.HALF_UP));
if (!iLine.save(get_TrxName())) if (!iLine.save(get_TrxName()))
{ {
m_processMsg = "Could not create Invoice Line from Order Line"; m_processMsg = "Could not create Invoice Line from Order Line";

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -146,7 +147,7 @@ public class MOrderLandedCost extends X_C_OrderLandedCost {
if (base.signum() != 0) if (base.signum() != 0)
{ {
BigDecimal result = getAmt().multiply(base); BigDecimal result = getAmt().multiply(base);
result = result.divide(total, orderLine.getParent().getC_Currency().getCostingPrecision(), BigDecimal.ROUND_HALF_UP); result = result.divide(total, orderLine.getParent().getC_Currency().getCostingPrecision(), RoundingMode.HALF_UP);
allocation.setAmt(result.doubleValue(), orderLine.getParent().getC_Currency().getCostingPrecision()); allocation.setAmt(result.doubleValue(), orderLine.getParent().getC_Currency().getCostingPrecision());
} }
allocation.saveEx(); allocation.saveEx();

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -63,7 +64,7 @@ public class MOrderLandedCostAllocation extends X_C_OrderLandedCostAllocation {
{ {
BigDecimal bd = BigDecimal.valueOf(Amt); BigDecimal bd = BigDecimal.valueOf(Amt);
if (bd.scale() > precision) if (bd.scale() > precision)
bd = bd.setScale(precision, BigDecimal.ROUND_HALF_UP); bd = bd.setScale(precision, RoundingMode.HALF_UP);
super.setAmt(bd); super.setAmt(bd);
} // setAmt } // setAmt

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
@ -305,7 +306,7 @@ public class MOrderLine extends X_C_OrderLine
setPriceEntered(getPriceActual()); setPriceEntered(getPriceActual());
else else
setPriceEntered(getPriceActual().multiply(getQtyOrdered() setPriceEntered(getPriceActual().multiply(getQtyOrdered()
.divide(getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP))); // recision .divide(getQtyEntered(), 12, RoundingMode.HALF_UP))); // recision
// Calculate Discount // Calculate Discount
setDiscount(m_productPrice.getDiscount()); setDiscount(m_productPrice.getDiscount());
@ -356,7 +357,7 @@ public class MOrderLine extends X_C_OrderLine
BigDecimal bd = getPriceActual().multiply(getQtyOrdered()); BigDecimal bd = getPriceActual().multiply(getQtyOrdered());
int precision = getPrecision(); int precision = getPrecision();
if (bd.scale() > precision) if (bd.scale() > precision)
bd = bd.setScale(precision, BigDecimal.ROUND_HALF_UP); bd = bd.setScale(precision, RoundingMode.HALF_UP);
super.setLineNetAmt (bd); super.setLineNetAmt (bd);
} // setLineNetAmt } // setLineNetAmt
@ -676,7 +677,7 @@ public class MOrderLine extends X_C_OrderLine
return; return;
BigDecimal discount = list.subtract(getPriceActual()) BigDecimal discount = list.subtract(getPriceActual())
.multiply(Env.ONEHUNDRED) .multiply(Env.ONEHUNDRED)
.divide(list, getPrecision(), BigDecimal.ROUND_HALF_UP); .divide(list, getPrecision(), RoundingMode.HALF_UP);
setDiscount(discount); setDiscount(discount);
} // setDiscount } // setDiscount
@ -717,7 +718,7 @@ public class MOrderLine extends X_C_OrderLine
if (QtyEntered != null && getC_UOM_ID() != 0) if (QtyEntered != null && getC_UOM_ID() != 0)
{ {
int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID()); int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID());
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_UP); QtyEntered = QtyEntered.setScale(precision, RoundingMode.HALF_UP);
} }
super.setQtyEntered (QtyEntered); super.setQtyEntered (QtyEntered);
} // setQtyEntered } // setQtyEntered
@ -732,7 +733,7 @@ public class MOrderLine extends X_C_OrderLine
if (QtyOrdered != null && product != null) if (QtyOrdered != null && product != null)
{ {
int precision = product.getUOMPrecision(); int precision = product.getUOMPrecision();
QtyOrdered = QtyOrdered.setScale(precision, BigDecimal.ROUND_HALF_UP); QtyOrdered = QtyOrdered.setScale(precision, RoundingMode.HALF_UP);
} }
super.setQtyOrdered(QtyOrdered); super.setQtyOrdered(QtyOrdered);
} // setQtyOrdered } // setQtyOrdered

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -152,10 +153,10 @@ public class MOrderPaySchedule extends X_C_OrderPaySchedule
else else
{ {
due = due.multiply(paySchedule.getPercentage()) due = due.multiply(paySchedule.getPercentage())
.divide(Env.ONEHUNDRED, scale, BigDecimal.ROUND_HALF_UP); .divide(Env.ONEHUNDRED, scale, RoundingMode.HALF_UP);
setDueAmt (due); setDueAmt (due);
BigDecimal discount = due.multiply(paySchedule.getDiscount()) BigDecimal discount = due.multiply(paySchedule.getDiscount())
.divide(Env.ONEHUNDRED, scale, BigDecimal.ROUND_HALF_UP); .divide(Env.ONEHUNDRED, scale, RoundingMode.HALF_UP);
setDiscountAmt (discount); setDiscountAmt (discount);
setIsValid(true); setIsValid(true);
} }

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
@ -136,9 +137,9 @@ public class MProductPrice extends X_M_ProductPrice
*/ */
public void setPrices (BigDecimal PriceList, BigDecimal PriceStd, BigDecimal PriceLimit) public void setPrices (BigDecimal PriceList, BigDecimal PriceStd, BigDecimal PriceLimit)
{ {
setPriceLimit (PriceLimit.setScale(this.getM_PriceList_Version().getM_PriceList().getPricePrecision(), BigDecimal.ROUND_HALF_UP)); setPriceLimit (PriceLimit.setScale(this.getM_PriceList_Version().getM_PriceList().getPricePrecision(), RoundingMode.HALF_UP));
setPriceList (PriceList.setScale(this.getM_PriceList_Version().getM_PriceList().getPricePrecision(), BigDecimal.ROUND_HALF_UP)); setPriceList (PriceList.setScale(this.getM_PriceList_Version().getM_PriceList().getPricePrecision(), RoundingMode.HALF_UP));
setPriceStd (PriceStd.setScale(this.getM_PriceList_Version().getM_PriceList().getPricePrecision(), BigDecimal.ROUND_HALF_UP)); setPriceStd (PriceStd.setScale(this.getM_PriceList_Version().getM_PriceList().getPricePrecision(), RoundingMode.HALF_UP));
} // setPrice } // setPrice
/** /**

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -826,7 +827,7 @@ public class MProductPricing extends AbstractProductPricing
Discount = BigDecimal.valueOf((m_PriceList.doubleValue() - m_PriceStd.doubleValue()) Discount = BigDecimal.valueOf((m_PriceList.doubleValue() - m_PriceStd.doubleValue())
/ m_PriceList.doubleValue() * 100.0); / m_PriceList.doubleValue() * 100.0);
if (Discount.scale() > 2) if (Discount.scale() > 2)
Discount = Discount.setScale(2, BigDecimal.ROUND_HALF_UP); Discount = Discount.setScale(2, RoundingMode.HALF_UP);
return Discount; return Discount;
} // getDiscount } // getDiscount
@ -898,7 +899,7 @@ public class MProductPricing extends AbstractProductPricing
{ {
if (m_precision >= 0 // -1 = no rounding if (m_precision >= 0 // -1 = no rounding
&& bd.scale() > m_precision) && bd.scale() > m_precision)
return bd.setScale(m_precision, BigDecimal.ROUND_HALF_UP); return bd.setScale(m_precision, RoundingMode.HALF_UP);
return bd; return bd;
} // round } // round

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
@ -249,7 +250,7 @@ public class MRMALine extends X_M_RMALine
BigDecimal bd = getAmt().multiply(getQty()); BigDecimal bd = getAmt().multiply(getQty());
int precision = getPrecision(); int precision = getPrecision();
if (bd.scale() > precision) if (bd.scale() > precision)
bd = bd.setScale(precision, BigDecimal.ROUND_HALF_UP); bd = bd.setScale(precision, RoundingMode.HALF_UP);
return bd; return bd;
} // getAmt } // getAmt

View File

@ -18,6 +18,7 @@ package org.compiere.model;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
@ -274,7 +275,7 @@ public class MRequisition extends X_M_Requisition implements DocAction
{ {
MRequisitionLine line = lines[i]; MRequisitionLine line = lines[i];
BigDecimal lineNet = line.getQty().multiply(line.getPriceActual()); BigDecimal lineNet = line.getQty().multiply(line.getPriceActual());
lineNet = lineNet.setScale(precision, BigDecimal.ROUND_HALF_UP); lineNet = lineNet.setScale(precision, RoundingMode.HALF_UP);
if (lineNet.compareTo(line.getLineNetAmt()) != 0) if (lineNet.compareTo(line.getLineNetAmt()) != 0)
{ {
line.setLineNetAmt(lineNet); line.setLineNetAmt(lineNet);

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Comparator; import java.util.Comparator;
import java.util.Properties; import java.util.Properties;
@ -148,7 +149,7 @@ public class MRfQResponseLineQty extends X_C_RfQResponseLineQty implements Compa
// Calculate // Calculate
// double result = price.doubleValue() * (100.0 - discount.doubleValue()) / 100.0; // double result = price.doubleValue() * (100.0 - discount.doubleValue()) / 100.0;
BigDecimal factor = Env.ONEHUNDRED.subtract(discount); BigDecimal factor = Env.ONEHUNDRED.subtract(discount);
return price.multiply(factor).divide(Env.ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP); return price.multiply(factor).divide(Env.ONEHUNDRED, 2, RoundingMode.HALF_UP);
} // getNetAmt } // getNetAmt

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -264,17 +265,17 @@ public class MTax extends X_C_Tax
BigDecimal tax = Env.ZERO; BigDecimal tax = Env.ZERO;
for (MTax taxc : taxarray) { for (MTax taxc : taxarray) {
BigDecimal multiplier = taxc.getRate().divide(Env.ONEHUNDRED, 12, BigDecimal.ROUND_HALF_UP); BigDecimal multiplier = taxc.getRate().divide(Env.ONEHUNDRED, 12, RoundingMode.HALF_UP);
if (!taxIncluded) // $100 * 6 / 100 == $6 == $100 * 0.06 if (!taxIncluded) // $100 * 6 / 100 == $6 == $100 * 0.06
{ {
BigDecimal itax = amount.multiply(multiplier).setScale(scale, BigDecimal.ROUND_HALF_UP); BigDecimal itax = amount.multiply(multiplier).setScale(scale, RoundingMode.HALF_UP);
tax = tax.add(itax); tax = tax.add(itax);
} }
else // $106 - ($106 / (100+6)/100) == $6 == $106 - ($106/1.06) else // $106 - ($106 / (100+6)/100) == $6 == $106 - ($106/1.06)
{ {
multiplier = multiplier.add(Env.ONE); multiplier = multiplier.add(Env.ONE);
BigDecimal base = amount.divide(multiplier, 12, BigDecimal.ROUND_HALF_UP); BigDecimal base = amount.divide(multiplier, 12, RoundingMode.HALF_UP);
BigDecimal itax = amount.subtract(base).setScale(scale, BigDecimal.ROUND_HALF_UP); BigDecimal itax = amount.subtract(base).setScale(scale, RoundingMode.HALF_UP);
tax = tax.add(itax); tax = tax.add(itax);
} }
} }

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Properties; import java.util.Properties;
@ -78,7 +79,7 @@ public class MTest extends X_Test
setT_DateTime(new Timestamp (System.currentTimeMillis())); setT_DateTime(new Timestamp (System.currentTimeMillis()));
setT_Integer(testNo); setT_Integer(testNo);
setT_Amount(new BigDecimal(testNo)); setT_Amount(new BigDecimal(testNo));
setT_Number(Env.ONE.divide(new BigDecimal(testNo), BigDecimal.ROUND_HALF_UP)); setT_Number(Env.ONE.divide(new BigDecimal(testNo), RoundingMode.HALF_UP));
// //
setC_Currency_ID(100); // USD setC_Currency_ID(100); // USD
setC_Location_ID(109); // Monroe setC_Location_ID(109); // Monroe

View File

@ -17,6 +17,7 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -216,7 +217,7 @@ public class MUOM extends X_C_UOM
if (!stdPrecision) if (!stdPrecision)
precision = getCostingPrecision(); precision = getCostingPrecision();
if (qty.scale() > precision) if (qty.scale() > precision)
return qty.setScale(getStdPrecision(), BigDecimal.ROUND_HALF_UP); return qty.setScale(getStdPrecision(), RoundingMode.HALF_UP);
return qty; return qty;
} // round } // round

View File

@ -18,6 +18,7 @@ package org.compiere.model;
import java.awt.Point; import java.awt.Point;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -191,7 +192,7 @@ public class MUOMConversion extends X_C_UOM_Conversion
s_conversions.put(p, mr); s_conversions.put(p, mr);
// reverse // reverse
if (dr == null && mr != null) if (dr == null && mr != null)
dr = Env.ONE.divide(mr, BigDecimal.ROUND_HALF_UP); dr = Env.ONE.divide(mr, RoundingMode.HALF_UP);
if (dr != null) if (dr != null)
s_conversions.put(new Point(p.y,p.x), dr); s_conversions.put(new Point(p.y,p.x), dr);
} }
@ -445,7 +446,7 @@ public class MUOMConversion extends X_C_UOM_Conversion
// Calculate & Scale // Calculate & Scale
retValue = retValue.multiply(qty); retValue = retValue.multiply(qty);
if (retValue.scale() > precision) if (retValue.scale() > precision)
retValue = retValue.setScale(precision, BigDecimal.ROUND_HALF_UP); retValue = retValue.setScale(precision, RoundingMode.HALF_UP);
return retValue; return retValue;
} // convert } // convert

View File

@ -21,6 +21,7 @@ import java.io.DataOutputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URL; import java.net.URL;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -191,7 +192,7 @@ public abstract class PaymentProcessor
else else
{ {
if (value.scale() < 2) if (value.scale() < 2)
value = value.setScale(2, BigDecimal.ROUND_HALF_UP); value = value.setScale(2, RoundingMode.HALF_UP);
return createPair (name, String.valueOf(value), maxLength); return createPair (name, String.valueOf(value), maxLength);
} }
} // createPair } // createPair

View File

@ -17,6 +17,7 @@
package org.compiere.print; package org.compiere.print;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -132,25 +133,25 @@ public class PrintDataFunction
// Mean = sum/count - round to 4 digits // Mean = sum/count - round to 4 digits
if (function == F_MEAN) if (function == F_MEAN)
{ {
BigDecimal mean = m_sum.divide(count, 4, BigDecimal.ROUND_HALF_UP); BigDecimal mean = m_sum.divide(count, 4, RoundingMode.HALF_UP);
if (mean.scale() > 4) if (mean.scale() > 4)
mean = mean.setScale(4, BigDecimal.ROUND_HALF_UP); mean = mean.setScale(4, RoundingMode.HALF_UP);
return mean; return mean;
} }
// Variance = ( sum of squares - (square of sum / count) ) / count // Variance = ( sum of squares - (square of sum / count) ) / count
BigDecimal ss = m_sum.multiply(m_sum); BigDecimal ss = m_sum.multiply(m_sum);
ss = ss.divide(count, 10, BigDecimal.ROUND_HALF_UP); ss = ss.divide(count, 10, RoundingMode.HALF_UP);
BigDecimal variance = m_sumSquare.subtract(ss).divide(count, 10, BigDecimal.ROUND_HALF_UP); BigDecimal variance = m_sumSquare.subtract(ss).divide(count, 10, RoundingMode.HALF_UP);
if (function == F_VARIANCE) if (function == F_VARIANCE)
{ {
if (variance.scale() > 4) if (variance.scale() > 4)
variance = variance.setScale(4, BigDecimal.ROUND_HALF_UP); variance = variance.setScale(4, RoundingMode.HALF_UP);
return variance; return variance;
} }
// Standard Deviation // Standard Deviation
BigDecimal deviation = BigDecimal.valueOf(Math.sqrt(variance.doubleValue())); BigDecimal deviation = BigDecimal.valueOf(Math.sqrt(variance.doubleValue()));
if (deviation.scale() > 4) if (deviation.scale() > 4)
deviation = deviation.setScale(4, BigDecimal.ROUND_HALF_UP); deviation = deviation.setScale(4, RoundingMode.HALF_UP);
return deviation; return deviation;
} // getValue } // getValue

View File

@ -17,6 +17,7 @@
package org.compiere.sla; package org.compiere.sla;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -146,7 +147,7 @@ public class DeliveryAccuracy extends SLACriteria
// Calculate with 2 digits precision // Calculate with 2 digits precision
if (count != 0) if (count != 0)
retValue = total.divide(new BigDecimal(count), 2, BigDecimal.ROUND_HALF_UP); retValue = total.divide(new BigDecimal(count), 2, RoundingMode.HALF_UP);
return retValue; return retValue;
} // calculateMeasure } // calculateMeasure

View File

@ -2,6 +2,8 @@ package org.compiere.util;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import static java.math.BigDecimal.valueOf; import static java.math.BigDecimal.valueOf;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -74,10 +76,10 @@ između
StringBuilder rezultat = new StringBuilder(); StringBuilder rezultat = new StringBuilder();
// zaokruži na dvije decimale // zaokruži na dvije decimale
broj = broj.setScale(2, BigDecimal.ROUND_HALF_EVEN); broj = broj.setScale(2, RoundingMode.HALF_EVEN);
// kune (dio bez decimala) // kune (dio bez decimala)
BigDecimal kune = broj.setScale(0, BigDecimal.ROUND_DOWN); BigDecimal kune = broj.setScale(0, RoundingMode.DOWN);
rezultat.append(slovima(kune, "kuna", false, false)); rezultat.append(slovima(kune, "kuna", false, false));
rezultat.append(RAZMAK + "i" + RAZMAK); rezultat.append(RAZMAK + "i" + RAZMAK);

View File

@ -13,6 +13,7 @@
package org.compiere.util; package org.compiere.util;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
/** /**
* Portuguese Amount in Words * Portuguese Amount in Words
@ -248,7 +249,7 @@ public class AmtInWords_PT implements AmtInWords
public String getAmtInWords (BigDecimal amount) throws Exception public String getAmtInWords (BigDecimal amount) throws Exception
{ {
amount = amount.setScale(2, BigDecimal.ROUND_HALF_UP); amount = amount.setScale(2, RoundingMode.HALF_UP);
String samount = amount.toString(); String samount = amount.toString();
samount = samount.replaceAll("\\.", ","); samount = samount.replaceAll("\\.", ",");

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.util; package org.compiere.util;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
/** /**
* Amount in Words for Zh_CN (CNY in Simplified Chinese) * Amount in Words for Zh_CN (CNY in Simplified Chinese)
@ -139,7 +140,7 @@ public class AmtInWords_ZH implements AmtInWords
} }
// round to 1/100, get long number ,eg -5432.135 = 543214 // round to 1/100, get long number ,eg -5432.135 = 543214
long lnumber = number.movePointRight(2).setScale(0, BigDecimal.ROUND_HALF_UP).abs().longValue(); long lnumber = number.movePointRight(2).setScale(0, RoundingMode.HALF_UP).abs().longValue();
// number must less 10000000000000 (10^13) // number must less 10000000000000 (10^13)
if (lnumber >= 1000000000000000L) { if (lnumber >= 1000000000000000L) {

View File

@ -18,6 +18,7 @@ package org.compiere.wf;
import java.awt.Point; import java.awt.Point;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -496,7 +497,7 @@ public class MWFNode extends X_AD_WF_Node
return 0; return 0;
// //
BigDecimal change = new BigDecimal (seconds) BigDecimal change = new BigDecimal (seconds)
.divide(divide, BigDecimal.ROUND_DOWN) .divide(divide, RoundingMode.DOWN)
.multiply(getDynPriorityChange()); .multiply(getDynPriorityChange());
return change.intValue(); return change.intValue();
} // calculateDynamicPriority } // calculateDynamicPriority

View File

@ -17,6 +17,7 @@
package org.eevolution.model; package org.eevolution.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
@ -485,7 +486,7 @@ public class MDDOrderLine extends X_DD_OrderLine
if (QtyEntered != null && getC_UOM_ID() != 0) if (QtyEntered != null && getC_UOM_ID() != 0)
{ {
int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID()); int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID());
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_UP); QtyEntered = QtyEntered.setScale(precision, RoundingMode.HALF_UP);
} }
super.setQtyEntered (QtyEntered); super.setQtyEntered (QtyEntered);
} // setQtyEntered } // setQtyEntered
@ -500,7 +501,7 @@ public class MDDOrderLine extends X_DD_OrderLine
if (QtyOrdered != null && product != null) if (QtyOrdered != null && product != null)
{ {
int precision = product.getUOMPrecision(); int precision = product.getUOMPrecision();
QtyOrdered = QtyOrdered.setScale(precision, BigDecimal.ROUND_HALF_UP); QtyOrdered = QtyOrdered.setScale(precision, RoundingMode.HALF_UP);
} }
super.setQtyOrdered(QtyOrdered); super.setQtyOrdered(QtyOrdered);
} // setQtyOrdered } // setQtyOrdered

View File

@ -227,7 +227,7 @@ public class MPPProductBOMLine extends X_PP_Product_BOMLine
if (includeScrapQty) if (includeScrapQty)
{ {
BigDecimal scrapDec = getScrap().divide(Env.ONEHUNDRED, 12, BigDecimal.ROUND_UP); BigDecimal scrapDec = getScrap().divide(Env.ONEHUNDRED, 12, BigDecimal.ROUND_UP);
qty = qty.divide(Env.ONE.subtract(scrapDec), precision, BigDecimal.ROUND_HALF_UP); qty = qty.divide(Env.ONE.subtract(scrapDec), precision, RoundingMode.HALF_UP);
} }
// //
if (qty.scale() > precision) if (qty.scale() > precision)

View File

@ -17,6 +17,7 @@
package org.globalqss.process; package org.globalqss.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -229,7 +230,7 @@ public class CashFlow extends SvrProcess {
open = open.subtract(paid); open = open.subtract(paid);
} }
if (open.scale() > curr.getStdPrecision()) if (open.scale() > curr.getStdPrecision())
open = open.setScale(curr.getStdPrecision(), BigDecimal.ROUND_HALF_UP); open = open.setScale(curr.getStdPrecision(), RoundingMode.HALF_UP);
BigDecimal invoiced = order.getGrandTotal().subtract(open); BigDecimal invoiced = order.getGrandTotal().subtract(open);
if (isPaySchedule) { if (isPaySchedule) {
MOrderPaySchedule[] schedule = MOrderPaySchedule.getOrderPaySchedule(getCtx(), order_id, 0, get_TrxName()); MOrderPaySchedule[] schedule = MOrderPaySchedule.getOrderPaySchedule(getCtx(), order_id, 0, get_TrxName());

View File

@ -26,6 +26,7 @@ package org.globalqss.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -543,11 +544,11 @@ public class GLJournalGenerate extends SvrProcess
if (roundFactor < 0) { if (roundFactor < 0) {
BigDecimal divisor = BigDecimal.valueOf(Math.pow(10, -roundFactor)); BigDecimal divisor = BigDecimal.valueOf(Math.pow(10, -roundFactor));
sourceAmt = sourceAmt.divide(divisor, MathContext.UNLIMITED); sourceAmt = sourceAmt.divide(divisor, MathContext.UNLIMITED);
sourceAmt = sourceAmt.setScale(0, BigDecimal.ROUND_HALF_UP); sourceAmt = sourceAmt.setScale(0, RoundingMode.HALF_UP);
sourceAmt = sourceAmt.multiply(divisor, MathContext.UNLIMITED); sourceAmt = sourceAmt.multiply(divisor, MathContext.UNLIMITED);
sourceAmt = sourceAmt.setScale(0, BigDecimal.ROUND_HALF_UP); sourceAmt = sourceAmt.setScale(0, RoundingMode.HALF_UP);
} else { } else {
sourceAmt = sourceAmt.setScale(roundFactor, BigDecimal.ROUND_HALF_UP); sourceAmt = sourceAmt.setScale(roundFactor, RoundingMode.HALF_UP);
} }
return sourceAmt; return sourceAmt;
} }

View File

@ -168,7 +168,7 @@ public class MyValidator implements ModelValidator
// Calculate Discount // Calculate Discount
BigDecimal discountPercent = new BigDecimal(3); // 3% example BigDecimal discountPercent = new BigDecimal(3); // 3% example
BigDecimal discountAmt = totalLines.multiply(discountPercent); BigDecimal discountAmt = totalLines.multiply(discountPercent);
discountAmt = discountAmt.divide(Env.ONEHUNDRED, order.getPrecision(), BigDecimal.ROUND_HALF_UP); discountAmt = discountAmt.divide(Env.ONEHUNDRED, order.getPrecision(), RoundingMode.HALF_UP);
discountLine.setPrice(discountAmt.negate()); discountLine.setPrice(discountAmt.negate());
if (!discountLine.save()) if (!discountLine.save())
return "Could not save discount line"; return "Could not save discount line";

View File

@ -14,6 +14,7 @@
package test.functional; package test.functional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import org.compiere.model.MLocator; import org.compiere.model.MLocator;
import org.compiere.model.MStorageOnHand; import org.compiere.model.MStorageOnHand;
@ -44,12 +45,12 @@ public class MStorageTest extends AdempiereTestCase
loc.setXYZ("X"+locatorValue, "Y"+locatorValue, "Z"+locatorValue); loc.setXYZ("X"+locatorValue, "Y"+locatorValue, "Z"+locatorValue);
loc.saveEx(); loc.saveEx();
// //
BigDecimal targetQty = BigDecimal.valueOf(qtyOnHand).setScale(12, BigDecimal.ROUND_HALF_UP); BigDecimal targetQty = BigDecimal.valueOf(qtyOnHand).setScale(12, RoundingMode.HALF_UP);
MStorageOnHand s1 = MStorageOnHand.getCreate(getCtx(), loc.get_ID(), product_id, 0,null, getTrxName()); MStorageOnHand s1 = MStorageOnHand.getCreate(getCtx(), loc.get_ID(), product_id, 0,null, getTrxName());
s1.setQtyOnHand(targetQty); s1.setQtyOnHand(targetQty);
s1.saveEx(); s1.saveEx();
// //
BigDecimal qty = MStorageReservation.getQtyAvailable(wh.get_ID(), product_id, 0, getTrxName()).setScale(12, BigDecimal.ROUND_HALF_UP); BigDecimal qty = MStorageReservation.getQtyAvailable(wh.get_ID(), product_id, 0, getTrxName()).setScale(12, RoundingMode.HALF_UP);
assertEquals("Error on locator "+locatorValue, targetQty, qty); assertEquals("Error on locator "+locatorValue, targetQty, qty);
// //
return loc; return loc;
@ -57,8 +58,8 @@ public class MStorageTest extends AdempiereTestCase
private void assertWarehouseQty(MWarehouse wh, BigDecimal targetQty) private void assertWarehouseQty(MWarehouse wh, BigDecimal targetQty)
{ {
BigDecimal qty = MStorageReservation.getQtyAvailable(wh.get_ID(), product_id, 0, getTrxName()); BigDecimal qty = MStorageReservation.getQtyAvailable(wh.get_ID(), product_id, 0, getTrxName());
qty = qty.setScale(12, BigDecimal.ROUND_HALF_UP); qty = qty.setScale(12, RoundingMode.HALF_UP);
targetQty = targetQty.setScale(12, BigDecimal.ROUND_HALF_UP); targetQty = targetQty.setScale(12, RoundingMode.HALF_UP);
assertEquals(targetQty, qty); assertEquals(targetQty, qty);
} }

View File

@ -29,6 +29,7 @@
package org.adempiere.process.rpl.imp; package org.adempiere.process.rpl.imp;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
@ -696,7 +697,7 @@ public class ImportHelper {
else if( DisplayType.isNumeric(column.getAD_Reference_ID())) else if( DisplayType.isNumeric(column.getAD_Reference_ID()))
{ {
valuecol="Round("+valuecol+",2)"; valuecol="Round("+valuecol+",2)";
params[col] = new BigDecimal((String)cols[col]).setScale(2, BigDecimal.ROUND_HALF_UP); params[col] = new BigDecimal((String)cols[col]).setScale(2, RoundingMode.HALF_UP);
} }
else else
{ {

View File

@ -28,6 +28,7 @@ import java.awt.event.KeyListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -718,7 +719,7 @@ class myJTree extends JTree
sb.append(" ["+((KeyNamePair) userObject.elementAt(3)).getName().trim()+"]"); sb.append(" ["+((KeyNamePair) userObject.elementAt(3)).getName().trim()+"]");
//BOMQty //BOMQty
BigDecimal BOMQty = (BigDecimal)(userObject.elementAt(4)); BigDecimal BOMQty = (BigDecimal)(userObject.elementAt(4));
sb.append("x"+BOMQty.setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); sb.append("x"+BOMQty.setScale(2, RoundingMode.HALF_UP).stripTrailingZeros());
return sb.toString(); return sb.toString();
} }

View File

@ -28,6 +28,7 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
@ -485,7 +486,7 @@ public final class Calculator extends CDialog
char op = token.charAt(0); char op = token.charAt(0);
if (op == '%') { if (op == '%') {
firstNo = firstNo.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); firstNo = firstNo.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP);
m_number = firstNo; m_number = firstNo;
} }
@ -523,13 +524,13 @@ public final class Calculator extends CDialog
// Percent operation // Percent operation
if (op2 == '%') if (op2 == '%')
secondNo = secondNo.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); secondNo = secondNo.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP);
switch (op) switch (op)
{ {
case '/': case '/':
m_number = firstNo m_number = firstNo
.divide(secondNo, m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); .divide(secondNo, m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP);
break; break;
case '*': case '*':
m_number = firstNo.multiply(secondNo); m_number = firstNo.multiply(secondNo);
@ -543,7 +544,7 @@ public final class Calculator extends CDialog
default: default:
break; break;
} }
return m_number.setScale(m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); return m_number.setScale(m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP);
} // evaluate } // evaluate

View File

@ -17,6 +17,7 @@
package org.compiere.grid.ed; package org.compiere.grid.ed;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.text.ParseException; import java.text.ParseException;
@ -228,7 +229,7 @@ public final class MDocNumber extends PlainDocument
{ {
Number number = m_format.parse(value); Number number = m_format.parse(value);
percentValue = new BigDecimal (number.toString()); percentValue = new BigDecimal (number.toString());
percentValue = percentValue.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); percentValue = percentValue.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP);
m_tc.setText(m_format.format(percentValue)); m_tc.setText(m_format.format(percentValue));
} }
} }

View File

@ -37,6 +37,7 @@ import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.logging.Level; import java.util.logging.Level;
@ -462,7 +463,7 @@ public final class VNumber extends JComponent
return Integer.valueOf(bd.intValue()); return Integer.valueOf(bd.intValue());
if (bd.signum() == 0) if (bd.signum() == 0)
return bd; return bd;
return bd.setScale(m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP); return bd.setScale(m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -16,6 +16,7 @@
package org.adempiere.webui.apps.form; package org.adempiere.webui.apps.form;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -327,7 +328,7 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
MUOM u = new MUOM(product.getCtx(), product.getC_UOM_ID(), product.get_TrxName()); MUOM u = new MUOM(product.getCtx(), product.getC_UOM_ID(), product.get_TrxName());
KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol()); KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol());
line.add(uom); // 3 C_UOM_ID line.add(uom); // 3 C_UOM_ID
line.add((BigDecimal) (Env.ONE).setScale(4, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); // 4 QtyBOM line.add((BigDecimal) (Env.ONE).setScale(4, RoundingMode.HALF_UP).stripTrailingZeros()); // 4 QtyBOM
// dummy root node, as first node is not displayed in tree // dummy root node, as first node is not displayed in tree
mySimpleTreeNode parent = new mySimpleTreeNode("Root",new ArrayList<TreeNode<Object>>()); mySimpleTreeNode parent = new mySimpleTreeNode("Root",new ArrayList<TreeNode<Object>>());
@ -449,7 +450,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()); 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()); KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol());
line.add(uom); // 3 C_UOM_ID line.add(uom); // 3 C_UOM_ID
line.add((BigDecimal) ((bomline.getBOMQty()!=null) ? bomline.getBOMQty() : Env.ZERO).setScale(4, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); // 4 QtyBOM line.add((BigDecimal) ((bomline.getBOMQty()!=null) ? bomline.getBOMQty() : Env.ZERO).setScale(4, RoundingMode.HALF_UP).stripTrailingZeros()); // 4 QtyBOM
mySimpleTreeNode child = new mySimpleTreeNode(line,new ArrayList<TreeNode<Object>>()); mySimpleTreeNode child = new mySimpleTreeNode(line,new ArrayList<TreeNode<Object>>());
if (!reload) if (!reload)
@ -478,7 +479,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()); 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()); KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol());
line.add(uom); // 3 C_UOM_ID line.add(uom); // 3 C_UOM_ID
line.add((BigDecimal) ((bom.getBOMQty()!=null) ? bom.getBOMQty() : Env.ZERO).setScale(4, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); // 4 QtyBOM line.add((BigDecimal) ((bom.getBOMQty()!=null) ? bom.getBOMQty() : Env.ZERO).setScale(4, RoundingMode.HALF_UP).stripTrailingZeros()); // 4 QtyBOM
if(m_selected_id == bom.getM_ProductBOM_ID() || getM_Product_ID() == bom.getM_ProductBOM_ID()) if(m_selected_id == bom.getM_ProductBOM_ID() || getM_Product_ID() == bom.getM_ProductBOM_ID())
dataBOM.add(line); dataBOM.add(line);
@ -563,7 +564,7 @@ class mySimpleTreeNode extends DefaultTreeNode<Object>
sb.append(" ["+((KeyNamePair) userObject.elementAt(3)).getName().trim()+"]"); sb.append(" ["+((KeyNamePair) userObject.elementAt(3)).getName().trim()+"]");
// BOMQty // BOMQty
BigDecimal BOMQty = (BigDecimal)(userObject.elementAt(4)); BigDecimal BOMQty = (BigDecimal)(userObject.elementAt(4));
sb.append("x"+BOMQty.setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros()); sb.append("x"+BOMQty.setScale(2, RoundingMode.HALF_UP).stripTrailingZeros());
return sb.toString(); return sb.toString();
} }

View File

@ -15,6 +15,7 @@ package org.adempiere.webui.apps.graph;
import java.awt.Point; import java.awt.Point;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -417,7 +418,7 @@ public class WGraph extends Div implements IdSpace {
td.setSclass("pa-tdcontent"); td.setSclass("pa-tdcontent");
tr.appendChild(td); tr.appendChild(td);
text = new Text(format.format(m_goal.getMeasureTarget().setScale(2, text = new Text(format.format(m_goal.getMeasureTarget().setScale(2,
BigDecimal.ROUND_HALF_UP))); RoundingMode.HALF_UP)));
td.appendChild(text); td.appendChild(text);
tr = new Tr(); tr = new Tr();
@ -432,7 +433,7 @@ public class WGraph extends Div implements IdSpace {
td.setSclass("pa-tdcontent"); td.setSclass("pa-tdcontent");
tr.appendChild(td); tr.appendChild(td);
text = new Text(format.format(m_goal.getMeasureActual().setScale(2, text = new Text(format.format(m_goal.getMeasureActual().setScale(2,
BigDecimal.ROUND_HALF_UP))); RoundingMode.HALF_UP)));
td.appendChild(text); td.appendChild(text);
GraphColumn[] bList = getGraphColumnList(); GraphColumn[] bList = getGraphColumnList();
@ -483,11 +484,11 @@ public class WGraph extends Div implements IdSpace {
}); });
a.setDynamicProperty("href", "javascript:;"); a.setDynamicProperty("href", "javascript:;");
text = new Text(format.format(value.setScale(2, BigDecimal.ROUND_HALF_UP))); text = new Text(format.format(value.setScale(2, RoundingMode.HALF_UP)));
a.appendChild(text); a.appendChild(text);
} else { } else {
text = new Text(format.format(value.setScale(2, BigDecimal.ROUND_HALF_UP))); text = new Text(format.format(value.setScale(2, RoundingMode.HALF_UP)));
} }
} }
tr = new Tr(); tr = new Tr();

View File

@ -18,6 +18,7 @@
package org.adempiere.webui.editor; package org.adempiere.webui.editor;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import org.adempiere.webui.ClientInfo; import org.adempiere.webui.ClientInfo;
@ -221,7 +222,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
divisor = BigDecimal.TEN; divisor = BigDecimal.TEN;
else else
divisor = BigDecimal.TEN.pow(decimalPlaces); divisor = BigDecimal.TEN.pow(decimalPlaces);
BigDecimal newValue = oldValue.divide(divisor, decimalPlaces, BigDecimal.ROUND_HALF_UP); BigDecimal newValue = oldValue.divide(divisor, decimalPlaces, RoundingMode.HALF_UP);
return newValue; return newValue;
} //getAddDecimalPlaces } //getAddDecimalPlaces

View File

@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -416,7 +417,7 @@ public class WAttachment extends Window implements EventListener<Event>
size = size.divide(new BigDecimal("1024")); size = size.divide(new BigDecimal("1024"));
unit = " MB"; unit = " MB";
} }
size = size.setScale(2, BigDecimal.ROUND_HALF_EVEN); size = size.setScale(2, RoundingMode.HALF_EVEN);
sizeLabel.setText(size.toPlainString() + unit); sizeLabel.setText(size.toPlainString() + unit);
bSave.setEnabled(true); bSave.setEnabled(true);

View File

@ -19,6 +19,7 @@ package org.adempiere.webui.window;
import static org.compiere.model.SystemIDs.COLUMN_M_MOVEMENTLINE_M_ATTRIBUTESETINSTANCE_ID; import static org.compiere.model.SystemIDs.COLUMN_M_MOVEMENTLINE_M_ATTRIBUTESETINSTANCE_ID;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -1061,7 +1062,7 @@ public class WPAttributeDialog extends Window implements EventListener<Event>
mandatory += " - " + attributes[i].getName(); mandatory += " - " + attributes[i].getName();
//setMAttributeInstance doesn't work without decimal point //setMAttributeInstance doesn't work without decimal point
if (value != null && value.scale() == 0) if (value != null && value.scale() == 0)
value = value.setScale(1, BigDecimal.ROUND_HALF_UP); value = value.setScale(1, RoundingMode.HALF_UP);
attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value); attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value);
} }
else if (MAttribute.ATTRIBUTEVALUETYPE_Date.equals(attributes[i].getAttributeValueType())) else if (MAttribute.ATTRIBUTEVALUETYPE_Date.equals(attributes[i].getAttributeValueType()))

View File

@ -14,6 +14,7 @@
package org.compiere.grid; package org.compiere.grid;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -448,7 +449,7 @@ public abstract class CreateFromInvoice extends CreateFrom
product = MProduct.get(Env.getCtx(), M_Product_ID); product = MProduct.get(Env.getCtx(), M_Product_ID);
precision = product.getUOMPrecision(); precision = product.getUOMPrecision();
} }
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_DOWN); QtyEntered = QtyEntered.setScale(precision, RoundingMode.HALF_DOWN);
// //
if (log.isLoggable(Level.FINE)) log.fine("Line QtyEntered=" + QtyEntered if (log.isLoggable(Level.FINE)) log.fine("Line QtyEntered=" + QtyEntered
+ ", Product_ID=" + M_Product_ID + ", Product_ID=" + M_Product_ID
@ -586,7 +587,7 @@ public abstract class CreateFromInvoice extends CreateFrom
BigDecimal igt = invoice.getGrandTotal(); BigDecimal igt = invoice.getGrandTotal();
BigDecimal percent = Env.ONE; BigDecimal percent = Env.ONE;
if (ogt.compareTo(igt) != 0) if (ogt.compareTo(igt) != 0)
percent = igt.divide(ogt, 10, BigDecimal.ROUND_HALF_UP); percent = igt.divide(ogt, 10, RoundingMode.HALF_UP);
MCurrency cur = MCurrency.get(p_order.getCtx(), p_order.getC_Currency_ID()); MCurrency cur = MCurrency.get(p_order.getCtx(), p_order.getC_Currency_ID());
int scale = cur.getStdPrecision(); int scale = cur.getStdPrecision();
@ -596,7 +597,7 @@ public abstract class CreateFromInvoice extends CreateFrom
if (percent != Env.ONE) { if (percent != Env.ONE) {
BigDecimal propDueAmt = ops.getDueAmt().multiply(percent); BigDecimal propDueAmt = ops.getDueAmt().multiply(percent);
if (propDueAmt.scale() > scale) if (propDueAmt.scale() > scale)
propDueAmt = propDueAmt.setScale(scale, BigDecimal.ROUND_HALF_UP); propDueAmt = propDueAmt.setScale(scale, RoundingMode.HALF_UP);
ips.setDueAmt(propDueAmt); ips.setDueAmt(propDueAmt);
} }
ips.setC_Invoice_ID(invoice.getC_Invoice_ID()); ips.setC_Invoice_ID(invoice.getC_Invoice_ID());

View File

@ -15,6 +15,7 @@
package org.compiere.grid; package org.compiere.grid;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -595,7 +596,7 @@ public abstract class CreateFromShipment extends CreateFrom
MProduct product = MProduct.get(Env.getCtx(), M_Product_ID); MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
precision = product.getUOMPrecision(); precision = product.getUOMPrecision();
} }
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_DOWN); QtyEntered = QtyEntered.setScale(precision, RoundingMode.HALF_DOWN);
// //
if (log.isLoggable(Level.FINE)) log.fine("Line QtyEntered=" + QtyEntered if (log.isLoggable(Level.FINE)) log.fine("Line QtyEntered=" + QtyEntered
+ ", Product=" + M_Product_ID + ", Product=" + M_Product_ID
@ -620,7 +621,7 @@ public abstract class CreateFromShipment extends CreateFrom
{ {
iol.setMovementQty(QtyEntered iol.setMovementQty(QtyEntered
.multiply(ol.getQtyOrdered()) .multiply(ol.getQtyOrdered())
.divide(ol.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP)); .divide(ol.getQtyEntered(), 12, RoundingMode.HALF_UP));
iol.setC_UOM_ID(ol.getC_UOM_ID()); iol.setC_UOM_ID(ol.getC_UOM_ID());
} }
iol.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID()); iol.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
@ -641,7 +642,7 @@ public abstract class CreateFromShipment extends CreateFrom
{ {
iol.setQtyEntered(QtyEntered iol.setQtyEntered(QtyEntered
.multiply(il.getQtyInvoiced()) .multiply(il.getQtyInvoiced())
.divide(il.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP)); .divide(il.getQtyEntered(), 12, RoundingMode.HALF_UP));
iol.setC_UOM_ID(il.getC_UOM_ID()); iol.setC_UOM_ID(il.getC_UOM_ID());
} }
iol.setDescription(il.getDescription()); iol.setDescription(il.getDescription());

View File

@ -23,6 +23,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URL; import java.net.URL;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
@ -514,7 +515,7 @@ public class DB_Oracle implements AdempiereDatabase
{ {
try try
{ {
result = number.setScale(scale, BigDecimal.ROUND_HALF_UP); result = number.setScale(scale, RoundingMode.HALF_UP);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -25,6 +25,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URL; import java.net.URL;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
@ -495,7 +496,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
{ {
try try
{ {
result = number.setScale(scale, BigDecimal.ROUND_HALF_UP); result = number.setScale(scale, RoundingMode.HALF_UP);
} }
catch (Exception e) catch (Exception e)
{ {