[ofbiz-framework] branch release17.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 release17.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 release17.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release17.12 by this push:
     new 921db68  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.
921db68 is described below

commit 921db68bdea34f2757b7d3b6f142d6255a8d3950
Author: Suraj Khurana <[hidden email]>
AuthorDate: Sat Mar 27 16:29:30 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 4590127..8d8607a 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
@@ -2119,14 +2119,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"));
                         }
@@ -2174,7 +2174,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) {
@@ -2215,6 +2215,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");
@@ -2290,6 +2291,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);