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 564669800a Improved: Validate the InventoryItem and the issued
quantity in the issueInventoryItemToShipment service
564669800a is described below
commit 564669800ac49dac22800632f776e03c79ba19f3
Author: Mridul Pathak <[email protected]>
AuthorDate: Thu Oct 8 13:00:18 2026 +0530
Improved: Validate the InventoryItem and the issued quantity in the
issueInventoryItemToShipment service
- Reject an InventoryItem whose product differs from the product of the
ShipmentItem.
- Compute the quantity already issued to the shipment item from its
ItemIssuance records instead of taking it from the totalIssuedQty parameter,
and remove that parameter from the service and the AddItemsFromInventory form.
- Return a clear error when the InventoryItem or the ShipmentItem does not
exist, or when the ShipmentItem is not associated with a return item.
---
applications/product/config/ProductUiLabels.xml | 12 ++++++++
.../shipment/issuance/IssuanceServices.xml | 35 +++++++++++++++++++++-
.../product/servicedef/services_shipment.xml | 5 ----
.../template/shipment/AddItemsFromInventory.ftl | 1 -
4 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/applications/product/config/ProductUiLabels.xml
b/applications/product/config/ProductUiLabels.xml
index 261bf5ae30..84d2635d03 100644
--- a/applications/product/config/ProductUiLabels.xml
+++ b/applications/product/config/ProductUiLabels.xml
@@ -20202,6 +20202,18 @@
<value xml:lang="zh">没有发放订单明细送货组库存预留到送货
${parameters.shipmentId},因为要发放的数量是空的,订单 ${orderItemShipGrpInvRes.orderId}、订单明细
${orderItemShipGrpInvRes.orderItemSeqId}、库存明细
${orderItemShipGrpInvRes.inventoryItemId}</value>
<value xml:lang="zh-TW">沒有發放訂單細項出貨群組庫存預留到出貨
${parameters.shipmentId},因為要發放的數量是空的,訂單 ${orderItemShipGrpInvRes.orderId}、訂單細項
${orderItemShipGrpInvRes.orderItemSeqId}、庫存細項
${orderItemShipGrpInvRes.inventoryItemId}</value>
</property>
+ <property key="ProductIssueInventoryItemNotFound">
+ <value xml:lang="en">Not issuing inventory item
${parameters.inventoryItemId} to shipment ${parameters.shipmentId} because the
inventory item does not exist</value>
+ </property>
+ <property key="ProductIssueInventoryItemShipmentItemNotFound">
+ <value xml:lang="en">Not issuing inventory item
${parameters.inventoryItemId} to shipment ${parameters.shipmentId} because
shipment item ${parameters.shipmentItemSeqId} does not exist</value>
+ </property>
+ <property key="ProductIssueInventoryItemProductMismatch">
+ <value xml:lang="en">Not issuing inventory item
${parameters.inventoryItemId} to shipment ${parameters.shipmentId} shipment
item ${parameters.shipmentItemSeqId} because the product of the inventory item
${inventoryItem.productId} is not the product of the shipment item
${shipmentItem.productId}</value>
+ </property>
+ <property key="ProductIssueInventoryItemNoReturnItemShipment">
+ <value xml:lang="en">Not issuing inventory item
${parameters.inventoryItemId} to shipment ${parameters.shipmentId} shipment
item ${parameters.shipmentItemSeqId} because the shipment item is not
associated with a return item</value>
+ </property>
<property key="ProductNotIssueOrderToShipmentQuantityLess">
<value xml:lang="de">Führe keine Reservierung durch für Lieferung
[${parameters.shipmentId}] weil die Reservierungsmenge ${parameters.quantity}
kleiner oder gleich 0 ist für Bestellung ${orderItemShipGrpInvRes.orderId}
Auftragsposition ${orderItemShipGrpInvRes.orderItemSeqId} Bestandsposition
${orderItemShipGrpInvRes.inventoryItemId}</value>
<value xml:lang="en">Not issuing Order Item Ship Group Inventory
Reservation to shipment [${parameters.shipmentId}] because the quantity to
issue ${parameters.quantity} is less than or equal to 0 for order
${orderItemShipGrpInvRes.orderId} order item
${orderItemShipGrpInvRes.orderItemSeqId} inventoryItem
${orderItemShipGrpInvRes.inventoryItemId}</value>
diff --git
a/applications/product/minilang/shipment/issuance/IssuanceServices.xml
b/applications/product/minilang/shipment/issuance/IssuanceServices.xml
index 80d4f806cd..8c617ad1df 100644
--- a/applications/product/minilang/shipment/issuance/IssuanceServices.xml
+++ b/applications/product/minilang/shipment/issuance/IssuanceServices.xml
@@ -670,14 +670,47 @@ under the License.
<set field="shipmentId" from-field="parameters.shipmentId"/>
<set field="shipmentItemSeqId"
from-field="parameters.shipmentItemSeqId"/>
<entity-one entity-name="InventoryItem" value-field="inventoryItem"/>
+ <entity-one entity-name="ShipmentItem" value-field="shipmentItem"/>
+ <if-empty field="inventoryItem">
+ <add-error>
+ <fail-property resource="ProductUiLabels"
property="ProductIssueInventoryItemNotFound"/>
+ </add-error>
+ </if-empty>
+ <if-empty field="shipmentItem">
+ <add-error>
+ <fail-property resource="ProductUiLabels"
property="ProductIssueInventoryItemShipmentItemNotFound"/>
+ </add-error>
+ </if-empty>
+ <check-errors/>
+ <!-- the InventoryItem has to be of the same product as the
ShipmentItem -->
+ <if-compare-field field="inventoryItem.productId"
to-field="shipmentItem.productId" operator="not-equals">
+ <add-error>
+ <fail-property resource="ProductUiLabels"
property="ProductIssueInventoryItemProductMismatch"/>
+ </add-error>
+ </if-compare-field>
<entity-and entity-name="ReturnItemShipment"
list="returnItemShipments">
<field-map field-name="shipmentId"
from-field="parameters.shipmentId"/>
<field-map field-name="shipmentItemSeqId"
from-field="parameters.shipmentItemSeqId"/>
</entity-and>
<first-from-list list="returnItemShipments"
entry="returnItemShipment"/>
+ <if-empty field="returnItemShipment">
+ <add-error>
+ <fail-property resource="ProductUiLabels"
property="ProductIssueInventoryItemNoReturnItemShipment"/>
+ </add-error>
+ </if-empty>
+ <check-errors/>
+ <!-- the quantity already issued is computed here, it must not be
trusted from the caller -->
+ <entity-and entity-name="ItemIssuance" list="itemIssuances">
+ <field-map field-name="shipmentId"
from-field="parameters.shipmentId"/>
+ <field-map field-name="shipmentItemSeqId"
from-field="parameters.shipmentItemSeqId"/>
+ </entity-and>
+ <set field="totalIssuedQty" type="BigDecimal" value="0"/>
+ <iterate list="itemIssuances" entry="itemIssuance">
+ <set field="totalIssuedQty" value="${totalIssuedQty$bigDecimal +
itemIssuance.quantity$bigDecimal}" type="BigDecimal"/>
+ </iterate>
<calculate field="quantityNotIssued">
<calcop operator="subtract" field="returnItemShipment.quantity">
- <calcop operator="get" field="parameters.totalIssuedQty"/>
+ <calcop operator="get" field="totalIssuedQty"/>
</calcop>
</calculate>
<!-- make sure specified quantity is not less than or equal to 0 -->
diff --git a/applications/product/servicedef/services_shipment.xml
b/applications/product/servicedef/services_shipment.xml
index e3a2079e54..e82629763f 100644
--- a/applications/product/servicedef/services_shipment.xml
+++ b/applications/product/servicedef/services_shipment.xml
@@ -586,11 +586,6 @@ under the License.
<fail-property resource="ProductErrorUiLabels"
property="ProductRequiredFieldMissingQuantity"/>
</type-validate>
</attribute>
- <attribute name="totalIssuedQty" type="BigDecimal" mode="IN"
optional="false">
- <type-validate>
- <fail-property resource="ProductErrorUiLabels"
property="ProductRequiredFieldMissingTotalIssuedQty"/>
- </type-validate>
- </attribute>
<attribute name="itemIssuanceId" type="String" mode="OUT"
optional="false">
<type-validate>
<fail-property resource="ProductErrorUiLabels"
property="ProductRequiredFieldMissingItemIssuanceId"/>
diff --git a/applications/product/template/shipment/AddItemsFromInventory.ftl
b/applications/product/template/shipment/AddItemsFromInventory.ftl
index 50fc471740..d4daae8a6d 100644
--- a/applications/product/template/shipment/AddItemsFromInventory.ftl
+++ b/applications/product/template/shipment/AddItemsFromInventory.ftl
@@ -56,7 +56,6 @@ under the License.
<form name="issueInventoryItemToShipment_${item_index}"
action="<@ofbizUrl>issueInventoryItemToShipment</@ofbizUrl>" method="post">
<input type="hidden" name="shipmentId"
value="${shipmentId}"/>
<input type="hidden" name="shipmentItemSeqId"
value="${item.shipmentItemSeqId}"/>
- <input type="hidden" name="totalIssuedQty"
value="${item.totalQtyIssued}"/>
<span>
<@htmlTemplate.lookupField
formName="issueInventoryItemToShipment_${item_index}" name="inventoryItemId"
id="inventoryItemId"
fieldFormName="LookupInventoryItem?orderId=${item.orderId}&partyId=${item.partyId}&productId=${item.productId}"/>
</span>