svn commit: r431720 - in /incubator/ofbiz/trunk/applications/order: src/org/ofbiz/order/order/ webapp/ordermgr/WEB-INF/actions/return/ webapp/ordermgr/return/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r431720 - in /incubator/ofbiz/trunk/applications/order: src/org/ofbiz/order/order/ webapp/ordermgr/WEB-INF/actions/return/ webapp/ordermgr/return/

sichen
Author: sichen
Date: Tue Aug 15 15:36:04 2006
New Revision: 431720

URL: http://svn.apache.org/viewvc?rev=431720&view=rev
Log:
Add order return totals to return items form so user knows how much of the order was already refunded and credited.  Refactored OrderReadHelper.getOrderReturnTotalBd methods to handle return types.

Modified:
    incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
    incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnItems.bsh
    incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnHeader.ftl
    incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl
    incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItems.ftl

Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?rev=431720&r1=431719&r2=431720&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Tue Aug 15 15:36:04 2006
@@ -1456,17 +1456,26 @@
         return getOrderReturnedQuantityBd().doubleValue();
     }
 
-    public BigDecimal getOrderReturnedTotalBd() {
-        return getOrderReturnedTotalBd(false);
-    }
-
     /** @deprecated */
     public double getOrderReturnedTotal() {
         return getOrderReturnedTotalBd().doubleValue();
     }
 
-    public BigDecimal getOrderReturnedTotalBd(boolean includeAll) {
+    /** @deprecated */
+    public double getOrderReturnedTotal(boolean includeAll) {
+        return getOrderReturnedTotalBd(includeAll).doubleValue();
+    }
+
+    /**
+     * Get the returned total by return type (credit, refund, etc.).  Specify returnTypeId = null to get sum over all
+     * return types.  Specify includeAll = true to sum up over all return statuses except cancelled.  Specify includeAll
+     * = false to sum up over RECEIVED And COMPLETED returns.
+     */
+    public BigDecimal getOrderReturnedTotalByTypeBd(String returnTypeId, boolean includeAll) {
         List returnedItemsBase = getOrderReturnItems();
+        if (returnTypeId != null) {
+            returnedItemsBase = EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("returnTypeId", returnTypeId));
+        }
         List returnedItems = new ArrayList(returnedItemsBase.size());
 
         // get only the RETURN_RECEIVED and RETURN_COMPLETED statusIds
@@ -1474,6 +1483,7 @@
             returnedItems.addAll(EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("statusId", "RETURN_RECEIVED")));
             returnedItems.addAll(EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("statusId", "RETURN_COMPLETED")));
         } else {
+            // otherwise get all of them except cancelled ones
             returnedItems.addAll(EntityUtil.filterByAnd(returnedItemsBase,
                     UtilMisc.toList(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "RETURN_CANCELLED"))));
         }
@@ -1503,9 +1513,27 @@
         return returnedAmount.setScale(scale, rounding);
     }
 
-    /** @deprecated */
-    public double getOrderReturnedTotal(boolean includeAll) {
-        return getOrderReturnedTotalBd(includeAll).doubleValue();
+    /** Gets the total return credit for COMPLETED and RECEIVED returns. */
+    public BigDecimal getOrderReturnedCreditTotalBd() {
+        return getOrderReturnedTotalByTypeBd("RTN_CREDIT", false);
+    }
+
+    /** Gets the total return refunded for COMPLETED and RECEIVED returns. */
+    public BigDecimal getOrderReturnedRefundTotalBd() {
+        return getOrderReturnedTotalByTypeBd("RTN_REFUND", false);
+    }
+
+    /** Gets the total return amount (all return types) for COMPLETED and RECEIVED returns. */
+    public BigDecimal getOrderReturnedTotalBd() {
+        return getOrderReturnedTotalByTypeBd(null, false);
+    }
+
+    /**
+     * Gets the total returned over all return types.  Specify true to include all return statuses
+     * except cancelled.  Specify false to include only COMPLETED and RECEIVED returns.
+     */
+    public BigDecimal getOrderReturnedTotalBd(boolean includeAll) {
+        return getOrderReturnedTotalByTypeBd(null, includeAll);
     }
 
     public BigDecimal getOrderNonReturnedTaxAndShippingBd() {

Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnItems.bsh
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnItems.bsh?rev=431720&r1=431719&r2=431720&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnItems.bsh (original)
+++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnItems.bsh Tue Aug 15 15:36:04 2006
@@ -62,13 +62,13 @@
 }
 context.put("returnItemTypeMap", typeMap);
 
-orderId = request.getParameter("orderId");
 if (orderId != null) {
     order = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
     Map returnRes = dispatcher.runSync("getReturnableItems", UtilMisc.toMap("orderId", orderId));
     context.put("returnableItems", returnRes.get("returnableItems"));
 
    orh = new OrderReadHelper(order);
+   context.put("orh", orh);
    context.put("orderHeaderAdjustments", orh.getAvailableOrderHeaderAdjustments());
 
     // get the order shipping amount

Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnHeader.ftl
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnHeader.ftl?rev=431720&r1=431719&r2=431720&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnHeader.ftl (original)
+++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnHeader.ftl Tue Aug 15 15:36:04 2006
@@ -163,8 +163,7 @@
             <option value="${currentStatus.statusId}">---</option>
           </#if>
           <#list returnStatus as status>
-  ${status}
-            <option value="${status.statusIdTo}">${status.get("description",locale)}</option>
+            <option value="${status.statusIdTo}">${status.get("transitionName",locale)}</option>
           </#list>
         </select>
       </td>

Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl?rev=431720&r1=431719&r2=431720&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl (original)
+++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl Tue Aug 15 15:36:04 2006
@@ -24,6 +24,26 @@
                 <input type="checkbox" name="selectAll" value="Y" onclick="javascript:toggleAll(this, '${selectAllFormName}');"/>
               </td>
             </tr>
+
+            <#-- information about orders and amount refunded/credited on past returns -->
+            <#if orh?exists>
+            <tr><td colspan="10">
+                <table border='0' width='100%' cellpadding='2' cellspacing='0'>
+                  <tr>
+                    <td class="tabletext" width="25%">${uiLabelMap.OrderOrderTotal}</td>
+                    <td class="tabletext"><@ofbizCurrency amount=orh.getOrderGrandTotal() isoCode=orh.getCurrency()/></td>
+                  </tr>  
+                  <tr>
+                    <td class="tabletext" width="25%">${uiLabelMap.OrderAmountAlreadyCredited}</td>
+                    <td class="tabletext"><@ofbizCurrency amount=orh.getOrderReturnedCreditTotalBd() isoCode=orh.getCurrency()/></td>
+                  </tr>  
+                  <tr>
+                    <td class="tabletext" width="25%">${uiLabelMap.OrderAmountAlreadyRefunded}</td>
+                    <td class="tabletext"><@ofbizCurrency amount=orh.getOrderReturnedRefundTotalBd() isoCode=orh.getCurrency()/></td>
+                  </tr>  
+                </table>  
+            </td></tr>
+            </#if>
             <tr>
               <td><div class="tableheadtext">${uiLabelMap.CommonDescription}</div></td>
               <td><div class="tableheadtext">${uiLabelMap.OrderOrderQty}</div></td>

Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItems.ftl
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItems.ftl?rev=431720&r1=431719&r2=431720&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItems.ftl (original)
+++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItems.ftl Tue Aug 15 15:36:04 2006
@@ -76,6 +76,26 @@
   <#assign readOnly = (returnHeader.statusId != "RETURN_REQUESTED")>
     
   <tr><td colspan="10"><div class="head3">${uiLabelMap.OrderItemsReturned} ${uiLabelMap.CommonIn} ${uiLabelMap.OrderOrderReturn} #${returnId}</div></td></tr>
+
+  <#-- information about orders and amount refunded/credited on past returns -->
+  <#if orh?exists>
+  <tr><td colspan="10">
+      <table border='0' width='100%' cellpadding='2' cellspacing='0'>
+        <tr>
+          <td class="tabletext" width="25%">${uiLabelMap.OrderOrderTotal}</td>
+          <td class="tabletext"><@ofbizCurrency amount=orh.getOrderGrandTotal() isoCode=orh.getCurrency()/></td>
+        </tr>  
+        <tr>
+          <td class="tabletext" width="25%">${uiLabelMap.OrderAmountAlreadyCredited}</td>
+          <td class="tabletext"><@ofbizCurrency amount=orh.getOrderReturnedCreditTotalBd() isoCode=orh.getCurrency()/></td>
+        </tr>  
+        <tr>
+          <td class="tabletext" width="25%">${uiLabelMap.OrderAmountAlreadyRefunded}</td>
+          <td class="tabletext"><@ofbizCurrency amount=orh.getOrderReturnedRefundTotalBd() isoCode=orh.getCurrency()/></td>
+        </tr>  
+      </table>  
+  </td></tr>
+  </#if>
   <tr><td colspan="10"><hr class="sepbar"></td></tr>
   <tr>
     <td><div class="tableheadtext">${uiLabelMap.OrderOrderItems}</div></td>