[ofbiz-framework] branch release18.12 updated: Fixed: ChangeReason was not being set on OrderStatus when orderItem was marked cancelled with reason. (OFBIZ-12210) Thanks Lalit Dashora for reporting the issue and providing the patch.

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

[ofbiz-framework] branch release18.12 updated: Fixed: ChangeReason was not being set on OrderStatus when orderItem was marked cancelled with reason. (OFBIZ-12210) Thanks Lalit Dashora for reporting the issue and providing the patch.

surajk
This is an automated email from the ASF dual-hosted git repository.

surajk pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release18.12 by this push:
     new bbab5e1  Fixed: ChangeReason was not being set on OrderStatus when orderItem was marked cancelled with reason. (OFBIZ-12210) Thanks Lalit Dashora for reporting the issue and providing the patch.
bbab5e1 is described below

commit bbab5e18b4cfa611c9fbe84ad602925262e8bb91
Author: Suraj Khurana <[hidden email]>
AuthorDate: Sat Mar 27 16:23:02 2021 +0530

    Fixed: ChangeReason was not being set on OrderStatus when orderItem was marked cancelled with reason.
    (OFBIZ-12210)
    Thanks Lalit Dashora for reporting the issue and providing the patch.
---
 .../java/org/apache/ofbiz/order/order/OrderServices.java     | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
index c83b34a..94d173e 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
@@ -2133,14 +2133,14 @@ public class OrderServices {
                         }
                     }
 
+                    String reasonEnumId = null;
+                    if (UtilValidate.isNotEmpty(itemReasonMap)) {
+                        reasonEnumId = itemReasonMap.get(orderItem.getString("orderItemSeqId"));
+                    }
 
                     //  create order item change record
                     if (!"Y".equals(orderItem.getString("isPromo"))) {
-                        String reasonEnumId = null;
                         String changeComments = null;
-                        if (UtilValidate.isNotEmpty(itemReasonMap)) {
-                            reasonEnumId = itemReasonMap.get(orderItem.getString("orderItemSeqId"));
-                        }
                         if (UtilValidate.isNotEmpty(itemCommentMap)) {
                             changeComments = itemCommentMap.get(orderItem.getString("orderItemSeqId"));
                         }
@@ -2190,7 +2190,7 @@ public class OrderServices {
                             }
                         }
                         // all items are cancelled -- mark the item as cancelled
-                        Map<String, Object> statusCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItem.getString("orderItemSeqId"), "statusId", itemStatus, "userLogin", userLogin);
+                        Map<String, Object> statusCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItem.getString("orderItemSeqId"), "statusId", itemStatus, "changeReason", reasonEnumId, "userLogin", userLogin);
                         try {
                             dispatcher.runSyncIgnore("changeOrderItemStatus", statusCtx);
                         } catch (GenericServiceException e) {
@@ -2231,6 +2231,7 @@ public class OrderServices {
         String orderId = (String) context.get("orderId");
         String orderItemSeqId = (String) context.get("orderItemSeqId");
         String fromStatusId = (String) context.get("fromStatusId");
+        String changeReason = (String) context.get("changeReason");
         String statusId = (String) context.get("statusId");
         Timestamp statusDateTime = (Timestamp) context.get("statusDateTime");
         Locale locale = (Locale) context.get("locale");
@@ -2306,6 +2307,7 @@ public class OrderServices {
                 changeFields.put("statusId", statusId);
                 changeFields.put("orderId", orderId);
                 changeFields.put("orderItemSeqId", orderItem.getString("orderItemSeqId"));
+                changeFields.put("changeReason", changeReason);
                 changeFields.put("statusDatetime", statusDateTime);
                 changeFields.put("statusUserLogin", userLogin.getString("userLoginId"));
                 GenericValue orderStatus = delegator.makeValue("OrderStatus", changeFields);