svn commit: r577898 - in /ofbiz/trunk/applications/product: config/ webapp/facility/WEB-INF/ webapp/facility/WEB-INF/actions/inventory/ webapp/facility/facility/ widget/facility/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r577898 - in /ofbiz/trunk/applications/product: config/ webapp/facility/WEB-INF/ webapp/facility/WEB-INF/actions/inventory/ webapp/facility/facility/ widget/facility/

apatel-2
Author: apatel
Date: Thu Sep 20 12:58:03 2007
New Revision: 577898

URL: http://svn.apache.org/viewvc?rev=577898&view=rev
Log:
added two report to get value of stock Inventory

Added:
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh
Modified:
    ofbiz/trunk/applications/product/config/ProductUiLabels.properties
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml
    ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?rev=577898&r1=577897&r2=577898&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Thu Sep 20 12:58:03 2007
@@ -434,6 +434,7 @@
 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 @@
 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.

Added: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh?rev=577898&view=auto
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh (added)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh Thu Sep 20 12:58:03 2007
@@ -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);

Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml?rev=577898&r1=577897&r2=577898&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml Thu Sep 20 12:58:03 2007
@@ -1127,6 +1127,14 @@
         <security https="true" auth="true"/>
         <response name="success" type="view" value="InventoryReports"/>
     </request-map>
+    <request-map uri="InventoryItemTotals">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" value="InventoryItemTotals"/>
+    </request-map>
+    <request-map uri="InventoryItemGrandTotals">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" value="InventoryItemGrandTotals"/>
+    </request-map>
 
     <!-- ================ Lookup Requests ================= -->
     <request-map uri="LookupOrderHeaderAndShipInfo"><security https="true" auth="true"/><response name="success" type="view" value="LookupOrderHeaderAndShipInfo"/></request-map>
@@ -1211,6 +1219,8 @@
     <view-map name="QuickShipOrder" type="screen" page="component://product/widget/facility/ShipmentScreens.xml#QuickShipOrder"/>
     
     <view-map name="InventoryReports" type="screen" page="component://product/widget/facility/ReportScreens.xml#InventoryReports"/>
+    <view-map name="InventoryItemTotals" type="screen" page="component://product/widget/facility/FacilityScreens.xml#InventoryItemTotals"/>
+    <view-map name="InventoryItemGrandTotals" type="screen" page="component://product/widget/facility/FacilityScreens.xml#InventoryItemGrandTotals"/>
 
     <view-map name="LookupOrderHeaderAndShipInfo" type="screen" page="component://order/widget/ordermgr/LookupScreens.xml#LookupOrderHeaderAndShipInfo"/>
     <view-map name="LookupPurchaseOrderHeaderAndShipInfo" type="screen" page="component://order/widget/ordermgr/LookupScreens.xml#LookupPurchaseOrderHeaderAndShipInfo"/>

Modified: ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml?rev=577898&r1=577897&r2=577898&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml (original)
+++ ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml Thu Sep 20 12:58:03 2007
@@ -343,4 +343,23 @@
         </field>
         <field name="submitButton" title="${uiLabelMap.CommonSubmit}"><submit button-type="button"/></field>
     </form>
+    <form name="ListInventoryItemTotals" type="list" target="" title="" list-name="inventoryItemTotals"
+        default-title-style="tableheadtext" default-widget-style="tabletext" default-tooltip-style="tabletext"
+        paginate-target="InventoryItemTotals" override-list-size="${overrideListSize}">
+        
+        <field name="inventoryItemGrandTotals"><hidden/></field>
+        <field name="productId" title="${uiLabelMap.ProductProductId}"><display/></field>
+        <field name="quantityOnHand" title="${uiLabelMap.ProductQoh}" widget-area-style="tabletextright"><display/></field>
+        <field name="availableToPromise" title="${uiLabelMap.ProductAtp}" widget-area-style="tabletextright"><display/></field>
+        <field name="costPrice" title="${uiLabelMap.ProductCostPrice}" widget-area-style="tabletextright"><display/></field>
+        <field name="retailPrice" title="${uiLabelMap.ProductRetailPrice}" widget-area-style="tabletextright"><display/></field>
+        <field name="totalCostPrice" title="${uiLabelMap.CommonTotal} ${uiLabelMap.ProductCostPrice}" widget-area-style="tabletextright"><display/></field>
+        <field name="totalRetailPrice" title="${uiLabelMap.CommonTotal} ${uiLabelMap.ProductRetailPrice}" widget-area-style="tabletextright"><display/></field>
+    </form>
+    <form name="ListInventoryItemGrandTotals" type="list" list-name="inventoryItemGrandTotals">
+        <field name="qohGrandTotal" title="${uiLabelMap.ProductQoh} ${uiLabelMap.CommonTotal} ${uiLabelMap.CommonQty}" widget-area-style="tabletextright"><display/></field>
+        <field name="atpGrandTotal" title="${uiLabelMap.ProductAtp} ${uiLabelMap.CommonTotal} ${uiLabelMap.CommonQty}" widget-area-style="tabletextright"><display/></field>
+        <field name="totalCostPriceGrandTotal" title="${uiLabelMap.CommonTotal} ${uiLabelMap.ProductCostPrice}" widget-area-style="tabletextright"><display/></field>
+        <field name="totalRetailPriceGrandTotal" title="${uiLabelMap.CommonTotal} ${uiLabelMap.ProductRetailPrice}" widget-area-style="tabletextright"><display/></field>
+    </form>
 </forms>

Modified: ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml?rev=577898&r1=577897&r2=577898&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml Thu Sep 20 12:58:03 2007
@@ -244,6 +244,8 @@
                             <!--<link target="ViewFacilityInventoryByProductSimple?facilityId=${facilityId}" text="${uiLabelMap.CommonPrint}" style="buttontext"/>-->
                             <link target="ViewFacilityInventoryByProductReport?${searchParameterString}" text="${uiLabelMap.CommonPrint}" style="buttontext"/>
                             <link target="ViewFacilityInventoryByProductExport?${searchParameterString}" text="${uiLabelMap.CommonExport}" style="buttontext"/>
+                            <link target="InventoryItemTotals?facilityId=${facilityId}&amp;action=Y" text="${uiLabelMap.ProductInventoryItemTotals}" style="buttontext"/>
+                            <link target="InventoryItemGrandTotals?facilityId=${facilityId}&amp;action=Y" text="${uiLabelMap.ProductInventoryItemGrandTotals}" style="buttontext"/>
                         </container>
 
                         <include-form name="FindFacilityInventoryByProduct" location="component://product/webapp/facility/facility/FacilityForms.xml"/>
@@ -364,6 +366,56 @@
         </section>
     </screen>
 
+    <screen name="InventoryItemTotals">
+        <section>
+            <actions>
+                <set field="titleProperty" value="PageTitleEditFacilityInventoryItems"/>
+                <set field="headerItem" value="facility"/>
+                <set field="tabButtonItem" value="ViewFacilityInventoryByProduct"/>
+                <set field="facilityId" from-field="parameters.facilityId"/>
+                <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer" default-value="0"/>
+                <set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="50"/>
+                
+                <entity-one entity-name="Facility" value-name="facility" use-cache="true"/>
+                <script location="component://product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="CommonFacilityDecorator" location="${parameters.commonFacilityDecoratorLocation}">
+                    <decorator-section name="body">
+                        <container>
+                            <label style="head2" text="${uiLabelMap.ProductInventoryItemTotals} ${uiLabelMap.CommonFor} ${facility.facilityName}"/>
+                        </container>
+                        <include-form name="ListInventoryItemTotals" location="component://product/webapp/facility/facility/FacilityForms.xml"/>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
+    
+    <screen name="InventoryItemGrandTotals">
+        <section>
+            <actions>
+                <set field="titleProperty" value="PageTitleEditFacilityInventoryItems"/>
+                <set field="headerItem" value="facility"/>
+                <set field="tabButtonItem" value="ViewFacilityInventoryByProduct"/>
+                <set field="facilityId" from-field="parameters.facilityId"/>
+                
+                <entity-one entity-name="Facility" value-name="facility" use-cache="true"/>
+                <script location="component://product/webapp/facility/WEB-INF/actions/inventory/InventoryItemTotals.bsh"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="CommonFacilityDecorator" location="${parameters.commonFacilityDecoratorLocation}">
+                    <decorator-section name="body">
+                        <container>
+                            <label style="head2" text="${uiLabelMap.ProductInventoryItemGrandTotals} ${uiLabelMap.CommonFor} ${facility.facilityName}"/>
+                        </container>
+                        <include-form name="ListInventoryItemGrandTotals" location="component://product/webapp/facility/facility/FacilityForms.xml"/>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
+    
     <screen name="EditFacilityGroups">
         <section>
             <actions>