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

mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release24.09 by this push:
     new 8ab57fe2a0 Fixed: Regressions in ShipmentServices.groovy introduced by 
the mini-lang conversion (OFBIZ-13661)
8ab57fe2a0 is described below

commit 8ab57fe2a03cb33bcd45d9cd9cfbddaacd23baa3
Author: Mridul Pathak <[email protected]>
AuthorDate: Thu Oct 8 18:59:41 2026 +0530

    Fixed: Regressions in ShipmentServices.groovy introduced by the mini-lang 
conversion (OFBIZ-13661)
    
    The Groovy conversion of ShipmentServices.xml changed the behaviour of 
several services. Restore the mini-lang behaviour:
    
    - quickShipEntireOrder: accept the setPackedOnly String in the sub-method 
instead of a Boolean (a String such as Y raised a MissingMethodException), and 
collect the shipments, messages and ship group facilities of all facilities 
instead of keeping the last ones, returning shipmentIds as well
    - removeOrderShipmentFromShipment: subtract the removed OrderShipment 
quantity from the ShipmentItem quantity, not the other way round
    - setShipmentSettingsFromPrimaryOrder: use the ShipmentRouteSegment field 
names estimatedStartDate and estimatedArrivalDate, keep the destination contact 
mech and telecom number when the ship group has none, keep an explicit 
estimatedShipCost of zero, and do not fail when no FacilityContactMech is found 
for a purchase shipment
    - issueSerializedInvToShipmentPackageAndSetTracking: look up the route 
segment 00001
    - checkAndUpdateWorkEffort: only change the dates and facility of the 
shipment WorkEfforts when the corresponding value is passed
    - ensureRouteSegPackage (release24.09 only): look the 
ShipmentPackageRouteSeg up with its full key, as trunk already does, so that an 
existing package route segment is no longer created a second time
    
    (cherry picked from commit b682e33bd288bdcf8995f0aea832acb144a1fb41)
---
 .../ofbiz/product/shipment/ShipmentServices.groovy | 45 +++++++++++++---------
 .../workeffort/WorkEffortServicesScript.groovy     | 20 +++++++---
 2 files changed, 41 insertions(+), 24 deletions(-)

diff --git 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentServices.groovy
 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentServices.groovy
index 7b1cb96173..6337c19279 100644
--- 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentServices.groovy
+++ 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentServices.groovy
@@ -331,7 +331,9 @@ Map setShipmentSettingsFromPrimaryOrder() {
             GenericValue destinationFacility = from('FacilityContactMech')
                     .where(contactMechId: shipment.destinationContactMechId)
                     .queryFirst()
-            shipment.destinationFacilityId = destinationFacility.facilityId
+            if (destinationFacility) {
+                shipment.destinationFacilityId = destinationFacility.facilityId
+            }
         }
     }
     /*
@@ -342,11 +344,15 @@ Map setShipmentSettingsFromPrimaryOrder() {
      */
     if (orderItemShipGroup) {
         if (orderHeader.orderTypeId == 'SALES_ORDER') {
-            shipment.destinationContactMechId = 
orderItemShipGroup.contactMechId
-            shipment.destinationTelecomNumberId = 
orderItemShipGroup.telecomContactMechId
+            if (orderItemShipGroup.contactMechId) {
+                shipment.destinationContactMechId = 
orderItemShipGroup.contactMechId
+            }
+            if (orderItemShipGroup.telecomContactMechId) {
+                shipment.destinationTelecomNumberId = 
orderItemShipGroup.telecomContactMechId
+            }
         }
     }
-    if (!shipment.estimatedShipCost) {
+    if (shipment.estimatedShipCost == null) {
         OrderReadHelper orderReadHelper = new OrderReadHelper(orderHeader)
         List orderItems = orderReadHelper.getValidOrderItems()
         List orderAdjustments = orderReadHelper.getAdjustments()
@@ -365,8 +371,8 @@ Map setShipmentSettingsFromPrimaryOrder() {
     List shipmentRouteSegments = 
from('ShipmentRouteSegment').where(shipmentRouteSegmentMap).queryList()
     if (!shipmentRouteSegments) {
         // estimatedShipDate, estimatedArrivalDate
-        shipmentRouteSegmentMap.estimatedstartDate = shipment.estimatedShipDate
-        shipmentRouteSegmentMap.estimatedarrivalDate = 
shipment.estimatedArrivalDate
+        shipmentRouteSegmentMap.estimatedStartDate = shipment.estimatedShipDate
+        shipmentRouteSegmentMap.estimatedArrivalDate = 
shipment.estimatedArrivalDate
         shipmentRouteSegmentMap.originFacilityId = shipment.originFacilityId
         shipmentRouteSegmentMap.originContactMechId = 
shipment.originContactMechId
         shipmentRouteSegmentMap.originTelecomNumberId = 
shipment.originTelecomNumberId
@@ -678,13 +684,14 @@ Map ensureRouteSegPackage() {
     GenericValue shipmentRouteSegment = 
from('ShipmentRouteSegment').where(parameters).cache().queryOne()
     List shipmentPackages = from('ShipmentPackage').where(shipmentId: 
shipmentRouteSegment.shipmentId).queryList()
     for (GenericValue shipmentPackage : shipmentPackages) {
+        Map sprsMap = [shipmentId: parameters.shipmentId,
+            shipmentRouteSegmentId: parameters.shipmentRouteSegmentId,
+            shipmentPackageSeqId: shipmentPackage.shipmentPackageSeqId]
         GenericValue checkShipmentPackageRouteSeg = 
from('ShipmentPackageRouteSeg')
-                .where(shipmentRouteSegment as Map)
+                .where(sprsMap)
                 .queryOne()
         if (!checkShipmentPackageRouteSeg) {
-            run service: 'createShipmentPackageRouteSeg', with: [shipmentId: 
parameters.shipmentId,
-                                                                 
shipmentRouteSegmentId: parameters.shipmentRouteSegmentId,
-                                                                 
shipmentPackageSeqId: shipmentPackage.shipmentPackageSeqId]
+            run service: 'createShipmentPackageRouteSeg', with: sprsMap
         }
     }
     return success()
@@ -758,8 +765,9 @@ Map checkCanChangeShipmentStatusGeneral(Map 
inputParameters) {
  */
 Map quickShipEntireOrder() {
     Map result = success()
-    List successMessageList
-    List shipmentShipGroupFacilityList
+    List successMessageList = []
+    List shipmentShipGroupFacilityList = []
+    List shipmentIds = []
     // first get the order header; make sure we have a product store
     GenericValue orderHeader = from('OrderHeader').where(parameters).queryOne()
     if (!orderHeader || !orderHeader.productStoreId) {
@@ -792,15 +800,16 @@ Map quickShipEntireOrder() {
                 serviceResult.orderItemListByShGrpMap, 
serviceResult.orderItemShipGroupList,
                 serviceResult.orderItemAndShipGroupAssocList, 
orderItemShipGrpInvResFacilityId,
                 parameters.eventDate, parameters.setPackedOnly)
-        successMessageList = serviceResultCSFFASG.successMessageList
-        shipmentIds = serviceResultCSFFASG.shipmentIds
-        shipmentShipGroupFacilityList = 
serviceResultCSFFASG.shipmentShipGroupFacilityList
+        successMessageList.addAll(serviceResultCSFFASG.successMessageList)
+        shipmentIds.addAll(serviceResultCSFFASG.shipmentIds)
+        
shipmentShipGroupFacilityList.addAll(serviceResultCSFFASG.shipmentShipGroupFacilityList)
     }
     logInfo('Finished quickShipEntireOrder:\n' +
             "shipmentShipGroupFacilityList=${shipmentShipGroupFacilityList}\n" 
+
             "successMessageList=${successMessageList}")
     result.shipmentShipGroupFacilityList = shipmentShipGroupFacilityList
     result.successMessageList = successMessageList
+    result.shipmentIds = shipmentIds
     if (!shipmentShipGroupFacilityList) {
         String errorMessage = UtilProperties.getMessage('ProductUiLabels', 
'FacilityShipmentNotCreated', locale)
         return error(errorMessage)
@@ -928,7 +937,7 @@ Map getOrderItemShipGroupLists(GenericValue orderHeader) {
 Map createShipmentForFacilityAndShipGroup(GenericValue orderHeader, Map 
orderItemListByShGrpMap,
                                           List orderItemShipGroupList, List 
orderItemAndShipGroupAssocList,
                                           String 
orderItemShipGrpInvResFacilityId,
-                                          Timestamp eventDate, Boolean 
setPackedOnly) {
+                                          Timestamp eventDate, String 
setPackedOnly) {
     Map result = success()
     List shipmentIds = []
     List shipmentShipGroupFacilityList = []
@@ -1153,7 +1162,7 @@ Map issueSerializedInvToShipmentPackageAndSetTracking() {
     if (routeSegLookup.shipmentPackageSeqId) {
         routeSegLookup.shipmentId = itemIssuance.shipmentId
         // quick ship orders should only have one route segment
-        routeSegLookup.shipmentRouteSegmentId = '0001'
+        routeSegLookup.shipmentRouteSegmentId = '00001'
         GenericValue packageRouteSegment = 
from('ShipmentPackageRouteSeg').where(routeSegLookup).queryOne()
         if (packageRouteSegment) {
             packageRouteSegment.trackingCode = parameters.trackingNum
@@ -1308,7 +1317,7 @@ Map removeOrderShipmentFromShipment() {
     GenericValue orderShipment = 
from('OrderShipment').where(parameters).queryOne()
     GenericValue shipmentItem = 
from('ShipmentItem').where(parameters).queryOne()
     run service: 'deleteOrderShipment', with: parameters
-    shipmentItem.quantity = orderShipment.quantity - shipmentItem.quantity
+    shipmentItem.quantity = shipmentItem.quantity - orderShipment.quantity
     if (shipmentItem.quantity > (BigDecimal.ZERO)) {
         run service: 'updateShipmentItem', with: shipmentItem.getAllFields()
     } else {
diff --git 
a/applications/workeffort/src/main/groovy/org/apache/ofbiz/workeffort/workeffort/workeffort/WorkEffortServicesScript.groovy
 
b/applications/workeffort/src/main/groovy/org/apache/ofbiz/workeffort/workeffort/workeffort/WorkEffortServicesScript.groovy
index cd44efac31..a23b5aa6bf 100644
--- 
a/applications/workeffort/src/main/groovy/org/apache/ofbiz/workeffort/workeffort/workeffort/WorkEffortServicesScript.groovy
+++ 
b/applications/workeffort/src/main/groovy/org/apache/ofbiz/workeffort/workeffort/workeffort/WorkEffortServicesScript.groovy
@@ -105,9 +105,13 @@ Map checkAndUpdateWorkEffort() {
             && ['SHIPMENT_CANCELLED', 'SHIPMENT_PACKED', 
'SHIPMENT_SHIPPED'].contains(parameters.statusId))) {
         GenericValue estShipWe = from('WorkEffort').where(workEffortId: 
lookedUpValue.estimatedShipWorkEffId).queryOne()
         if (estShipWe) {
-            estShipWe.estimatedStartDate = parameters.estimatedShipDate
-            estShipWe.estimatedCompletionDate = parameters.estimatedShipDate
-            estShipWe.facilityId = parameters.originFacilityId
+            if (parameters.estimatedShipDate != null) {
+                estShipWe.estimatedStartDate = parameters.estimatedShipDate
+                estShipWe.estimatedCompletionDate = 
parameters.estimatedShipDate
+            }
+            if (parameters.originFacilityId != null) {
+                estShipWe.facilityId = parameters.originFacilityId
+            }
             if ((parameters.statusId) && (parameters.statusId != 
lookedUpValue.statusId)) {
                 switch (parameters.statusId) {
                     case 'SHIPMENT_CANCELLED':
@@ -137,9 +141,13 @@ Map checkAndUpdateWorkEffort() {
                 .where(workEffortId: lookedUpValue.estimatedArrivalWorkEffId)
                 .queryOne()
         if (estimatedArrivalWorkEffort) {
-            estimatedArrivalWorkEffort.estimatedStartDate = 
parameters.estimatedArrivalDate
-            estimatedArrivalWorkEffort.estimatedCompletionDate = 
parameters.estimatedArrivalDate
-            estimatedArrivalWorkEffort.facilityId = 
parameters.destinationFacilityId
+            if (parameters.estimatedArrivalDate != null) {
+                estimatedArrivalWorkEffort.estimatedStartDate = 
parameters.estimatedArrivalDate
+                estimatedArrivalWorkEffort.estimatedCompletionDate = 
parameters.estimatedArrivalDate
+            }
+            if (parameters.destinationFacilityId != null) {
+                estimatedArrivalWorkEffort.facilityId = 
parameters.destinationFacilityId
+            }
             Map serviceResult = run service: 'updateWorkEffort', with: 
estimatedArrivalWorkEffort
             if (!ServiceUtil.isSuccess(serviceResult)) {
                 return error(serviceResult.errorMessage)

Reply via email to