You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by si...@apache.org on 2007/02/16 23:48:45 UTC

svn commit: r508633 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java

Author: sichen
Date: Fri Feb 16 14:48:44 2007
New Revision: 508633

URL: http://svn.apache.org/viewvc?view=rev&rev=508633
Log:
OFBIZ-459: Support refunds to non-credit card.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java?view=diff&rev=508633&r1=508632&r2=508633
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Fri Feb 16 14:48:44 2007
@@ -890,11 +890,6 @@
                     }
                 }
 
-                if (prefSplitMap == null || prefSplitMap.size() == 0) {
-                    Debug.logError("We didn't find any possible payment prefs to use for RTN: " + returnId + " ORD: " + orderId, module);
-                    return ServiceUtil.returnError("Unable to refund order #" + orderId + "; there are no available payment preferences.");                     
-                }
-
                 // Keep a decreasing total of the amount remaining to refund
                 BigDecimal amountLeftToRefund = new BigDecimal(orderTotal.doubleValue()).setScale(decimals, rounding);
 
@@ -1035,6 +1030,24 @@
                             amountLeftToRefund = amountLeftToRefund.subtract(amountToRefund);
                         }
                     }                    
+                }
+
+                // OFBIZ-459:  Create a "filler" payment and return item response by hand for the remaining amount, note that this won't be applied to the invoice
+                if (amountLeftToRefund.compareTo(ZERO) == 1) {
+                    try {
+                        Map input = UtilMisc.toMap("userLogin", userLogin, "amount", new Double(amountLeftToRefund.doubleValue()), "statusId", "PMNT_NOT_PAID");
+                        input.put("partyIdTo", returnHeader.get("fromPartyId"));
+                        input.put("partyIdFrom", returnHeader.get("toPartyId"));
+                        input.put("paymentTypeId", "CUSTOMER_REFUND");
+                        Map results = dispatcher.runSync("createPayment", input);
+                        if (ServiceUtil.isError(results)) return results;
+
+                        input = UtilMisc.toMap("userLogin", userLogin, "paymentId", results.get("paymentId"), "responseAmount", new Double(amountLeftToRefund.doubleValue()));
+                        results = dispatcher.runSync("createReturnItemResponse", input);
+                        if (ServiceUtil.isError(results)) return results;
+                    } catch (GenericServiceException e) {
+                        return ServiceUtil.returnError(e.getMessage());
+                    }
                 }
             }
         }