Author: jacopoc
Date: Tue Jul 10 07:55:03 2007 New Revision: 554967 URL: http://svn.apache.org/viewvc?view=rev&rev=554967 Log: Added ability to select which return adjustments can be included in a return; still some work needs to be done to improve the information on screen (right now there is no way to know the amount already returned of a given adjustment; the return type must be selected for each adjustments but it would be better to add some Javascript code to enhance the user experience). Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml ofbiz/trunk/applications/order/servicedef/services_return.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml?view=diff&rev=554967&r1=554966&r2=554967 ============================================================================== --- ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml (original) +++ ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml Tue Jul 10 07:55:03 2007 @@ -359,18 +359,28 @@ <create-value value-name="newEntity"/> <refresh-value value-name="newEntity"/> - <!-- create return adjustments for all adjustments associated with the order item --> - <if-not-empty field-name="orderItem"> - <get-related value-name="orderItem" relation-name="OrderAdjustment" list-name="orderAdjustments"/> - <iterate entry-name="orderAdjustment" list-name="orderAdjustments"> - <clear-field field-name="returnAdjCtx"/> - <set field="returnAdjCtx.returnId" from-field="parameters.returnId"/> - <set field="returnAdjCtx.returnItemSeqId" from-field="newEntity.returnItemSeqId"/> - <set field="returnAdjCtx.returnTypeId" from-field="newEntity.returnTypeId"/> - <set field="returnAdjCtx.orderAdjustmentId" from-field="orderAdjustment.orderAdjustmentId"/> - <call-service service-name="createReturnAdjustment" in-map-name="returnAdjCtx"/> - </iterate> - </if-not-empty> + <if> + <condition> + <or> + <if-empty field-name="parameters.includeAdjustments"/> + <if-compare field-name="parameters.includeAdjustments" operator="equals" value="Y"/> + </or> + </condition> + <then> + <!-- create return adjustments for all adjustments associated with the order item --> + <if-not-empty field-name="orderItem"> + <get-related value-name="orderItem" relation-name="OrderAdjustment" list-name="orderAdjustments"/> + <iterate entry-name="orderAdjustment" list-name="orderAdjustments"> + <clear-field field-name="returnAdjCtx"/> + <set field="returnAdjCtx.returnId" from-field="parameters.returnId"/> + <set field="returnAdjCtx.returnItemSeqId" from-field="newEntity.returnItemSeqId"/> + <set field="returnAdjCtx.returnTypeId" from-field="newEntity.returnTypeId"/> + <set field="returnAdjCtx.orderAdjustmentId" from-field="orderAdjustment.orderAdjustmentId"/> + <call-service service-name="createReturnAdjustment" in-map-name="returnAdjCtx"/> + </iterate> + </if-not-empty> + </then> + </if> </simple-method> <simple-method method-name="updateReturnItem" short-description="Update Return Item"> <check-permission permission="ORDERMGR" action="_UPDATE"><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunUpdateReturnHeader"/></check-permission> Modified: ofbiz/trunk/applications/order/servicedef/services_return.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services_return.xml?view=diff&rev=554967&r1=554966&r2=554967 ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services_return.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services_return.xml Tue Jul 10 07:55:03 2007 @@ -76,6 +76,7 @@ ORDERMGR_CREATE, but, if the former, the returnPrice will be overriden by the returnablePrice from getReturnableQuantity.</description> <implements service="returnItemInterface"/> <attribute name="returnItemMapKey" type="String" mode="IN" optional="true"/> + <attribute name="includeAdjustments" type="String" mode="IN" optional="true"/> <!-- The default is "Y": the adjustments associated with the item are included in the return --> <attribute name="returnItemSeqId" type="String" mode="OUT" optional="false"/> <override name="returnReasonId" optional="true"/> </service> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?view=diff&rev=554967&r1=554966&r2=554967 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Tue Jul 10 07:55:03 2007 @@ -2931,32 +2931,6 @@ } /** - * Get order item adjustments that have no corresponding returnAdjustment - * @return orderAdjustmentList - */ - public List getNotReturnedOrderItemAdjustments(GenericValue orderItem) { - List filteredAdjustments = new ArrayList(); - try { - List orderAdjustments = orderItem.getRelated("OrderAdjustment"); - if (orderAdjustments != null) { - Iterator orderAdjIterator = orderAdjustments.iterator(); - while (orderAdjIterator.hasNext()) { - GenericValue orderAdjustment = (GenericValue) orderAdjIterator.next(); - long count = 0; - // TODO: we have to change this to also compute the adjustment amount minus the already returned amount - count = orderItem.getDelegator().findCountByAnd("ReturnAdjustment", UtilMisc.toMap("orderAdjustmentId", orderAdjustment.get("orderAdjustmentId"))); - if (count == 0) { - filteredAdjustments.add(orderAdjustment); - } - } - } - } catch (GenericEntityException e) { - Debug.logError(e, module); - } - return filteredAdjustments; - } - - /** * Get the total return adjustments for a set of key -> value condition pairs. Done for code efficiency. * @param delegator * @param condition 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=554967&r1=554966&r2=554967 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Tue Jul 10 07:55:03 2007 @@ -484,7 +484,13 @@ returnable.put(item, returnInfo); // Order item adjustments - List itemAdjustments = orh.getNotReturnedOrderItemAdjustments(item); + List itemAdjustments = null; + try { + itemAdjustments = orderItem.getRelated("OrderAdjustment"); + } catch (GenericEntityException e) { + Debug.logError(e, module); + return ServiceUtil.returnError("Unable to obtain order item adjustments"); + } if (UtilValidate.isNotEmpty(itemAdjustments)) { Iterator itemAdjustmentsIt = itemAdjustments.iterator(); while (itemAdjustmentsIt.hasNext()) { @@ -1994,6 +2000,20 @@ UtilMisc.toMap("returnId", returnId, "returnItemSeqId", returnItemSeqId)); Debug.log("returnId:" + returnId + ",returnItemSeqId:" + returnItemSeqId); orderItem = returnItem.getRelatedOne("OrderItem"); + } else { + // we don't have the returnItemSeqId but before we consider this + // an header adjustment we try to get a return item in this return + // associated to the same order item to which the adjustments refers (if any) + if (UtilValidate.isNotEmpty(orderAdjustment.getString("orderItemSeqId")) && + !"_NA_".equals(orderAdjustment.getString("orderItemSeqId"))) { + returnItem = EntityUtil.getFirst(delegator.findByAnd("ReturnItem", + UtilMisc.toMap("returnId", returnId, + "orderId", orderAdjustment.getString("orderId"), + "orderItemSeqId", orderAdjustment.getString("orderItemSeqId")))); + if (UtilValidate.isNotEmpty(returnItem)) { + orderItem = returnItem.getRelatedOne("OrderItem"); + } + } } } catch (GenericEntityException e) { Debug.logError(e, module); @@ -2111,7 +2131,13 @@ String serviceName = UtilValidate.isNotEmpty(orderItemSeqId) ? "createReturnItem" : "createReturnAdjustment"; Debug.logInfo("serviceName:" + serviceName, module); try { - return dispatcher.runSync(serviceName, filterServiceContext(dctx, serviceName, context)); + Map inMap = filterServiceContext(dctx, serviceName, context); + if ("createReturnItem".equals(serviceName)) { + // we don't want to automatically include the adjustments + // when the return item is created because they are selectable by the user + inMap.put("includeAdjustments", "N"); + } + return dispatcher.runSync(serviceName, inMap); } catch (org.ofbiz.service.GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); Modified: ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl?view=diff&rev=554967&r1=554966&r2=554967 ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl Tue Jul 10 07:55:03 2007 @@ -67,12 +67,8 @@ <#assign adjustmentType = orderItem.getRelatedOne("OrderAdjustmentType")/> <#assign description = orderItem.description?default(adjustmentType.get("description",locale))/> - <#-- <input type="hidden" name="returnAdjustmentTypeId_o_${rowCount}" value="${returnAdjustmentType}"/> <input type="hidden" name="orderAdjustmentId_o_${rowCount}" value="${orderItem.orderAdjustmentId}"/> - <input type="hidden" name="returnItemSeqId_o_${rowCount}" value="_NA_"/> - <input type="hidden" name="description_o_${rowCount}" value="${description}"/> - --> <tr> <td colspan="4"> ${description?default("N/A")} @@ -81,8 +77,7 @@ ${orderItem.amount?string("##0.00")} <#--<input type="text" class="inputBox" size="8" name="amount_o_${rowCount}" <#if orderItem.amount?has_content>value="${orderItem.amount?string("##0.00")}"</#if>/>--> </td> - <td colspan="3"></td> - <#-- + <td></td> <td> <select name="returnTypeId_o_${rowCount}" class="selectBox"> <#list returnTypes as type> @@ -90,15 +85,11 @@ </#list> </select> </td> - --> <td></td> - <#-- <td align="right"> <input type="checkbox" name="_rowSubmit_o_${rowCount}" value="Y" onclick="javascript:checkToggle(this, '${selectAllFormName}');"/> </td> - --> </tr> - <#else> <#-- this is an order item --> <#assign returnItemType = returnItemTypeMap.get(returnableItems.get(orderItem).get("itemTypeKey"))/> |
Free forum by Nabble | Edit this page |