Author: diveshdutta
Date: Sun Jun 19 00:46:55 2016 New Revision: 1749111 URL: http://svn.apache.org/viewvc?rev=1749111&view=rev Log: [OFBIZ-7190] Now CSR should be able to cancel order items of multiple ship groups. Also CSR should be able to cancel quantities less than ordered quantity. This should also fix OFBIZ-7255. Thanks Ankush Upadhyay for your patch. Thanks Mohammad Kathawala and Ratnesh Upadhyay for reporting the issues. Modified: ofbiz/trunk/applications/order/servicedef/services.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/trunk/applications/order/template/order/EditOrderItems.ftl Modified: ofbiz/trunk/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=1749111&r1=1749110&r2=1749111&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services.xml Sun Jun 19 00:46:55 2016 @@ -282,6 +282,7 @@ under the License. <attribute name="cancelQuantity" type="BigDecimal" mode="IN" optional="true"/> <attribute name="itemReasonMap" type="Map" mode="IN" string-map-prefix="irm_" optional="true"/> <attribute name="itemCommentMap" type="Map" mode="IN" string-map-prefix="icm_" optional="true"/> + <attribute name="itemQtyMap" type="Map" mode="IN" string-map-prefix="iqm_" optional="true"/> </service> <service name="cancelOrderItemNoActions" engine="java" auth="true" location="org.ofbiz.order.order.OrderServices" invoke="cancelOrderItem"> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java?rev=1749111&r1=1749110&r2=1749111&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java Sun Jun 19 00:46:55 2016 @@ -34,6 +34,7 @@ import javax.servlet.http.HttpSession; import org.apache.commons.io.IOUtils; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.content.data.DataResourceWorker; import org.ofbiz.entity.Delegator; @@ -43,6 +44,7 @@ import org.ofbiz.entity.util.EntityQuery import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ServiceUtil; +import java.math.BigDecimal; /** * Order Events @@ -112,21 +114,21 @@ public class OrderEvents { Map<String, Object> resultMap = new HashMap<String, Object>(); String orderId = request.getParameter("orderId"); - String[] orderItemSeqIds = request.getParameterValues("selectedItem"); - - if (orderItemSeqIds != null) { - for (String orderItemSeqId : orderItemSeqIds) { - try { - GenericValue orderItem = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryOne(); - List<GenericValue> orderItemShipGroupAssocs = orderItem.getRelated("OrderItemShipGroupAssoc", null, null, false); - for (GenericValue orderItemShipGroupAssoc : orderItemShipGroupAssocs) { - GenericValue orderItemShipGroup = orderItemShipGroupAssoc.getRelatedOne("OrderItemShipGroup", false); - String shipGroupSeqId = orderItemShipGroup.getString("shipGroupSeqId"); - + String[] selectedItems = request.getParameterValues("selectedItem"); + + + + if (selectedItems != null) { + for (String selectedItem : selectedItems) { + String [] orderItemSeqIdAndOrderItemShipGrpId = selectedItem.split(":"); + String orderItemSeqId = orderItemSeqIdAndOrderItemShipGrpId[0]; + String shipGroupSeqId = orderItemSeqIdAndOrderItemShipGrpId[1]; + BigDecimal cancelQuantity = new BigDecimal(request.getParameter("iqm_"+orderItemSeqId+":"+shipGroupSeqId)); Map<String, Object> contextMap = new HashMap<String, Object>(); contextMap.put("orderId", orderId); contextMap.put("orderItemSeqId", orderItemSeqId); contextMap.put("shipGroupSeqId", shipGroupSeqId); + contextMap.put("cancelQuantity", cancelQuantity); contextMap.put("userLogin", userLogin); contextMap.put("locale", locale); try { @@ -144,11 +146,6 @@ public class OrderEvents { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } - } - } catch (GenericEntityException e) { - Debug.logError(e, module); - return "error"; - } } return "success"; } else { Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1749111&r1=1749110&r2=1749111&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Sun Jun 19 00:46:55 2016 @@ -2058,7 +2058,14 @@ public class OrderServices { String shipGroupSeqId = (String) context.get("shipGroupSeqId"); Map<String, String> itemReasonMap = UtilGenerics.checkMap(context.get("itemReasonMap")); Map<String, String> itemCommentMap = UtilGenerics.checkMap(context.get("itemCommentMap")); - + Map<String, String> itemQuantityMap = UtilGenerics.checkMap(context.get("itemQtyMap")); + if ((cancelQuantity == null) && UtilValidate.isNotEmpty(itemQuantityMap)) { + String key = orderItemSeqId+":"+shipGroupSeqId; + if (UtilValidate.isNotEmpty(itemQuantityMap.get(key))) { + cancelQuantity = new BigDecimal(itemQuantityMap.get(key)); + } + + } // debugging message info String itemMsgInfo = orderId + " / " + orderItemSeqId + " / " + shipGroupSeqId; @@ -2157,12 +2164,15 @@ public class OrderServices { "orderId", orderItem.getString("orderId"), "orderItemSeqId", orderItem.getString("orderItemSeqId"), "shipGroupSeqId", orderItemShipGroupAssoc.getString("shipGroupSeqId")); - try { - dispatcher.runSync("deleteOrderItemShipGroupAssoc", localCtx); - } catch (GenericServiceException e) { - Debug.logError(e, module); - return ServiceUtil.returnError(e.getMessage()); + if (availableQuantity.compareTo(thisCancelQty) == 0) { + try { + dispatcher.runSync("deleteOrderItemShipGroupAssoc", localCtx); + } catch (GenericServiceException e) { + Debug.logError(e, module); + return ServiceUtil.returnError(e.getMessage()); + } } + // create order item change record if (!"Y".equals(orderItem.getString("isPromo"))) { Modified: ofbiz/trunk/applications/order/template/order/EditOrderItems.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/template/order/EditOrderItems.ftl?rev=1749111&r1=1749110&r2=1749111&view=diff ============================================================================== --- ofbiz/trunk/applications/order/template/order/EditOrderItems.ftl (original) +++ ofbiz/trunk/applications/order/template/order/EditOrderItems.ftl Sun Jun 19 00:46:55 2016 @@ -257,7 +257,7 @@ under the License. <td align="center"> <input type="text" name="iqm_${shipGroupAssoc.orderItemSeqId}:${shipGroupAssoc.shipGroupSeqId}" size="6" value="${shipGroupQty?string.number}"/> <#if itemSelectable> - <input type="checkbox" name="selectedItem" value="${orderItem.orderItemSeqId}" /> + <input type="checkbox" name="selectedItem" value="${orderItem.orderItemSeqId}:${shipGroupAssoc.shipGroupSeqId}" /> </#if> </td> </#if> |
Free forum by Nabble | Edit this page |