You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2014/03/26 19:07:07 UTC

svn commit: r1581972 - /ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.groovy

Author: jacopoc
Date: Wed Mar 26 18:07:07 2014
New Revision: 1581972

URL: http://svn.apache.org/r1581972
Log:
Misc fixes to get the right values for total cost and total retail value of inventory items; thanks to Igor Gallingani for the bug report in OFBIZ-4985.

Modified:
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.groovy

Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.groovy?rev=1581972&r1=1581971&r2=1581972&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.groovy Wed Mar 26 18:07:07 2014
@@ -36,8 +36,6 @@ if (action) {
     conditions.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, null));
     conditionList = EntityCondition.makeCondition(conditions, EntityOperator.OR);
     try {
-        // create resultMap to stop issue with the first puts in the while loop
-        resultMap = [:];
         beganTransaction = TransactionUtil.begin();
         invItemListItr = delegator.find("InventoryItem", conditionList, null, null, ['productId'], null);
         while ((inventoryItem = invItemListItr.next()) != null) {
@@ -49,6 +47,8 @@ if (action) {
                 availableToPromiseTotal = inventoryItem.getDouble("availableToPromiseTotal");
                 costPrice = inventoryItem.getDouble("unitCost");
                 retailPrice = 0.0;
+                totalCostPrice = 0.0;
+                totalRetailPrice = 0.0;
                 productPrices = product.getRelated("ProductPrice", null, null, false);
                 if (productPrices) {
                     productPrices.each { productPrice ->
@@ -59,12 +59,10 @@ if (action) {
                 }
                 if (costPrice && quantityOnHandTotal) {
                     totalCostPrice = costPrice * quantityOnHandTotal;
-                    resultMap.totalCostPrice = totalCostPrice;
                     totalCostPriceGrandTotal += totalCostPrice;
                 }
                 if (retailPrice && quantityOnHandTotal) {
                     totalRetailPrice = retailPrice * quantityOnHandTotal;
-                    resultMap.totalRetailPrice = totalRetailPrice;
                     totalRetailPriceGrandTotal += totalRetailPrice;
                 }
                 if (quantityOnHandTotal) {
@@ -81,7 +79,7 @@ if (action) {
                 }
 
                 resultMap = [productId : product.productId, quantityOnHand : quantityOnHandTotal, availableToPromise : availableToPromiseTotal,
-                             costPrice : costPrice, retailPrice : retailPrice];
+                             costPrice : costPrice, retailPrice : retailPrice, totalCostPrice : totalCostPrice, totalRetailPrice : totalRetailPrice];
                 inventoryItemTotals.add(resultMap);
             }
         }