Author: sichen
Date: Wed Mar 14 13:53:14 2007
New Revision: 518321
URL:
http://svn.apache.org/viewvc?view=rev&rev=518321Log:
Set purchase shipment status to PURCH_SHIP_SHIPPED in the updatePurchaseShipmentFromReceipt service, so that the shipment can be marked received if necessary, since the existence of a shipment receipt logically indicates that the shipment was shipped.
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java?view=diff&rev=518321&r1=518320&r2=518321==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Wed Mar 14 13:53:14 2007
@@ -796,10 +796,19 @@
String shipmentId = (String) context.get("shipmentId");
GenericValue userLogin = (GenericValue) context.get("userLogin");
try {
- List shipmentAndItems = delegator.findByAnd("ShipmentAndItem", UtilMisc.toMap("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED"));
- if (shipmentAndItems.size() == 0) return ServiceUtil.returnSuccess();
+
List shipmentReceipts = delegator.findByAnd("ShipmentReceipt", UtilMisc.toMap("shipmentId", shipmentId));
if (shipmentReceipts.size() == 0) return ServiceUtil.returnSuccess();
+
+ // If there are shipment receipts, the shipment must have been shipped, so set the shipment status to PURCH_SHIP_SHIPPED if it's only PURCH_SHIP_CREATED
+ GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
+ if ((! UtilValidate.isEmpty(shipment)) && "PURCH_SHIP_CREATED".equals(shipment.getString("statusId"))) {
+ Map updateShipmentMap = dispatcher.runSync("updateShipment", UtilMisc.toMap("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED", "userLogin", userLogin));
+ if (ServiceUtil.isError(updateShipmentMap)) return updateShipmentMap;
+ }
+
+ List shipmentAndItems = delegator.findByAnd("ShipmentAndItem", UtilMisc.toMap("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED"));
+ if (shipmentAndItems.size() == 0) return ServiceUtil.returnSuccess();
// store the quanitity of each product shipped in a hashmap keyed to productId
Map shippedCountMap = new HashMap();