Author: sichen
Date: Tue Jun 26 09:54:50 2007
New Revision: 550855
URL:
http://svn.apache.org/viewvc?view=rev&rev=550855Log:
Add a dummy package to outgoing UPS rate requests if no packages exist (which can happen if none of the products involved have weights configured)
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java?view=diff&rev=550855&r1=550854&r2=550855==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java Tue Jun 26 09:54:50 2007
@@ -1529,10 +1529,27 @@
private static void splitEstimatePackages(Document requestDoc, Element shipmentElement, List shippableItemInfo, double maxWeight, double minWeight) {
List packages = getPackageSplit(shippableItemInfo, maxWeight);
+ if (UtilValidate.isNotEmpty(packages)) {
Iterator i = packages.iterator();
while (i.hasNext()) {
Map packageMap = (Map) i.next();
addPackageElement(requestDoc, shipmentElement, shippableItemInfo, packageMap, minWeight);
+ }
+ } else {
+
+ // Add a dummy package
+ String totalWeightStr = UtilProperties.getPropertyValue("shipment", "shipment.ups.min.estimate.weight", "1");
+ double packageWeight = 1;
+ try {
+ packageWeight = Double.parseDouble(totalWeightStr);
+ } catch (NumberFormatException e) {
+ Debug.logError(e, module);
+ }
+ Element packageElement = UtilXml.addChildElement(shipmentElement, "Package", requestDoc);
+ Element packagingTypeElement = UtilXml.addChildElement(packageElement, "PackagingType", requestDoc);
+ UtilXml.addChildElementValue(packagingTypeElement, "Code", "00", requestDoc);
+ Element packageWeightElement = UtilXml.addChildElement(packageElement, "PackageWeight", requestDoc);
+ UtilXml.addChildElementValue(packageWeightElement, "Weight", "" + packageWeight, requestDoc);
}
}