svn commit: r791105 - in /ofbiz/trunk/applications/order/webapp/ordermgr/order: editorderitems.ftl orderitems.ftl

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

svn commit: r791105 - in /ofbiz/trunk/applications/order/webapp/ordermgr/order: editorderitems.ftl orderitems.ftl

mor-2
Author: mor
Date: Sat Jul  4 11:19:04 2009
New Revision: 791105

URL: http://svn.apache.org/viewvc?rev=791105&view=rev
Log:
Remaining and Outstanding quantity on Order detail page and edit order page were wrong.
Fix provided by Dives Dutta, part of OFBIZ-2689 (https://issues.apache.org/jira/browse/OFBIZ-2689)

Modified:
    ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl
    ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl?rev=791105&r1=791104&r2=791105&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl Sat Jul  4 11:19:04 2009
@@ -145,7 +145,26 @@
                                   </#if>
                               </td>
                               <td class="align-text" valign="top" nowrap="nowrap">
-                                  <#assign remainingQuantity = (orderItem.quantity?default(0) - orderItem.cancelQuantity?default(0))>
+                                <#assign shippedQuantity = orderReadHelper.getItemShippedQuantity(orderItem)>
+                                <#assign shipmentReceipts = delegator.findByAnd("ShipmentReceipt", {"orderId" : orderHeader.getString("orderId"), "orderItemSeqId" : orderItem.orderItemSeqId})/>
+                                <#assign totalReceived = 0.0>
+                                <#if shipmentReceipts?exists && shipmentReceipts?has_content>
+                                  <#list shipmentReceipts as shipmentReceipt>
+                                    <#if shipmentReceipt.quantityAccepted?exists && shipmentReceipt.quantityAccepted?has_content>
+                                      <#assign  quantityAccepted = shipmentReceipt.quantityAccepted>
+                                      <#assign totalReceived = quantityAccepted + totalReceived>
+                                    </#if>
+                                    <#if shipmentReceipt.quantityRejected?exists && shipmentReceipt.quantityRejected?has_content>
+                                      <#assign  quantityRejected = shipmentReceipt.quantityRejected>
+                                      <#assign totalReceived = quantityRejected + totalReceived>
+                                    </#if>
+                                  </#list>
+                                </#if>
+                                <#if orderHeader.orderTypeId == "PURCHASE_ORDER">
+                                  <#assign remainingQuantity = ((orderItem.quantity?default(0) - orderItem.cancelQuantity?default(0)) - totalReceived?double)>
+                                <#else>
+                                  <#assign remainingQuantity = ((orderItem.quantity?default(0) - orderItem.cancelQuantity?default(0)) - shippedQuantity?double)>
+                                </#if>
                                   ${uiLabelMap.OrderOrdered}&nbsp;${orderItem.quantity?default(0)?string.number}&nbsp;&nbsp;<br/>
                                   ${uiLabelMap.OrderCancelled}:&nbsp;${orderItem.cancelQuantity?default(0)?string.number}&nbsp;&nbsp;<br/>
                                   ${uiLabelMap.OrderRemaining}:&nbsp;${remainingQuantity}&nbsp;&nbsp;<br/>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl?rev=791105&r1=791104&r2=791105&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl Sat Jul  4 11:19:04 2009
@@ -145,7 +145,25 @@
                     <table>
                       <tr valign="top">
                         <#assign shippedQuantity = orderReadHelper.getItemShippedQuantity(orderItem)>
-                        <#assign remainingQuantity = (orderItem.quantity?default(0) - orderItem.cancelQuantity?default(0) - shippedQuantity)>
+                        <#assign shipmentReceipts = delegator.findByAnd("ShipmentReceipt", {"orderId" : orderHeader.getString("orderId"), "orderItemSeqId" : orderItem.orderItemSeqId})/>
+                        <#assign totalReceived = 0.0>
+                        <#if shipmentReceipts?exists && shipmentReceipts?has_content>
+                          <#list shipmentReceipts as shipmentReceipt>
+                            <#if shipmentReceipt.quantityAccepted?exists && shipmentReceipt.quantityAccepted?has_content>
+                              <#assign  quantityAccepted = shipmentReceipt.quantityAccepted>
+                              <#assign totalReceived = quantityAccepted + totalReceived>
+                            </#if>
+                            <#if shipmentReceipt.quantityRejected?exists && shipmentReceipt.quantityRejected?has_content>
+                              <#assign  quantityRejected = shipmentReceipt.quantityRejected>
+                              <#assign totalReceived = quantityRejected + totalReceived>
+                            </#if>
+                          </#list>
+                        </#if>
+                        <#if orderHeader.orderTypeId == "PURCHASE_ORDER">
+                            <#assign remainingQuantity = ((orderItem.quantity?default(0) - orderItem.cancelQuantity?default(0)) - totalReceived?double)>
+                        <#else>
+                            <#assign remainingQuantity = ((orderItem.quantity?default(0) - orderItem.cancelQuantity?default(0)) - shippedQuantity?double)>
+                        </#if>
                         <#-- to compute shortfall amount, sum up the orderItemShipGrpInvRes.quantityNotAvailable -->
                         <#assign shortfalledQuantity = 0/>
                         <#list orderItemShipGrpInvResList as orderItemShipGrpInvRes>
@@ -188,7 +206,10 @@
                           <#-- Make sure digital goods without shipments don't always remainn "outstanding": if item is completed, it must have no outstanding quantity.  -->
                           <#if (orderItem.statusId != null) && (orderItem.statusId == "ITEM_COMPLETED")>
                           0
-                          <#else>${orderItem.quantity?default(0) - orderItem.cancelQuantity?default(0) - shippedQuantity}
+                          <#elseif orderHeader.orderTypeId == "PURCHASE_ORDER">
+                            ${(orderItem.quantity?default(0) - orderItem.cancelQuantity?default(0)) - totalReceived?double}
+                          <#elseif orderHeader.orderTypeId == "SALES_ORDER">
+                            ${(orderItem.quantity?default(0) - orderItem.cancelQuantity?default(0)) - shippedQuantity?double}
                           </#if>
                           </td>
                        </tr>