Author: jonesde
Date: Thu Sep  6 16:26:05 2007
New Revision: 573408

URL: http://svn.apache.org/viewvc?rev=573408&view=rev
Log:
Added error message(s) is ShipmentItems are not completely fulfilled, enforcing 
requirement of one Show Shipment message per Shipment

Modified:
    
ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java

Modified: 
ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java?rev=573408&r1=573407&r2=573408&view=diff
==============================================================================
--- 
ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java 
(original)
+++ 
ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java 
Thu Sep  6 16:26:05 2007
@@ -500,12 +500,35 @@
                 }
                 
                 if (errorMapList.size() == 0) {
-                    // TODOLATER: to support mulitple and partial Show 
Shipment messages per shipment: 
+                    // NOTTODOLATER: to support mulitple and partial Show 
Shipment messages per shipment: 
                     //check here if the entire shipment has been issues, ie 
there should be sufficient 
                     //ItemIssuance quantities for the ShipmentItem quantities
                     // NOTE ON THIS DEJ20070906: this is actually really bad 
because it implies the shipment 
                     //has been split and that isn't really allowed; maybe 
better to return an error!
-                    // TODO: if shipment is not completely fulfilled here 
return an error
+                    
+                    List shipmentItemList = 
delegator.findByAnd("ShipmentItem", UtilMisc.toMap("shipmentId", shipmentId));
+                    Iterator shipmentItemIter = shipmentItemList.iterator();
+                    while (shipmentItemIter.hasNext()) {
+                        GenericValue shipmentItem = (GenericValue) 
shipmentItemIter.next();
+                        int shipmentItemQuantity = 
shipmentItem.getDouble("quantity").intValue();
+                        
+                        int totalItemIssuanceQuantity = 0;
+                        List itemIssuanceList = 
delegator.findByAnd("ItemIssuance", UtilMisc.toMap("shipmentId", shipmentId, 
"shipmentItemSeqId", shipmentItem.get("shipmentItemSeqId")));
+                        Iterator itemIssuanceIter = 
itemIssuanceList.iterator();
+                        while (itemIssuanceIter.hasNext()) {
+                            GenericValue itemIssuance = (GenericValue) 
itemIssuanceIter.next();
+                            totalItemIssuanceQuantity += 
itemIssuance.getDouble("quantity").intValue();
+                        }
+                        
+                        if (shipmentItemQuantity > totalItemIssuanceQuantity) {
+                            String errMsg = "ShipmentItem [" + shipmentId + 
":" + shipmentItem.get("shipmentItemSeqId") + "] was not completely fulfilled; 
shipment item quantity was [" + shipmentItemQuantity + "], but total fulfilled 
is only [" + totalItemIssuanceQuantity + "]";
+                            errorMapList.add(UtilMisc.toMap("description", 
errMsg, "reasonCode", "ShipmentItemNotCompletelyFulfilled"));
+                            Debug.logError(errMsg, module);
+                        }
+                    }
+                }
+
+                if (errorMapList.size() == 0) {
                     Map resultMap = 
dispatcher.runSync("setShipmentStatusPackedAndShipped", 
UtilMisc.toMap("shipmentId", shipmentId, "userLogin", userLogin));              
 
                     if (ServiceUtil.isError(resultMap)) {
                         String errMsg = ServiceUtil.getErrorMessage(resultMap);


Reply via email to