Fixes issue 31026: Wrong warehouse in Inventory Amount Update Lines
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Thu, 08 Oct 2015 14:15:32 +0200
changeset 27658 8d000060c64f
parent 27657 86d642f37bde
child 27659 f396fccd99e9
Fixes issue 31026: Wrong warehouse in Inventory Amount Update Lines

When current costing rule does not have Warehouse Dimension flag activated, warehouse field should be empty in Inventory Amount Update Lines.
In this case, SL_InvAmtUpd_ProductRefDate callout will return a null warehouseId.
Document date and Reference date references in Inventory Amount update have been changed from Date to DateTime, to get the correct value when checking the current costing rule.
Reference date will also have Document date value as default value instead of current date.
src-db/database/sourcedata/AD_COLUMN.xml
src/org/openbravo/erpCommon/ad_callouts/SL_InvAmtUpd_ProductRefDate.java
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Thu Oct 08 09:33:06 2015 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Thu Oct 08 14:15:32 2015 +0200
@@ -231766,9 +231766,9 @@
 <!--203C2E66223345CDBD2A5391BA5212AA-->  <HELP><![CDATA[The date used as a Reference for the document]]></HELP>
 <!--203C2E66223345CDBD2A5391BA5212AA-->  <COLUMNNAME><![CDATA[Referencedate]]></COLUMNNAME>
 <!--203C2E66223345CDBD2A5391BA5212AA-->  <AD_TABLE_ID><![CDATA[F26CC88DB04946F1A19DF05749C4381F]]></AD_TABLE_ID>
-<!--203C2E66223345CDBD2A5391BA5212AA-->  <AD_REFERENCE_ID><![CDATA[15]]></AD_REFERENCE_ID>
+<!--203C2E66223345CDBD2A5391BA5212AA-->  <AD_REFERENCE_ID><![CDATA[16]]></AD_REFERENCE_ID>
 <!--203C2E66223345CDBD2A5391BA5212AA-->  <FIELDLENGTH><![CDATA[19]]></FIELDLENGTH>
-<!--203C2E66223345CDBD2A5391BA5212AA-->  <DEFAULTVALUE><![CDATA[@#Date@]]></DEFAULTVALUE>
+<!--203C2E66223345CDBD2A5391BA5212AA-->  <DEFAULTVALUE><![CDATA[@Documentdate@]]></DEFAULTVALUE>
 <!--203C2E66223345CDBD2A5391BA5212AA-->  <ISKEY><![CDATA[N]]></ISKEY>
 <!--203C2E66223345CDBD2A5391BA5212AA-->  <ISPARENT><![CDATA[N]]></ISPARENT>
 <!--203C2E66223345CDBD2A5391BA5212AA-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
@@ -234001,7 +234001,7 @@
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <NAME><![CDATA[Document date]]></NAME>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <COLUMNNAME><![CDATA[Documentdate]]></COLUMNNAME>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <AD_TABLE_ID><![CDATA[F6B6AD5679FF4A798D2A3D44B232C52C]]></AD_TABLE_ID>
-<!--2A9149F05DDC4F5CBE30066C08579533-->  <AD_REFERENCE_ID><![CDATA[15]]></AD_REFERENCE_ID>
+<!--2A9149F05DDC4F5CBE30066C08579533-->  <AD_REFERENCE_ID><![CDATA[16]]></AD_REFERENCE_ID>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <FIELDLENGTH><![CDATA[19]]></FIELDLENGTH>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <DEFAULTVALUE><![CDATA[@#Date@]]></DEFAULTVALUE>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <ISKEY><![CDATA[N]]></ISKEY>
@@ -234015,7 +234015,7 @@
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <AD_ELEMENT_ID><![CDATA[F9666DCCC70646EC811384E23D8FE498]]></AD_ELEMENT_ID>
-<!--2A9149F05DDC4F5CBE30066C08579533-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--2A9149F05DDC4F5CBE30066C08579533-->  <ISSESSIONATTR><![CDATA[Y]]></ISSESSIONATTR>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--2A9149F05DDC4F5CBE30066C08579533-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
--- a/src/org/openbravo/erpCommon/ad_callouts/SL_InvAmtUpd_ProductRefDate.java	Thu Oct 08 09:33:06 2015 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_InvAmtUpd_ProductRefDate.java	Thu Oct 08 14:15:32 2015 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -65,18 +65,20 @@
       referenceDate = outputFormat.parse(info.getStringParameter("inpreferencedate", null));
 
       CostingRule costRule = CostingUtils.getCostDimensionRule(organization, referenceDate);
+      if (costRule.isWarehouseDimension()) {
+        info.addResult("inpiswarehousedimension", "Y");
+      } else {
+        info.addResult("inpiswarehousedimension", "N");
+        info.addResult("inpmWarehouseId", null);
+      }
+
       if (product == null) {
         return;
       }
       costDimensions = CostingUtils.getEmptyDimensions();
-      if (costRule.isWarehouseDimension()) {
-        info.addResult("inpiswarehousedimension", "Y");
-        if (warehouseId != null && !warehouseId.isEmpty()) {
-          Warehouse warehouse = OBDal.getInstance().get(Warehouse.class, warehouseId);
-          costDimensions.put(CostDimension.Warehouse, warehouse);
-        }
-      } else {
-        info.addResult("inpiswarehousedimension", "N");
+      if (costRule.isWarehouseDimension() && warehouseId != null && !warehouseId.isEmpty()) {
+        Warehouse warehouse = OBDal.getInstance().get(Warehouse.class, warehouseId);
+        costDimensions.put(CostDimension.Warehouse, warehouse);
       }
       currentValuedStock = CostAdjustmentUtils.getValuedStockOnMovementDate(product, organization,
           referenceDate, costDimensions, currency, costRule.isBackdatedTransactionsFixed());