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 c42e684a48 Fix regressions in CheckoutServices, 
RequirementServicesScript and OrderDeliveryServices
c42e684a48 is described below

commit c42e684a48f011e52d08b756992d97bcbb3a33de
Author: Mridul Pathak <[email protected]>
AuthorDate: Thu Oct 22 21:26:16 2026 +0530

    Fix regressions in CheckoutServices, RequirementServicesScript and 
OrderDeliveryServices
    
    Three regressions from the minilang conversion and a later rename:
    
    - CheckoutServices removes the contact mech of a purpose from the shopping 
cart before adding the new one, so submitting a checkout step again with a 
changed address no longer leaves the previous shipping, billing, phone and 
email contact mechs in the cart, as the replacing addContactMech did before the 
rename.
    - autoAssignRequirementToSupplier assigns a requirement with a quantity of 
0, as the minilang if-not-empty did, instead of skipping it because of Groovy 
truthiness.
    - sendOrderDeliveryScheduleNotification no longer throws a 
NullPointerException when the current user has no email address or the schedule 
is missing, it skips the sender and logs that there is insufficient data, as 
the minilang did.
---
 .../groovy/org/apache/ofbiz/order/order/CheckoutServices.groovy  | 5 +++++
 .../org/apache/ofbiz/order/order/OrderDeliveryServices.groovy    | 9 ++++++---
 .../ofbiz/order/requirement/RequirementServicesScript.groovy     | 2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/order/CheckoutServices.groovy
 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/order/CheckoutServices.groovy
index 2b2fd3146a..6c7a303091 100644
--- 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/order/CheckoutServices.groovy
+++ 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/order/CheckoutServices.groovy
@@ -86,6 +86,7 @@ Map createUpdateCustomerAndShippingAddress() {
     result.shipToPhoneContactMechId = serviceResultCUPTN.contactMechId
 
     if (shipToPhoneContactMechId) {
+        shoppingCart.removeContactMechId('PHONE_SHIPPING')
         shoppingCart.addContactMechId('PHONE_SHIPPING', 
shipToPhoneContactMechId)
     }
     // Create Update email address
@@ -98,9 +99,11 @@ Map createUpdateCustomerAndShippingAddress() {
     result.emailContactMechId = serviceResultCUPEM.contactMechId
     result.partyId = partyId
     if (parameters.emailContactMechId) {
+        shoppingCart.removeContactMechId('ORDER_EMAIL')
         shoppingCart.addContactMechId('ORDER_EMAIL', 
parameters.emailContactMechId)
     }
     shoppingCart.setUserLogin(userLogin, dispatcher)
+    shoppingCart.removeContactMechId('SHIPPING_LOCATION')
     shoppingCart.addContactMechId('SHIPPING_LOCATION', 
parameters.shipToContactMechId)
     shoppingCart.setAllShippingContactMechId(parameters.shipToContactMechId)
     shoppingCart.setOrderPartyId(partyId)
@@ -153,6 +156,7 @@ Map createUpdateBillingAddressAndPaymentMethod() {
     parameters.billToContactMechId = serviceResultCUBA.contactMechId
     result.contactMechId = serviceResultCUBA.contactMechId
     if (parameters.billToContactMechId) {
+        shoppingCart.removeContactMechId('BILLING_LOCATION')
         shoppingCart.addContactMechId('BILLING_LOCATION', 
parameters.billToContactMechId)
     }
     // Create Update Billing Telecom Number
@@ -169,6 +173,7 @@ Map createUpdateBillingAddressAndPaymentMethod() {
     String billToPhoneContactMechId = serviceResultCUPTN.contactMechId
     result.billToPhoneContactMechId = serviceResultCUPTN.contactMechId
     if (billToPhoneContactMechId) {
+        shoppingCart.removeContactMechId('PHONE_BILLING')
         shoppingCart.addContactMechId('PHONE_BILLING', 
billToPhoneContactMechId)
     }
     // Create Update credit card
diff --git 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderDeliveryServices.groovy
 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderDeliveryServices.groovy
index b9c1b0e89e..7dcb9eb087 100644
--- 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderDeliveryServices.groovy
+++ 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderDeliveryServices.groovy
@@ -77,7 +77,10 @@ Map sendOrderDeliveryScheduleNotification() {
     // find email address for currently logged in user, set as sendFrom
     Map curUserPcmFindMap = [partyId: userLogin.partyId, contactMechTypeId: 
'EMAIL_ADDRESS']
     GenericValue curUserPartyAndContactMech = 
from('PartyAndContactMech').where(curUserPcmFindMap).queryFirst()
-    Map sendEmailMap = [sendFrom: curUserPartyAndContactMech.infoString]
+    Map sendEmailMap = [:]
+    if (curUserPartyAndContactMech) {
+        sendEmailMap.sendFrom = curUserPartyAndContactMech.infoString
+    }
 
     // find email addresses of all parties in SHIPMENT_CLERK roleTypeId, set 
as sendTo
     Map shipmentClerkFindMap = [roleTypeId: 'SHIPMENT_CLERK']
@@ -100,8 +103,8 @@ Map sendOrderDeliveryScheduleNotification() {
         }
     }
     // set subject, contentType, templateName, templateData
-    sendEmailMap.subject = 'Delivery Information Updated for Order #' + 
orderDeliverySchedule.orderId
-    if (orderDeliverySchedule.orderItemSeqId != '_NA_') {
+    sendEmailMap.subject = 'Delivery Information Updated for Order #' + 
(orderDeliverySchedule?.orderId ?: '')
+    if (orderDeliverySchedule && orderDeliverySchedule.orderItemSeqId != 
'_NA_') {
         StringBuilder newSubject = new StringBuilder()
         newSubject.append(sendEmailMap.subject)
         newSubject.append(' Item #' + orderDeliverySchedule.orderItemSeqId)
diff --git 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/requirement/RequirementServicesScript.groovy
 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/requirement/RequirementServicesScript.groovy
index 7e11e89519..3155579e07 100644
--- 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/requirement/RequirementServicesScript.groovy
+++ 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/requirement/RequirementServicesScript.groovy
@@ -48,7 +48,7 @@ Map autoAssignRequirementToSupplier() {
     require(requirement as boolean, 'Entity value not found with name: 
requirement Method = autoAssignRequirementToSupplier')
     if (requirement.requirementTypeId == 'PRODUCT_REQUIREMENT'
             && requirement.productId
-            && requirement.quantity) {
+            && requirement.quantity != null) {
         EntityCondition condition = new EntityConditionBuilder().AND {
             EQUALS(productId: requirement.productId)
             LESS_THAN_EQUAL_TO(minimumOrderQuantity: requirement.quantity)

Reply via email to