Author: sichen
Date: Thu Oct 5 13:44:44 2006 New Revision: 453376 URL: http://svn.apache.org/viewvc?view=rev&rev=453376 Log: OFBIZ-337 - Allow returns of partially shipped orders. Modified: incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderview.bsh incubator/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl Modified: incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml?view=diff&rev=453376&r1=453375&r2=453376 ============================================================================== --- incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml (original) +++ incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml Thu Oct 5 13:44:44 2006 @@ -773,6 +773,10 @@ <key-map field-name="orderId"/> <key-map field-name="orderItemSeqId"/> </view-link> + <relation type="one-nofk" rel-entity-name="OrderItem"> + <key-map field-name="orderId"/> + <key-map field-name="orderItemSeqId"/> + </relation> </view-entity> <view-entity entity-name="OrderItemQuantityReportGroupByProduct" package-name="org.ofbiz.order.order" Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java?view=diff&rev=453376&r1=453375&r2=453376 ============================================================================== --- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original) +++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Thu Oct 5 13:44:44 2006 @@ -334,7 +334,7 @@ // get the returnable quantity double returnableQuantity = 0.00; - if (returnable && itemStatus.equals("ITEM_COMPLETED")) { + if (returnable && (itemStatus.equals("ITEM_APPROVED") || itemStatus.equals("ITEM_COMPLETED"))) { List returnedItems = null; try { returnedItems = orderItem.getRelated("ReturnItem"); @@ -392,17 +392,33 @@ Map returnable = new HashMap(); if (orderHeader != null) { - List orderItems = null; + + // OrderItems which have been issued may be returned. + EntityConditionList whereConditions = new EntityConditionList(UtilMisc.toList( + new EntityExpr("orderId", EntityOperator.EQUALS, orderHeader.getString("orderId")), + new EntityExpr("orderItemStatusId", EntityOperator.IN, UtilMisc.toList("ITEM_APPROVED", "ITEM_COMPLETED")) + ), EntityOperator.AND); + EntityConditionList havingConditions = new EntityConditionList(UtilMisc.toList( + new EntityExpr("quantityIssued", EntityOperator.GREATER_THAN, new Double(0)) + ), EntityOperator.AND); + List orderItemQuantitiesIssued = null; try { - orderItems = orderHeader.getRelatedByAnd("OrderItem", UtilMisc.toMap("statusId", "ITEM_COMPLETED")); + orderItemQuantitiesIssued = delegator.findByCondition("OrderItemQuantityReportGroupByItem", whereConditions, havingConditions, UtilMisc.toList("orderId", "orderItemSeqId"), UtilMisc.toList("orderItemSeqId"), null); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderErrorUnableToGetReturnHeaderFromItem", locale)); } - if (orderItems != null) { - Iterator i = orderItems.iterator(); + if (orderItemQuantitiesIssued != null) { + Iterator i = orderItemQuantitiesIssued.iterator(); while (i.hasNext()) { - GenericValue item = (GenericValue) i.next(); + GenericValue orderItemQuantityIssued = (GenericValue) i.next(); + GenericValue item = null; + try { + item = orderItemQuantityIssued.getRelatedOne("OrderItem"); + } catch( GenericEntityException e ) { + Debug.logError(e, module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderErrorUnableToGetOrderItemInformation", locale)); + } Map serviceResult = null; try { serviceResult = dispatcher.runSync("getReturnableQuantity", UtilMisc.toMap("orderItem", item)); @@ -413,6 +429,11 @@ if (serviceResult.containsKey(ModelService.ERROR_MESSAGE)) { return ServiceUtil.returnError((String) serviceResult.get(ModelService.ERROR_MESSAGE)); } else { + + // Don't add the OrderItem to the map of returnable OrderItems if there isn't any returnable quantity. + if (((Double) serviceResult.get("returnableQuantity")).doubleValue() == 0 ) { + continue; + } Map returnInfo = new HashMap(); // first the return info (quantity/price) returnInfo.put("returnableQuantity", serviceResult.get("returnableQuantity")); Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderview.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderview.bsh?view=diff&rev=453376&r1=453375&r2=453376 ============================================================================== --- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderview.bsh (original) +++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderview.bsh Thu Oct 5 13:44:44 2006 @@ -348,6 +348,14 @@ productStoreId = orderHeader.getRelatedOne("ProductStore").getString("productStoreId"); productStoreShipmentMethList = delegator.findByAndCache("ProductStoreShipmentMethView", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNumber")); context.put("productStoreShipmentMethList",productStoreShipmentMethList); + + // Get a map of returnable items + returnableItems = new HashMap(); + returnableItemServiceMap = dispatcher.runSync("getReturnableItems", UtilMisc.toMap("orderId", orderId)); + if (returnableItemServiceMap.get("returnableItems") != null) { + returnableItems = returnableItemServiceMap.get("returnableItems"); + } + context.put("returnableItems", returnableItems); } List paymentMethodValueMaps = PaymentWorker.getPartyPaymentMethodValueMaps(delegator, partyId, false); Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl?view=diff&rev=453376&r1=453375&r2=453376 ============================================================================== --- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl (original) +++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl Thu Oct 5 13:44:44 2006 @@ -20,12 +20,17 @@ <div class="screenlet-header"> <div class="boxlink"> <#if security.hasEntityPermission("ORDERMGR", "_UPDATE", session)> - <#if orderHeader?has_content && orderHeader.statusId != "ORDER_CANCELLED" && orderHeader.statusId != "ORDER_COMPLETED"> + <#if orderHeader?has_content && orderHeader.statusId != "ORDER_CANCELLED"> <div class="tabletext"> - <#-- - <a href="<@ofbizUrl>cancelOrderItem?${paramString}</@ofbizUrl>" class="buttontext">${uiLabelMap.OrderCancelAllItems}</a> - --> - <a href="<@ofbizUrl>editOrderItems?${paramString}</@ofbizUrl>" class="buttontext">${uiLabelMap.OrderEditItems}</a> + <#if orderHeader.statusId != "ORDER_COMPLETED"> + <#-- + <a href="<@ofbizUrl>cancelOrderItem?${paramString}</@ofbizUrl>" class="submenutext">${uiLabelMap.OrderCancelAllItems}</a> + --> + <a href="<@ofbizUrl>editOrderItems?${paramString}</@ofbizUrl>" class="submenutextright">${uiLabelMap.OrderEditItems}</a> + </#if> + <#if returnableItems?has_content> + <a href="<@ofbizUrl>quickreturn?orderId=${orderId}&party_id=${partyId?if_exists}&returnHeaderTypeId=${returnHeaderTypeId}</@ofbizUrl>" class="submenutextright">${uiLabelMap.OrderCreateReturn}</a> + </#if> </div> </#if> </#if> |
Free forum by Nabble | Edit this page |