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

gsperi 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 08cd4d01be Fixed: inv. reservation places order if not enough qty 
(OFBIZ-12455)
08cd4d01be is described below

commit 08cd4d01be13217441b1d6df4b735808510c3a50
Author: Giulio Speri <giulio.sp...@mpstyle.it>
AuthorDate: Thu Apr 7 23:24:01 2022 +0200

    Fixed: inv. reservation places order if not enough qty (OFBIZ-12455)
    
    If quantity not reserved is not 0, requireInventory is set to Y, system
    let an order to be placed anyway.
    
    The usage of the service around the project let make an important
    assertion: we can consider that also reserveInventory flag of the
    ProductStore is Y, since right now is always the caller context that
    checks for the reserveInventory flag.
    
    This fix simply returns a specific error to the caller, avoiding the
    system to place the order.
    
    Thanks Nicola Mazzoni for helping in debug this issue and Jacopo
    Cappellato for the patch review.
---
 applications/product/config/ProductUiLabels.xml                  | 4 ++++
 .../minilang/product/inventory/InventoryReserveServices.xml      | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/applications/product/config/ProductUiLabels.xml 
b/applications/product/config/ProductUiLabels.xml
index b296d7a13e..bd720e8f0e 100644
--- a/applications/product/config/ProductUiLabels.xml
+++ b/applications/product/config/ProductUiLabels.xml
@@ -20866,6 +20866,10 @@
         <value xml:lang="zh">这个明细缺货</value>
         <value xml:lang="zh-TW">這個細項缺貨</value>
     </property>
+    <property key="ProductCannotReserveInventoryNotEnoughStock">
+       <value xml:lang="it">Impossibile riservare l'articolo 
${parameters.productId}: quantità in stock non sufficiente nel deposito 
${parameters.facilityId}. Quantità  non riservata è 
${parameters.quantityNotReserved}</value>
+        <value xml:lang="en">Cannot reserve product ${parameters.productId}: 
not enough quantity left in stock for facility ${parameters.facilityId}. 
Quantity not reserved is ${parameters.quantityNotReserved}</value>
+     </property>
     <property key="ProductItemPrc">
         <value xml:lang="de">Position Preis</value>
         <value xml:lang="en">Item Prc</value>
diff --git 
a/applications/product/minilang/product/inventory/InventoryReserveServices.xml 
b/applications/product/minilang/product/inventory/InventoryReserveServices.xml
index fb4f603715..5146bec889 100644
--- 
a/applications/product/minilang/product/inventory/InventoryReserveServices.xml
+++ 
b/applications/product/minilang/product/inventory/InventoryReserveServices.xml
@@ -163,7 +163,14 @@ under the License.
                 -->
                 <if-compare field="parameters.quantityNotReserved" 
operator="not-equals" value="0" type="BigDecimal">
                     <if-compare field="parameters.requireInventory" 
operator="equals" value="Y">
-                        <!-- use this else pattern to accomplish the anything 
but Y logic, ie if not specified default to inventory NOT required -->
+                        <!-- if there is still quantity not reserved but 
ProductStore is configured to require inventory, we can 
+                            assume here that also reserveInventory is set to Y 
(reserveInventory is checked by caller services).
+                           In such a scenario we return an error and avoid 
order creation. 
+                       -->
+                        <add-error>
+                            <fail-property resource="ProductUiLabels" 
property="ProductCannotReserveInventoryNotEnoughStock"/>
+                        </add-error>
+                        <check-errors/>
                     <else>
                         <if-not-empty field="lastNonSerInventoryItem">
                             <!-- subtract from quantityNotReserved from the 
availableToPromise of existing inventory item -->

Reply via email to