Author: jaz
Date: Tue Apr  3 13:30:56 2007
New Revision: 525264

URL: http://svn.apache.org/viewvc?view=rev&rev=525264
Log:
few changes to use entity list iterators when doing inventory lookups; added 
code to get totals from serialized inventory records; next to add view to get 
totals (instead of doing math in simple methods)

Modified:
    ofbiz/trunk/applications/product/entitydef/eecas.xml
    
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml
    
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
    ofbiz/trunk/applications/product/servicedef/services_facility.xml

Modified: ofbiz/trunk/applications/product/entitydef/eecas.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/eecas.xml?view=diff&rev=525264&r1=525263&r2=525264
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/eecas.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/eecas.xml Tue Apr  3 13:30:56 
2007
@@ -34,13 +34,18 @@
     <eca entity="ProductContent" operation="create-store" event="return">
         <action service="indexProductKeywords" mode="sync"/>
     </eca>
-    
+
+    <!-- inventory related ECAs -->
     <eca entity="InventoryItem" operation="create-store" event="return">
         <condition field-name="productId" operator="is-not-empty"/>
         <condition field-name="availableToPromiseTotal" 
operator="is-not-empty"/>
         <condition field-name="availableToPromiseTotal" operator="less-equals" 
value="0" type="Double"/>
         <action service="checkProductInventoryDiscontinuation" mode="async"/>
     </eca>
+    <!-- update the totals for serialized inventory items -->
+    <eca entity="InventoryItem" operation="create-store" event="return">       
    
+        <action service="updateSerializedInventoryTotals" mode="sync"/> 
+    </eca>    
     <!-- Just in case an InventoryItem is ever created with ATP/QOH values, 
catch and handle that -->
     <eca entity="InventoryItem" operation="create" event="return">
         <action service="createInventoryItemCheckSetAtpQoh" mode="sync"/>

Modified: 
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml?view=diff&rev=525264&r1=525263&r2=525264
==============================================================================
--- 
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml
 (original)
+++ 
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml
 Tue Apr  3 13:30:56 2007
@@ -78,7 +78,7 @@
         <set from-field="parameters.quantity" 
field="parameters.quantityNotReserved"/>
 
         <!-- first reserve against InventoryItems in FLT_PICKLOC type 
locations, then FLT_BULK locations, then InventoryItems with no locations -->
-        <find-by-and entity-name="InventoryItemAndLocation" 
map-name="lookupFieldMap" list-name="inventoryItemAndLocations" 
order-by-list-name="orderByList"/>
+        <find-by-and entity-name="InventoryItemAndLocation" 
map-name="lookupFieldMap" list-name="inventoryItemAndLocations" 
use-iterator="true" order-by-list-name="orderByList"/>
         <iterate entry-name="inventoryItemAndLocation" 
list-name="inventoryItemAndLocations">
             <if-compare 
field-name="inventoryItemAndLocation.locationTypeEnumId" operator="equals" 
value="FLT_PICKLOC">
                 <!-- this is a little trick to get the InventoryItem value 
object without doing a query, possible since all fields on InventoryItem are 
also on InventoryItemAndLocation with the same names -->
@@ -86,8 +86,10 @@
                 <call-simple-method 
method-name="reserveForInventoryItemInline"/>
             </if-compare>
         </iterate>
+
         <!-- still some left? try the FLT_BULK locations -->
         <if-compare field-name="parameters.quantityNotReserved" 
operator="greater" value="0" type="Double">
+            <find-by-and entity-name="InventoryItemAndLocation" 
map-name="lookupFieldMap" list-name="inventoryItemAndLocations" 
use-iterator="true" order-by-list-name="orderByList"/>
             <iterate entry-name="inventoryItemAndLocation" 
list-name="inventoryItemAndLocations">
                 <if-compare 
field-name="inventoryItemAndLocation.locationTypeEnumId" operator="equals" 
value="FLT_BULK">
                     <!-- this is a little trick to get the InventoryItem value 
object without doing a query, possible since all fields on InventoryItem are 
also on InventoryItemAndLocation with the same names -->
@@ -98,8 +100,8 @@
         </if-compare>
 
         <!-- last of all try reserving in InventoryItems that have no 
locationSeqId, ie are not in any particular location -->
-        <if-compare field-name="parameters.quantityNotReserved" 
operator="greater" value="0" type="Double">
-            <find-by-and entity-name="InventoryItem" map-name="lookupFieldMap" 
list-name="inventoryItems" order-by-list-name="orderByList"/>
+        <if-compare field-name="parameters.quantityNotReserved" 
operator="greater" value="0" type="Double">            
+            <find-by-and entity-name="InventoryItem" map-name="lookupFieldMap" 
list-name="inventoryItems" use-iterator="true" 
order-by-list-name="orderByList"/>
             <iterate entry-name="inventoryItem" list-name="inventoryItems">
                 <if-empty field-name="inventoryItem.locationSeqId">
                     <call-simple-method 
method-name="reserveForInventoryItemInline"/>

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?view=diff&rev=525264&r1=525263&r2=525264
==============================================================================
--- 
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
 (original)
+++ 
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
 Tue Apr  3 13:30:56 2007
@@ -185,6 +185,68 @@
         <set field="inventoryItem.quantityOnHandTotal" 
from-field="inventoryItemDetailSummary.quantityOnHandTotal"/>
         <store-value value-name="inventoryItem"/>
     </simple-method>
+    <simple-method method-name="updateSerializedInventoryTotals" 
short-description="Update the totals on serialized inventory">
+        <entity-one entity-name="InventoryItem" value-name="inventoryItem"/>
+        <if-compare field-name="inventoryItem.inventoryItemTypeId" 
value="SERIALIZED_INV_ITEM" operator="equals">
+            <if>
+                <!-- available -->
+                <condition>
+                    <and>
+                        <if-compare field-name="inventoryItem.statusId" 
value="INV_AVAILABLE" operator="equals"/>
+                        <or>
+                            <if-compare 
field-name="inventoryItem.availableToPromiseTotal" value="1" 
operator="not-equals" type="Double"/>
+                            <if-compare 
field-name="inventoryItem.quantityOnHandTotal" value="1" operator="not-equals" 
type="Double"/>
+                        </or>
+                    </and>
+                </condition>
+                <then>
+                    <set field="inventoryItem.availableToPromiseTotal" 
value="1" type="Double"/>
+                    <set field="inventoryItem.quantityOnHandTotal" value="1" 
type="Double"/>
+                    <log level="always" message="Storing totals 
[${inventoryItem.inventoryItemId}] for INV_AVAIABLE [1/1]"/>
+                    <store-value value-name="inventoryItem"/>
+                </then>
+
+                <!-- delivered -->
+                <else-if>
+                    <condition>
+                        <and>
+                            <if-compare field-name="inventoryItem.statusId" 
value="INV_DELIVERED" operator="equals"/>
+                            <or>
+                                <if-compare 
field-name="inventoryItem.availableToPromiseTotal" value="0" 
operator="not-equals" type="Double"/>
+                                <if-compare 
field-name="inventoryItem.quantityOnHandTotal" value="0" operator="not-equals" 
type="Double"/>
+                            </or>
+                        </and>
+                    </condition>
+                    <then>
+                        <set field="inventoryItem.availableToPromiseTotal" 
value="0" type="Double"/>
+                        <set field="inventoryItem.quantityOnHandTotal" 
value="0" type="Double"/>
+                        <log level="always" message="Storing totals 
[${inventoryItem.inventoryItemId}] for INV_DELIVERED [0/0]"/>
+                        <store-value value-name="inventoryItem"/>
+                    </then>
+                </else-if>
+
+                <!-- any promised; or on-hand but not available status -->
+                <else-if>
+                    <condition>
+                        <and>
+                            <if-compare field-name="inventoryItem.statusId" 
value="INV_AVAILABLE" operator="not-equals"/>
+                            <if-compare field-name="inventoryItem.statusId" 
value="INV_DELIVERED" operator="not-equals"/>
+                            <or>
+                                <if-compare 
field-name="inventoryItem.availableToPromiseTotal" value="0" 
operator="not-equals" type="Double"/>
+                                <if-compare 
field-name="inventoryItem.quantityOnHandTotal" value="1" operator="not-equals" 
type="Double"/>
+                            </or>
+                        </and>
+                    </condition>
+                    <then>
+                        <set field="inventoryItem.availableToPromiseTotal" 
value="0" type="Double"/>
+                        <set field="inventoryItem.quantityOnHandTotal" 
value="1" type="Double"/>
+                        <log level="always" message="Storing totals 
[${inventoryItem.inventoryItemId}] for other status [1/0]"/>
+                        <store-value value-name="inventoryItem"/>
+                    </then>
+                </else-if>
+            </if>
+        </if-compare>
+    </simple-method>
     <simple-method method-name="updateOldInventoryToDetailAll" 
short-description="Update Old Inventory To Detail All">
         <!-- find all InventoryItem records where oldQuantityOnHand or 
oldAvailableToPromise are not null -->
         <entity-condition entity-name="InventoryItem" 
list-name="inventoryItemList">
@@ -219,6 +281,7 @@
         <if>
             <condition>
                 <and>
+                    <not><if-empty field-name="product"/></not>
                     <if-compare field-name="product.salesDiscWhenNotAvail" 
operator="equals" value="Y"/>
                     <or>
                         <if-empty 
field-name="product.salesDiscontinuationDate"/>
@@ -418,9 +481,9 @@
 
         <!-- we might get away with a cache here since real serious errors 
will occur during the reservation service... but only if we need the speed -->
         <if-compare field-name="parameters.useCache" operator="equals" 
value="true" type="Boolean">
-            <find-by-and entity-name="InventoryItem" map-name="lookupFieldMap" 
list-name="inventoryItems" use-cache="true"/>
+            <find-by-and entity-name="InventoryItem" map-name="lookupFieldMap" 
list-name="inventoryItems" use-iterator="true" use-cache="true"/>
             <else>
-                <find-by-and entity-name="InventoryItem" 
map-name="lookupFieldMap" list-name="inventoryItems" use-cache="false"/>
+                <find-by-and entity-name="InventoryItem" 
map-name="lookupFieldMap" list-name="inventoryItems" use-iterator="true" 
use-cache="false"/>
             </else>
         </if-compare>
         

Modified: ofbiz/trunk/applications/product/servicedef/services_facility.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_facility.xml?view=diff&rev=525264&r1=525263&r2=525264
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_facility.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_facility.xml Tue Apr  
3 13:30:56 2007
@@ -83,6 +83,11 @@
         </description>
         <attribute name="inventoryItemId" type="String" mode="IN" 
optional="false"/>
     </service>
+    <service name="updateSerializedInventoryTotals" 
default-entity-name="InventoryItem" engine="simple"
+                location="org/ofbiz/product/inventory/InventoryServices.xml" 
invoke="updateSerializedInventoryTotals" auth="false">
+        <description>Sets the ATP/QOH totals for serialized inventory 
items</description>                    
+        <attribute name="inventoryItemId" type="String" mode="IN" 
optional="false"/>
+    </service>
 
     <service name="createInventoryItemVariance" 
default-entity-name="InventoryItemVariance" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" 
invoke="createInventoryItemVariance" auth="true">


Reply via email to