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 ef97472bdd Fix regressions in ShipmentReceiptServices and 
ProductFeatureServicesScript
ef97472bdd is described below

commit ef97472bddc194b0d03bc3c3ee4e4215339ece56
Author: Mridul Pathak <[email protected]>
AuthorDate: Thu Oct 22 18:04:59 2026 +0530

    Fix regressions in ShipmentReceiptServices and ProductFeatureServicesScript
    
    Four regressions from the minilang conversion:
    
    - cancelReceivedItems skips the inventory item steps for a receipt that has 
no inventory item.
    - quickReceiveReturn adds the receive fields to the existing receiveCtx 
instead of replacing it, so the unitCost from getReturnItemInitialCost reaches 
receiveInventoryProduct.
    - updateIssuanceShipmentAndPoOnReceiveInventory converts 
orderCurrencyUnitPrice or unitCost to a BigDecimal with the user locale and 
leaves the order item price untouched when neither is given.
    - applyFeatureToProductFromTypeAndCode only falls back to the feature 
default sequence number when sequenceNum is null, so an explicit 0 is kept.
---
 .../feature/ProductFeatureServicesScript.groovy    |  4 +-
 .../shipment/ShipmentReceiptServices.groovy        | 66 +++++++++++-----------
 2 files changed, 37 insertions(+), 33 deletions(-)

diff --git 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/feature/ProductFeatureServicesScript.groovy
 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/feature/ProductFeatureServicesScript.groovy
index 82bb585d2e..50cc42e8c0 100644
--- 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/feature/ProductFeatureServicesScript.groovy
+++ 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/feature/ProductFeatureServicesScript.groovy
@@ -34,7 +34,9 @@ Map applyFeatureToProductFromTypeAndCode() {
     for (GenericValue productFeature : productFeatures) {
         Map applyFeatureContext = [*: parameters]
         applyFeatureContext.productFeatureId = productFeature.productFeatureId
-        applyFeatureContext.sequenceNum = applyFeatureContext.sequenceNum ?: 
productFeature.defaultSequenceNum
+        if (applyFeatureContext.sequenceNum == null) {
+            applyFeatureContext.sequenceNum = productFeature.defaultSequenceNum
+        }
         run service: 'applyFeatureToProduct', with: applyFeatureContext
     }
     return success()
diff --git 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentReceiptServices.groovy
 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentReceiptServices.groovy
index 14387bd364..78b22f486a 100644
--- 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentReceiptServices.groovy
+++ 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentReceiptServices.groovy
@@ -21,6 +21,7 @@ package org.apache.ofbiz.product.shipment
 import java.math.RoundingMode
 import java.sql.Timestamp
 
+import org.apache.ofbiz.base.util.ObjectType
 import org.apache.ofbiz.base.util.UtilDateTime
 import org.apache.ofbiz.base.util.UtilProperties
 import org.apache.ofbiz.entity.GenericValue
@@ -259,17 +260,17 @@ Map quickReceiveReturn() {
                         parameters.inventoryItemTypeId = 'SERIALIZED_INV_ITEM'
                         returnItem.returnQuantity = BigDecimal.ONE
                     }
-                    receiveCtx = [inventoryItemTypeId: 
parameters.inventoryItemTypeId,
-                                  statusId: returnItem.expectedItemStatus,
-                                  productId: returnItem.productId,
-                                  returnItemSeqId: returnItem.returnItemSeqId,
-                                  returnId: returnItem.returnId,
-                                  quantityAccepted: returnItem.returnQuantity,
-                                  facilityId: 
returnHeader.destinationFacilityId,
-                                  shipmentId: shipmentId, // important: 
associate ShipmentReceipt with return shipment created
-                                  comments: "Returned Item RA# 
${returnItem.returnId}",
-                                  datetimeReceived: nowTimestamp,
-                                  quantityRejected: BigDecimal.ZERO
+                    receiveCtx << [inventoryItemTypeId: 
parameters.inventoryItemTypeId,
+                                   statusId: returnItem.expectedItemStatus,
+                                   productId: returnItem.productId,
+                                   returnItemSeqId: returnItem.returnItemSeqId,
+                                   returnId: returnItem.returnId,
+                                   quantityAccepted: returnItem.returnQuantity,
+                                   facilityId: 
returnHeader.destinationFacilityId,
+                                   shipmentId: shipmentId, // important: 
associate ShipmentReceipt with return shipment created
+                                   comments: "Returned Item RA# 
${returnItem.returnId}",
+                                   datetimeReceived: nowTimestamp,
+                                   quantityRejected: BigDecimal.ZERO
                     ]
                     Map serviceResult = run service: 
'receiveInventoryProduct', with: receiveCtx
                     result.successMessageList = 
serviceResult.successMessageList
@@ -310,14 +311,12 @@ BigDecimal getReceivedQuantityForOrderItem (GenericValue 
orderItem) {
  */
 Map updateIssuanceShipmentAndPoOnReceiveInventory() {
     GenericValue orderItem = from('OrderItem').where(parameters).queryOne()
-    if (parameters.orderCurrencyUnitPrice) {
-        if (parameters.orderCurrencyUnitPrice != orderItem.unitPrice) {
-            orderItem.unitPrice = new BigDecimal 
(parameters.orderCurrencyUnitPrice)
-            orderItem.store()
-        }
-    } else {
-        if (parameters.unitCost != orderItem.unitPrice) {
-            orderItem.unitPrice = parameters.unitCost
+    // orderCurrencyUnitPrice takes precedence over unitCost; both are 
Strings, an empty one leaves the price untouched
+    Object newUnitPriceValue = parameters.orderCurrencyUnitPrice ?: 
parameters.unitCost
+    if (newUnitPriceValue) {
+        BigDecimal newUnitPrice = 
ObjectType.simpleTypeOrObjectConvert(newUnitPriceValue, 'BigDecimal', null, 
locale)
+        if (newUnitPrice != orderItem.unitPrice) {
+            orderItem.unitPrice = newUnitPrice
             orderItem.store()
         }
     }
@@ -392,20 +391,23 @@ Map cancelReceivedItems() {
     shipmentReceipt.quantityRejected = 0.0
     shipmentReceipt.store()
 
-    // create record for InventoryItemDetail entity
+    // a receipt without accepted units has no inventory item (OFBIZ-13376), 
so there is nothing to zero out or balance
     GenericValue inventoryItem = delegator.getRelatedOne('InventoryItem', 
shipmentReceipt, false)
-    Map inventoryItemDetailMap = [inventoryItemId: 
inventoryItem.inventoryItemId]
-    inventoryItemDetailMap.quantityOnHandDiff = 
inventoryItem.quantityOnHandTotal * (-1)
-    inventoryItemDetailMap.availableToPromiseDiff = 
inventoryItem.availableToPromiseTotal * (-1)
-    run service: 'createInventoryItemDetail', with: inventoryItemDetailMap
-
-    // Balance the inventory item
-    // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" 
user since this is a trusted side
-    // effect of an already-permitted shipment-receipt operation
-    Map balanceInventoryItemMap = [inventoryItemId: 
inventoryItem.inventoryItemId,
-                                   priorityOrderId: shipmentReceipt.orderId, 
priorityOrderItemSeqId: shipmentReceipt.orderItemSeqId,
-                                   userLogin: 
from('UserLogin').where(userLoginId: 'system').cache().queryOne()]
-    run service: 'balanceInventoryItems', with: balanceInventoryItemMap
+    if (inventoryItem) {
+        // create record for InventoryItemDetail entity
+        Map inventoryItemDetailMap = [inventoryItemId: 
inventoryItem.inventoryItemId]
+        inventoryItemDetailMap.quantityOnHandDiff = 
inventoryItem.quantityOnHandTotal * (-1)
+        inventoryItemDetailMap.availableToPromiseDiff = 
inventoryItem.availableToPromiseTotal * (-1)
+        run service: 'createInventoryItemDetail', with: inventoryItemDetailMap
+
+        // Balance the inventory item
+        // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" 
user since this is a trusted side
+        // effect of an already-permitted shipment-receipt operation
+        Map balanceInventoryItemMap = [inventoryItemId: 
inventoryItem.inventoryItemId,
+                                       priorityOrderId: 
shipmentReceipt.orderId, priorityOrderItemSeqId: shipmentReceipt.orderItemSeqId,
+                                       userLogin: 
from('UserLogin').where(userLoginId: 'system').cache().queryOne()]
+        run service: 'balanceInventoryItems', with: balanceInventoryItemMap
+    }
 
     // update the shipment status, if shipment was received
     GenericValue shipment = delegator.getRelatedOne('Shipment', 
shipmentReceipt, false)

Reply via email to