Big Decimal exception at completing Physical Inventory for products with cost=0
I reproduced it once with the following:
Create a Physical Inventory entry.
Create a line with a product which has costs=0.
Complete the Physical Inventory.
==> Error: Exception
java.lang.ArithmeticException: Rounding necessary (0): java.math.BigDecimal.divideAndRound(BigDecimal.java:1435)
The cause:
MCost.calculateAverageInv()
Statement newAmt = newAmt.setScale(as.getCostingPrecision());
(line 867)
The fix:
setScale() should be called with a second argument, specifying the required precision:
newAmt = newAmt.setScale(as.getCostingPrecision(),RoundingMode.HALF_UP);
This bug can actually happen always when evaluating costs for products with costs=0
I tried to reproduce it on testadempiere, but it doesn't seem to come to MCost.calculateAverageInv() .
Anyway, it is safer to call setScale() with a rounding mode.
Mario Calderon
Committed revision 12014
http://adempiere.svn.sourceforge.net/adempiere/?rev=12014&view=rev
Regards,
Carlos Ruiz
Merged fix from release to trunk with Revision: 12031
http://adempiere.svn.sourceforge.net/adempiere/?rev=12031&view=rev
Regards,
Tony
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).