You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by bi...@apache.org on 2008/11/03 11:38:04 UTC

svn commit: r710035 - in /ofbiz/trunk/applications/product: script/org/ofbiz/product/inventory/InventoryServices.xml script/org/ofbiz/shipment/issuance/IssuanceServices.xml servicedef/secas.xml servicedef/services_facility.xml

Author: bibryam
Date: Mon Nov  3 02:38:04 2008
New Revision: 710035

URL: http://svn.apache.org/viewvc?rev=710035&view=rev
Log:
Changing serialized inventory owner after item issuance cause errors in accounting transaction services, because the new owner usually is not an internal organization.
I moved the change owner logic to a separate service and and added seca rule to invoke it after all accounting transactions are in place.

Modified:
    ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
    ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml
    ofbiz/trunk/applications/product/servicedef/secas.xml
    ofbiz/trunk/applications/product/servicedef/services_facility.xml

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=710035&r1=710034&r2=710035&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 Nov  3 02:38:04 2008
@@ -1268,4 +1268,40 @@
         </assert>
         <check-errors/>
     </simple-method>
+    <simple-method method-name="changeOwnerUponIssuance" short-description="If product store setOwnerUponIssuance is Y or empty, set the inventory item owner upon issuance.">
+        <entity-one entity-name="ItemIssuance" value-name="itemIssuance"/>
+        <get-related-one value-name="itemIssuance" relation-name="InventoryItem" to-value-name="inventoryItem"/>
+        <if-not-empty field="inventoryItem">
+            <if-compare field="inventoryItem.inventoryItemTypeId" operator="equals" value="SERIALIZED_INV_ITEM">
+                <get-related-one value-name="itemIssuance" relation-name="OrderHeader" to-value-name="orderHeader"/>
+                <if-not-empty field="orderHeader">
+                    <set field="orderRoleAndMap.orderId" from-field="orderHeader.orderId"/>
+                    <set field="orderRoleAndMap.roleTypeId" value="END_USER_CUSTOMER"/>
+                    <find-by-and entity-name="OrderRole" list-name="orderRoles" map-name="orderRoleAndMap"/>
+                    <first-from-list list-name="orderRoles" entry-name="orderRole"/>
+                    <entity-one entity-name="ProductStore" value-name="productStore" auto-field-map="false">
+                        <field-map field-name="productStoreId" env-name="orderHeader.productStoreId"/>
+                    </entity-one>
+                    <if>
+                        <condition>
+                            <and>
+                                <not><if-empty field="orderRole"/></not>
+                                <or>
+                                    <if-empty field="productStore"/>
+                                    <if-empty field="productStore.setOwnerUponIssuance"/>
+                                    <if-compare field="productStore.setOwnerUponIssuance" operator="equals" value="Y"/>
+                                </or>
+                            </and>
+                        </condition>
+                        <then>
+                            <set field="updateContext.ownerPartyId" from-field="orderRole.partyId"/>
+                        </then>
+                    </if>
+                </if-not-empty>
+                <set field="updateContext.inventoryItemId" from-field="inventoryItem.inventoryItemId"/>
+                <call-service service-name="updateInventoryItem" in-map-name="updateContext"/>
+            </if-compare>
+        </if-not-empty>
+    </simple-method>    
+    
 </simple-methods>

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml?rev=710035&r1=710034&r2=710035&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml Mon Nov  3 02:38:04 2008
@@ -41,31 +41,6 @@
         <get-related-one value-name="newEntity" relation-name="InventoryItem" to-value-name="inventoryItem"/>
         <if-not-empty field="inventoryItem">
             <if-compare field="inventoryItem.inventoryItemTypeId" operator="equals" value="SERIALIZED_INV_ITEM">
-                <get-related-one value-name="newEntity" relation-name="OrderHeader" to-value-name="orderHeader"/>
-                <if-not-empty field="orderHeader">
-                    <set field="orderRoleAndMap.orderId" from-field="orderHeader.orderId"/>
-                    <set field="orderRoleAndMap.roleTypeId" value="END_USER_CUSTOMER"/>
-                    <find-by-and entity-name="OrderRole" list-name="orderRoles" map-name="orderRoleAndMap"/>
-                    <first-from-list list-name="orderRoles" entry-name="orderRole"/>
-                    <entity-one entity-name="ProductStore" value-name="productStore" auto-field-map="false">
-                        <field-map field-name="productStoreId" env-name="orderHeader.productStoreId"/>
-                    </entity-one>
-                    <if>
-                        <condition>
-                            <and>
-                                <not><if-empty field="orderRole"/></not>
-                                <or>
-                                    <if-empty field="productStore"/>
-                                    <if-empty field="productStore.setOwnerUponIssuance"/>
-                                    <if-compare field="productStore.setOwnerUponIssuance" operator="equals" value="Y"/>
-                                </or>
-                            </and>
-                        </condition>
-                        <then>
-                            <set field="updateContext.ownerPartyId" from-field="orderRole.partyId"/>
-                        </then>
-                    </if>
-                </if-not-empty>
                 <set field="updateContext.inventoryItemId" from-field="inventoryItem.inventoryItemId"/>
                 <set field="updateContext.statusId" value="INV_DELIVERED"/>
                 <call-service service-name="updateInventoryItem" in-map-name="updateContext"/>

Modified: ofbiz/trunk/applications/product/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/secas.xml?rev=710035&r1=710034&r2=710035&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/secas.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/secas.xml Mon Nov  3 02:38:04 2008
@@ -38,6 +38,11 @@
         <condition-field field-name="oldOwnerPartyId" operator="not-equals" to-field-name="ownerPartyId"/>
         <action service="createInventoryItemStatus" mode="sync"/>
     </eca>
+    <eca service="createItemIssuance" event="return"><!-- change the owner after item issuance transactions are created for old owner -->
+        <condition field-name="orderId" operator="is-not-empty"/>
+        <condition field-name="inventoryItemId" operator="is-not-empty"/>    
+        <action service="changeOwnerUponIssuance" mode="sync"/>
+    </eca>    
 
     <!-- inventory transfer -->
     <eca service="createInventoryTransfer" event="invoke">

Modified: ofbiz/trunk/applications/product/servicedef/services_facility.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_facility.xml?rev=710035&r1=710034&r2=710035&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_facility.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_facility.xml Mon Nov  3 02:38:04 2008
@@ -70,7 +70,11 @@
         <attribute name="oldProductId" mode="OUT" optional="true" type="String"/>
         <attribute name="oldStatusId" mode="OUT" optional="true" type="String"/>
     </service>
-
+    <service name="changeOwnerUponIssuance" engine="simple"  auth="true"
+        location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="changeOwnerUponIssuance">
+        <description>If product store setOwnerUponIssuance is Y or empty, set the inventory item owner upon issuance.</description>
+        <attribute name="itemIssuanceId" type="String" mode="IN" optional="false"/>
+    </service>    
     <service name="createInventoryItemStatus" engine="simple" default-entity-name="InventoryItemStatus"
             location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createInventoryItemStatus">
         <description>Create an inventory item status record</description>