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!)

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@981025 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ashish Vijaywargiya
2010-07-31 09:44:07 +00:00
parent 4448c4a866
commit cf89bc0197
@@ -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);