svn commit: r569456 - /ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java

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

svn commit: r569456 - /ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java

jonesde
Author: jonesde
Date: Fri Aug 24 10:01:15 2007
New Revision: 569456

URL: http://svn.apache.org/viewvc?rev=569456&view=rev
Log:
Changed to only request a returnlabel if it is a cross-ship replacement

Modified:
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java

Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java?rev=569456&r1=569455&r2=569456&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Fri Aug 24 10:01:15 2007
@@ -657,12 +657,33 @@
                     // Check if order was a return replacement order (associated with return)
                     GenericValue returnItemResponse = EntityUtil.getFirst(delegator.findByAnd("ReturnItemResponse", UtilMisc.toMap("replacementOrderId", orderId)));
                     if (returnItemResponse != null) {
-                        bodyParameters.put("shipnotes", "RETURNLABEL");
+                        boolean includeReturnLabel = false;
                         
                         // Get the associated return Id (replaceReturnId)
                         String returnItemResponseId = returnItemResponse.getString("returnItemResponseId");
-                        GenericValue returnItem = EntityUtil.getFirst(delegator.findByAnd("ReturnItem", UtilMisc.toMap("returnItemResponseId", returnItemResponseId)));
-                        bodyParameters.put("replacementReturnId", returnItem.getString("returnId"));
+                        List returnItemList = delegator.findByAnd("ReturnItem", UtilMisc.toMap("returnItemResponseId", returnItemResponseId));
+                        GenericValue firstReturnItem = EntityUtil.getFirst(returnItemList);
+                        if (firstReturnItem != null) {
+                            bodyParameters.put("replacementReturnId", firstReturnItem.getString("returnId"));
+                        } else {
+                            Debug.logWarning("Could not find a ReturnItem for returnItemResponseId [" + returnItemResponseId + "]; this really shouldn't happen but isn't a real error either. It means a ReturnItemResponse was created but not attached to any item!", module);
+                        }
+
+                        // return label should only be sent when we want a return label to be included; this would be for a cross-ship replacement type ReturnItem
+                        
+                        // go through the returnItemList and if any are cross-ship replacement, then include a label (not for wait replacement in other words)
+                        Iterator returnItemIter = returnItemList.iterator();
+                        while (returnItemIter.hasNext()) {
+                            GenericValue returnItem = (GenericValue) returnItemIter.next();
+                            if ("returnTypeId".equals(returnItem.getString("RTN_CSREPLACE"))) {
+                                includeReturnLabel = true;
+                            }
+                        }
+                        
+                        if (includeReturnLabel) {
+                            bodyParameters.put("shipnotes", "RETURNLABEL");
+                        }
+                        
                     }
                     // tracking shipper account, other Party info
                     String partyId = shipment.getString("partyIdTo");