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 38ca49f0e0 Fixed: convertUom custom parameters and rounding 
regressions (OFBIZ-13530)
38ca49f0e0 is described below

commit 38ca49f0e0d9d2b4ecc1a55d82c26d04a5bdf77c
Author: Mridul Pathak <[email protected]>
AuthorDate: Thu Sep 10 11:38:33 2026 +0530

    Fixed: convertUom custom parameters and rounding regressions (OFBIZ-13530)
    
    - Use makeValidContext on parameters for convertUomCustom instead of 
nonexistent parameters.convertUom
    - Apply final rounding whenever roundingMode is non-empty, matching 
original minilang behavior
---
 .../org/apache/ofbiz/common/CommonServicesScript.groovy    | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git 
a/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
 
b/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
index abde52d4c9..b6a01a95f7 100644
--- 
a/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
+++ 
b/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
@@ -101,7 +101,7 @@ Map convertUom() {
     // Do custom conversion, if we have customMethodId
     if (uomConversion.customMethodId) { //custom conversion?
         logVerbose("using custom conversion 
customMethodId=${uomConversion.customMethodId}")
-        Map customParms = parameters.convertUom
+        Map customParms = dctx.makeValidContext('convertUomCustom', 
ModelService.IN_PARAM, parameters)
         customParms.uomConversion = uomConversion
         Map serviceResult = run service: 'convertUomCustom', with: customParms
         convertedValue = serviceResult.convertedValue
@@ -119,8 +119,16 @@ Map convertUom() {
     // round result, if UomConversion[Dated] so specifies
     decimalScale = uomConversion.decimalScale ?: parameters.defaultDecimalScale
     roundingMode = uomConversion.roundingMode ?: parameters.defaultRoundingMode
-    if (parameters.defaultRoundingMode != roundingMode) {
-        convertedValue = convertedValue.setScale(decimalScale, roundingMode)
+    if (convertedValue && roundingMode) {
+        if (roundingMode instanceof String) {
+            String modeStr = roundingMode.replace('ROUND_', 
'').replaceAll('([a-z])([A-Z])', '$1_$2').toUpperCase()
+            try {
+                roundingMode = RoundingMode.valueOf(modeStr)
+            } catch (IllegalArgumentException e) {
+                roundingMode = RoundingMode.HALF_EVEN
+            }
+        }
+        convertedValue = convertedValue.setScale(decimalScale as int, 
roundingMode)
     }
     // no UomConversion or UomConversionDated found
 

Reply via email to