This is an automated email from the ASF dual-hosted git repository. gsperi pushed a commit to branch release18.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/release18.12 by this push: new 9a6b54af2e Fixed: multiple facility inventory reservation issue (OFBIZ-12264) 9a6b54af2e is described below commit 9a6b54af2e8cd689b82f566327887486030175e0 Author: Giulio Speri <giulio.sp...@mpstyle.it> AuthorDate: Tue Apr 5 23:10:46 2022 +0200 Fixed: multiple facility inventory reservation issue (OFBIZ-12264) The ProductStore is set up to reserve inventory from more than one facility, so the flag oneInventoryFacility is set to N. Flags requireInventory and reserveInventory are both to Y. Flag allocateInventory is N. A product can be anyway reserved in a ProductStoreFacility with its thru date set and past, so is disabled, and if is not present enough inventory quantity on other facilities. Added filtering by date on multiple facility code in reserveStoreInventoryMethod() and on isStoreInventoryAvailable(). This is the first part of the problem resolution; the second part is accomplished by path to OFBIZ-12455 Jira. Thanks: Jacques Le Roux and Pierre SMith for Jira feedbacks, Nicola Mazzoni for helping in bug analaysis and Jacopo Cappellato for path review. --- .../minilang/product/store/ProductStoreServices.xml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/applications/product/minilang/product/store/ProductStoreServices.xml b/applications/product/minilang/product/store/ProductStoreServices.xml index e5baab4aba..2eab4c9cae 100644 --- a/applications/product/minilang/product/store/ProductStoreServices.xml +++ b/applications/product/minilang/product/store/ProductStoreServices.xml @@ -177,7 +177,7 @@ under the License. </else> </if-compare> <else> - <entity-and entity-name="ProductStoreFacility" list="productStoreFacilities" use-cache="true"> + <entity-and entity-name="ProductStoreFacility" list="productStoreFacilities" filter-by-date="true" use-cache="true"> <field-map field-name="productStoreId" from-field="productStore.productStoreId"/> <order-by field-name="sequenceNum"/> </entity-and> @@ -188,24 +188,23 @@ under the License. <!-- Right now the answer is yes, it only succeeds if one facility has sufficient inventory for the order. --> <set from-field="parameters.productId" field="callServiceMap.productId"/> <set from-field="productStoreFacility.facilityId" field="callServiceMap.facilityId"/> - <log level="info" message="ProductStoreService:In productStoreFacilities loop: [${parameters.facilityId}]"/> + <log level="info" message="ProductStoreService:In productStoreFacilities loop: [${productStoreFacility.facilityId}]"/> <call-service service-name="getInventoryAvailableByFacility" in-map-name="callServiceMap"> <result-to-field result-name="availableToPromiseTotal"/> </call-service> <clear-field field="callServiceMap"/> - <if-compare-field field="availableToPromiseTotal" to-field="parameters.quantity" operator="greater-equals" type="BigDecimal"> <set field="storeFound" from-field="productStoreFacility"/> </if-compare-field> <clear-field field="availableToPromiseTotal"/> </if-empty> </iterate> - <!-- didn't find anything? Take the first facility from list --> <if-empty field="storeFound"> <first-from-list list="productStoreFacilities" entry="storeFound"/> + <get-related-one value-field="productStore" relation-name="Facility" to-value-field="defaultStoreFound" /> </if-empty> - <set from-field="storeFound.facilityId" field="facilityId" default-value=""/> + <set from-field="storeFound.facilityId" field="facilityId" default-value="defaultStoreFound.facilityId"/> <set-service-fields service-name="reserveProductInventoryByFacility" map="parameters" to-map="callServiceMap"/> <set from-field="facilityId" field="callServiceMap.facilityId"/> <set from-field="requireInventory" field="callServiceMap.requireInventory"/> @@ -213,11 +212,11 @@ under the License. <call-service service-name="reserveProductInventoryByFacility" in-map-name="callServiceMap"> <result-to-field result-name="quantityNotReserved"/> </call-service> - <log level="info" message="Inventory IS reserved in facility with id [${storeFound.facilityId}] for product id [${parameters.productId}]; desired quantity was ${parameters.quantity}"/> + <log level="warning" message="Inventory IS reserved in facility with id [${facilityId}] for product id [${parameters.productId}]; desired quantity was ${parameters.quantity}"/> </else> </if-compare> <else> - <entity-and entity-name="ProductStoreFacility" list="productStoreFacilities" use-cache="true"> + <entity-and entity-name="ProductStoreFacility" list="productStoreFacilities" filter-by-date="true" use-cache="true"> <field-map field-name="productStoreId" from-field="productStore.productStoreId"/> <field-map field-name="facilityId" from-field="facilityId"/> <order-by field-name="sequenceNum"/> @@ -350,7 +349,7 @@ under the License. </else> </if-compare-field> <else> - <entity-and entity-name="ProductStoreFacility" list="productStoreFacilities" use-cache="true"> + <entity-and entity-name="ProductStoreFacility" list="productStoreFacilities" filter-by-date="true" use-cache="true"> <field-map field-name="productStoreId" from-field="productStore.productStoreId"/> <order-by field-name="sequenceNum"/> </entity-and>