[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.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1749111 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Divesh Dutta
2016-06-19 00:46:55 +00:00
parent 03b5a15bf2
commit a2d99d0430
4 changed files with 31 additions and 23 deletions
@@ -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">
@@ -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 {
@@ -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"))) {
@@ -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>