Fixes Issue 39888. When canceling a cost adjustment:
authorDavid Miguelez <david.miguelez@openbravo.com>
Mon, 14 Jan 2019 09:40:46 +0100
changeset 35316 a913d96060c7
parent 35315 4b812cac3744
child 35317 00f3ad11d13d
Fixes Issue 39888. When canceling a cost adjustment:

* Keep the Negative Stock Correction and Backdated Transactions
flags with the same values as the original record
* When retrieving the lines of the Adjustment, retrieve also the lines
from Adjusments in Voided Status
src/org/openbravo/costing/AverageCostAdjustment.java
src/org/openbravo/costing/CancelCostAdjustment.java
--- a/src/org/openbravo/costing/AverageCostAdjustment.java	Wed Dec 26 17:28:40 2018 +0100
+++ b/src/org/openbravo/costing/AverageCostAdjustment.java	Mon Jan 14 09:40:46 2019 +0100
@@ -768,7 +768,7 @@
     critLines.add(Restrictions.eq(CostAdjustmentLine.PROPERTY_INVENTORYTRANSACTION, trx));
     critLines.add(Restrictions.or(//
         Restrictions.eq("ca.id", getCostAdj().getId()),//
-        Restrictions.eq("ca." + CostAdjustment.PROPERTY_DOCUMENTSTATUS, "CO")));
+        Restrictions.not(Restrictions.eq("ca." + CostAdjustment.PROPERTY_DOCUMENTSTATUS, "DR"))));
 
     return critLines.list();
   }
--- a/src/org/openbravo/costing/CancelCostAdjustment.java	Wed Dec 26 17:28:40 2018 +0100
+++ b/src/org/openbravo/costing/CancelCostAdjustment.java	Mon Jan 14 09:40:46 2019 +0100
@@ -23,6 +23,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.hibernate.ScrollMode;
@@ -40,8 +42,6 @@
 import org.openbravo.model.materialmgmt.cost.CostAdjustment;
 import org.openbravo.model.materialmgmt.cost.CostAdjustmentLine;
 import org.openbravo.service.db.DbUtility;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
 
 public class CancelCostAdjustment extends BaseActionHandler {
   private static final Logger log = LogManager.getLogger();
@@ -118,8 +118,7 @@
         lineCancel.setCreatedBy(OBContext.getOBContext().getUser());
         lineCancel.setCostAdjustment(cacProxy);
         lineCancel.setAdjustmentAmount(lineOrig.getAdjustmentAmount().negate());
-        lineCancel.setBackdatedTrx(Boolean.FALSE);
-        lineCancel.setNegativeStockCorrection(Boolean.FALSE);
+
         if (lineOrig.getInventoryTransaction().isCostPermanent()) {
           lineOrig.getInventoryTransaction().setCostPermanent(Boolean.FALSE);
           OBDal.getInstance().save(lineOrig.getInventoryTransaction());