[costadj]Fixes issue in tree definition of adjustment lines.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Tue, 05 Aug 2014 15:16:44 +0200
changeset 24771 41af845fd98c
parent 24770 450bfff6274e
child 24772 0419c13400c4
[costadj]Fixes issue in tree definition of adjustment lines.
src-db/database/sourcedata/AD_REF_TABLE.xml
src/org/openbravo/costing/AverageCostAdjustment.java
--- a/src-db/database/sourcedata/AD_REF_TABLE.xml	Tue Aug 05 10:11:01 2014 +0200
+++ b/src-db/database/sourcedata/AD_REF_TABLE.xml	Tue Aug 05 15:16:44 2014 +0200
@@ -1165,7 +1165,7 @@
 <!--23AD2773FD02451DA75D1387A970CE82-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--23AD2773FD02451DA75D1387A970CE82-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--23AD2773FD02451DA75D1387A970CE82-->  <AD_TABLE_ID><![CDATA[34E79323CEC847C2A9ED2C8430AC73D1]]></AD_TABLE_ID>
-<!--23AD2773FD02451DA75D1387A970CE82-->  <AD_KEY><![CDATA[FD0CA136DD4B9858E040007F01001C35]]></AD_KEY>
+<!--23AD2773FD02451DA75D1387A970CE82-->  <AD_KEY><![CDATA[FD0CA136DD439858E040007F01001C35]]></AD_KEY>
 <!--23AD2773FD02451DA75D1387A970CE82-->  <AD_DISPLAY><![CDATA[FD0CA136DD4C9858E040007F01001C35]]></AD_DISPLAY>
 <!--23AD2773FD02451DA75D1387A970CE82-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
 <!--23AD2773FD02451DA75D1387A970CE82--></AD_REF_TABLE>
--- a/src/org/openbravo/costing/AverageCostAdjustment.java	Tue Aug 05 10:11:01 2014 +0200
+++ b/src/org/openbravo/costing/AverageCostAdjustment.java	Tue Aug 05 15:16:44 2014 +0200
@@ -83,9 +83,6 @@
     BigDecimal currentStock = getCurrentStock();
     BigDecimal currentValueAmt = getCurrentValuedStock();
     if (currentStock.signum() != 0) {
-      // FIXME: Cuando entra por segunda vez a buscar las rtansactiones relacionadas está
-      // considerando 2 veces el adjustemeent balance porque ya está incluido en el current value
-      // amount
       cost = currentValueAmt.add(adjustmentBalance).divide(currentStock, precission,
           RoundingMode.HALF_UP);
     }
@@ -147,9 +144,9 @@
             // If there is a difference insert a cost adjustment line.
             CostAdjustmentLine newCAL = CostAdjustmentUtils.insertCostAdjustmentLine(trx,
                 getCostAdjLine().getCostAdjustment(), expectedCost.subtract(trxCost), false,
-                trx.getTransactionProcessDate(), null);
-            // newCAL.setParentCostAdjustmentLine((CostAdjustmentLine) OBDal.getInstance().getProxy(
-            // CostAdjustmentLine.ENTITY_NAME, strCostAdjLineId));
+                trx.getTransactionProcessDate(), trx.getMovementDate());
+            newCAL.setParentCostAdjustmentLine((CostAdjustmentLine) OBDal.getInstance().getProxy(
+                CostAdjustmentLine.ENTITY_NAME, strCostAdjLineId));
             newCAL.setRelatedTransactionAdjusted(false);
             OBDal.getInstance().save(newCAL);
           }