Fixes bug 29079: Fixed Costing Background infinite loop.
authorUnai Martirena <unai.martirena@openbravo.com>
Thu, 26 Feb 2015 15:36:55 +0100
changeset 26087 4b1565029827
parent 26086 67607f6caaee
child 26089 e0dc3cac2184
Fixes bug 29079: Fixed Costing Background infinite loop.

Costing Background process, due to Cost Adjustments new implementation, on a certain point of the code, it was not applying correctly a setScale method to round a value of the expected cost. This was causing to have allways a difference between the expected cost and unitcost. Because of this, an adjustment was being created to adjust this difference, and to adjust all related transactions, causing an infinite loop
src/org/openbravo/costing/AverageCostAdjustment.java
--- a/src/org/openbravo/costing/AverageCostAdjustment.java	Thu Feb 26 15:29:20 2015 +0100
+++ b/src/org/openbravo/costing/AverageCostAdjustment.java	Thu Feb 26 15:36:55 2015 +0100
@@ -343,8 +343,8 @@
         } else if (cost != null && !isVoidedTrx(trx, currentTrxType)) {
           if (!trx.isCostPermanent()) {
             // Check current trx unit cost matches new expected cost
-            BigDecimal expectedCost = cost.multiply(trx.getMovementQuantity().abs()
-                .setScale(costCurPrecission, RoundingMode.HALF_UP));
+            BigDecimal expectedCost = cost.multiply(trx.getMovementQuantity().abs()).setScale(
+                costCurPrecission, RoundingMode.HALF_UP);
             BigDecimal unitCost = CostAdjustmentUtils.getTrxCost(trx, true, OBDal.getInstance()
                 .get(Currency.class, strCurrentCurId));
             unitCost = unitCost.add(trxAdjAmt);