Fixes Issue 28301: Cost is properly calculated after two backdated transactions.
authorUnai Martirena <unai.martirena@openbravo.com>
Thu, 04 Dec 2014 11:37:10 +0100
changeset 25487 cc0f6b428be8
parent 25486 35d365d804ad
child 25488 7084255c151e
Fixes Issue 28301: Cost is properly calculated after two backdated transactions.

The problem was in updateBDCostingTimeRange function. While updating the backdated average costing time, if a previous costing record was found, the future ending date was assigned to backdated costing record, not to the current costing, leaving as current costing the backdated costing record, and this is wrong.
src/org/openbravo/costing/AverageCostAdjustment.java
--- a/src/org/openbravo/costing/AverageCostAdjustment.java	Thu Dec 04 11:31:24 2014 +0100
+++ b/src/org/openbravo/costing/AverageCostAdjustment.java	Thu Dec 04 11:37:10 2014 +0100
@@ -761,8 +761,8 @@
 
     Costing curCosting = getTrxCurrentCosting(trx);
     if (curCosting != null) {
-      bdCosting.setEndingDate(curCosting.getEndingDate());
-      curCosting.setEndingDate(trx.getTransactionProcessDate());
+      curCosting.setEndingDate(bdCosting.getEndingDate());
+      bdCosting.setEndingDate(trx.getTransactionProcessDate());
       OBDal.getInstance().save(curCosting);
     } else {
       // There isn't any previous costing.