details:   https://code.openbravo.com/erp/devel/pi/rev/6db8cd340ee2
changeset: 32708:6db8cd340ee2
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Fri Sep 15 04:46:11 2017 +0530
summary:   Fixes issue 36825: Warehouse field of Inventory Amount Update Lines 
not shown

Warehouse field of Inventory Amount Update Lines is not shown after
saving the record although it has a value

Set SQL based value for auxiliar input iswarehousedimension in inventory amount 
update
line tab. It is calculated on organization and reference date in the line tab.

details:   https://code.openbravo.com/erp/devel/pi/rev/cebdb602a9f1
changeset: 32709:cebdb602a9f1
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Mon Sep 18 11:40:40 2017 +0200
summary:   Related to issue 36825: Code review improvements

Use min to retrieve only one record.
Remove coalesce as Warehouse_Dimension is a not null column.
Rename alias with a shorter name.
Remove IsActive condition.
Remove exists condition and change datefrom and dateto conditions to retrieve 
always the current costing rule.
SL_InvAmtUpd_ProductRefDate callout will remove warehouse value in case 
auxiliary input retrieves false.

diffstat:

 src-db/database/sourcedata/AD_AUXILIARINPUT.xml                          |   6 
+-
 src/org/openbravo/erpCommon/ad_callouts/SL_InvAmtUpd_ProductRefDate.java |  26 
+++++-----
 2 files changed, 18 insertions(+), 14 deletions(-)

diffs (88 lines):

diff -r f9da9c951a5d -r cebdb602a9f1 
src-db/database/sourcedata/AD_AUXILIARINPUT.xml
--- a/src-db/database/sourcedata/AD_AUXILIARINPUT.xml   Mon Sep 18 10:20:43 
2017 +0200
+++ b/src-db/database/sourcedata/AD_AUXILIARINPUT.xml   Mon Sep 18 11:40:40 
2017 +0200
@@ -2311,7 +2311,11 @@
 <!--600FD6A6E8E74921AA876A03ECF46C41-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--600FD6A6E8E74921AA876A03ECF46C41-->  
<AD_TAB_ID><![CDATA[BD883B355F1B448A9CB6BD472600EB2D]]></AD_TAB_ID>
 <!--600FD6A6E8E74921AA876A03ECF46C41-->  
<NAME><![CDATA[isWarehouseDimension]]></NAME>
-<!--600FD6A6E8E74921AA876A03ECF46C41-->  <CODE><![CDATA[N]]></CODE>
+<!--600FD6A6E8E74921AA876A03ECF46C41-->  <CODE><![CDATA[@SQL=SELECT 
min(r.Warehouse_Dimension)
+FROM M_Costing_Rule r
+WHERE r.AD_Org_ID = @AD_ORG_ID@
+AND r.Dateto IS NULL
+AND r.IsValidated = 'Y']]></CODE>
 <!--600FD6A6E8E74921AA876A03ECF46C41-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--600FD6A6E8E74921AA876A03ECF46C41--></AD_AUXILIARINPUT>
 
diff -r f9da9c951a5d -r cebdb602a9f1 
src/org/openbravo/erpCommon/ad_callouts/SL_InvAmtUpd_ProductRefDate.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SL_InvAmtUpd_ProductRefDate.java  
Mon Sep 18 10:20:43 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_InvAmtUpd_ProductRefDate.java  
Mon Sep 18 11:40:40 2017 +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-2016 Openbravo SLU
+ * All portions are Copyright (C) 2014-2017 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -27,6 +27,7 @@
 
 import javax.servlet.ServletException;
 
+import org.apache.commons.lang.StringUtils;
 import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.costing.CostAdjustmentUtils;
@@ -47,9 +48,9 @@
       Date referenceDate;
       BigDecimal currentValuedStock = BigDecimal.ZERO;
       BigDecimal currentStock = BigDecimal.ZERO;
-      HashMap<CostDimension, BaseOBObject> costDimensions;
 
       String warehouseId = info.getStringParameter("inpmWarehouseId", null);
+      String isWarehouseDimension = 
info.getStringParameter("isWarehouseDimension");
       String productId = info.getStringParameter("inpmProductId", null);
       Product product = OBDal.getInstance().get(Product.class, productId);
       String orgId = info.getStringParameter("inpadOrgId", null);
@@ -62,19 +63,18 @@
 
       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");
+      if (StringUtils.equals(isWarehouseDimension, "N")) {
+        warehouseId = null;
         info.addResult("inpmWarehouseId", null);
       }
 
       if (product == null) {
         return;
       }
-      costDimensions = CostingUtils.getEmptyDimensions();
-      if (costRule.isWarehouseDimension() && warehouseId != null && 
!warehouseId.isEmpty()) {
+
+      CostingRule costRule = CostingUtils.getCostDimensionRule(organization, 
referenceDate);
+      HashMap<CostDimension, BaseOBObject> costDimensions = 
CostingUtils.getEmptyDimensions();
+      if (costRule.isWarehouseDimension() && 
StringUtils.isNotEmpty(warehouseId)) {
         Warehouse warehouse = OBDal.getInstance().get(Warehouse.class, 
warehouseId);
         costDimensions.put(CostDimension.Warehouse, warehouse);
       }
@@ -84,10 +84,10 @@
           referenceDate, costDimensions, 
costRule.isBackdatedTransactionsFixed());
       info.addResult("inpcurInventoryAmount", currentValuedStock);
       info.addResult("inponhandqty", currentStock);
-      info.addResult(
-          "inpcurUnitcost",
-          currentStock.intValue() == 0 ? BigDecimal.ZERO : 
currentValuedStock.divide(currentStock,
-              currency.getPricePrecision().intValue(), RoundingMode.HALF_UP));
+      info.addResult("inpcurUnitcost",
+          currentStock.intValue() == 0 ? BigDecimal.ZERO
+              : currentValuedStock.divide(currentStock, 
currency.getPricePrecision().intValue(),
+                  RoundingMode.HALF_UP));
     } catch (ParseException ignore) {
     }
   }

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to