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

golja 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 32e158c0b5 Improved: Prevent RFQ creation from an empty shopping list. 
(OFBIZ-11224) (#2253)
32e158c0b5 is described below

commit 32e158c0b5d31f1409b23012776d1449cc01c967
Author: Rehan Khan <[email protected]>
AuthorDate: Sat Oct 24 02:54:13 2026 +0530

    Improved: Prevent RFQ creation from an empty shopping list. (OFBIZ-11224) 
(#2253)
    
    Creating a “Request For Quote” from an empty e-commerce shopping list
    created an empty CustRequest record.
    The createCustRequestFromCart service created the request header before
    retrieving or validating the cart items. When the shopping list
    contained no items, the item-creation loop simply did nothing, leaving
    an invalid RFQ header in the database.
    
    Retrieve and validate the cart items before creating the CustRequest
    header.
    Return OFBiz’s existing localised message when the cart is empty: There
    are no items in the cart.
    
    Thanks: Arpit Mor for reporting the issue.
---
 .../order/minilang/request/CustRequestServices.xml | 23 +++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/applications/order/minilang/request/CustRequestServices.xml 
b/applications/order/minilang/request/CustRequestServices.xml
index d2a88be53e..8f8bf0e2e5 100644
--- a/applications/order/minilang/request/CustRequestServices.xml
+++ b/applications/order/minilang/request/CustRequestServices.xml
@@ -266,6 +266,28 @@ under the License.
     </simple-method>
 
     <simple-method method-name="createCustRequestFromCart" 
short-description="Create a CustRequest from a ShoppingCart">
+        <call-object-method obj-field="parameters.cart" method-name="items" 
ret-field="items"/>
+        <!-- Validate requestable items before creating the CustRequest 
header. -->
+        <set value="false" field="hasRequestableItems"/>
+        <iterate list="items" entry="item">
+            <call-object-method obj-field="item" method-name="getIsPromo" 
ret-field="isPromo"/>
+            <if-compare field="isPromo" value="false" operator="equals" 
type="Boolean">
+                <call-object-method obj-field="item" 
method-name="getProductId" ret-field="itemProductId"/>
+                <call-object-method obj-field="item" method-name="getQuantity" 
ret-field="itemQuantity"/>
+                <if-compare field="itemQuantity" value="0" operator="greater" 
type="BigDecimal">
+                    <if-not-empty field="itemProductId">
+                        <set value="true" field="hasRequestableItems"/>
+                    </if-not-empty>
+                </if-compare>
+            </if-compare>
+        </iterate>
+        <if-compare field="hasRequestableItems" value="false" 
operator="equals" type="Boolean">
+            <add-error>
+                <fail-property resource="OrderErrorUiLabels" 
property="checkhelper.no_items_in_cart"/>
+            </add-error>
+        </if-compare>
+        <check-errors/>
+
         <call-object-method obj-field="parameters.cart" 
method-name="getPartyId" ret-field="createCustRequestInMap.fromPartyId"/>
         <set value="RF_QUOTE" 
field="createCustRequestInMap.custRequestTypeId"/>
         <set value="CRQ_SUBMITTED" field="createCustRequestInMap.statusId"/>
@@ -284,7 +306,6 @@ under the License.
         <entity-one entity-name="CustRequest" value-field="custRequest" 
auto-field-map="true"/>
 
         <!-- create, for every cart item, a request item -->
-        <call-object-method obj-field="parameters.cart" method-name="items" 
ret-field="items"/>
         <iterate list="items" entry="item">
             <!-- a new request item is created -->
             <clear-field field="createCustRequestItemInMap"/>

Reply via email to