[OFBiz] SVN: r7894 - in trunk/applications/product: script/org/ofbiz/shipment/shipment servicedef

jacopo@svn.ofbiz.org jacopo at svn.ofbiz.org
Wed Jun 28 12:30:47 CDT 2006


Author: jacopo
Date: 2006-06-28 12:30:16 -0500 (Wed, 28 Jun 2006)
New Revision: 7894

Modified:
   trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
   trunk/applications/product/servicedef/secas_shipment.xml
   trunk/applications/product/servicedef/services_shipment.xml
Log:
When a purchase shipment is marked as 'received' a purchase order invoice is created for the received items and the shipment is virtually closed.
However if the items actually received (ShipmentReceipts) are only a part of the order items assigned to the shipment (ItemIssuances), it was no more possible to create a new shipment and assign them to it (because they were already assigned to the first shipment).
This patch will solve this issue: every time a purchase shipment is marked as 'received' all its ItemIssuances are balanced to equal the total quantities actually received.
In this way, the items assigned to the shipment but not received are released and can be assigned to another shipment.
I've implemented it with a new (minilang) service ("balanceItemIssuancesForShipment") that is triggered by a seca by the prurchase shipment's status change.



Modified: trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
===================================================================
--- trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml	2006-06-28 14:26:47 UTC (rev 7893)
+++ trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml	2006-06-28 17:30:16 UTC (rev 7894)
@@ -645,6 +645,35 @@
         </if>
     </simple-method>
 
+    <simple-method method-name="balanceItemIssuancesForShipment" short-description="Release the purchase order's items assigned to the shipment but not actually received">
+        <check-permission permission="FACILITY" action="_CREATE">
+            <alt-permission permission="FACILITY" action="_UPDATE"/>
+            <fail-message message="Security Error: to run balanceItemIssuancesForShipment you must have the FACILITY_CREATE, FACILITY_UPDATE or FACILITY_ADMIN permission"/>
+        </check-permission>
+        <check-errors/>
+
+        <entity-one entity-name="Shipment" value-name="shipment"/>
+        <get-related value-name="shipment" relation-name="ItemIssuance" list-name="issuances"/>
+        <iterate list-name="issuances" entry-name="issuance">
+            <entity-and entity-name="ShipmentReceipt" list-name="receipts">
+                <field-map field-name="shipmentId" env-name="shipment.shipmentId"/>
+                <field-map field-name="orderId" env-name="issuance.orderId"/>
+                <field-map field-name="orderItemSeqId" env-name="issuance.orderItemSeqId"/>
+            </entity-and>
+            <iterate list-name="receipts" entry-name="receipt">
+                <calculate field-name="issuanceQuantity" type="Double">
+                    <calcop field-name="receipt.quantityAccepted" operator="add">
+                        <calcop field-name="receipt.quantityRejected" operator="get"/>
+                        <calcop field-name="issuanceQuantity" operator="get"/>
+                    </calcop>
+                </calculate>
+            </iterate>
+            <set field="issuance.quantity" from-field="issuanceQuantity"/>
+            <store-value value-name="issuance"/>
+            <clear-field field-name="issuanceQuantity"/>
+        </iterate>
+    </simple-method>
+
     <!-- ShipmentItem services -->
     <simple-method method-name="createShipmentItem" short-description="Create ShipmentItem">
         <check-permission permission="FACILITY" action="_CREATE">

Modified: trunk/applications/product/servicedef/secas_shipment.xml
===================================================================
--- trunk/applications/product/servicedef/secas_shipment.xml	2006-06-28 14:26:47 UTC (rev 7893)
+++ trunk/applications/product/servicedef/secas_shipment.xml	2006-06-28 17:30:16 UTC (rev 7894)
@@ -33,6 +33,7 @@
         <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
         <condition field-name="statusId" operator="equals" value="PURCH_SHIP_RECEIVED"/>
         <condition field-name="shipmentTypeId" operator="equals" value="PURCHASE_SHIPMENT"/>
+        <action service="balanceItemIssuancesForShipment" mode="sync"/>
         <action service="createInvoicesFromShipment" mode="sync"/>
     </eca>
 

Modified: trunk/applications/product/servicedef/services_shipment.xml
===================================================================
--- trunk/applications/product/servicedef/services_shipment.xml	2006-06-28 14:26:47 UTC (rev 7893)
+++ trunk/applications/product/servicedef/services_shipment.xml	2006-06-28 17:30:16 UTC (rev 7894)
@@ -158,6 +158,15 @@
         <description>Send Shipment Scheduled Notification</description>
         <attribute name="shipmentId" type="String" mode="IN" optional="false"/>
     </service>
+    <service name="balanceItemIssuancesForShipment" engine="simple"
+            location="org/ofbiz/shipment/shipment/ShipmentServices.xml" invoke="balanceItemIssuancesForShipment" auth="true">
+        <description>
+            Release the purchase order's items assigned to the shipment but not 
+            actually received; it is invoked as a seca when the purchase shipment
+            is marked as 'received'
+        </description>
+        <attribute name="shipmentId" type="String" mode="IN" optional="false"/>
+    </service>
 
     <!-- ShipmentItem Services -->
     <service name="createShipmentItem" default-entity-name="ShipmentItem" engine="simple"



More information about the Svn mailing list