Author: jacopoc
Date: Mon Jul 9 03:40:26 2007 New Revision: 554599 URL: http://svn.apache.org/viewvc?view=rev&rev=554599 Log: Added information about order item level adjustment to the create return items screens (both standard and quick). For now the adjustments cannot be selected (they are always automatically added to the return if the corresponding order item is selected. I still need to improve the code to show the already returned portion of an adjustment. Modified: 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/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=554599&r1=554598&r2=554599 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Mon Jul 9 03:40:26 2007 @@ -2931,6 +2931,32 @@ } /** + * 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=554599&r1=554598&r2=554599 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Mon Jul 9 03:40:26 2007 @@ -22,6 +22,7 @@ import java.math.BigDecimal; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -395,9 +396,9 @@ return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderErrorUnableToGetReturnItemInformation", locale)); } - Map returnable = new HashMap(); + Map returnable = new LinkedHashMap(); if (orderHeader != null) { - + OrderReadHelper orh = new OrderReadHelper(orderHeader); // OrderItems which have been issued may be returned. EntityConditionList whereConditions = new EntityConditionList(UtilMisc.toList( new EntityExpr("orderId", EntityOperator.EQUALS, orderHeader.getString("orderId")), @@ -481,6 +482,21 @@ returnInfo.put("itemTypeKey", itemTypeKey); returnable.put(item, returnInfo); + + // Order item adjustments + List itemAdjustments = orh.getNotReturnedOrderItemAdjustments(item); + if (UtilValidate.isNotEmpty(itemAdjustments)) { + Iterator itemAdjustmentsIt = itemAdjustments.iterator(); + while (itemAdjustmentsIt.hasNext()) { + GenericValue itemAdjustment = (GenericValue)itemAdjustmentsIt.next(); + returnInfo = new HashMap(); + returnInfo.put("returnableQuantity", new Double(1.0)); + // TODO: the returnablePrice should be set to the amount minus the already returned amount + returnInfo.put("returnablePrice", itemAdjustment.get("amount")); + returnInfo.put("itemTypeKey", itemTypeKey); + returnable.put(itemAdjustment, returnInfo); + } + } } } } else { 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=554599&r1=554598&r2=554599 ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl Mon Jul 9 03:40:26 2007 @@ -61,67 +61,108 @@ <#if returnableItems?has_content> <#assign rowCount = 0> <#list returnableItems.keySet() as orderItem> - <#assign returnItemType = returnItemTypeMap.get(returnableItems.get(orderItem).get("itemTypeKey"))/> - <input type="hidden" name="returnItemTypeId_o_${rowCount}" value="${returnItemType}"/> - <input type="hidden" name="orderId_o_${rowCount}" value="${orderItem.orderId}"/> - <input type="hidden" name="orderItemSeqId_o_${rowCount}" value="${orderItem.orderItemSeqId}"/> - <input type="hidden" name="description_o_${rowCount}" value="${orderItem.itemDescription?if_exists}"/> + <#if orderItem.orderAdjustmentId?has_content> + <#-- this is an order item adjustment --> + <#assign returnAdjustmentType = returnItemTypeMap.get(orderItem.get("orderAdjustmentTypeId"))/> + <#assign adjustmentType = orderItem.getRelatedOne("OrderAdjustmentType")/> + <#assign description = orderItem.description?default(adjustmentType.get("description",locale))/> - <#-- need some order item information --> - <#assign orderHeader = orderItem.getRelatedOne("OrderHeader")> - <#assign itemCount = orderItem.quantity> - <#assign itemPrice = orderItem.unitPrice> - <#-- end of order item information --> + <#-- + <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")} + </td> + <td> + ${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> + <select name="returnTypeId_o_${rowCount}" class="selectBox"> + <#list returnTypes as type> + <option value="${type.returnTypeId}" <#if type.returnTypeId == "RTN_REFUND">selected</#if>>${type.get("description",locale)?default(type.returnTypeId)}</option> + </#list> + </select> + </td> + --> + <td></td> + <#-- + <td align="right"> + <input type="checkbox" name="_rowSubmit_o_${rowCount}" value="Y" onclick="javascript:checkToggle(this, '${selectAllFormName}');"/> + </td> + --> + </tr> - <tr> - <td> - <div class="tabletext"> - <#if orderItem.productId?exists> - <b>${orderItem.productId}</b>: - <input type="hidden" name="productId_o_${rowCount}" value="${orderItem.productId}"> - </#if> - ${orderItem.itemDescription} - </div> - </td> - <td align='center'> - <div class="tabletext">${orderItem.quantity?string.number}</div> - </td> - <td> - <input type="text" class="inputBox" size="6" name="returnQuantity_o_${rowCount}" value="${returnableItems.get(orderItem).get("returnableQuantity")}"/> - </td> - <td align='left'> - <div class="tabletext"><@ofbizCurrency amount=orderItem.unitPrice isoCode=orderHeader.currencyUom/></div> - </td> - <td> - <input type="text" class="inputBox" size="8" name="returnPrice_o_${rowCount}" value="${returnableItems.get(orderItem).get("returnablePrice")?string("##0.00")}"/> - </td> - <td> - <select name="returnReasonId_o_${rowCount}" class="selectBox"> - <#list returnReasons as reason> - <option value="${reason.returnReasonId}">${reason.get("description",locale)?default(reason.returnReasonId)}</option> - </#list> - </select> - </td> - <td> - <select name="returnTypeId_o_${rowCount}" class="selectBox"> - <#list returnTypes as type> - <option value="${type.returnTypeId}" <#if type.returnTypeId=="RTN_REFUND">selected</#if>>${type.get("description",locale)?default(type.returnTypeId)}</option> - </#list> - </select> - </td> - <td> - <select name="expectedItemStatus_o_${rowCount}" class="selectBox"> - <option value="INV_RETURNED">${uiLabelMap.OrderReturned}</option> - <option value="INV_RETURNED">---</option> - <#list itemStts as status> - <option value="${status.statusId}">${status.get("description",locale)}</option> - </#list> - </select> - </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"))/> + <input type="hidden" name="returnItemTypeId_o_${rowCount}" value="${returnItemType}"/> + <input type="hidden" name="orderId_o_${rowCount}" value="${orderItem.orderId}"/> + <input type="hidden" name="orderItemSeqId_o_${rowCount}" value="${orderItem.orderItemSeqId}"/> + <input type="hidden" name="description_o_${rowCount}" value="${orderItem.itemDescription?if_exists}"/> + + <#-- need some order item information --> + <#assign orderHeader = orderItem.getRelatedOne("OrderHeader")> + <#assign itemCount = orderItem.quantity> + <#assign itemPrice = orderItem.unitPrice> + <#-- end of order item information --> + + <tr> + <td> + <div class="tabletext"> + <#if orderItem.productId?exists> + <b>${orderItem.productId}</b>: + <input type="hidden" name="productId_o_${rowCount}" value="${orderItem.productId}"> + </#if> + ${orderItem.itemDescription} + </div> + </td> + <td align='center'> + <div class="tabletext">${orderItem.quantity?string.number}</div> + </td> + <td> + <input type="text" class="inputBox" size="6" name="returnQuantity_o_${rowCount}" value="${returnableItems.get(orderItem).get("returnableQuantity")}"/> + </td> + <td align='left'> + <div class="tabletext"><@ofbizCurrency amount=orderItem.unitPrice isoCode=orderHeader.currencyUom/></div> + </td> + <td> + <input type="text" class="inputBox" size="8" name="returnPrice_o_${rowCount}" value="${returnableItems.get(orderItem).get("returnablePrice")?string("##0.00")}"/> + </td> + <td> + <select name="returnReasonId_o_${rowCount}" class="selectBox"> + <#list returnReasons as reason> + <option value="${reason.returnReasonId}">${reason.get("description",locale)?default(reason.returnReasonId)}</option> + </#list> + </select> + </td> + <td> + <select name="returnTypeId_o_${rowCount}" class="selectBox"> + <#list returnTypes as type> + <option value="${type.returnTypeId}" <#if type.returnTypeId=="RTN_REFUND">selected</#if>>${type.get("description",locale)?default(type.returnTypeId)}</option> + </#list> + </select> + </td> + <td> + <select name="expectedItemStatus_o_${rowCount}" class="selectBox"> + <option value="INV_RETURNED">${uiLabelMap.OrderReturned}</option> + <option value="INV_RETURNED">---</option> + <#list itemStts as status> + <option value="${status.statusId}">${status.get("description",locale)}</option> + </#list> + </select> + </td> + <td align="right"> + <input type="checkbox" name="_rowSubmit_o_${rowCount}" value="Y" onclick="javascript:checkToggle(this, '${selectAllFormName}');"/> + </td> + </tr> + </#if> <#assign rowCount = rowCount + 1> </#list> |
Free forum by Nabble | Edit this page |