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

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


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

commit 4a10a9fea96c9d143e13c06d04ed09e016592829
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
---
 .../ofbiz/product/shipment/ShipmentServices.groovy | 36 +++++++++++++---------
 .../workeffort/WorkEffortServicesScript.groovy     | 20 ++++++++----
 2 files changed, 36 insertions(+), 20 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 2b2d30f2fc..b5c577ff34 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
@@ -328,7 +328,9 @@ Map setShipmentSettingsFromPrimaryOrder() {
             GenericValue destinationFacility = from('FacilityContactMech')
                     .where(contactMechId: shipment.destinationContactMechId)
                     .queryFirst()
-            shipment.destinationFacilityId = destinationFacility.facilityId
+            if (destinationFacility) {
+                shipment.destinationFacilityId = destinationFacility.facilityId
+            }
         }
     }
     /*
@@ -339,11 +341,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()
@@ -362,8 +368,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
@@ -753,8 +759,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()
     require(orderHeader && orderHeader.productStoreId,
@@ -781,15 +788,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 = label('ProductUiLabels', 
'FacilityShipmentNotCreated')
         fail(errorMessage)
@@ -916,7 +924,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 = []
@@ -1141,7 +1149,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
@@ -1293,7 +1301,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 252fd18960..4b9fdcec01 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
@@ -97,9 +97,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':
@@ -127,9 +131,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
             require(ServiceUtil.isSuccess(serviceResult) as boolean, 
serviceResult.errorMessage)
         }

Reply via email to