Author: ashish
Date: Sat Jul 31 09:44:07 2010
New Revision: 981025

URL: http://svn.apache.org/viewvc?rev=981025&view=rev
Log:
When we pass fractional package weight to UPS like (0.5) then it gives error. 
This is because in UpsServices.java file, package weight has been changed to 
boxWeight.intValue() so it converts 0.5 to 0. Now if we pass only boxWeight big 
decimal number, code runs perfectly fine on confirming shipment.

Searched out in ups shipping document and found that we should pass this 
fractional weight to ups to its next full weight. For example 0.5 will be sent 
as 1.0 and 1.2 will be sent as 2.0 etc. Here is the link: 
http://www.ups.com/content/us/en/resources/prepare/oversize.html
search for this text "Determine the Actual Weight" in this link.

Having come to know this fact I converted boxWeight.intValue() code into 
boxWeight.setScale(0, boxWeight.ROUND_CEILING) which solves this purpose which 
is given in above mentioned link.

Patch from Vivek Mishra(Thanks!)

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?rev=981025&r1=981024&r2=981025&view=diff
==============================================================================
--- 
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
 Sat Jul 31 09:44:07 2010
@@ -521,7 +521,7 @@ public class UpsServices {
                     return ServiceUtil.returnError("Weight value not found for 
ShipmentRouteSegment with shipmentId " + shipmentId + ", shipmentRouteSegmentId 
" + shipmentRouteSegmentId + ", and shipmentPackageSeqId " + 
shipmentPackage.getString("shipmentPackageSeqId"));
                 }
                 BigDecimal boxWeight = shipmentPackage.getBigDecimal("weight");
-                UtilXml.addChildElementValue(packageWeightElement, "Weight", 
UtilValidate.isNotEmpty(boxWeight) ? ""+boxWeight.intValue() : "", 
shipmentConfirmRequestDoc);
+                UtilXml.addChildElementValue(packageWeightElement, "Weight", 
UtilValidate.isNotEmpty(boxWeight) ? ""+ boxWeight.setScale(0, 
boxWeight.ROUND_CEILING) : "", shipmentConfirmRequestDoc);
                 // Adding only when order is not an international order
                 if (!internationalServiceCodes.contains(carrierServiceCode)) {
                     Element referenceNumberElement = 
UtilXml.addChildElement(packageElement, "ReferenceNumber", 
shipmentConfirmRequestDoc);


Reply via email to