svn commit: r536951 - in /ofbiz/trunk/applications/order: script/org/ofbiz/order/order/OrderReturnServices.xml servicedef/secas.xml servicedef/services_return.xml src/org/ofbiz/order/order/OrderReturnServices.java

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

svn commit: r536951 - in /ofbiz/trunk/applications/order: script/org/ofbiz/order/order/OrderReturnServices.xml servicedef/secas.xml servicedef/services_return.xml src/org/ofbiz/order/order/OrderReturnServices.java

jacopoc
Author: jacopoc
Date: Thu May 10 10:54:40 2007
New Revision: 536951

URL: http://svn.apache.org/viewvc?view=rev&rev=536951
Log:
When a replacement return item is cancelled, the replacement order items associated to it are also cancelled.

Modified:
    ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml
    ofbiz/trunk/applications/order/servicedef/secas.xml
    ofbiz/trunk/applications/order/servicedef/services_return.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java

Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml?view=diff&rev=536951&r1=536950&r2=536951
==============================================================================
--- ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml (original)
+++ ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml Thu May 10 10:54:40 2007
@@ -780,6 +780,33 @@
         </iterate>
     </simple-method>
 
+    <simple-method method-name="cancelReplacementOrderItems" short-description="Cancel the associated OrderItems of the replacement order, if any.">
+        <check-permission permission="ORDERMGR" action="_UPDATE"><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCancelReturnItems"/></check-permission>
+        <check-errors/>
+        <entity-one entity-name="ReturnItem" value-name="returnItem"/>
+        <if>
+            <condition>
+                <or>
+                    <if-compare field-name="returnItem.returnTypeId" operator="equals" value="RTN_REPLACE"/>
+                    <if-compare field-name="returnItem.returnTypeId" operator="equals" value="RTN_CSREPLACE"/>
+                    <if-compare field-name="returnItem.returnTypeId" operator="equals" value="RTN_REPAIR_REPLACE"/>
+                </or>
+            </condition>
+            <then>
+                <!-- get the returned order item -->
+                <get-related-one value-name="returnItem" relation-name="OrderItem" to-value-name="orderItem"/>
+                <!-- get the order items of the replacement order associated to the returned item  -->
+                <set field="oiaMap.orderItemAssocTypeId" value="REPLACEMENT"/>
+                <get-related value-name="orderItem" relation-name="FromOrderItemAssoc" map-name="oiaMap" list-name="replacementOrderItems"/>
+                <iterate list-name="replacementOrderItems" entry-name="replacementOrderItem">
+                    <set field="orderItemMap.orderId" from-field="replacementOrderItem.toOrderId"/>
+                    <set field="orderItemMap.orderItemSeqId" from-field="replacementOrderItem.toOrderItemSeqId"/>
+                    <call-service service-name="cancelOrderItem" in-map-name="orderItemMap"/>
+                </iterate>
+            </then>
+        </if>
+    </simple-method>
+
     <simple-method method-name="processWaitReplacementReturn" short-description="Process the replacements in a wait return">
         <set field="inMap.returnId" from-field="parameters.returnId"/>
         <set field="inMap.returnTypeId" value="RTN_REPLACE"/>

Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?view=diff&rev=536951&r1=536950&r2=536951
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/secas.xml Thu May 10 10:54:40 2007
@@ -171,6 +171,12 @@
         <action service="resetGrandTotal" mode="sync"/>
     </eca>
 
+    <eca service="updateReturnItem" event="commit">
+        <condition field-name="statusId" operator="equals" value="RETURN_CANCELLED"/>
+        <condition field-name="currentStatusId" operator="not-equals" value="RETURN_CANCELLED"/>
+        <action service="cancelReplacementOrderItems" mode="sync"/>
+    </eca>
+
     <eca service="updateReturnStatusFromReceipt" event="global-commit">
         <condition field-name="returnHeaderStatus" operator="equals" value="RETURN_RECEIVED"/>
         <action service="processWaitReplacementReturn" mode="sync" persist="true"/>

Modified: ofbiz/trunk/applications/order/servicedef/services_return.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services_return.xml?view=diff&rev=536951&r1=536950&r2=536951
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services_return.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services_return.xml Thu May 10 10:54:40 2007
@@ -115,7 +115,13 @@
         <description>Cancel ReturnItems and set their status to "RETURN_CANCELLED"</description>
         <attribute name="returnId" type="String" mode="IN" optional="false"/>
     </service>
-    
+
+    <service name="cancelReplacementOrderItems" engine="simple"
+            location="org/ofbiz/order/order/OrderReturnServices.xml" invoke="cancelReplacementOrderItems">
+        <description>Cancel the associated OrderItems of the replacement order, if any.</description>
+        <auto-attributes entity-name="ReturnItem" include="pk" mode="IN" optional="false"/>
+    </service>
+
     <!-- services for return adjustments -->
     <service name="returnAdjustmentInterface" engine="interface" location="" invoke="">
         <description>Return Adjustment Interface</description>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java?view=diff&rev=536951&r1=536950&r2=536951
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Thu May 10 10:54:40 2007
@@ -1516,6 +1516,11 @@
                                                     GenericValue newOrderItemShipGroupAssoc = delegator.makeValue("OrderItemShipGroupAssoc", UtilMisc.toMap("orderItemSeqId", newItem.getString("orderItemSeqId"), "shipGroupSeqId", orderItemShipGroupAssoc.getString("shipGroupSeqId"), "quantity", repairQuantity));
                                                     orderItemShipGroupInfo.add(newOrderItemShipGroupAssoc);
                                                 }
+                                                // Create an association between the repair order item and the order item of the original order
+                                                newOrderItemAssoc = delegator.makeValue("OrderItemAssoc", UtilMisc.toMap("orderId", orderHeader.getString("orderId"),
+                                                        "orderItemSeqId", orderItem.getString("orderItemSeqId"), "shipGroupSeqId", "_NA_",
+                                                        "toOrderItemSeqId", newItem.getString("orderItemSeqId"), "toShipGroupSeqId", "_NA_", "orderItemAssocTypeId", "REPLACEMENT"));
+                                                orderItemAssocs.add(newOrderItemAssoc);
                                             }
                                         }
                                     }