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:
Deepak Pansheriya 2023-04-17 13:55:05 +05:30 committed by GitHub
parent dd0e6c95ea
commit 76daedf6ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 16 deletions

View File

@ -602,7 +602,7 @@ public class CalloutInvoice extends CalloutEngine
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
// //
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, pp.getPriceStd()); C_UOM_To_ID, pp.getPriceStd(), 12);
if (PriceEntered == null) if (PriceEntered == null)
PriceEntered = pp.getPriceStd(); PriceEntered = pp.getPriceStd();
// //
@ -617,7 +617,7 @@ public class CalloutInvoice extends CalloutEngine
{ {
PriceActual = (BigDecimal)value; PriceActual = (BigDecimal)value;
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, PriceActual); C_UOM_To_ID, PriceActual, 12);
if (PriceEntered == null) if (PriceEntered == null)
PriceEntered = PriceActual; PriceEntered = PriceActual;
// //
@ -629,7 +629,7 @@ public class CalloutInvoice extends CalloutEngine
{ {
PriceEntered = (BigDecimal)value; PriceEntered = (BigDecimal)value;
PriceActual = MUOMConversion.convertProductTo (ctx, M_Product_ID, PriceActual = MUOMConversion.convertProductTo (ctx, M_Product_ID,
C_UOM_To_ID, PriceEntered); C_UOM_To_ID, PriceEntered, 12);
if (PriceActual == null) if (PriceActual == null)
PriceActual = PriceEntered; PriceActual = PriceEntered;
// //
@ -649,7 +649,7 @@ public class CalloutInvoice extends CalloutEngine
{ {
PriceActual = PriceLimit; PriceActual = PriceLimit;
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, PriceLimit); C_UOM_To_ID, PriceLimit, 12);
if (PriceEntered == null) if (PriceEntered == null)
PriceEntered = PriceLimit; PriceEntered = PriceLimit;
if (log.isLoggable(Level.FINE)) log.fine("amt =(under) PriceEntered=" + PriceEntered + ", Actual" + 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 // Line Net Amt
BigDecimal LineNetAmt = QtyInvoiced.multiply(PriceActual); BigDecimal LineNetAmt = QtyEntered.multiply(PriceEntered);
if (LineNetAmt.scale() > StdPrecision) if (LineNetAmt.scale() > StdPrecision)
LineNetAmt = LineNetAmt.setScale(StdPrecision, RoundingMode.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);
@ -768,7 +768,7 @@ public class CalloutInvoice extends CalloutEngine
boolean conversion = QtyEntered.compareTo(QtyInvoiced) != 0; boolean conversion = QtyEntered.compareTo(QtyInvoiced) != 0;
PriceActual = (BigDecimal)mTab.getValue("PriceActual"); PriceActual = (BigDecimal)mTab.getValue("PriceActual");
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, PriceActual); C_UOM_To_ID, PriceActual, 12);
if (PriceEntered == null) if (PriceEntered == null)
PriceEntered = PriceActual; PriceEntered = PriceActual;
if (log.isLoggable(Level.FINE)) log.fine("qty - UOM=" + C_UOM_To_ID if (log.isLoggable(Level.FINE)) log.fine("qty - UOM=" + C_UOM_To_ID

View File

@ -1073,7 +1073,7 @@ public class CalloutOrder extends CalloutEngine
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
// //
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, pp.getPriceStd()); C_UOM_To_ID, pp.getPriceStd(), 12);
if (PriceEntered == null) if (PriceEntered == null)
PriceEntered = pp.getPriceStd(); PriceEntered = pp.getPriceStd();
// //
@ -1094,7 +1094,7 @@ public class CalloutOrder extends CalloutEngine
{ {
PriceActual = (BigDecimal)value; PriceActual = (BigDecimal)value;
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, PriceActual); C_UOM_To_ID, PriceActual, 12);
if (PriceEntered == null) if (PriceEntered == null)
PriceEntered = PriceActual; PriceEntered = PriceActual;
// //
@ -1106,7 +1106,7 @@ public class CalloutOrder extends CalloutEngine
{ {
PriceEntered = (BigDecimal)value; PriceEntered = (BigDecimal)value;
PriceActual = MUOMConversion.convertProductTo (ctx, M_Product_ID, PriceActual = MUOMConversion.convertProductTo (ctx, M_Product_ID,
C_UOM_To_ID, PriceEntered); C_UOM_To_ID, PriceEntered, 12);
if (PriceActual == null) if (PriceActual == null)
PriceActual = PriceEntered; PriceActual = PriceEntered;
// //
@ -1123,7 +1123,7 @@ public class CalloutOrder extends CalloutEngine
if (PriceActual.scale() > StdPrecision) if (PriceActual.scale() > StdPrecision)
PriceActual = PriceActual.setScale(StdPrecision, RoundingMode.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, 12);
if (PriceEntered == null) if (PriceEntered == null)
PriceEntered = PriceActual; PriceEntered = PriceActual;
mTab.setValue("PriceActual", PriceActual); mTab.setValue("PriceActual", PriceActual);
@ -1153,7 +1153,7 @@ public class CalloutOrder extends CalloutEngine
{ {
PriceActual = PriceLimit; PriceActual = PriceLimit;
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, PriceLimit); C_UOM_To_ID, PriceLimit, 12);
if (PriceEntered == null) if (PriceEntered == null)
PriceEntered = PriceLimit; PriceEntered = PriceLimit;
if (log.isLoggable(Level.FINE)) log.fine("(under) PriceEntered=" + PriceEntered + ", Actual" + 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 // Line Net Amt
BigDecimal LineNetAmt = QtyOrdered.multiply(PriceActual); BigDecimal LineNetAmt = QtyEntered.multiply(PriceEntered);
if (LineNetAmt.scale() > StdPrecision) if (LineNetAmt.scale() > StdPrecision)
LineNetAmt = LineNetAmt.setScale(StdPrecision, RoundingMode.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);
@ -1227,7 +1227,7 @@ public class CalloutOrder extends CalloutEngine
boolean conversion = QtyEntered.compareTo(QtyOrdered) != 0; boolean conversion = QtyEntered.compareTo(QtyOrdered) != 0;
PriceActual = (BigDecimal)mTab.getValue("PriceActual"); PriceActual = (BigDecimal)mTab.getValue("PriceActual");
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, PriceActual); C_UOM_To_ID, PriceActual, 12);
if (PriceEntered == null) if (PriceEntered == null)
PriceEntered = PriceActual; PriceEntered = PriceActual;
if (log.isLoggable(Level.FINE)) log.fine("UOM=" + C_UOM_To_ID if (log.isLoggable(Level.FINE)) log.fine("UOM=" + C_UOM_To_ID

View File

@ -3165,7 +3165,7 @@ public class MInvoice extends X_C_Invoice implements DocAction, IDocsPostProcess
if(invoiceLine.getC_UOM_ID()!=inoutLine.getC_UOM_ID()) { if(invoiceLine.getC_UOM_ID()!=inoutLine.getC_UOM_ID()) {
invoiceLine.setC_UOM_ID(inoutLine.getC_UOM_ID()); invoiceLine.setC_UOM_ID(inoutLine.getC_UOM_ID());
BigDecimal PriceEntered = MUOMConversion.convertProductFrom (Env.getCtx(), M_Product_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) if (PriceEntered == null)
throw new AdempiereException("No Conversion For Price=" + invoiceLine.getPriceEntered()); throw new AdempiereException("No Conversion For Price=" + invoiceLine.getPriceEntered());
invoiceLine.setPriceEntered(PriceEntered); invoiceLine.setPriceEntered(PriceEntered);

View File

@ -546,7 +546,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
public void setLineNetAmt () public void setLineNetAmt ()
{ {
// Calculations & Rounding // Calculations & Rounding
BigDecimal bd = getPriceActual().multiply(getQtyInvoiced()); BigDecimal bd = getPriceEntered().multiply(getQtyEntered());
int precision = getPrecision(); int precision = getPrecision();
if (bd.scale() > precision) if (bd.scale() > precision)
bd = bd.setScale(precision, RoundingMode.HALF_UP); bd = bd.setScale(precision, RoundingMode.HALF_UP);

View File

@ -367,7 +367,7 @@ public class MOrderLine extends X_C_OrderLine
*/ */
public void setLineNetAmt () public void setLineNetAmt ()
{ {
BigDecimal bd = getPriceActual().multiply(getQtyOrdered()); BigDecimal bd = getPriceEntered().multiply(getQtyEntered());
int precision = getPrecision(); int precision = getPrecision();
if (bd.scale() > precision) if (bd.scale() > precision)
bd = bd.setScale(precision, RoundingMode.HALF_UP); bd = bd.setScale(precision, RoundingMode.HALF_UP);