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 25623 a39bd13414a2
parent 25622 a705033f90f1
child 25624 d9a1d24601e3
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	Fri Dec 19 12:01:16 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.