IDEMPIERE-5671: Fixing Line net amount has error due to rounding. (#1782)
* IDEMPIERE-5671: Fixing Line net amount has error due to rounding. * IDEMPIERE-5671: on price calculation add 12 decimal rounding to avoid rounding error Co-authored-by: carg67@gmail.com
This commit is contained in:
parent
dd0e6c95ea
commit
76daedf6ad
|
@ -602,7 +602,7 @@ public class CalloutInvoice extends CalloutEngine
|
|||
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
||||
//
|
||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, pp.getPriceStd());
|
||||
C_UOM_To_ID, pp.getPriceStd(), 12);
|
||||
if (PriceEntered == null)
|
||||
PriceEntered = pp.getPriceStd();
|
||||
//
|
||||
|
@ -617,7 +617,7 @@ public class CalloutInvoice extends CalloutEngine
|
|||
{
|
||||
PriceActual = (BigDecimal)value;
|
||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, PriceActual);
|
||||
C_UOM_To_ID, PriceActual, 12);
|
||||
if (PriceEntered == null)
|
||||
PriceEntered = PriceActual;
|
||||
//
|
||||
|
@ -629,7 +629,7 @@ public class CalloutInvoice extends CalloutEngine
|
|||
{
|
||||
PriceEntered = (BigDecimal)value;
|
||||
PriceActual = MUOMConversion.convertProductTo (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, PriceEntered);
|
||||
C_UOM_To_ID, PriceEntered, 12);
|
||||
if (PriceActual == null)
|
||||
PriceActual = PriceEntered;
|
||||
//
|
||||
|
@ -649,7 +649,7 @@ public class CalloutInvoice extends CalloutEngine
|
|||
{
|
||||
PriceActual = PriceLimit;
|
||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, PriceLimit);
|
||||
C_UOM_To_ID, PriceLimit, 12);
|
||||
if (PriceEntered == null)
|
||||
PriceEntered = PriceLimit;
|
||||
if (log.isLoggable(Level.FINE)) log.fine("amt =(under) PriceEntered=" + PriceEntered + ", Actual" + PriceLimit);
|
||||
|
@ -666,7 +666,7 @@ public class CalloutInvoice extends CalloutEngine
|
|||
}
|
||||
|
||||
// Line Net Amt
|
||||
BigDecimal LineNetAmt = QtyInvoiced.multiply(PriceActual);
|
||||
BigDecimal LineNetAmt = QtyEntered.multiply(PriceEntered);
|
||||
if (LineNetAmt.scale() > StdPrecision)
|
||||
LineNetAmt = LineNetAmt.setScale(StdPrecision, RoundingMode.HALF_UP);
|
||||
if (log.isLoggable(Level.INFO)) log.info("amt = LineNetAmt=" + LineNetAmt);
|
||||
|
@ -768,7 +768,7 @@ public class CalloutInvoice extends CalloutEngine
|
|||
boolean conversion = QtyEntered.compareTo(QtyInvoiced) != 0;
|
||||
PriceActual = (BigDecimal)mTab.getValue("PriceActual");
|
||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, PriceActual);
|
||||
C_UOM_To_ID, PriceActual, 12);
|
||||
if (PriceEntered == null)
|
||||
PriceEntered = PriceActual;
|
||||
if (log.isLoggable(Level.FINE)) log.fine("qty - UOM=" + C_UOM_To_ID
|
||||
|
|
|
@ -1073,7 +1073,7 @@ public class CalloutOrder extends CalloutEngine
|
|||
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
||||
//
|
||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, pp.getPriceStd());
|
||||
C_UOM_To_ID, pp.getPriceStd(), 12);
|
||||
if (PriceEntered == null)
|
||||
PriceEntered = pp.getPriceStd();
|
||||
//
|
||||
|
@ -1094,7 +1094,7 @@ public class CalloutOrder extends CalloutEngine
|
|||
{
|
||||
PriceActual = (BigDecimal)value;
|
||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, PriceActual);
|
||||
C_UOM_To_ID, PriceActual, 12);
|
||||
if (PriceEntered == null)
|
||||
PriceEntered = PriceActual;
|
||||
//
|
||||
|
@ -1106,7 +1106,7 @@ public class CalloutOrder extends CalloutEngine
|
|||
{
|
||||
PriceEntered = (BigDecimal)value;
|
||||
PriceActual = MUOMConversion.convertProductTo (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, PriceEntered);
|
||||
C_UOM_To_ID, PriceEntered, 12);
|
||||
if (PriceActual == null)
|
||||
PriceActual = PriceEntered;
|
||||
//
|
||||
|
@ -1123,7 +1123,7 @@ public class CalloutOrder extends CalloutEngine
|
|||
if (PriceActual.scale() > StdPrecision)
|
||||
PriceActual = PriceActual.setScale(StdPrecision, RoundingMode.HALF_UP);
|
||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, PriceActual);
|
||||
C_UOM_To_ID, PriceActual, 12);
|
||||
if (PriceEntered == null)
|
||||
PriceEntered = PriceActual;
|
||||
mTab.setValue("PriceActual", PriceActual);
|
||||
|
@ -1153,7 +1153,7 @@ public class CalloutOrder extends CalloutEngine
|
|||
{
|
||||
PriceActual = PriceLimit;
|
||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, PriceLimit);
|
||||
C_UOM_To_ID, PriceLimit, 12);
|
||||
if (PriceEntered == null)
|
||||
PriceEntered = PriceLimit;
|
||||
if (log.isLoggable(Level.FINE)) log.fine("(under) PriceEntered=" + PriceEntered + ", Actual" + PriceLimit);
|
||||
|
@ -1171,7 +1171,7 @@ public class CalloutOrder extends CalloutEngine
|
|||
}
|
||||
|
||||
// Line Net Amt
|
||||
BigDecimal LineNetAmt = QtyOrdered.multiply(PriceActual);
|
||||
BigDecimal LineNetAmt = QtyEntered.multiply(PriceEntered);
|
||||
if (LineNetAmt.scale() > StdPrecision)
|
||||
LineNetAmt = LineNetAmt.setScale(StdPrecision, RoundingMode.HALF_UP);
|
||||
if (log.isLoggable(Level.INFO)) log.info("LineNetAmt=" + LineNetAmt);
|
||||
|
@ -1227,7 +1227,7 @@ public class CalloutOrder extends CalloutEngine
|
|||
boolean conversion = QtyEntered.compareTo(QtyOrdered) != 0;
|
||||
PriceActual = (BigDecimal)mTab.getValue("PriceActual");
|
||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||
C_UOM_To_ID, PriceActual);
|
||||
C_UOM_To_ID, PriceActual, 12);
|
||||
if (PriceEntered == null)
|
||||
PriceEntered = PriceActual;
|
||||
if (log.isLoggable(Level.FINE)) log.fine("UOM=" + C_UOM_To_ID
|
||||
|
|
|
@ -3165,7 +3165,7 @@ public class MInvoice extends X_C_Invoice implements DocAction, IDocsPostProcess
|
|||
if(invoiceLine.getC_UOM_ID()!=inoutLine.getC_UOM_ID()) {
|
||||
invoiceLine.setC_UOM_ID(inoutLine.getC_UOM_ID());
|
||||
BigDecimal PriceEntered = MUOMConversion.convertProductFrom (Env.getCtx(), M_Product_ID,
|
||||
inoutLine.getC_UOM_ID(), invoiceLine.getPriceEntered());
|
||||
inoutLine.getC_UOM_ID(), invoiceLine.getPriceEntered(), 12);
|
||||
if (PriceEntered == null)
|
||||
throw new AdempiereException("No Conversion For Price=" + invoiceLine.getPriceEntered());
|
||||
invoiceLine.setPriceEntered(PriceEntered);
|
||||
|
|
|
@ -546,7 +546,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
|
|||
public void setLineNetAmt ()
|
||||
{
|
||||
// Calculations & Rounding
|
||||
BigDecimal bd = getPriceActual().multiply(getQtyInvoiced());
|
||||
BigDecimal bd = getPriceEntered().multiply(getQtyEntered());
|
||||
int precision = getPrecision();
|
||||
if (bd.scale() > precision)
|
||||
bd = bd.setScale(precision, RoundingMode.HALF_UP);
|
||||
|
|
|
@ -367,7 +367,7 @@ public class MOrderLine extends X_C_OrderLine
|
|||
*/
|
||||
public void setLineNetAmt ()
|
||||
{
|
||||
BigDecimal bd = getPriceActual().multiply(getQtyOrdered());
|
||||
BigDecimal bd = getPriceEntered().multiply(getQtyEntered());
|
||||
int precision = getPrecision();
|
||||
if (bd.scale() > precision)
|
||||
bd = bd.setScale(precision, RoundingMode.HALF_UP);
|
||||
|
|
Loading…
Reference in New Issue