svn commit: r520120 - in /ofbiz/trunk/applications: order/config/ order/servicedef/ order/src/org/ofbiz/order/order/ order/webapp/ordermgr/WEB-INF/ order/webapp/ordermgr/order/ product/webapp/facility/WEB-INF/ product/webapp/facility/WEB-INF/actions/sh...

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

svn commit: r520120 - in /ofbiz/trunk/applications: order/config/ order/servicedef/ order/src/org/ofbiz/order/order/ order/webapp/ordermgr/WEB-INF/ order/webapp/ordermgr/order/ product/webapp/facility/WEB-INF/ product/webapp/facility/WEB-INF/actions/sh...

sichen
Author: sichen
Date: Mon Mar 19 15:18:20 2007
New Revision: 520120

URL: http://svn.apache.org/viewvc?view=rev&rev=520120
Log:
Completing purchase orders:
- Link from ReceiveInventoryAgainstPurchaseOrder and orderview (for approved purchase orders) screens calls completePurchaseOrder service group
- Unreceived order item quantities are cancelled and product requirements generated for those quantities
- Order item status set to completed (or cancelled, if total quantity was cancelled)
- checkOrderItemStatus service is called to make sure that the order status correctly reflects the item statuses

Small fixes to ReceiveInventoryAgainstPurchaseOrder screen:
- Adding a UPCA column
- Cancelled quantity in a separate column
- Using orderItem to calculate quantities instead of orderItemAndShipGroupAssoc, since the latter can have its quantity figure manipulated in some cases
- Formatting fixes and fix to possible NPE when an orderId is not passed

Modified:
    ofbiz/trunk/applications/order/config/OrderErrorUiLabels.properties
    ofbiz/trunk/applications/order/config/OrderUiLabels.properties
    ofbiz/trunk/applications/order/servicedef/services.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl
    ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml

Modified: ofbiz/trunk/applications/order/config/OrderErrorUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderErrorUiLabels.properties?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderErrorUiLabels.properties (original)
+++ ofbiz/trunk/applications/order/config/OrderErrorUiLabels.properties Mon Mar 19 15:18:20 2007
@@ -104,6 +104,8 @@
 OrderErrorNoValidOrderHeaderFoundForOrderId=ERROR : No valid order header found for orderId : ${orderId}
 OrderErrorOrderItemAndOrOrderHeaderDontExist=ERROR : OrderItem and/or OrderHeader don't exist
 OrderErrorOrderItemCantBeModified=ERROR : OrderItem can't be modified
+OrderErrorOrderIdNotFound=ERROR: Order with ID [${orderId}] not found
+OrderErrorOrderNotPurchaseOrder=Order ${orderId} is not a Purchase Order
 OrderErrorOrderTypeLookupFailed=ERROR : OrderType lookup failed :
 OrderErrorProcessingOfflinePayments=<li>Error processing offline payments.
 OrderErrorTheProductStoreIdCanOnlyBeNullForPurchaseOrders=ERROR: The productStoreId can only be null for purchase orders

Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.properties?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderUiLabels.properties (original)
+++ ofbiz/trunk/applications/order/config/OrderUiLabels.properties Mon Mar 19 15:18:20 2007
@@ -215,6 +215,7 @@
 OrderFindRequirements=Find Requirements
 OrderFindRequirementsForSupplier=Find Requirements For Supplier
 OrderFindReturn=Find Returns
+OrderForceCompletePurchaseOrder=Force Complete Purchase Order
 OrderGift=Gift?
 OrderGiftCard=Gift Card
 OrderGiftMessage=Gift Message

Modified: ofbiz/trunk/applications/order/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services.xml Mon Mar 19 15:18:20 2007
@@ -600,4 +600,27 @@
         <attribute type="String" mode="OUT" name="orderPaymentPreferenceId"/>
     </service>
     
+    <service name="completePurchaseOrder" engine="group" auth="true">
+        <description>Completes a purchase order by cancelling remaining (unreceived) item quantities and generating new product requirements
+            from those quantities</description>
+        <group>
+            <invoke name="cancelRemainingPurchaseOrderItems" result-to-context="true"/>
+            <invoke name="generateReqsFromCancelledPOItems" result-to-context="true"/>
+            <invoke name="checkOrderItemStatus" result-to-context="true"/>
+        </group>
+    </service>
+
+    <service name="cancelRemainingPurchaseOrderItems" engine="java"
+            location="org.ofbiz.order.order.OrderServices" invoke="cancelRemainingPurchaseOrderItems" auth="true">
+        <description>Cancels remaining (unreceived) quantities for items of an order. Does not consider received-but-rejected quantities.</description>
+        <attribute name="orderId" type="String" mode="IN" optional="false"/>
+    </service>
+
+    <service name="generateReqsFromCancelledPOItems" engine="java"
+            location="org.ofbiz.order.order.OrderServices" invoke="generateReqsFromCancelledPOItems" auth="true">
+        <description>Generates a product requirement for the total cancelled quantity over all order items for each product</description>
+        <attribute name="orderId" type="String" mode="IN" optional="false"/>
+        <attribute name="facilityId" type="String" mode="IN" optional="false"/>
+    </service>
+
 </services>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Mon Mar 19 15:18:20 2007
@@ -3762,4 +3762,159 @@
         }
     }
 
+    /**
+     * Generates a product requirement for the total cancelled quantity over all order items for each product
+     * @param dctx
+     * @param context
+     * @return
+     */
+    public static Map generateReqsFromCancelledPOItems(DispatchContext dctx, Map context) {
+        GenericDelegator delegator = dctx.getDelegator();
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        Locale locale = (Locale) context.get("locale");
+        
+        String orderId = (String) context.get("orderId");
+        String facilityId = (String) context.get("facilityId");
+
+        try {
+
+            GenericValue orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
+            
+            if (UtilValidate.isEmpty(orderHeader)) {
+                String errorMessage = UtilProperties.getMessage(resource_error, "OrderErrorOrderIdNotFound", UtilMisc.toMap("orderId", orderId), locale);
+                Debug.logError(errorMessage, module);
+                return ServiceUtil.returnError(errorMessage);
+            }
+            
+            if (! "PURCHASE_ORDER".equals(orderHeader.getString("orderTypeId"))) {
+                String errorMessage = UtilProperties.getMessage(resource_error, "ProductErrorOrderNotPurchaseOrder", UtilMisc.toMap("orderId", orderId), locale);
+                Debug.logError(errorMessage, module);
+                return ServiceUtil.returnError(errorMessage);
+            }
+            
+            // Build a map of productId -> quantity cancelled over all order items
+            Map productRequirementQuantities = new HashMap();
+            List orderItems = orderHeader.getRelated("OrderItem");
+            Iterator oiit = orderItems.iterator();
+            while (oiit.hasNext()) {
+                GenericValue orderItem = (GenericValue) oiit.next();
+                if (! "PRODUCT_ORDER_ITEM".equals(orderItem.getString("orderItemTypeId"))) continue;
+                
+                // Get the cancelled quantity for the item
+                double orderItemCancelQuantity = 0;
+                if (! UtilValidate.isEmpty(orderItem.get("cancelQuantity")) ) {
+                    orderItemCancelQuantity = orderItem.getDouble("cancelQuantity").doubleValue();
+                }
+
+                if (orderItemCancelQuantity <= 0) continue;
+                
+                String productId = orderItem.getString("productId");
+                if (productRequirementQuantities.containsKey(productId)) {
+                    orderItemCancelQuantity += ((Double) productRequirementQuantities.get(productId)).doubleValue();
+                }
+                productRequirementQuantities.put(productId, new Double(orderItemCancelQuantity));
+                
+            }
+
+            // Generate requirements for each of the product quantities
+            Iterator cqit = productRequirementQuantities.keySet().iterator();
+            while (cqit.hasNext()) {
+                String productId = (String) cqit.next();
+                Double requiredQuantity = (Double) productRequirementQuantities.get(productId);
+                Map createRequirementResult = dispatcher.runSync("createRequirement", UtilMisc.toMap("requirementTypeId", "PRODUCT_REQUIREMENT", "facilityId", facilityId, "productId", productId, "quantity", requiredQuantity, "userLogin", userLogin));
+                if (ServiceUtil.isError(createRequirementResult)) return createRequirementResult;                
+            }
+            
+        } catch (GenericEntityException e) {
+            Debug.logError(e, module);
+            return ServiceUtil.returnError(e.getMessage());
+        } catch (GenericServiceException se) {
+            Debug.logError(se, module);
+            return ServiceUtil.returnError(se.getMessage());
+        }
+
+        return ServiceUtil.returnSuccess();
+    }
+
+    /**
+     * Cancels remaining (unreceived) quantities for items of an order. Does not consider received-but-rejected quantities.
+     * @param dctx
+     * @param context
+     * @return
+     */
+    public static Map cancelRemainingPurchaseOrderItems(DispatchContext dctx, Map context) {
+        GenericDelegator delegator = dctx.getDelegator();
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        Locale locale = (Locale) context.get("locale");
+        
+        String orderId = (String) context.get("orderId");
+
+        try {
+
+            GenericValue orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
+            
+            if (UtilValidate.isEmpty(orderHeader)) {
+                String errorMessage = UtilProperties.getMessage(resource_error, "OrderErrorOrderIdNotFound", UtilMisc.toMap("orderId", orderId), locale);
+                Debug.logError(errorMessage, module);
+                return ServiceUtil.returnError(errorMessage);
+            }
+            
+            if (! "PURCHASE_ORDER".equals(orderHeader.getString("orderTypeId"))) {
+                String errorMessage = UtilProperties.getMessage(resource_error, "OrderErrorOrderNotPurchaseOrder", UtilMisc.toMap("orderId", orderId), locale);
+                Debug.logError(errorMessage, module);
+                return ServiceUtil.returnError(errorMessage);
+            }
+            
+            List orderItems = orderHeader.getRelated("OrderItem");
+            Iterator oiit = orderItems.iterator();
+            while (oiit.hasNext()) {
+                GenericValue orderItem = (GenericValue) oiit.next();
+                if (! "PRODUCT_ORDER_ITEM".equals(orderItem.getString("orderItemTypeId"))) continue;
+                
+                // Get the ordered quantity for the item
+                double orderItemQuantity = 0;
+                if (! UtilValidate.isEmpty(orderItem.get("quantity"))) {
+                    orderItemQuantity = orderItem.getDouble("quantity").doubleValue();
+                }
+                double orderItemCancelQuantity = 0;
+                if (! UtilValidate.isEmpty(orderItem.get("cancelQuantity")) ) {
+                    orderItemCancelQuantity = orderItem.getDouble("cancelQuantity").doubleValue();
+                }
+
+                // Get the received quantity for the order item - ignore the quantityRejected, since rejected items should be reordered
+                List shipmentReceipts = orderItem.getRelated("ShipmentReceipt");
+                double receivedQuantity = 0;
+                Iterator srit = shipmentReceipts.iterator();
+                while (srit.hasNext()) {
+                    GenericValue shipmentReceipt = (GenericValue) srit.next();
+                    if (! UtilValidate.isEmpty(shipmentReceipt.get("quantityAccepted")) ) {
+                        receivedQuantity += shipmentReceipt.getDouble("quantityAccepted").doubleValue();
+                    }
+                }
+                
+                double quantityToCancel = orderItemQuantity - orderItemCancelQuantity - receivedQuantity;
+                if (quantityToCancel <= 0) continue;
+                
+                Map cancelOrderItemResult = dispatcher.runSync("cancelOrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "cancelQuantity", new Double(quantityToCancel), "userLogin", userLogin));
+                if (ServiceUtil.isError(cancelOrderItemResult)) return cancelOrderItemResult;      
+                
+                orderItem.refresh();
+                if ("ITEM_APPROVED".equals(orderItem.getString("statusId"))) {
+                    Map changeOrderItemStatusResult = dispatcher.runSync("changeOrderItemStatus", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "statusId", "ITEM_COMPLETED", "userLogin", userLogin));
+                    if (ServiceUtil.isError(changeOrderItemStatusResult)) return changeOrderItemStatusResult;      
+                }
+            }
+
+        } catch (GenericEntityException e) {
+            Debug.logError(e, module);
+            return ServiceUtil.returnError(e.getMessage());
+        } catch (GenericServiceException se) {
+            Debug.logError(se, module);
+            return ServiceUtil.returnError(se.getMessage());
+        }
+
+        return ServiceUtil.returnSuccess();
+    }
 }

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Mon Mar 19 15:18:20 2007
@@ -283,6 +283,12 @@
         <response name="success" type="request-redirect" value="orderview"/>
         <response name="error" type="request-redirect" value="orderview"/>
     </request-map>
+    <request-map uri="completePurchaseOrder">
+        <security https="true" auth="true"/>
+        <event type="service" path="" invoke="completePurchaseOrder"/>
+        <response name="success" type="view" value="orderview"/>
+        <response name="error" type="view" value="orderview"/>
+    </request-map>
     <request-map uri="editOrderItems">
         <security https="true" auth="true"/>
         <response name="success" type="view" value="editorderitems"/>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl Mon Mar 19 15:18:20 2007
@@ -296,6 +296,17 @@
                    </select>
                    <input type="submit" class="smallSubmit" value="${uiLabelMap.OrderQuickReceivePurchaseOrder}"/>
                  </form>
+                 <#if orderHeader.statusId != "ORDER_COMPLETED">
+                   <form action="<@ofbizUrl>completePurchaseOrder?externalLoginKey=${externalLoginKey}</@ofbizUrl>" method="POST">
+                     <input type="hidden" name="orderId" value="${orderId}"/>
+                     <select name="facilityId" class="selectBox">
+                       <#list facilities as facility>
+                         <option value="${facility.facilityId}">${facility.facilityName}</option>
+                       </#list>
+                     </select>
+                     <input type="submit" class="smallSubmit" value="${uiLabelMap.OrderForceCompletePurchaseOrder}"/>
+                   </form>
+                 </#if>
                  </#if>
                </#if>
              </div>

Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh Mon Mar 19 15:18:20 2007
@@ -28,7 +28,6 @@
 orderId = request.getParameter("purchaseOrderId");
 shipGroupSeqId = request.getParameter("shipGroupSeqId");
 context.put("shipmentId", shipmentId);
-context.put("orderId", orderId);
 context.put("shipGroupSeqId", shipGroupSeqId);
 
 // Retrieve the map resident in session which stores order item quantities to receive
@@ -69,6 +68,7 @@
 if (UtilValidate.isEmpty(shipGroupSeqId)) {
     shipGroupSeqId = shipment.get("primaryShipGroupSeqId");
 }
+context.put("orderId", orderId);
 
 if (UtilValidate.isEmpty(orderId)) {
     return;
@@ -120,20 +120,23 @@
 while (orderItemIter.hasNext()) {
     orderItemAndShipGroupAssoc = orderItemIter.next();
     product = orderItemAndShipGroupAssoc.getRelatedOne("Product");
+    
+    // Get the order item, since the orderItemAndShipGroupAssoc's quantity field is manipulated in some cases
+    orderItem = delegator.findByPrimaryKey("OrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemAndShipGroupAssoc.get("orderItemSeqId")));
     orderItemData = new HashMap();
 
     // Get the item's ordered quantity
     totalOrdered = 0;
-    ordered = orderItemAndShipGroupAssoc.getDouble("quantity");
+    ordered = orderItem.getDouble("quantity");
     if (ordered != null)
         totalOrdered += ordered.doubleValue();
-    cancelled = orderItemAndShipGroupAssoc.getDouble("cancelQuantity");
+    cancelled = orderItem.getDouble("cancelQuantity");
     if (cancelled != null)
         totalOrdered -= cancelled.doubleValue();
 
     // Get the item quantity received from all shipments via the ShipmentReciept entity
     totalReceived = 0.0;
-    receipts = delegator.findByAnd("ShipmentReceipt", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemAndShipGroupAssoc.get("orderItemSeqId")));
+    receipts = delegator.findByAnd("ShipmentReceipt", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId")));
     if (receipts != null && receipts.size() > 0) {
         recIter = receipts.iterator();
         while (recIter.hasNext()) {
@@ -152,7 +155,7 @@
         if (! UtilValidate.isEmpty(product)) {
             result = dispatcher.runSync("getProductCost", UtilMisc.toMap("productId", product.get("productId"), "currencyUomId", baseCurrencyUomId, "costComponentTypePrefix", "EST_STD", "userLogin", request.getAttribute("userLogin")));
             if (!ServiceUtil.isError(result)) {
-                orderItemAndShipGroupAssoc.put("unitPrice", result.get("productCost"));
+                orderItem.put("unitPrice", result.get("productCost"));
             }
         }
     }
@@ -174,9 +177,10 @@
     totalAvailableToReceive += availableToReceive;
     orderItemData.put("availableToReceive", availableToReceive);
     orderItemData.put("totalQuantityReceived", totalReceived);
-    orderItemData.put("orderItemAndShipGroupAssoc", orderItemAndShipGroupAssoc);
+    orderItemData.put("shipGroupSeqId", orderItemAndShipGroupAssoc.get("shipGroupSeqId"));
+    orderItemData.put("orderItem", orderItem);
     orderItemData.put("product", product);
-    orderItemDatas.put(orderItemAndShipGroupAssoc.getString("orderItemSeqId"), orderItemData);
+    orderItemDatas.put(orderItem.getString("orderItemSeqId"), orderItemData);
 }
 context.put("orderItemDatas", orderItemDatas.values());
 

Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml Mon Mar 19 15:18:20 2007
@@ -1013,6 +1013,12 @@
         <response name="success" type="view" value="ReceiveInventoryAgainstPurchaseOrder"/>
         <response name="error" type="view" value="ReceiveInventoryAgainstPurchaseOrder"/>
     </request-map>
+    <request-map uri="completePurchaseOrder">
+        <security https="true" auth="true"/>
+        <event type="service" path="" invoke="completePurchaseOrder"/>
+        <response name="success" type="view" value="ReceiveInventoryAgainstPurchaseOrder"/>
+        <response name="error" type="view" value="ReceiveInventoryAgainstPurchaseOrder"/>
+    </request-map>
     <!-- ================ Shipment Items From Order Requests ================= -->
     <request-map uri="EditShipmentPlan">
         <security https="true" auth="true"/>

Modified: ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl Mon Mar 19 15:18:20 2007
@@ -85,30 +85,49 @@
                 <table width="100%" cellpadding="2" cellspacing="0" border="1">
                     <tr>
                         <td><div class="tableheadtext">${uiLabelMap.ProductProduct}</div></td>
+                        
+                        <#-- Must use the uiLabelMap[""] notation since the label key has . in it -->
+                        <td><div class="tableheadtext">${uiLabelMap["GoodIdentificationType.description.UPCA"]}</div></td>
                         <td><div class="tableheadtext">${uiLabelMap.OrderOrder}</div></td>
+                        <td><div class="tableheadtext">${uiLabelMap.OrderCancelled}</div></td>
                         <td><div class="tableheadtext">${uiLabelMap.OrderBackOrdered}</div></td>
                         <td><div class="tableheadtext">${uiLabelMap.CommonReceived}</div></td>
                         <td><div class="tableheadtext">${uiLabelMap.ProductOpenQuantity}</div></td>
-                        <td><div class="tableheadtext">${uiLabelMap.CommonReceive}</div></td>
-                        <td><div class="tableheadtext">${uiLabelMap.ProductInventoryItemType}</div></td>
                         <#if itemsAvailableToReceive>
+                            <td><div class="tableheadtext">${uiLabelMap.CommonReceive}</div></td>
+                            <td><div class="tableheadtext">${uiLabelMap.ProductInventoryItemType}</div></td>
                             <td colspan="2" align="right">
                                 <div class="tableheadtext">${uiLabelMap.CommonAll}<input type="checkbox" name="selectAll" value="${uiLabelMap.CommonY}" onclick="javascript:toggleAll(this, 'selectAllForm');"></div>
                             </td>
                         </#if>
                     </tr>
                     <#list orderItemDatas?if_exists as orderItemData>
-                        <#assign orderItemAndShipGroupAssoc = orderItemData.orderItemAndShipGroupAssoc>
+                        <#assign orderItem = orderItemData.orderItem>
                         <#assign product = orderItemData.product?if_exists>
+                        <#assign itemShipGroupSeqId = orderItemData.shipGroupSeqId?if_exists>
                         <#assign totalQuantityReceived = orderItemData.totalQuantityReceived?default(0)>
                         <#assign availableToReceive = orderItemData.availableToReceive?default(0)>
                         <#assign backOrderedQuantity = orderItemData.backOrderedQuantity?default(0)>
                         
                         <tr>
-                            <td><div class="tabletext">${(product.internalName)?if_exists} [${orderItemAndShipGroupAssoc.productId?default("N/A")}]</div></td>
+                            <td><div class="tabletext">${(product.internalName)?if_exists} [${orderItem.productId?default("N/A")}]</div></td>
                             <td>
                                 <div class="tabletext">
-                                    ${orderItemAndShipGroupAssoc.quantity - orderItemAndShipGroupAssoc.cancelQuantity?default(0)}
+                                    <#assign upcaLookup = Static["org.ofbiz.base.util.UtilMisc"].toMap("productId", product.productId, "goodIdentificationTypeId", "UPCA")/>
+                                    <#assign upca = delegator.findByPrimaryKeyCache("GoodIdentification", upcaLookup)?if_exists/>
+                                    <#if upca?has_content>
+                                        ${upca.idValue?if_exists}
+                                    </#if>
+                                </div>
+                            </td>
+                            <td>
+                                <div class="tabletext">
+                                    ${orderItem.quantity}
+                                </div>
+                            </td>
+                            <td>
+                                <div class="tabletext">
+                                    ${orderItem.cancelQuantity?default(0)}
                                 </div>
                             </td>
                             <td>
@@ -121,7 +140,7 @@
                             </td>
                             <td>
                                 <div class="tabletext">
-                                    ${orderItemAndShipGroupAssoc.quantity - totalQuantityReceived}
+                                    ${orderItem.quantity - orderItem.cancelQuantity?default(0) - totalQuantityReceived}
                                 </div>
                             </td>
                             <#if availableToReceive &gt; 0 >
@@ -129,18 +148,18 @@
                                     <input type="hidden" name="productId_o_${rowCount}" value="${(product.productId)?if_exists}"/>
                                     <input type="hidden" name="facilityId_o_${rowCount}" value="${facilityId}"/>
                                     <input type="hidden" name="shipmentId_o_${rowCount}" value="${shipmentId}"/>
-                                    <input type="hidden" name="orderId_o_${rowCount}" value="${orderItemAndShipGroupAssoc.orderId}"/>
-                                    <input type="hidden" name="shipGroupSeqId_o_${rowCount}" value="${orderItemAndShipGroupAssoc.shipGroupSeqId}"/>
-                                    <input type="hidden" name="orderItemSeqId_o_${rowCount}" value="${orderItemAndShipGroupAssoc.orderItemSeqId}"/>
-                                    <input type="hidden" name="unitCost_o_${rowCount}" value="${orderItemAndShipGroupAssoc.unitPrice?default(0)}"/>
+                                    <input type="hidden" name="orderId_o_${rowCount}" value="${orderItem.orderId}"/>
+                                    <input type="hidden" name="shipGroupSeqId_o_${rowCount}" value="${itemShipGroupSeqId?if_exists}"/>
+                                    <input type="hidden" name="orderItemSeqId_o_${rowCount}" value="${orderItem.orderItemSeqId}"/>
+                                    <input type="hidden" name="unitCost_o_${rowCount}" value="${orderItem.unitPrice?default(0)}"/>
                                     <input type="hidden" name="currencyUomId_o_${rowCount}" value="${currencyUomId?default("")}"/>
                                     <input type="hidden" name="ownerPartyId_o_${rowCount}" value="${(facility.ownerPartyId)?if_exists}"/>
                                     <input type="hidden" name="datetimeReceived_o_${rowCount}" value="${now}"/>
                                     <input type="hidden" name="quantityRejected_o_${rowCount}" value="0"/>
                                     <#-- quantity field required by the chained issueOrderItemToShipment service -->
                                     <input type="hidden" name="quantity_o_${rowCount}" id="quantity_o_${rowCount}" value=""/>
-                                    <#if itemQuantitiesToReceive?exists && itemQuantitiesToReceive.get(orderItemAndShipGroupAssoc.orderItemSeqId)?exists>
-                                        <#assign quantityToReceive = itemQuantitiesToReceive.get(orderItemAndShipGroupAssoc.orderItemSeqId)>
+                                    <#if itemQuantitiesToReceive?exists && itemQuantitiesToReceive.get(orderItem.orderItemSeqId)?exists>
+                                        <#assign quantityToReceive = itemQuantitiesToReceive.get(orderItem.orderItemSeqId)>
                                     <#else>
                                         <#assign quantityToReceive = 0>
                                     </#if>
@@ -170,11 +189,16 @@
                     </#list>
                     <#if itemsAvailableToReceive>
                         <tr>
-                            <td colspan="8" align="right">
+                            <td colspan="10" align="right">
                                 <a href="<@ofbizUrl>ReceiveInventoryAgainstPurchaseOrder?shipmentId=${shipmentId}&purchaseOrderId=${orderId}&clearAll=Y</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonClearAll}</a>
                             </td>
                             <td align="right">
                                 <a class="smallSubmit" href="javascript:populateQuantities(${rowCount - 1});document.selectAllForm.submit();">${uiLabelMap.ProductReceiveItem}</a>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td colspan="11" align="right">
+                                <a class="smallSubmit" href="<@ofbizUrl>completePurchaseOrder?orderId=${orderId}&facilityId=${facilityId}&shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.OrderForceCompletePurchaseOrder}</a>
                             </td>
                         </tr>
                     </#if>

Modified: ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml?view=diff&rev=520120&r1=520119&r2=520120
==============================================================================
--- ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml Mon Mar 19 15:18:20 2007
@@ -323,6 +323,7 @@
     <screen name="ReceiveInventoryAgainstPurchaseOrder">
         <section>
             <actions>
+                <property-map resource="ProductEntityLabels" map-name="uiLabelMap" global="true"/>
                 <set field="titleProperty" value="ProductReceiveInventoryAgainstPurchaseOrder"/>
                 <set field="headerItem" value="shipment"/>
                 <set field="tabButtonItem" value="ProductReceiveInventoryAgainstPO"/>