Author: jonesde
Date: Wed Aug 22 20:59:15 2007
New Revision: 568816
URL: http://svn.apache.org/viewvc?rev=568816&view=rev
Log:
A number of improvements to receiveInventoryProduct to handle receipt of
serialized inventory better, in general and in the case where an item that was
sold is returned and put back into inventory, either on hold or ready to go
again; also a few little cleanups done while reviewing
Modified:
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
ofbiz/trunk/applications/product/servicedef/services_shipment.xml
Modified:
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml?rev=568816&r1=568815&r2=568816&view=diff
==============================================================================
---
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
(original)
+++
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
Wed Aug 22 20:59:15 2007
@@ -287,8 +287,8 @@
<and>
<if-compare field-name="inventoryItem.statusId"
value="INV_AVAILABLE" operator="equals"/>
<or>
- <if-compare
field-name="inventoryItem.availableToPromiseTotal" value="1"
operator="not-equals" type="Double"/>
- <if-compare
field-name="inventoryItem.quantityOnHandTotal" value="1" operator="not-equals"
type="Double"/>
+ <if-compare
field-name="inventoryItem.availableToPromiseTotal" operator="not-equals"
value="1" type="Double"/>
+ <if-compare
field-name="inventoryItem.quantityOnHandTotal" operator="not-equals" value="1"
type="Double"/>
</or>
</and>
</condition>
@@ -305,8 +305,8 @@
<and>
<if-compare field-name="inventoryItem.statusId"
value="INV_DELIVERED" operator="equals"/>
<or>
- <if-compare
field-name="inventoryItem.availableToPromiseTotal" value="0"
operator="not-equals" type="Double"/>
- <if-compare
field-name="inventoryItem.quantityOnHandTotal" value="0" operator="not-equals"
type="Double"/>
+ <if-compare
field-name="inventoryItem.availableToPromiseTotal" operator="not-equals"
value="0" type="Double"/>
+ <if-compare
field-name="inventoryItem.quantityOnHandTotal" operator="not-equals" value="0"
type="Double"/>
</or>
</and>
</condition>
@@ -322,11 +322,11 @@
<else-if>
<condition>
<and>
- <if-compare field-name="inventoryItem.statusId"
value="INV_AVAILABLE" operator="not-equals"/>
- <if-compare field-name="inventoryItem.statusId"
value="INV_DELIVERED" operator="not-equals"/>
+ <if-compare field-name="inventoryItem.statusId"
operator="not-equals" value="INV_AVAILABLE"/>
+ <if-compare field-name="inventoryItem.statusId"
operator="not-equals" value="INV_DELIVERED"/>
<or>
- <if-compare
field-name="inventoryItem.availableToPromiseTotal" value="0"
operator="not-equals" type="Double"/>
- <if-compare
field-name="inventoryItem.quantityOnHandTotal" value="1" operator="not-equals"
type="Double"/>
+ <if-compare
field-name="inventoryItem.availableToPromiseTotal" operator="not-equals"
value="0" type="Double"/>
+ <if-compare
field-name="inventoryItem.quantityOnHandTotal" operator="not-equals" value="1"
type="Double"/>
</or>
</and>
</condition>
Modified:
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml?rev=568816&r1=568815&r2=568816&view=diff
==============================================================================
---
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
(original)
+++
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
Wed Aug 22 20:59:15 2007
@@ -74,48 +74,99 @@
<simple-method method-name="receiveInventoryProduct"
short-description="Receive Inventory in new Inventory Item(s)">
<check-permission permission="FACILITY" action="_CREATE"><fail-message
message="Security Error: to run receiveInventoryProduct you must have the
FACILITY_CREATE or FACILITY_ADMIN permission"/></check-permission>
<check-errors/>
+
+ <!-- NOTES
+ - for serialized items with a serial number passed in: the
quantityAccepted _should_ always be 1
+ - if the type is SERIALIZED_INV_ITEM but there is not serial
number (which is weird...) we'll create a bunch of individual InventoryItems
+ - DEJ20070822: something to consider for the future: maybe instead
of this funny looping maybe for serialized items we should only allow a
quantity of 1, ie return an error if it is not 1
+ -->
<set field="loops" value="1" type="Double"/>
<if-compare value="SERIALIZED_INV_ITEM" operator="equals"
field-name="parameters.inventoryItemTypeId">
+ <!-- if we are serialized and either a serialNumber or
inventoyItemId is passed in and the quantityAccepted is greater than 1 then
complain -->
+ <if>
+ <condition>
+ <and>
+ <or>
+ <not><if-empty
field-name="parameters.serialNumber"/></not>
+ <not><if-empty
field-name="parameters.inventoryItemId"/></not>
+ </or>
+ <if-compare field-name="parameters.quantityAccepted"
operator="greater" value="1" type="Double"/>
+ </and>
+ </condition>
+ <then>
+ <add-error><fail-message message="Tried to receive a
serialized inventory item with serialNumber [${parameters.serialNumber}] or
inventoryItemId [${parameters.inventoryItemId}] passed in and quantityAccepted
[${parameters.quantityAccepted}] was greater than 1; we don't know what to do
with that!"/></add-error>
+ </then>
+ </if>
+
<set field="loops" from-field="parameters.quantityAccepted"/>
<set field="parameters.quantityAccepted" value="1" type="Double"/>
</if-compare>
+
<set field="parameters.quantityOnHandDiff"
from-field="parameters.quantityAccepted"/>
<set field="parameters.availableToPromiseDiff"
from-field="parameters.quantityAccepted"/>
-
- <loop count="${loops}" field="currentLoop">
- <log level="info" message="Looping and creating inventory info -
${currentLoop}"/>
- <clear-field field-name="serviceInMap"/>
- <set-service-fields service-name="createInventoryItem"
map-name="parameters" to-map-name="serviceInMap"/>
- <call-service service-name="createInventoryItem"
in-map-name="serviceInMap">
- <result-to-field result-name="inventoryItemId"
field-name="parameters.inventoryItemId"/>
- </call-service>
+ <!-- before getting going, see if there are any validation issues so
far -->
+ <check-errors/>
+
+ <loop count="${loops}" field="currentLoop">
+ <log level="info" message="receiveInventoryProduct Looping and
creating inventory info - ${currentLoop}"/>
+ <!-- if there is an inventoryItemId, update it (this will happen
when receiving serialized inventory already in the system, like for returns);
if not create one -->
<clear-field field-name="serviceInMap"/>
- <set-service-fields service-name="createInventoryItemDetail"
map-name="parameters" to-map-name="serviceInMap"/>
- <call-service service-name="createInventoryItemDetail"
in-map-name="serviceInMap">
- <result-to-field result-name="inventoryItemDetailSeqId"
field-name="parameters.inventoryItemDetailSeqId"/>
- </call-service>
+ <if-empty field-name="parameters.inventoryItemId">
+ <set-service-fields service-name="createInventoryItem"
map-name="parameters" to-map-name="serviceInMap"/>
+ <call-service service-name="createInventoryItem"
in-map-name="serviceInMap">
+ <result-to-field result-name="inventoryItemId"
field-name="parameters.inventoryItemId"/>
+ </call-service>
+
+ <else>
+ <set-service-fields service-name="updateInventoryItem"
map-name="parameters" to-map-name="serviceInMap"/>
+ <call-service service-name="updateInventoryItem"
in-map-name="serviceInMap"/>
+ </else>
+ </if-empty>
+
+ <!-- do this only for non-serialized inventory -->
+ <if-compare value="SERIALIZED_INV_ITEM" operator="not-equals"
field-name="parameters.inventoryItemTypeId">
+ <clear-field field-name="serviceInMap"/>
+ <set-service-fields service-name="createInventoryItemDetail"
map-name="parameters" to-map-name="serviceInMap"/>
+ <call-service service-name="createInventoryItemDetail"
in-map-name="serviceInMap">
+ <result-to-field result-name="inventoryItemDetailSeqId"
field-name="parameters.inventoryItemDetailSeqId"/>
+ </call-service>
+ </if-compare>
<clear-field field-name="serviceInMap"/>
<set-service-fields service-name="createShipmentReceipt"
map-name="parameters" to-map-name="serviceInMap"/>
<call-service service-name="createShipmentReceipt"
in-map-name="serviceInMap"/>
<!-- update serialized items to AVAILABLE (only if this is not a
return), which then triggers other SECA chains -->
- <if-compare value="SERIALIZED_INV_ITEM" operator="equals"
field-name="parameters.inventoryItemTypeId">
- <if-compare value="INV_RETURNED" operator="not-equals"
field-name="parameters.statusId">
+ <if>
+ <condition>
+ <and>
+ <if-compare value="SERIALIZED_INV_ITEM"
operator="equals" field-name="parameters.inventoryItemTypeId"/>
+ <if-empty field-name="parameters.returnId"/>
+ </and>
+ </condition>
+ <then>
<!-- Retrieve the new inventoryItem -->
<entity-one entity-name="InventoryItem"
value-name="inventoryItem"/>
-
- <!-- Don't reset the status if it's already set to
INV_PROMISED downstream -->
- <if-compare value="INV_PROMISED" operator="not-equals"
field-name="inventoryItem.statusId">
- <clear-field field-name="serviceInMap"/>
- <set field="serviceInMap.inventoryItemId"
from-field="parameters.inventoryItemId"/>
- <set field="serviceInMap.statusId"
value="INV_AVAILABLE"/> <!-- XXX set to returned instead -->
- <call-service service-name="updateInventoryItem"
in-map-name="serviceInMap"/>
- </if-compare>
- </if-compare>
- </if-compare>
+
+ <!-- Don't reset the status if it's already set to
INV_PROMISED or INV_ON_HOLD -->
+ <if>
+ <condition>
+ <and>
+ <if-compare value="INV_PROMISED"
operator="not-equals" field-name="inventoryItem.statusId"/>
+ <if-compare value="INV_ON_HOLD"
operator="not-equals" field-name="inventoryItem.statusId"/>
+ </and>
+ </condition>
+ <then>
+ <clear-field field-name="serviceInMap"/>
+ <set field="serviceInMap.inventoryItemId"
from-field="parameters.inventoryItemId"/>
+ <set field="serviceInMap.statusId"
value="INV_AVAILABLE"/> <!-- XXX set to returned instead -->
+ <call-service service-name="updateInventoryItem"
in-map-name="serviceInMap"/>
+ </then>
+ </if>
+ </then>
+ </if>
<clear-field field-name="serviceInMap"/>
<set-service-fields service-name="balanceInventoryItems"
map-name="parameters" to-map-name="serviceInMap"/>
Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=568816&r1=568815&r2=568816&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Wed Aug
22 20:59:15 2007
@@ -534,7 +534,7 @@
<attribute name="inventoryItemDetailSeqId" type="String" mode="IN"
optional="true"/>
<attribute name="priorityOrderId" type="String" mode="IN"
optional="true"/>
<attribute name="priorityOrderItemSeqId" type="String" mode="IN"
optional="true"/>
- <attribute name="inventoryItemId" type="String" mode="OUT"
optional="true"/>
+ <attribute name="inventoryItemId" type="String" mode="INOUT"
optional="true"><!-- allow this to be passed in to update an existing
InventoryItem, and all else is the same; if not passed in a new one will be
created --></attribute>
<override name="quantityAccepted" optional="false"/>
<override name="quantityRejected" optional="false"/>
<override name="inventoryItemTypeId" optional="false"/>