[OFBiz] SVN: r6943 - trunk/applications/order/src/org/ofbiz/order/order
sichen@svn.ofbiz.org
sichen at svn.ofbiz.org
Tue Mar 7 20:05:29 CST 2006
Author: sichen
Date: 2006-03-07 20:05:26 -0600 (Tue, 07 Mar 2006)
New Revision: 6943
Modified:
trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
Log:
Fixed rounding issue when order is returned. Now the order total, the return total, the return refund amount, and the payment applications for quick refund should all match.
Modified: trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java 2006-03-08 00:52:28 UTC (rev 6942)
+++ trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java 2006-03-08 02:05:26 UTC (rev 6943)
@@ -685,8 +685,8 @@
// refund (cash/charge) return
//TODO add adjustment total
public static Map processRefundReturn(DispatchContext dctx, Map context) {
+ GenericDelegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
- GenericDelegator delegator = dctx.getDelegator();
String returnId = (String) context.get("returnId");
GenericValue userLogin = (GenericValue) context.get("userLogin");
Locale locale = (Locale) context.get("locale");
@@ -801,7 +801,12 @@
GenericValue orderPayPref = (GenericValue) prefItemEntry.getKey();
List itemList = (List) prefItemEntry.getValue();
- Double thisRefundAmount = (Double) prefsAmount.get(orderPayPref);
+ // Get the refund amount as a BigDecimal due to rounding issues (the createReturnItemResponse simple method will turn 203.37999999999997 into 203.37)
+ BigDecimal thisRefundAmount = ZERO;
+ Double thisRefundAmountDouble = (Double) prefsAmount.get(orderPayPref);
+ if (thisRefundAmountDouble != null) thisRefundAmount = new BigDecimal(thisRefundAmountDouble.doubleValue());
+ thisRefundAmount = thisRefundAmount.setScale(decimals, rounding);
+
String paymentId = null;
// this can be extended to support additional electronic types
@@ -811,7 +816,7 @@
if (electronicTypes.contains(orderPayPref.getString("paymentMethodTypeId"))) {
// call the refund service to refund the payment
try {
- serviceResult = dispatcher.runSync("refundPayment", UtilMisc.toMap("orderPaymentPreference", orderPayPref, "refundAmount", thisRefundAmount, "userLogin", userLogin));
+ serviceResult = dispatcher.runSync("refundPayment", UtilMisc.toMap("orderPaymentPreference", orderPayPref, "refundAmount", new Double(thisRefundAmount.doubleValue()), "userLogin", userLogin));
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError("Error in refund payment", null, null, serviceResult);
}
@@ -833,7 +838,7 @@
// fill out the data for the new ReturnItemResponse
Map response = FastMap.newInstance();
response.put("orderPaymentPreferenceId", orderPayPref.getString("orderPaymentPreferenceId"));
- response.put("responseAmount", thisRefundAmount);
+ response.put("responseAmount", new Double(thisRefundAmount.doubleValue()));
response.put("responseDate", now);
response.put("userLogin", userLogin);
if (paymentId != null) {
More information about the Svn
mailing list