svn commit: r782662 - in /ofbiz/trunk/applications/product: entitydef/ script/org/ofbiz/product/inventory/ servicedef/ src/org/ofbiz/product/spreadsheetimport/ webapp/facility/WEB-INF/actions/facility/ webapp/facility/facility/

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

svn commit: r782662 - in /ofbiz/trunk/applications/product: entitydef/ script/org/ofbiz/product/inventory/ servicedef/ src/org/ofbiz/product/spreadsheetimport/ webapp/facility/WEB-INF/actions/facility/ webapp/facility/facility/

jacopoc
Author: jacopoc
Date: Mon Jun  8 15:06:41 2009
New Revision: 782662

URL: http://svn.apache.org/viewvc?rev=782662&view=rev
Log:
Implemented simple "sell-through" (http://en.wikipedia.org/wiki/Sell-through) information to the find inventory screen.

Added:
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ComputeProductSellThroughData.groovy   (with props)
Modified:
    ofbiz/trunk/applications/product/entitydef/entitymodel.xml
    ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
    ofbiz/trunk/applications/product/servicedef/services_facility.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java
    ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml

Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?rev=782662&r1=782661&r2=782662&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Mon Jun  8 15:06:41 2009
@@ -1989,6 +1989,8 @@
         <alias entity-alias="II" name="facilityId" group-by="true"></alias>
         <alias entity-alias="II" name="productId" group-by="true"></alias>
         <alias entity-alias="IID" name="effectiveDate"><description>For query only, not in fields to select.</description></alias>
+        <alias entity-alias="IID" name="orderId"><description>For query only, not in fields to select.</description></alias>
+        <alias entity-alias="IID" name="quantityOnHandDiff"><description>For query only, not in fields to select.</description></alias>
         <view-link entity-alias="II" rel-entity-alias="IID">
             <key-map field-name="inventoryItemId"/>
         </view-link>

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml?rev=782662&r1=782661&r2=782662&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml Mon Jun  8 15:06:41 2009
@@ -636,6 +636,40 @@
         <field-to-result field="parameters.quantityOnHandTotal" result-name="quantityOnHandTotal"/>
     </simple-method>
 
+    <simple-method method-name="countProductInventoryOnHand" short-description="Count Inventory On Hand for a Product constrained by a facilityId at a given date." use-transaction="false">
+        <entity-condition entity-name="InventoryItemDetailForSum" list="inventoryItemDetailTotals">
+            <condition-list combine="and">
+                <condition-expr field-name="effectiveDate" operator="less-equals" from-field="parameters.inventoryCountDate"/>
+                <condition-expr field-name="facilityId" operator="equals" from-field="parameters.facilityId"/>
+                <condition-expr field-name="productId" operator="equals" from-field="parameters.productId"/>
+            </condition-list>
+            <select-field field-name="quantityOnHandSum"/>
+        </entity-condition>
+        <first-from-list entry="inventoryItemDetailTotal" list="inventoryItemDetailTotals"/>
+        <set field="quantityOnHandTotal" from-field="inventoryItemDetailTotal.quantityOnHandSum" type="BigDecimal" default-value="0"/>
+        <field-to-result field="quantityOnHandTotal" result-name="quantityOnHandTotal"/>
+    </simple-method>
+
+    <simple-method method-name="countProductInventoryShippedForSales" short-description="Count Inventory Shipped for Sales Orders for a Product constrained by a facilityId in a given date range." use-transaction="false">
+        <if-empty field="parameters.thruDate">
+            <now-timestamp field="parameters.thruDate"/>
+        </if-empty>
+        <entity-condition entity-name="InventoryItemDetailForSum" list="inventoryItemDetailTotals">
+            <condition-list combine="and">
+                <condition-expr field-name="effectiveDate" operator="greater-equals" from-field="parameters.fromDate"/>
+                <condition-expr field-name="effectiveDate" operator="less" from-field="parameters.thruDate"/>
+                <condition-expr field-name="facilityId" operator="equals" from-field="parameters.facilityId"/>
+                <condition-expr field-name="productId" operator="equals" from-field="parameters.productId"/>
+                <condition-expr field-name="orderId" operator="not-equals" from-field="nullField"/>
+                <condition-expr field-name="quantityOnHandDiff" operator="less" value="0"/>
+            </condition-list>
+            <select-field field-name="quantityOnHandSum"/>
+        </entity-condition>
+        <first-from-list entry="inventoryItemDetailTotal" list="inventoryItemDetailTotals"/>
+        <set field="quantityOnHandTotal" from-field="${inventoryItemDetailTotal.quantityOnHandSum * -1}" type="BigDecimal" default-value="0"/>
+        <field-to-result field="quantityOnHandTotal" result-name="quantityOnHandTotal"/>
+    </simple-method>
+
     <simple-method method-name="getMktgPackagesAvailable" short-description="Get Marketing Packages Available From Components In Inventory" login-required="false" use-transaction="false">
         <set field="availableToPromiseTotal" value="0" type="BigDecimal"/>
         <set field="quantityOnHandTotal" value="0" type="BigDecimal"/>

Modified: ofbiz/trunk/applications/product/servicedef/services_facility.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_facility.xml?rev=782662&r1=782661&r2=782662&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_facility.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_facility.xml Mon Jun  8 15:06:41 2009
@@ -208,6 +208,25 @@
         <attribute name="quantityOnHandTotal" type="BigDecimal" mode="OUT" optional="false"/>
         <attribute name="availableToPromiseTotal" type="BigDecimal" mode="OUT" optional="false"/>
     </service>
+    <service name="countProductInventoryOnHand" engine="simple"
+                location="component://product/script/org/ofbiz/product/inventory/InventoryServices.xml" invoke="countProductInventoryOnHand" auth="true" use-transaction="false">
+        <description>Count Inventory On Hand for a Product constrained by a facilityId at a given date.</description>
+        <attribute name="productId" type="String" mode="IN" optional="false"/>
+        <attribute name="facilityId" type="String" mode="IN" optional="false"/>
+        <attribute name="statusId" type="String" mode="IN" optional="true"/>
+        <attribute name="inventoryCountDate" type="Timestamp" mode="IN" optional="false"/>
+        <attribute name="quantityOnHandTotal" type="BigDecimal" mode="OUT" optional="true"/>
+    </service>
+    <service name="countProductInventoryShippedForSales" engine="simple"
+                location="component://product/script/org/ofbiz/product/inventory/InventoryServices.xml" invoke="countProductInventoryShippedForSales" auth="true" use-transaction="false">
+        <description>Count Inventory Shipped for Sales Orders for a Product constrained by a facilityId in a given date range.</description>
+        <attribute name="productId" type="String" mode="IN" optional="false"/>
+        <attribute name="facilityId" type="String" mode="IN" optional="false"/>
+        <attribute name="statusId" type="String" mode="IN" optional="true"/>
+        <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/>
+        <attribute name="thruDate" type="Timestamp" mode="IN" optional="true"/>
+        <attribute name="quantityOnHandTotal" type="BigDecimal" mode="OUT" optional="true"/>
+    </service>
     <service name="getProductInventorySummaryForItems" engine="java"
                 location="org.ofbiz.product.inventory.InventoryServices" invoke="getProductInventorySummaryForItems" auth="false" use-transaction="false">
         <description>Get ATP/QOH Availability for a list of OrderItems by summing over all facilities.  If the item is a MARKETING_PKG_AUTO/PICK, then put its quantity available from components

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java?rev=782662&r1=782661&r2=782662&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java Mon Jun  8 15:06:41 2009
@@ -48,8 +48,8 @@
     /**
      * This method is responsible to import spreadsheet data into "Product" and
      * "InventoryItem" entities into database. The method uses the
-     * ImportProductHelper class to perform its opertaion. The method uses "Apache
-     * POI" api for importing spreadsheet(xls files) data.
+     * ImportProductHelper class to perform its operation. The method uses "Apache
+     * POI" api for importing spreadsheet (xls files) data.
      *
      * Note : Create the spreadsheet directory in the ofbiz home folder and keep
      * your xls files in this folder only.

Added: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ComputeProductSellThroughData.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ComputeProductSellThroughData.groovy?rev=782662&view=auto
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ComputeProductSellThroughData.groovy (added)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ComputeProductSellThroughData.groovy Mon Jun  8 15:06:41 2009
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+if (parameters.fromDateSellThrough) {
+    Timestamp fromDate = null;
+    Timestamp thruDate = null;
+    try {
+        fromDate = Timestamp.valueOf(parameters.fromDateSellThrough);
+        thruDate = Timestamp.valueOf(parameters.thruDateSellThrough);
+    } catch(Exception e) {}
+    inventoryCountResult = dispatcher.runSync("countProductInventoryOnHand", [productId : productId, facilityId : facilityId, inventoryCountDate : fromDate, userLogin : userLogin]);
+    if (inventoryCountResult.quantityOnHandTotal && inventoryCountResult.quantityOnHandTotal > 0) {
+        inventoryShippedForSalesResult = dispatcher.runSync("countProductInventoryShippedForSales", [productId : productId, facilityId : facilityId, fromDate : fromDate, thruDate : thruDate, userLogin : userLogin]);
+        context.sellThroughInitialInventory = inventoryCountResult.quantityOnHandTotal;
+        context.sellThroughInventorySold = inventoryShippedForSalesResult.quantityOnHandTotal;
+        context.sellThroughPercentage = inventoryShippedForSalesResult.quantityOnHandTotal / inventoryCountResult.quantityOnHandTotal * 100;
+    }
+}

Propchange: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ComputeProductSellThroughData.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ComputeProductSellThroughData.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ComputeProductSellThroughData.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=782662&r1=782661&r2=782662&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml (original)
+++ ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml Mon Jun  8 15:06:41 2009
@@ -414,6 +414,8 @@
         </field>
         <field name="VIEW_SIZE" entry-name="viewSize" title="${uiLabelMap.ProductShowProductsPerPage}"><text/></field>
         <field name="monthsInPastLimit" entry-name="monthsInPastLimit"><text/></field>
+        <field name="fromDateSellThrough"><date-time/></field>
+        <field name="thruDateSellThrough"><date-time/></field>
         <field name="submitButton" title="${uiLabelMap.CommonFind}" widget-style="smallSubmit">
             <submit button-type="button"/>
         </field>
@@ -429,6 +431,7 @@
                 <field-map field-name="checkTime" from-field="checkTime"/>
                 <field-map field-name="statusId" from-field="statusId"/>
             </service>
+            <script location="component://product/webapp/facility/WEB-INF/actions/facility/ComputeProductSellThroughData.groovy"/>
         </row-actions>
         <field name="items" title="${uiLabelMap.ProductProductId}" widget-style="buttontext">
             <hyperlink target="EditFacilityInventoryItems" description="${productId}">
@@ -455,6 +458,10 @@
         <field name="defaultPrice" title="${uiLabelMap.ProductDefaultPrice}"><display description="${resultMap.defultPrice}"/></field>
         <field name="listPrice" title="${uiLabelMap.ProductListPrice}"><display description="${resultMap.listPrice}"/></field>
         <field name="wholeSalePrice" title="${uiLabelMap.ProductWholeSalePrice}"><display description="${resultMap.wholeSalePrice}"/></field>
+        <field name="fromDateSellThrough" entry-name="parameters.fromDateSellThrough"><display/></field>
+        <field name="sellThroughInitialInventory"><display/></field>
+        <field name="sellThroughInventorySold"><display/></field>
+        <field name="sellThroughPercentage"><display/></field>
     </form>
 
     <!-- multi-form for list of packages ready to be weighted and scheduled for shipment -->