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 528199b34c Fixed: Regressions in QuoteServicesScript.groovy introduced 
by the mini-lang conversion (OFBIZ-13660)
528199b34c is described below

commit 528199b34c520f1f431dd7fc024ac4386feb9e77
Author: Mridul Pathak <[email protected]>
AuthorDate: Thu Oct 8 18:14:12 2026 +0530

    Fixed: Regressions in QuoteServicesScript.groovy introduced by the 
mini-lang conversion (OFBIZ-13660)
    
    The Groovy conversion of QuoteServices.xml changed the behaviour of several 
services. Restore the mini-lang behaviour:
    
    - copyQuote: copy each quote item with the copyQuoteItem service so that 
the item level adjustments are copied too
    - createQuoteAndQuoteItemForRequest: build the quote from the request 
fields the mini-lang used instead of spreading the whole CustRequest, which 
leaked its CRQ_ status into the quote, let the submitted quote item fields take 
precedence over the request item, and skip a quote role that createQuote 
already created
    - createQuoteItem and autoUpdateQuotePrice: treat a price of zero as a 
value instead of as missing
---
 .../ofbiz/order/quote/QuoteServicesScript.groovy   | 34 ++++++++++++++--------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/quote/QuoteServicesScript.groovy
 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/quote/QuoteServicesScript.groovy
index 10a86cef60..5c05d30f6f 100644
--- 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/quote/QuoteServicesScript.groovy
+++ 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/quote/QuoteServicesScript.groovy
@@ -208,9 +208,10 @@ Map copyQuote() {
     if (parameters.copyQuoteItems == 'Y') {
         List quoteItems = quote.getRelated('QuoteItem', null, null, false)
         for (GenericValue quoteItem : quoteItems) {
-            Map serviceContext = dctx.makeValidContext('createQuoteItem', 
ModelService.IN_PARAM,
-                    [*: quoteItem, quoteId: quoteIdTo, userLogin: userLogin])
-            serviceResult = dispatcher.runSync('createQuoteItem', 
serviceContext)
+            Map serviceContext = dctx.makeValidContext('copyQuoteItem', 
ModelService.IN_PARAM,
+                    [quoteId: quoteItem.quoteId, quoteItemSeqId: 
quoteItem.quoteItemSeqId, quoteIdTo: quoteIdTo,
+                     copyQuoteAdjustments: parameters.copyQuoteAdjustments, 
userLogin: userLogin])
+            serviceResult = dispatcher.runSync('copyQuoteItem', serviceContext)
             if (ServiceUtil.isError(serviceResult)) {
                 return serviceResult
             }
@@ -328,7 +329,7 @@ Map createQuoteItem() {
         delegator.setNextSubSeqId(quoteItem, 'quoteItemSeqId', 5, 1)
     }
 
-    if (!parameters.quoteUnitPrice && parameters.productId) {
+    if (parameters.quoteUnitPrice == null && parameters.productId) {
         GenericValue product = from('Product').where('productId', 
parameters.productId).cache().queryOne()
         require(product?.isVirtual != 'Y', 'OrderErrorUiLabels', 
'OrderCannotAddVirtualProductToQuote')
         if (product?.productTypeId?.startsWith('AGGREGATED')
@@ -432,27 +433,36 @@ Map createQuoteAndQuoteItemForRequest() {
     Map input = [
         userLogin: userLogin,
         *: parameters,
-        *: custRequest,
         quoteTypeId: 'PROPOSAL',
         partyId: custRequest.fromPartyId,
         quoteName: custRequest.custRequestName,
-        currencyUomId: custRequest.maximumAmountUomId
+        description: custRequest.description,
+        currencyUomId: custRequest.maximumAmountUomId,
+        productStoreId: custRequest.productStoreId,
+        salesChannelEnumId: custRequest.salesChannelEnumId
     ]
     input.statusId = input.statusId ?: 'QUO_CREATED'
     Map serviceResult = run service: 'createQuote', with: input
     String quoteId = serviceResult.quoteId
 
+    // the quote item fields submitted by the caller take precedence over the 
ones of the request item
     serviceResult = run service: 'createQuoteItem', with: [
-        *: custRequestItem,
-        comments: custRequestItem.story,
+        *: (custRequestItem ?: [:]),
+        *: parameters.findAll { key, value -> value != null },
+        comments: custRequestItem?.story ?: parameters.comments,
         quoteId: quoteId
     ]
     String quoteItemSeqId = serviceResult.quoteItemSeqId
 
-    // copy the roles from the request to the quote
+    // copy the roles from the request to the quote, createQuote may already 
have added the request taker
     List custRequestParties = from('CustRequestParty').where(custRequestId: 
custRequest.custRequestId).queryList()
     custRequestParties?.each { GenericValue custPartyRole ->
-        serviceResult = run service: 'createQuoteRole', with: [*: 
custPartyRole, quoteId: quoteId]
+        GenericValue existingQuoteRole = from('QuoteRole')
+                .where(quoteId: quoteId, partyId: custPartyRole.partyId, 
roleTypeId: custPartyRole.roleTypeId)
+                .queryOne()
+        if (!existingQuoteRole) {
+            serviceResult = run service: 'createQuoteRole', with: [*: 
custPartyRole, quoteId: quoteId]
+        }
     }
 
     return [successMessage: null, quoteId: quoteId, quoteItemSeqId: 
quoteItemSeqId]
@@ -545,9 +555,9 @@ Map autoUpdateQuotePrice() {
     require(security.hasEntityPermission('ORDERMGR', '_UPDATE', userLogin) as 
boolean,
             'OrderErrorUiLabels', 
'OrderSecurityErrorToRunAutoUpdateQuotePrice')
     Map fieldsToSet = [:]
-    if (parameters.manualQuoteUnitPrice) {
+    if (parameters.manualQuoteUnitPrice != null) {
         fieldsToSet.quoteUnitPrice = parameters.manualQuoteUnitPrice
-    } else if (parameters.defaultQuoteUnitPrice) {
+    } else if (parameters.defaultQuoteUnitPrice != null) {
         fieldsToSet.quoteUnitPrice = parameters.defaultQuoteUnitPrice
     }
     try {

Reply via email to