diff --git a/applications/product/config/ProductUiLabels.properties b/applications/product/config/ProductUiLabels.properties
index 7792ae7c57..90cf23c36b 100644
--- a/applications/product/config/ProductUiLabels.properties
+++ b/applications/product/config/ProductUiLabels.properties
@@ -434,6 +434,7 @@ ProductContent_Id=Content [ID]
ProductCopyProductCategoryMembersToAnotherCategory=Copy Product Category Members to Another Category
ProductCostPrice=Cost Price
ProductCosts=Costs
+ProductCostPrice=Cost Price
ProductCouldNotFindFacilityWithId=Could Not Find Facility with ID
ProductCouldNotFindProduct=Could Not Find Product with ID
ProductCouldNotFindProductCategoryWithId=Could not Find Product Category with Id
@@ -705,6 +706,8 @@ ProductInventoryItemTypeId=InventoryItem Type ID
ProductInventoryItems=Inventory Items
ProductInventoryItemsFor=Inventory Items for
ProductInventoryItemsToPick=Inventory Items to Pick
+ProductInventoryItemTotals=Inventory Item Totals
+ProductInventoryItemGrandTotals=Inventory Item Grand Totals
ProductInventoryMessage=Inventory Message
ProductInventoryReceive=Receive Inventory
ProductInventoryRequiredProduct=Should inventory be required to purchase this product? If not specified defaults to the Catalog setting.
diff --git a/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh b/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh
new file mode 100644
index 0000000000..402b2f8e69
--- /dev/null
+++ b/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.*;
+import javolution.util.FastList;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.entity.*;
+import org.ofbiz.entity.condition.*;
+import org.ofbiz.entity.transaction.*;
+
+delegator = request.getAttribute("delegator");
+dispatcher = request.getAttribute("dispatcher");
+
+action = request.getParameter("action");
+
+inventoryItemTotals = FastList.newInstance();
+qohGrandTotal = 0.0;
+atpGrandTotal = 0.0;
+costPriceGrandTotal = 0.0;
+retailPriceGrandTotal = 0.0;
+totalCostPriceGrandTotal = 0.0;
+totalRetailPriceGrandTotal = 0.0;
+boolean beganTransaction = false;
+if (action != null) {
+ conditions = UtilMisc.toList(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "INV_DELIVERED"));
+ conditions.add(new EntityExpr("statusId", EntityOperator.EQUALS, null));
+ conditionList = new EntityConditionList(conditions, EntityOperator.OR);
+ try {
+ beganTransaction = TransactionUtil.begin();
+ invItemListItr = delegator.findListIteratorByCondition("InventoryItem", conditionList, null, UtilMisc.toList("productId"));
+ while ((inventoryItem = invItemListItr.next()) != null) {
+ productId = inventoryItem.getString("productId");
+ product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
+ productFacility = delegator.findByPrimaryKey("ProductFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId));
+ if (productFacility != null) {
+ quantityOnHandTotal = inventoryItem.getDouble("quantityOnHandTotal");
+ availableToPromiseTotal = inventoryItem.getDouble("availableToPromiseTotal");
+ costPrice = inventoryItem.getDouble("unitCost");
+ retailPrice = 0.0;
+ productPrices = product.getRelated("ProductPrice");
+ if (productPrices != null) {
+ productPriceItr = productPrices.iterator();
+ while (productPriceItr.hasNext()) {
+ productPrice = productPriceItr.next();
+ if (("DEFAULT_PRICE").equals(productPrice.getString("productPriceTypeId"))) {
+ retailPrice = productPrice.getDouble("price");
+ }
+ }
+ }
+
+ totalCostPrice = costPrice * quantityOnHandTotal;
+ totalRetailPrice = retailPrice * availableToPromiseTotal;
+ qohGrandTotal += quantityOnHandTotal;
+ atpGrandTotal += availableToPromiseTotal;
+ costPriceGrandTotal += costPrice;
+ retailPriceGrandTotal += retailPrice;
+ totalCostPriceGrandTotal += totalCostPrice;
+ totalRetailPriceGrandTotal += totalRetailPrice;
+
+ resultMap = UtilMisc.toMap("productId", product.getString("productId"), "quantityOnHand", quantityOnHandTotal, "availableToPromise", availableToPromiseTotal,
+ "costPrice", costPrice, "retailPrice", retailPrice);
+ resultMap.put("totalCostPrice", totalCostPrice);
+ resultMap.put("totalRetailPrice", totalRetailPrice);
+ inventoryItemTotals.add(resultMap);
+ }
+ }
+ invItemListItr.close();
+ } catch (GenericEntityException e) {
+ String errMsg = "Failure in operation, rolling back transaction";
+ Debug.logError(e, errMsg, "findInventoryItemsByLabels");
+ try {
+ // only rollback the transaction if we started one...
+ TransactionUtil.rollback(beganTransaction, errMsg, e);
+ } catch (GenericEntityException e2) {
+ Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), "findInventoryItemsByLabels");
+ }
+ // after rolling back, rethrow the exception
+ throw e;
+ } finally {
+ // only commit the transaction if we started one... this will throw an exception if it fails
+ TransactionUtil.commit(beganTransaction);
+ }
+
+}
+
+inventoryItemGrandTotals = FastList.newInstance();
+inventoryItemGrandTotals.add(UtilMisc.toMap("qohGrandTotal", qohGrandTotal, "atpGrandTotal", atpGrandTotal,
+ "totalCostPriceGrandTotal", totalCostPriceGrandTotal, "totalRetailPriceGrandTotal", totalRetailPriceGrandTotal));
+
+context.put("inventoryItemTotals", inventoryItemTotals);
+context.put("inventoryItemGrandTotals", inventoryItemGrandTotals);
diff --git a/applications/product/webapp/facility/WEB-INF/controller.xml b/applications/product/webapp/facility/WEB-INF/controller.xml
index 0a5b7660b9..073d089877 100644
--- a/applications/product/webapp/facility/WEB-INF/controller.xml
+++ b/applications/product/webapp/facility/WEB-INF/controller.xml
@@ -1127,6 +1127,14 @@ under the License.