Author: ashish
Date: Fri Jun 19 09:37:04 2009 New Revision: 786430 URL: http://svn.apache.org/viewvc?rev=786430&view=rev Log: Applied patch from jira issue OFBIZ-2632 (Send valid formatted date for international orders to UPS in yyyMMDD) Thanks Pranay for your contribution on this. 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=786430&r1=786429&r2=786430&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 Fri Jun 19 09:37:04 2009 @@ -23,7 +23,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.math.MathContext; -import java.util.Date; +import java.text.SimpleDateFormat; import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -43,7 +43,6 @@ import org.ofbiz.base.util.HttpClient; import org.ofbiz.base.util.HttpClientException; import org.ofbiz.base.util.StringUtil; -import org.ofbiz.service.calendar.RecurrenceUtil; import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilNumber; @@ -88,6 +87,7 @@ public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding"); public static final MathContext generalRounding = new MathContext(10); public static final int returnServiceCode = 8; + public static final String dateFormatString = "yyyyMMdd"; public static Map<String, Object> upsShipmentConfirm(DispatchContext dctx, Map<String, ? extends Object> context) { Map<String, Object> result = FastMap.newInstance(); @@ -449,7 +449,8 @@ UtilXml.addChildElementValue(unitOfMeasurElement, "Code", "EA", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(productElement, "OriginCountryCode", "US", shipmentConfirmRequestDoc); } - String invoiceDate = RecurrenceUtil.formatDate((Date) shipment.getTimestamp("createdDate")); + SimpleDateFormat formatter = new SimpleDateFormat(dateFormatString); + String invoiceDate = formatter.format(shipment.getTimestamp("createdDate")); UtilXml.addChildElementValue(internationalFormsElement, "InvoiceDate", invoiceDate, shipmentConfirmRequestDoc); UtilXml.addChildElementValue(internationalFormsElement, "ReasonForExport","SALE", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(internationalFormsElement, "CurrencyCode", currencyCode, shipmentConfirmRequestDoc); @@ -522,7 +523,7 @@ } BigDecimal boxWeight = shipmentPackage.getBigDecimal("weight"); UtilXml.addChildElementValue(packageWeightElement, "Weight", UtilValidate.isNotEmpty(boxWeight) ? ""+boxWeight.intValue() : "", shipmentConfirmRequestDoc); - // Commenting as not accepted in case of international order + // Adding only when order is not an international order if (!internationalServiceCodes.contains(carrierServiceCode)) { Element referenceNumberElement = UtilXml.addChildElement(packageElement, "ReferenceNumber", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(referenceNumberElement, "Code", "MK", shipmentConfirmRequestDoc); @@ -2450,6 +2451,7 @@ // Top Level Element: Shipment Element shipmentElement = UtilXml.addChildElement(shipmentConfirmRequestElement, "Shipment", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipmentElement, "Description", "Goods for Shipment " + shipment.get("shipmentId"), shipmentConfirmRequestDoc); // Child of Shipment: ReturnService Element returnServiceElement = UtilXml.addChildElement(shipmentElement, "ReturnService", shipmentConfirmRequestDoc); @@ -2531,7 +2533,7 @@ Element emailMessageElement = UtilXml.addChildElement(labelDeliveryElement, "EMailMessage", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(emailMessageElement, "EMailAddress", recipientEmail, shipmentConfirmRequestDoc); UtilXml.addChildElementValue(emailMessageElement, "FromEMailAddress", senderEmail, shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(emailMessageElement, "FromName", originPostalAddress.getString("attnName"), shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(emailMessageElement, "FromName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) ? originPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(emailMessageElement, "Memo", UtilProperties.getPropertyValue("shipment", "shipment.ups.default.returnLabel.memo"), shipmentConfirmRequestDoc); UtilXml.addChildElementValue(emailMessageElement, "Subject", UtilProperties.getPropertyValue("shipment", "shipment.ups.default.returnLabel.subject"), shipmentConfirmRequestDoc); |
Free forum by Nabble | Edit this page |