svn commit: r568175 - in /ofbiz/trunk/applications: order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java product/src/org/ofbiz/shipment/shipment/ShipmentServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r568175 - in /ofbiz/trunk/applications: order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java product/src/org/ofbiz/shipment/shipment/ShipmentServices.java

apatel-2
Author: apatel
Date: Tue Aug 21 08:56:07 2007
New Revision: 568175

URL: http://svn.apache.org/viewvc?rev=568175&view=rev
Log:
Compute and return shipping estimate even if there is not shippingContactMechId. Left some commented code with comments to help others review the modifications.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java
    ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java?rev=568175&r1=568174&r2=568175&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java Tue Aug 21 08:56:07 2007
@@ -134,10 +134,12 @@
             carrierRoleTypeId = "CARRIER";
         }
 
-        if (shippingContactMechId == null) {
-            errorMessageList.add("Please Select Your Shipping Address.");
-            return ServiceUtil.returnError(errorMessageList);
-        }
+//  ShipmentCostEstimate entity allows null value for geoIdTo field. So if geoIdTo is null we should be using orderFlatPrice for shipping cost.
+//  So now calcShipmentCostEstimate service requires shippingContactMechId only if geoIdTo field has not null value.        
+//        if (shippingContactMechId == null) {
+//            errorMessageList.add("Please Select Your Shipping Address.");
+//            return ServiceUtil.returnError(errorMessageList);
+//        }
 
         // no shippable items; we won't change any shipping at all
         if (shippableQuantity == 0) {
@@ -213,6 +215,8 @@
         if (ServiceUtil.isError(genericEstimate)) {
             Debug.logError(ServiceUtil.getErrorMessage(genericEstimate), module);
             throw new GeneralException();
+        } else if (ServiceUtil.isFailure(genericEstimate)) {
+            genericShipAmt = new Double(-1);
         } else {
             genericShipAmt = (Double) genericEstimate.get("shippingEstimateAmount");
         }
@@ -251,4 +255,5 @@
         return externalShipAmt;
     }
 }
+
 

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?rev=568175&r1=568174&r2=568175&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Tue Aug 21 08:56:07 2007
@@ -262,8 +262,6 @@
             shipAddress = delegator.makeValue("PostalAddress", null);
             shipAddress.set("countryGeoId", shippingCountryCode);
             shipAddress.set("postalCodeGeoId", shippingPostalCode);
-        } else {
-            return ServiceUtil.returnError("Must have either shippingContactMechId or postalCode to run this service");
         }
         // Get the possible estimates.
         ArrayList estimateList = new ArrayList();
@@ -272,8 +270,11 @@
         while (i.hasNext()) {
             GenericValue thisEstimate = (GenericValue) i.next();
             String toGeo = thisEstimate.getString("geoIdTo");
+            if(UtilValidate.isNotEmpty(toGeo) && shipAddress ==null){
+                // This estimate requires shipping address details. We don't have it so we cannot use this estimate.
+                continue;
+            }
             List toGeoList = GeoWorker.expandGeoGroup(toGeo, delegator);
-
             // Make sure we have a valid GEOID.
             if (toGeoList == null || toGeoList.size() == 0 ||
                     GeoWorker.containsGeo(toGeoList, shipAddress.getString("countryGeoId"), delegator) ||
@@ -357,6 +358,7 @@
                         estimateList.add(thisEstimate);
                 }
             }
+
         }
 
         if (estimateList.size() < 1) {