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 c872040159 Fixed: Mini-lang to Groovy regressions in 
ProductStoreServices (OFBIZ-13576)
c872040159 is described below

commit c8720401596d439757401d58153ffb658afbddb6
Author: Mridul Pathak <[email protected]>
AuthorDate: Sun Sep 13 22:02:21 2026 +0530

    Fixed: Mini-lang to Groovy regressions in ProductStoreServices (OFBIZ-13576)
    
    - createProductStore: check parameters.showPricesWithVatTax (matching the
      entity field name) instead of the nonexistent showPriceWithVatTax, so the
      VAT tax authority validation actually runs.
    - reserveStoreInventory: guard the no-facility-has-enough-inventory fallback
      against a null productStore.inventoryFacilityId, which threw an NPE
      whenever the store had no configured default facility; still prefer the
      store's own configured facility per OFBIZ-12264's intent, now falling
      back further to the first configured ProductStoreFacility only when no
      default facility is set.
    - checkProductStoreRelatedPermission: resolve productStoreIdToCheck via the
      dynamic productStoreIdName key instead of a literal, misspelled
      inputParameter.productstoreIdName, restoring the CATALOG_ROLE-based
      override to actually receive a productStoreId.
    - checkProductStoreRelatedPermission: drop the redundant second
      EntityUtil.filterByDate() call, which used field names ("roleFromDate"/
      "roleThruDate") that don't exist on ProductStoreRole and crashed with an
      IllegalArgumentException whenever a role match was found; the preceding
      query already filters by the entity's real fromDate/thruDate fields.
---
 .../product/product/store/ProductStoreServices.groovy    | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/store/ProductStoreServices.groovy
 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/store/ProductStoreServices.groovy
index fdb0595cbc..023abf8c5c 100644
--- 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/store/ProductStoreServices.groovy
+++ 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/store/ProductStoreServices.groovy
@@ -28,7 +28,6 @@ import org.apache.ofbiz.base.util.UtilDateTime
 import org.apache.ofbiz.base.util.UtilProperties
 import org.apache.ofbiz.entity.GenericValue
 import org.apache.ofbiz.entity.util.EntityTypeUtil
-import org.apache.ofbiz.entity.util.EntityUtil
 import org.apache.ofbiz.service.ServiceUtil
 
 /**
@@ -43,7 +42,7 @@ Map createProductStore() {
             && !parameters.inventoryFacilityId) {
         return error(UtilProperties.getMessage('ProductUiLabels', 
'InventoryFacilityIdRequired', parameters.locale))
     }
-    if (parameters.showPriceWithVatTax == 'Y') {
+    if (parameters.showPricesWithVatTax == 'Y') {
         if (!parameters.vatTaxAuthGeoId) {
             return error(UtilProperties.getMessage('ProductUiLabels', 
'ProductVatTaxAuthGeoNotSet', parameters.locale))
         }
@@ -218,12 +217,13 @@ Map reserveStoreInventory() {
                     }
                 }
             }
-            // didn't find anything? Take the first facility from list
+            // didn't find anything? Fall back to the store's configured 
default facility, then the first facility from the list
             GenericValue defaultStoreFound
             if (!storeFound) {
-                defaultStoreFound = productStore.getRelatedOne('Facility', 
true)
+                defaultStoreFound = productStore.inventoryFacilityId ? 
productStore.getRelatedOne('Facility', true) : null
             }
-            facilityId = storeFound ? storeFound.facilityId : 
defaultStoreFound.facilityId
+            GenericValue firstStoreFacility = productStoreFacilities ? 
productStoreFacilities[0] : null
+            facilityId = storeFound?.facilityId ?: 
defaultStoreFound?.facilityId ?: firstStoreFacility?.facilityId
             Map serviceResult = run service: 
'reserveProductInventoryByFacility', with: [*: parameters,
                                                                                
          facilityId: facilityId,
                                                                                
          requireInventory: requireInventory,
@@ -386,16 +386,14 @@ Map checkProductStoreRelatedPermission(Map 
inputParameter) {
     String productStoreIdToCheck = inputParameter.productStoreIdToCheck
     callingMethodName = callingMethodName ?: 
UtilProperties.getMessage('CommonUiLabels', 'CommonPermissionThisOperation', 
locale)
     checkAction = checkAction ?: 'UPDATE'
-    productStoreIdName = productStoreIdName ?: inputParameter.productStoreId
-    productStoreIdToCheck = productStoreIdToCheck ?: 
inputParameter.productstoreIdName
+    productStoreIdName = productStoreIdName ?: 'productStoreId'
+    productStoreIdToCheck = productStoreIdToCheck ?: 
inputParameter[productStoreIdName]
 
     // find all role-store that this productStore is a member of
     if (!security.hasEntityPermission('CATALOG', ('_' + checkAction), 
userLogin)) {
         roleStores = from('ProductStoreRole')
                 .where(productStoreId: productStoreIdToCheck, partyId: 
userLogin.partyId, roleTypeId: 'LTD_ADMIN').filterByDate().queryList()
-        roleStores = EntityUtil.filterByDate(roleStores, 
UtilDateTime.nowTimestamp(), 'roleFromDate', 'roleThruDate', true)
     }
-    logInfo("Checking store permission, roleStores=${roleStores}")
     if (!(security.hasEntityPermission('CATALOG', ('_' + checkAction), 
userLogin) ||
     (security.hasEntityPermission('CATALOG_ROLE', ('_' + checkAction), 
userLogin) && roleStores))) {
         logVerbose('Permission check failed, user does not have permission')

Reply via email to