svn commit: r559376 - in /ofbiz/trunk/applications/product: entitydef/entitygroup.xml entitydef/entitymodel.xml script/org/ofbiz/product/inventory/InventoryServices.xml

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

svn commit: r559376 - in /ofbiz/trunk/applications/product: entitydef/entitygroup.xml entitydef/entitymodel.xml script/org/ofbiz/product/inventory/InventoryServices.xml

jonesde
Author: jonesde
Date: Wed Jul 25 02:40:47 2007
New Revision: 559376

URL: http://svn.apache.org/viewvc?view=rev&rev=559376
Log:
Some changes to make it easier and more efficient to track information and do queries to get QOH totals for a given moment in time

Modified:
    ofbiz/trunk/applications/product/entitydef/entitygroup.xml
    ofbiz/trunk/applications/product/entitydef/entitymodel.xml
    ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml

Modified: ofbiz/trunk/applications/product/entitydef/entitygroup.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitygroup.xml?view=diff&rev=559376&r1=559375&r2=559376
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitygroup.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitygroup.xml Wed Jul 25 02:40:47 2007
@@ -104,7 +104,9 @@
     <entity-group group="org.ofbiz" entity="InventoryItemAttribute" />
     <entity-group group="org.ofbiz" entity="InventoryItemDetail" />
     <entity-group group="org.ofbiz" entity="InventoryItemDetailSummary" />
+    <entity-group group="org.ofbiz" entity="InventoryItemDetailForSum" />
     <entity-group group="org.ofbiz" entity="InventoryItemStatus" />
+    <entity-group group="org.ofbiz" entity="InventoryItemStatusForCount" />
     <entity-group group="org.ofbiz" entity="InventoryItemTempRes" />
     <entity-group group="org.ofbiz" entity="InventoryItemType" />
     <entity-group group="org.ofbiz" entity="InventoryItemTypeAttr" />
@@ -117,7 +119,6 @@
     <entity-group group="org.ofbiz" entity="PhysicalInventory" />
     <entity-group group="org.ofbiz" entity="PhysicalInventoryAndVariance" />
     <entity-group group="org.ofbiz" entity="VarianceReason" />
-    <entity-group group="org.ofbiz" entity="InventoryItemAndDetail" />
 
   <!-- ========================================================= -->
   <!-- org.ofbiz.product.location -->

Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?view=diff&rev=559376&r1=559375&r2=559376
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Wed Jul 25 02:40:47 2007
@@ -1286,12 +1286,25 @@
       <alias entity-alias="IID" name="availableToPromiseTotal" field="availableToPromiseDiff" function="sum"/>
       <alias entity-alias="IID" name="quantityOnHandTotal" field="quantityOnHandDiff" function="sum"/>
     </view-entity>
+    <view-entity entity-name="InventoryItemDetailForSum" package-name="org.ofbiz.product.inventory"
+        title="Inventory Item  And Inventory Item Detail for Summation View Entity">
+        <member-entity entity-alias="II" entity-name="InventoryItem"/>        
+        <member-entity entity-alias="IID" entity-name="InventoryItemDetail"/>
+        <alias entity-alias="IID" name="quantityOnHandSum" field="quantityOnHandDiff" function="sum"/>
+        <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>  
+        <view-link entity-alias="II" rel-entity-alias="IID">
+            <key-map field-name="inventoryItemId"/>
+        </view-link>
+    </view-entity>
     <entity entity-name="InventoryItemStatus"
             package-name="org.ofbiz.product.inventory"
             title="Inventory Item Status History Entity">
       <field name="inventoryItemId" type="id-ne"></field>
       <field name="statusId" type="id-ne"></field>
       <field name="statusDatetime" type="date-time"></field>
+      <field name="statusEndDatetime" type="date-time"></field>
       <field name="ownerPartyId" type="id"><description>Used to track a changed (new) ownerPartyId as a status changes.</description></field>
       <field name="productId" type="id"><description>Used to track a changed (new) productId as a status changes. In other words over time the item may be represented by a different Product (like new versus refurbished).</description></field>
       <prim-key field="inventoryItemId"/>
@@ -1304,6 +1317,20 @@
         <key-map field-name="statusId"/>
       </relation>
     </entity>
+    <view-entity entity-name="InventoryItemStatusForCount" package-name="org.ofbiz.product.inventory">
+        <description>This view-entity is for querying a count (findCountByCondition) of InventoryItems that were in a certain status at a certain point in time.</description>
+        <member-entity entity-alias="IIS" entity-name="InventoryItemStatus"/>
+        <member-entity entity-alias="II" entity-name="InventoryItem"/>
+        <alias name="facilityId" entity-alias="II"/>
+        <alias name="inventoryItemId" entity-alias="IIS"/>
+        <alias name="productId" entity-alias="IIS"><description>Note that this is from the status entity because it may change over time.</description></alias>
+        <alias name="statusId" entity-alias="IIS"/>
+        <alias name="statusDatetime" entity-alias="IIS"/>
+        <alias name="statusEndDatetime" entity-alias="IIS"/>
+        <view-link entity-alias="IIS" rel-entity-alias="II">
+            <key-map field-name="inventoryItemId"/>
+        </view-link>
+    </view-entity>
     <entity entity-name="InventoryItemTempRes"
             package-name="org.ofbiz.product.inventory"
             title="Inventory Item Temporary Reservation Entity">
@@ -1524,21 +1551,6 @@
       <field name="description" type="description"></field>
       <prim-key field="varianceReasonId"/>
     </entity>
-    <view-entity entity-name="InventoryItemAndDetail"
-            package-name="org.ofbiz.product.inventory"
-            title="Inventory Item  And Inventory Item Detail View Entity">
-      <member-entity entity-alias="II" entity-name="InventoryItem"/>        
-      <member-entity entity-alias="IID" entity-name="InventoryItemDetail"/>
-      <alias entity-alias="II" name="inventoryItemId"/>
-      <alias entity-alias="II" name="productId"/>
-      <alias entity-alias="II" name="statusId"/>
-      <alias entity-alias="IID" name="inventoryItemDetailSeqId"/>  
-      <alias entity-alias="IID" name="effectiveDate"/>  
-      <alias entity-alias="IID" name="quantityOnHandDiff"/>
-      <view-link entity-alias="II" rel-entity-alias="IID">
-          <key-map field-name="inventoryItemId"/>
-      </view-link>
-    </view-entity>
 
   <!-- ========================================================= -->
   <!-- org.ofbiz.product.location -->

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=559376&r1=559375&r2=559376
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml Wed Jul 25 02:40:47 2007
@@ -217,12 +217,31 @@
     </simple-method>
 
     <simple-method method-name="createInventoryItemStatus" short-description="Create an inventory item status record">
-        <make-value value-name="invStatus" entity-name="InventoryItemStatus"/>
-        <set-nonpk-fields map-name="parameters" value-name="invStatus"/>
-        <set-pk-fields map-name="parameters" value-name="invStatus"/>
         <now-timestamp-to-env env-name="now"/>
-        <set field="invStatus.statusDatetime" from-field="now"/>
-        <create-value value-name="invStatus"/>
+
+        <!-- find the most recent InventoryItemStatus record and set the statusEndDatetime -->
+        <entity-and entity-name="InventoryItemStatus" list-name="oldInventoryItemStatusList">
+            <field-map field-name="inventoryItemId" env-name="parameters.inventoryItemId"/>
+            <order-by field-name="-statusDatetime"/>
+        </entity-and>
+        <first-from-list entry-name="oldInventoryItemStatus" list-name="oldInventoryItemStatusList"/>
+        <if-not-empty field-name="oldInventoryItemStatus">
+            <set field="oldInventoryItemStatusList.statusEndDatetime"/>
+            <store-value value-name="oldInventoryItemStatus"/>
+        </if-not-empty>
+        
+        <make-value value-name="inventoryItemStatus" entity-name="InventoryItemStatus"/>
+        <set-nonpk-fields map-name="parameters" value-name="inventoryItemStatus"/>
+        <set-pk-fields map-name="parameters" value-name="inventoryItemStatus"/>
+        <set field="inventoryItemStatus.statusDatetime" from-field="now"/>
+        
+        <!-- make sure the current productId is set, if not passed in look up the current value -->
+        <if-empty field-name="inventoryItemStatus.productId">
+            <entity-one entity-name="InventoryItem" value-name="inventoryItem"/>
+            <set field="inventoryItemStatus.productId" from-field="inventoryItem.productId"/>
+        </if-empty>
+        
+        <create-value value-name="inventoryItemStatus"/>
     </simple-method>
 
     <simple-method method-name="createInventoryItemDetail" short-description="Create an InventoryItemDetail">