Author: jacopoc
Date: Mon Dec 11 07:39:12 2006 New Revision: 485718 URL: http://svn.apache.org/viewvc?view=rev&rev=485718 Log: Order items that are replacements of existing order items are now associated using the OrderItemAssoc entity. Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java?view=diff&rev=485718&r1=485717&r2=485718 ============================================================================== --- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original) +++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Mon Dec 11 07:39:12 2006 @@ -1317,6 +1317,7 @@ List orderItems = new ArrayList(); List orderItemShipGroupInfo = new ArrayList(); List orderItemShipGroupIds = new ArrayList(); // this is used to store the ship group ids of the groups already added to the orderItemShipGroupInfo list + List orderItemAssocs = new ArrayList(); if (items != null) { Iterator ri = items.iterator(); int itemCount = 1; @@ -1370,12 +1371,23 @@ } catch(GenericEntityException gee) { Debug.logError(gee, module); } + // Create an association between the replacement order item and the order item of the original order + GenericValue 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); } } } orderMap.put("orderItems", orderItems); if (orderItemShipGroupInfo.size() > 0) { orderMap.put("orderItemShipGroupInfo", orderItemShipGroupInfo); + } + if (orderItemAssocs.size() > 0) { + orderMap.put("orderItemAssociations", orderItemAssocs); } } else { Debug.logError("No return items found??", module); Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?view=diff&rev=485718&r1=485717&r2=485718 ============================================================================== --- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Mon Dec 11 07:39:12 2006 @@ -804,7 +804,11 @@ Iterator oia = orderItemAssociations.iterator(); while (oia.hasNext()) { GenericValue orderItemAssociation = (GenericValue) oia.next(); - orderItemAssociation.set("toOrderId", orderId); + if (orderItemAssociation.get("toOrderId") == null) { + orderItemAssociation.set("toOrderId", orderId); + } else if (orderItemAssociation.get("orderId") == null) { + orderItemAssociation.set("orderId", orderId); + } toBeStored.add(orderItemAssociation); } } |
Free forum by Nabble | Edit this page |