Fixes issue 28192: Net Unit Price now is properly calculated.
authorUnai Martirena <unai.martirena@openbravo.com>
Thu, 04 Dec 2014 12:20:59 +0100
changeset 25619 6d705e1629ad
parent 25618 c9f5b83d0235
child 25620 aea4adf1ee5c
Fixes issue 28192: Net Unit Price now is properly calculated.

In order to calculate the Net Unit Price, the adjustments of the transaction are used, but it was not being used the signMultiplier of the transaction, and needs to be used.
src/org/openbravo/costing/AverageCostAdjustment.java
--- a/src/org/openbravo/costing/AverageCostAdjustment.java	Wed Dec 10 14:09:54 2014 +0100
+++ b/src/org/openbravo/costing/AverageCostAdjustment.java	Thu Dec 04 12:20:59 2014 +0100
@@ -281,7 +281,7 @@
           log.debug("New average cost: {}", cost.toPlainString());
           Costing curCosting = trx.getMaterialMgmtCostingList().get(0);
           BigDecimal trxPrice = curCosting.getPrice().multiply(trx.getMovementQuantity().abs())
-              .add(trxAdjAmt)
+              .add(trxAdjAmt.multiply(trxSignMultiplier))
               .divide(trx.getMovementQuantity().abs(), costCurPrecission, RoundingMode.HALF_UP);
 
           if (checkNegativeStockCorrection && currentStock.compareTo(trx.getMovementQuantity()) < 0
@@ -355,7 +355,7 @@
                   RoundingMode.HALF_UP);
             }
             BigDecimal trxPrice = curCosting.getPrice().multiply(trx.getMovementQuantity().abs())
-                .add(trxAdjAmt)
+                .add(trxAdjAmt.multiply(trxSignMultiplier))
                 .divide(trx.getMovementQuantity().abs(), costCurPrecission, RoundingMode.HALF_UP);
             if (curCosting.getCost().compareTo(cost) != 0) {
               curCosting.setPermanent(Boolean.FALSE);