Author: jacopoc
Date: Tue May 22 06:35:41 2007 New Revision: 540581 URL: http://svn.apache.org/viewvc?view=rev&rev=540581 Log: Added support for manual adjustments in the refund returns. 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=540581&r1=540580&r2=540581 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Tue May 22 06:35:41 2007 @@ -828,7 +828,6 @@ } // refund (cash/charge) return - //TODO add adjustment total public static Map processRefundReturn(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -848,7 +847,9 @@ return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderErrorGettingReturnHeaderItemInformation", locale)); } - if (returnHeader != null && returnItems != null && returnItems.size() > 0) { + BigDecimal adjustments = new BigDecimal(getReturnAdjustmentTotal(delegator, UtilMisc.toMap("returnId", returnId, "returnTypeId", "RTN_REFUND"))); + + if (returnHeader != null && ((returnItems != null && returnItems.size() > 0) || adjustments.compareTo(ZERO) > 0)) { Map itemsByOrder = new HashMap(); Map totalByOrder = new HashMap(); @@ -864,7 +865,7 @@ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); } - groupReturnItemsByOrder(returnItems, itemsByOrder, totalByOrder, delegator, returnId); + groupReturnItemsByOrder(returnItems, itemsByOrder, totalByOrder, delegator, returnId, "RTN_REFUND"); // process each one by order Set itemSet = itemsByOrder.entrySet(); @@ -1332,7 +1333,7 @@ if (returnHeader != null && returnItems != null && returnItems.size() > 0) { Map itemsByOrder = new HashMap(); Map totalByOrder = new HashMap(); - groupReturnItemsByOrder(returnItems, itemsByOrder, totalByOrder, delegator, returnId); + groupReturnItemsByOrder(returnItems, itemsByOrder, totalByOrder, delegator, returnId, returnTypeId); // process each one by order Set itemSet = itemsByOrder.entrySet(); @@ -1795,7 +1796,7 @@ * @param delegator * @param returnId */ - public static void groupReturnItemsByOrder(List returnItems, Map itemsByOrder, Map totalByOrder, GenericDelegator delegator, String returnId) { + public static void groupReturnItemsByOrder(List returnItems, Map itemsByOrder, Map totalByOrder, GenericDelegator delegator, String returnId, String returnTypeId) { Iterator itemIt = returnItems.iterator(); while (itemIt.hasNext()) { GenericValue item = (GenericValue) itemIt.next(); @@ -1844,7 +1845,9 @@ while (orderIterator.hasNext()) { String orderId = (String) orderIterator.next(); // find returnAdjustment for returnHeader - Map condition = UtilMisc.toMap("returnId", returnId, "returnItemSeqId", org.ofbiz.common.DataModelConstants.SEQ_ID_NA); + Map condition = UtilMisc.toMap("returnId", returnId, + "returnItemSeqId", org.ofbiz.common.DataModelConstants.SEQ_ID_NA, + "returnTypeId", returnTypeId); double existingTotal = ((Double) totalByOrder.get(orderId)).doubleValue() + getReturnAdjustmentTotal(delegator, condition); totalByOrder.put(orderId, new Double(existingTotal)); } |
Free forum by Nabble | Edit this page |