Author: jacopoc
Date: Sat Jan  2 18:20:19 2010
New Revision: 895250

URL: http://svn.apache.org/viewvc?rev=895250&view=rev
Log:
Pretty important change in the way purchase shipments and 
purchase-order-to-shipment mapping are modeled:
* OrderShipment entity (that was mostly unused) has been enhanced to properly 
associate order items (OrderItemShipGrpAssoc) to shipment items: this entity is 
now used in place of ItemIssuance (that was improperly used, in po, for the 
same purpose)
* as a consequence of the above change, I have updated the purchase order 
receive screens and business logic triggered by them

Modified:
    ofbiz/trunk/applications/order/entitydef/entitymodel.xml
    ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml
    
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml
    
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
    
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
    ofbiz/trunk/applications/product/servicedef/services_shipment.xml
    
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/ReceiveInventory.groovy
    
ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl
    ofbiz/trunk/applications/product/webapp/facility/shipment/ShipmentTabBar.ftl
    ofbiz/trunk/applications/product/widget/facility/ShipmentForms.xml
    ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml

Modified: ofbiz/trunk/applications/order/entitydef/entitymodel.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel.xml?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/order/entitydef/entitymodel.xml Sat Jan  2 
18:20:19 2010
@@ -1131,11 +1131,13 @@
             title="Order Shipment Entity">
       <field name="orderId" type="id-ne"></field>
       <field name="orderItemSeqId" type="id-ne"></field>
+      <field name="shipGroupSeqId" type="id-ne"></field>
       <field name="shipmentId" type="id-ne"></field>
       <field name="shipmentItemSeqId" type="id-ne"></field>
       <field name="quantity" type="fixed-point"></field>
       <prim-key field="orderId"/>
       <prim-key field="orderItemSeqId"/>
+      <prim-key field="shipGroupSeqId"/>
       <prim-key field="shipmentId"/>
       <prim-key field="shipmentItemSeqId"/>
       <relation type="one" fk-name="ORDER_SHPMT_OHDR" 
rel-entity-name="OrderHeader">
@@ -1152,6 +1154,11 @@
         <key-map field-name="shipmentId"/>
         <key-map field-name="shipmentItemSeqId"/>
       </relation>
+      <relation type="one-nofk" rel-entity-name="OrderItemShipGroupAssoc">
+        <key-map field-name="orderId"/>
+        <key-map field-name="orderItemSeqId"/>
+        <key-map field-name="shipGroupSeqId"/>
+      </relation>
     </entity>
     <entity entity-name="OrderStatus"
             package-name="org.ofbiz.order.order"

Modified: ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml 
(original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml Sat Jan 
 2 18:20:19 2010
@@ -332,6 +332,7 @@
       <field name="inventoryItemId" type="id"></field>
       <field name="productId" type="id"></field>
       <field name="shipmentId" type="id"></field>
+      <field name="shipmentItemSeqId" type="id"></field>
       <field name="shipmentPackageSeqId" type="id"></field>
       <field name="orderId" type="id"></field>
       <field name="orderItemSeqId" type="id"></field>
@@ -370,6 +371,10 @@
       <relation type="one-nofk" fk-name="SHP_RCPT_SHIPMT" 
rel-entity-name="Shipment">
         <key-map field-name="shipmentId"/>
       </relation>
+        <relation type="one-nofk" fk-name="SHP_RCPT_SHIPIT" 
rel-entity-name="ShipmentItem">
+          <key-map field-name="shipmentId"/>
+          <key-map field-name="shipmentItemSeqId"/>
+        </relation>
       <relation type="one" fk-name="SHP_RCPT_RETINVITM" 
rel-entity-name="ReturnItem">
         <key-map field-name="returnId"/>
         <key-map field-name="returnItemSeqId"/>

Modified: 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml
 (original)
+++ 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml
 Sat Jan  2 18:20:19 2010
@@ -128,8 +128,11 @@
         <entity-one entity-name="Shipment" value-field="shipment" 
auto-field-map="true"/>
 
         <call-simple-method method-name="findCreateIssueShipmentItem"/>
+        <!--
+            TODO: if we want to record the role of the facility operation we 
have to re-implement this using ShipmentReceiptRole
         <call-simple-method method-name="findCreateItemIssuance"/>
         <call-simple-method method-name="associateIssueRoles"/>
+        -->
     </simple-method>
 
     <simple-method method-name="issueOrderItemShipGrpInvResToShipment" 
short-description="Issue OrderItemShipGrpInvRes to Shipment">
@@ -308,6 +311,19 @@
             <store-value value-field="shipmentItem"/>
         </else>
         </if-empty>
+        <set from-field="parameters.shipmentId" 
field="orderShipmentCreate.shipmentId"/>
+        <set from-field="shipmentItem.shipmentItemSeqId" 
field="orderShipmentCreate.shipmentItemSeqId"/>
+        <set from-field="orderItem.orderId" 
field="orderShipmentCreate.orderId"/>
+        <set from-field="orderItem.orderItemSeqId" 
field="orderShipmentCreate.orderItemSeqId"/>
+        <if-not-empty field="orderItemShipGroupAssoc">
+            <set from-field="orderItemShipGroupAssoc.shipGroupSeqId" 
field="orderShipmentCreate.shipGroupSeqId"/>
+        </if-not-empty>
+        <if-not-empty field="orderItemShipGrpInvRes">
+            <set from-field="orderItemShipGrpInvRes.shipGroupSeqId" 
field="orderShipmentCreate.shipGroupSeqId"/>
+        </if-not-empty>
+        <set from-field="parameters.quantity" 
field="orderShipmentCreate.quantity"/>
+        <call-service service-name="createOrderShipment" 
in-map-name="orderShipmentCreate"/>
+
         <field-to-result field="shipmentItem.shipmentItemSeqId" 
result-name="shipmentItemSeqId"/>
     </simple-method>
     <simple-method method-name="findCreateItemIssuance" 
short-description="Find Create ItemIssuance - meant to be called in-line">
@@ -588,14 +604,26 @@
         </calculate>
         <call-service service-name="createInventoryItemDetail" 
in-map-name="createDetailMap"/>
     </simple-method>
-    <simple-method method-name="getTotalIssuedQuantityForOrderItem" 
short-description="Computes the total issued quantity for an order item">
+    <simple-method method-name="getTotalIssuedQuantityForOrderItem" 
short-description="Computes the total quantity assigned to shipment for a 
purchase order item">
         <set field="totalIssuedQuantity" type="BigDecimal" value="0"/>
-        <entity-and list="allItemIssuances" entity-name="ItemIssuance">
+        <entity-and list="orderShipments" entity-name="OrderShipment">
             <field-map field-name="orderId" from-field="orderItem.orderId"/>
             <field-map field-name="orderItemSeqId" 
from-field="orderItem.orderItemSeqId"/>
         </entity-and>
-        <iterate entry="itemIssuance" list="allItemIssuances">
-            <set field="totalIssuedQuantity" 
value="${totalIssuedQuantity$bigDecimal + itemIssuance.quantity$bigDecimal}" 
type="BigDecimal"/>
-        </iterate>
+        <if-not-empty field="orderShipments">
+                <iterate entry="orderShipment" list="orderShipments">
+                    <set field="totalIssuedQuantity" 
value="${totalIssuedQuantity$bigDecimal + orderShipment.quantity$bigDecimal}" 
type="BigDecimal"/>
+                </iterate>
+            <else>
+                <!-- This is here for backward compatibility only: 
ItemIssuances are no more created for purchase orders -->
+                <entity-and list="allItemIssuances" entity-name="ItemIssuance">
+                    <field-map field-name="orderId" 
from-field="orderItem.orderId"/>
+                    <field-map field-name="orderItemSeqId" 
from-field="orderItem.orderItemSeqId"/>
+                </entity-and>
+                <iterate entry="itemIssuance" list="allItemIssuances">
+                    <set field="totalIssuedQuantity" 
value="${totalIssuedQuantity$bigDecimal + itemIssuance.quantity$bigDecimal}" 
type="BigDecimal"/>
+                </iterate>
+            </else>
+        </if-not-empty>
     </simple-method>
 </simple-methods>

Modified: 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
 (original)
+++ 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
 Sat Jan  2 18:20:19 2010
@@ -355,53 +355,48 @@
             <set from-field="parameters.shipmentId" 
field="shipmentItemLookupPk.shipmentId"/>
             <find-by-primary-key entity-name="ShipmentItem" 
map="shipmentItemLookupPk" value-field="shipmentItem"/>
             
-            <!-- Create ItemIssuance for this ShipmentItem -->
-            <set from-field="parameters.quantity" 
field="itemIssuanceCreate.quantity"/>
-            <set from-field="shipmentItem.shipmentId" 
field="itemIssuanceCreate.shipmentId"/>
-            <set from-field="shipmentItem.shipmentItemSeqId" 
field="itemIssuanceCreate.shipmentItemSeqId"/>
-            <set from-field="orderItem.orderId" 
field="itemIssuanceCreate.orderId"/>
-            <set from-field="orderItem.orderItemSeqId" 
field="itemIssuanceCreate.orderItemSeqId"/>
+            <!-- Create OrderShipment for this ShipmentItem -->
+            <set from-field="parameters.quantity" 
field="orderShipmentCreate.quantity"/>
+            <set from-field="shipmentItem.shipmentId" 
field="orderShipmentCreate.shipmentId"/>
+            <set from-field="shipmentItem.shipmentItemSeqId" 
field="orderShipmentCreate.shipmentItemSeqId"/>
+            <set from-field="orderItem.orderId" 
field="orderShipmentCreate.orderId"/>
+            <set from-field="orderItem.orderItemSeqId" 
field="orderShipmentCreate.orderItemSeqId"/>
             
             <if-not-empty field="orderItemShipGroupAssoc">
                 <!-- If we have a ShipGroup Assoc for this Item to focus on, 
set that; this is mostly the case for purchase orders and such -->
-                <set from-field="orderItemShipGroupAssoc.shipGroupSeqId" 
field="itemIssuanceCreate.shipGroupSeqId"/>
+                <set from-field="orderItemShipGroupAssoc.shipGroupSeqId" 
field="orderShipmentCreate.shipGroupSeqId"/>
             </if-not-empty>
-
-            <set from-field="userLogin.userLoginId" 
field="itemIssuanceCreate.issuedByUserLoginId"/>
-            <call-service service-name="createItemIssuance" 
in-map-name="itemIssuanceCreate">
-                <result-to-field result-name="itemIssuanceId"/>
-            </call-service>
+            <call-service service-name="createOrderShipment" 
in-map-name="orderShipmentCreate"/>
         <else>
             <call-simple-method 
method-name="getTotalIssuedQuantityForOrderItem" 
xml-resource="component://product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml"/>
             <call-simple-method method-name="getReceivedQuantityForOrderItem"/>
             <set field="receivedQuantity" value="${receivedQuantity$bigDecimal 
+ parameters.quantity$bigDecimal}" type="BigDecimal"/>
-            <entity-and list="itemIssuances" entity-name="ItemIssuance">
+            <entity-and list="orderShipments" entity-name="OrderShipment">
                 <field-map field-name="orderId" 
from-field="orderItem.orderId"/>
                 <field-map field-name="orderItemSeqId" 
from-field="orderItem.orderItemSeqId"/>
                 <field-map field-name="shipmentId" 
from-field="shipmentItem.shipmentId"/>
                 <field-map field-name="shipmentItemSeqId" 
from-field="shipmentItem.shipmentItemSeqId"/>
                 <field-map field-name="shipGroupSeqId" 
from-field="orderItemShipGroupAssoc.shipGroupSeqId"/>
-                <order-by field-name="-issuedDateTime"/>
             </entity-and>
-            <first-from-list entry="itemIssuance" list="itemIssuances"/>
-            <set field="itemIssuanceId" 
from-field="itemIssuance.itemIssuanceId"/>
+            <first-from-list entry="orderShipment" list="orderShipments"/>
             <if-compare-field field="totalIssuedQuantity" operator="less" 
to-field="receivedQuantity" type="BigDecimal">
                 <set field="quantityToAdd" 
value="${receivedQuantity$bigDecimal - totalIssuedQuantity$bigDecimal}" 
type="BigDecimal"/>
                 <set field="shipmentItem.quantity" 
value="${shipmentItem.quantity$bigDecimal + quantityToAdd$bigDecimal}" 
type="BigDecimal"/>
                 <store-value value-field="shipmentItem"/>
                 <set field="shipmentItemSeqId" 
from-field="shipmentItem.shipmentItemSeqId"/>
                 
-                <set field="itemIssuance.quantity" 
value="${itemIssuance.quantity$bigDecimal + quantityToAdd$bigDecimal}" 
type="BigDecimal"/>
-                <store-value value-field="itemIssuance"/>
+                <set field="orderShipment.quantity" 
value="${orderShipment.quantity$bigDecimal + quantityToAdd$bigDecimal}" 
type="BigDecimal"/>
+                <store-value value-field="orderShipment"/>
             </if-compare-field>
         </else>
         </if-empty>
-
+        <!--
+            TODO: if we want to record the role of the facility operation we 
have to re-implement this using ShipmentReceiptRole
         <call-simple-method method-name="associateIssueRoles" 
xml-resource="component://product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml"/>
+        -->
 
         <set-service-fields service-name="receiveInventoryProduct" 
map="parameters" to-map="receiveInventoryProductCtx"/>
         <set field="receiveInventoryProductCtx.shipmentItemSeqId" 
from-field="shipmentItemSeqId"/>
-        <set field="receiveInventoryProductCtx.itemIssuanceId" 
from-field="itemIssuanceId"/>
         <call-service service-name="receiveInventoryProduct" 
in-map-name="receiveInventoryProductCtx">
             <result-to-result result-name="inventoryItemId"/>
         </call-service>
@@ -457,19 +452,20 @@
                     <set field="shipmentItem.quantity" 
value="${shipmentItem.quantity$bigDecimal + quantityToAdd$bigDecimal}" 
type="BigDecimal"/>
                     <store-value value-field="shipmentItem"/>
                     
-                    <entity-and list="itemIssuances" 
entity-name="ItemIssuance">
+                    <entity-and list="orderShipments" 
entity-name="OrderShipment">
                         <field-map field-name="orderId" 
from-field="parameters.orderId"/>
                         <field-map field-name="orderItemSeqId" 
from-field="parameters.orderItemSeqId"/>
                         <field-map field-name="shipmentId" 
from-field="parameters.shipmentId"/>
                         <field-map field-name="shipmentItemSeqId" 
from-field="shipmentItem.shipmentItemSeqId"/>
-                        <order-by field-name="-issuedDateTime"/>
                     </entity-and>
-                    <first-from-list entry="itemIssuance" 
list="itemIssuances"/>
-                    <set field="itemIssuance.quantity" 
value="${itemIssuance.quantity$bigDecimal + quantityToAdd$bigDecimal}" 
type="BigDecimal"/>
-                    <store-value value-field="itemIssuance"/>
-                    
+                    <first-from-list entry="orderShipment" 
list="orderShipments"/>
+                    <set field="orderShipment.quantity" 
value="${orderShipment.quantity$bigDecimal + quantityToAdd$bigDecimal}" 
type="BigDecimal"/>
+                    <store-value value-field="orderShipment"/>
+                    <!--
+                        TODO: if we want to record the role of the facility 
operation we have to re-implement this using ShipmentReceiptRole
                     <set field="itemIssuanceId" 
from-field="itemIssuance.itemIssuanceId"/>
                     <call-simple-method method-name="associateIssueRoles" 
xml-resource="component://product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml"/>
+                    -->
                 </if-compare-field>
             </if-not-empty>
         </if-not-empty>

Modified: 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
 (original)
+++ 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
 Sat Jan  2 18:20:19 2010
@@ -1937,6 +1937,7 @@
         <set from-field="parameters.shipmentItemSeqId" 
field="inMap.shipmentItemSeqId"/>
         <set from-field="parameters.orderId" field="inMap.orderId"/>
         <set from-field="parameters.orderItemSeqId" 
field="inMap.orderItemSeqId"/>
+        <set from-field="parameters.shipGroupSeqId" 
field="inMap.shipGroupSeqId"/>
         <call-service service-name="deleteOrderShipment" in-map-name="inMap"/>
 
         <calculate field="shipmentItem.quantity">
@@ -1979,11 +1980,6 @@
             <set-pk-fields value-field="orderHeaderLookupPk" map="parameters"/>
             <find-by-primary-key map="orderHeaderLookupPk" 
value-field="orderHeader"/>
 
-            <!-- make sure the order is of orderTypeId: SALES_ORDER -->
-            <if-compare field="orderHeader.orderTypeId" operator="not-equals" 
value="SALES_ORDER">
-                <string-to-list string="Not adding Order Item to plan for 
shipment [${parameters.shipmentId}] because the order is not a Sales Order for 
order [${parameters.orderId}] order item [${parameters.orderItemSeqId}]" 
list="error_list"/>
-            </if-compare>
-
             <!-- get orderItem -->
             <make-value entity-name="OrderItem" 
value-field="orderItemLookupPk"/>
             <set-pk-fields value-field="orderItemLookupPk" map="parameters"/>

Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Sat Jan  
2 18:20:19 2010
@@ -395,7 +395,6 @@
         <auto-attributes entity-name="OrderItemShipGroupAssoc" include="pk" 
mode="IN" optional="false"/>
         <attribute name="quantity" type="BigDecimal" mode="IN" 
optional="false"/>
         <attribute name="shipmentItemSeqId" type="String" mode="OUT" 
optional="false"/>
-        <attribute name="itemIssuanceId" type="String" mode="OUT" 
optional="false"/>
     </service>
     <service name="issueOrderItemShipGrpInvResToShipment" engine="simple"
             
location="component://product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml"
 invoke="issueOrderItemShipGrpInvResToShipment" auth="true">

Modified: 
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/ReceiveInventory.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/ReceiveInventory.groovy?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/ReceiveInventory.groovy
 (original)
+++ 
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/ReceiveInventory.groovy
 Sat Jan  2 18:20:19 2010
@@ -62,6 +62,19 @@
 
 shipments = null;
 if (purchaseOrder && !shipmentId) {
+    orderShipments = delegator.findList("OrderShipment", 
EntityCondition.makeCondition([orderId : purchaseOrderId]), null, null, null, 
false);
+    if (orderShipments) {
+        shipments = [] as TreeSet;
+        orderShipments.each { orderShipment ->
+            shipment = orderShipment.getRelatedOne("Shipment");
+            if (!"PURCH_SHIP_RECEIVED".equals(shipment.statusId) &&
+                !"SHIPMENT_CANCELLED".equals(shipment.statusId) &&
+                (!shipment.destinationFacilityId || 
facilityId.equals(shipment.destinationFacilityId))) {
+                shipments.add(shipment);
+            }
+        }
+    }
+    // This is here for backward compatibility: ItemIssuances are no more 
created for purchase shipments.
     issuances = delegator.findList("ItemIssuance", 
EntityCondition.makeCondition([orderId : purchaseOrderId]), null, null, null, 
false);
     if (issuances) {
         shipments = [] as TreeSet;
@@ -88,15 +101,28 @@
         purchaseOrderItems = purchaseOrder.getRelated("OrderItem", [productId 
: productId], null);
     } else if (shipment) {
         orderItems = purchaseOrder.getRelated("OrderItem");
-        issuances = shipment.getRelated("ItemIssuance", [orderId : 
purchaseOrderId], null);
         exprs = [] as ArrayList;
-        issuances.each { issuance ->
-            exprs.add(EntityCondition.makeCondition("orderItemSeqId", 
EntityOperator.EQUALS, issuance.orderItemSeqId));
-            double issuanceQty = issuance.getDouble("quantity").doubleValue();
-            if (shippedQuantities.containsKey(issuance.orderItemSeqId)) {
-                issuanceQty += 
((Double)shippedQuantities.get(issuance.orderItemSeqId)).doubleValue();
+        orderShipments = shipment.getRelated("OrderShipment", [orderId : 
purchaseOrderId], null);
+        if (orderShipments) {
+            orderShipments.each { orderShipment ->
+                exprs.add(EntityCondition.makeCondition("orderItemSeqId", 
EntityOperator.EQUALS, orderShipment.orderItemSeqId));
+                double orderShipmentQty = 
orderShipment.getDouble("quantity").doubleValue();
+                if 
(shippedQuantities.containsKey(orderShipment.orderItemSeqId)) {
+                    orderShipmentQty += 
((Double)shippedQuantities.get(orderShipment.orderItemSeqId)).doubleValue();
+                }
+                shippedQuantities.put(orderShipment.orderItemSeqId, 
orderShipmentQty);
+            }
+        } else {
+            // this is here for backward compatibility only: ItemIssuances are 
no more created for purchase shipments.
+            issuances = shipment.getRelated("ItemIssuance", [orderId : 
purchaseOrderId], null);
+            issuances.each { issuance ->
+                exprs.add(EntityCondition.makeCondition("orderItemSeqId", 
EntityOperator.EQUALS, issuance.orderItemSeqId));
+                double issuanceQty = 
issuance.getDouble("quantity").doubleValue();
+                if (shippedQuantities.containsKey(issuance.orderItemSeqId)) {
+                    issuanceQty += 
((Double)shippedQuantities.get(issuance.orderItemSeqId)).doubleValue();
+                }
+                shippedQuantities.put(issuance.orderItemSeqId, issuanceQty);
             }
-            shippedQuantities.put(issuance.orderItemSeqId, issuanceQty);
         }
         purchaseOrderItems = EntityUtil.filterByOr(orderItems, exprs);
     } else {

Modified: 
ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl 
(original)
+++ 
ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl 
Sat Jan  2 18:20:19 2010
@@ -49,7 +49,7 @@
                 <input type="hidden" name="purchaseOrderId" value 
="${(item.orderId)?if_exists}"/>
                 <input type="hidden" name="facilityId" value 
="${facilityId?if_exists}"/>
                 <tr>
-                  <td><a 
href="<@ofbizUrl>ViewShipment?shipmentId=${item.shipmentId?if_exists}</@ofbizUrl>"
 class="buttontext">${item.shipmentId?if_exists}</a></td>
+                  <td><a 
href="<@ofbizUrl>ViewShipment?shipmentId=${item.shipmentId?if_exists}</@ofbizUrl>"
 class="buttontext">${item.shipmentId?if_exists} 
${item.shipmentItemSeqId?if_exists}</a></td>
                   <td>${item.receiptId}</td>
                   <td>${item.getString("datetimeReceived").toString()}</td>
                   <td><a 
href="/ordermgr/control/orderview?orderId=${item.orderId}" 
class="buttontext">${item.orderId}</a></td>

Modified: 
ofbiz/trunk/applications/product/webapp/facility/shipment/ShipmentTabBar.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/shipment/ShipmentTabBar.ftl?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/webapp/facility/shipment/ShipmentTabBar.ftl 
(original)
+++ 
ofbiz/trunk/applications/product/webapp/facility/shipment/ShipmentTabBar.ftl 
Sat Jan  2 18:20:19 2010
@@ -25,21 +25,18 @@
         <ul>
             <li<#if selected="ViewShipment"> class="selected"</#if>><a 
href="<@ofbizUrl>ViewShipment?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.CommonView}</a></li>
             <li<#if selected="EditShipment"> class="selected"</#if>><a 
href="<@ofbizUrl>EditShipment?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.CommonEdit}</a></li>
-        <#if (shipment.shipmentTypeId)?exists && 
shipment.shipmentTypeId='SALES_SHIPMENT'>
-            <li<#if selected="EditShipmentPlan"> class="selected"</#if>><a 
href="<@ofbizUrl>EditShipmentPlan?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductShipmentPlan}</a></li>
-        </#if>
-        <#if (shipment.shipmentTypeId)?exists && (shipment.shipmentTypeId = 
"SALES_SHIPMENT" || shipment.shipmentTypeId = "PURCHASE_SHIPMENT")>
-            <li<#if selected="AddItemsFromOrder"> class="selected"</#if>><a 
href="<@ofbizUrl>AddItemsFromOrder?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductOrderItems}</a></li>
-        </#if>
-        <#if (shipment.shipmentTypeId)?exists && 
shipment.shipmentTypeId="PURCHASE_RETURN">
+        <#if (shipment.shipmentTypeId)?exists && shipment.shipmentTypeId = 
"PURCHASE_RETURN">
             <li<#if selected="AddItemsFromInventory"> 
class="selected"</#if>><a 
href="<@ofbizUrl>AddItemsFromInventory?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductOrderItems}</a></li>
         </#if>
-        <#if (shipment.shipmentTypeId)?exists && 
shipment.shipmentTypeId='SALES_SHIPMENT'>
+        <#if (shipment.shipmentTypeId)?exists && shipment.shipmentTypeId = 
"SALES_SHIPMENT">
+            <li<#if selected="EditShipmentPlan"> class="selected"</#if>><a 
href="<@ofbizUrl>EditShipmentPlan?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductShipmentPlan}</a></li>
+            <li<#if selected="AddItemsFromOrder"> class="selected"</#if>><a 
href="<@ofbizUrl>AddItemsFromOrder?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductOrderItems}</a></li>
             <li<#if selected="EditShipmentItems"> class="selected"</#if>><a 
href="<@ofbizUrl>EditShipmentItems?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductItems}</a></li>
             <li<#if selected="EditShipmentPackages"> class="selected"</#if>><a 
href="<@ofbizUrl>EditShipmentPackages?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductPackages}</a></li>
             <li<#if selected="EditShipmentRouteSegments"> 
class="selected"</#if>><a 
href="<@ofbizUrl>EditShipmentRouteSegments?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductRouteSegments}</a></li>
         </#if>
         <#if (shipment.shipmentTypeId)?exists && 
shipment.shipmentTypeId='PURCHASE_SHIPMENT'>
+            <li<#if selected="EditShipmentPlan"> class="selected"</#if>><a 
href="<@ofbizUrl>EditShipmentPlan?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductOrderItems}</a></li>
             <li<#if selected="ViewShipmentReceipts"> class="selected"</#if>><a 
href="<@ofbizUrl>ViewShipmentReceipts?shipmentId=${shipmentId}</@ofbizUrl>">${uiLabelMap.ProductShipmentReceipts}</a></li>
         </#if>
         </ul>

Modified: ofbiz/trunk/applications/product/widget/facility/ShipmentForms.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/facility/ShipmentForms.xml?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/facility/ShipmentForms.xml 
(original)
+++ ofbiz/trunk/applications/product/widget/facility/ShipmentForms.xml Sat Jan  
2 18:20:19 2010
@@ -152,7 +152,7 @@
         <!-- total planned quantity not issued -->
         <field name="totPlannedQuantity" 
title="${uiLabelMap.ProductTotPlannedQuantity}" ><display/></field>
         <!-- total issued quantity -->
-        <field name="totIssuedQuantity" 
title="${uiLabelMap.ProductTotIssuedQuantity}" ><display/></field>
+        <field name="totIssuedQuantity" 
title="${uiLabelMap.ProductTotIssuedQuantity}"><display/></field>
         <!-- planned weight -->
         <field name="weight" 
title="${uiLabelMap.ProductWeight}"><display/></field>
         <field name="weightUom" 
title="${uiLabelMap.CommonUom}"><display/></field>

Modified: ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml?rev=895250&r1=895249&r2=895250&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml 
(original)
+++ ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml Sat 
Jan  2 18:20:19 2010
@@ -243,11 +243,18 @@
                         <screenlet 
title="${uiLabelMap.ProductShipmentPlanList}">
                             <include-form name="listShipmentPlan" 
location="component://product/widget/facility//ShipmentForms.xml"/>
                             <label style="h2" 
text="${uiLabelMap.ProductShipmentTotalWeight}: ${totWeight} 
${uiLabelMap.ProductShipmentTotalVolume}: ${totVolume}"/>
-                            <link 
text="${uiLabelMap.ProductShipmentPlanToOrderItems}" target="AddItemsFromOrder">
-                                <parameter param-name="shipmentId"/>
-                                <parameter param-name="selectFromShipmentPlan" 
value="true"/>
-                            </link>
                         </screenlet>
+                        <section>
+                            <condition>
+                                <if-compare field="shipment.shipmentTypeId" 
operator="equals" value="SALES_SHIPMENT"/>
+                            </condition>
+                            <widgets>
+                                <link 
text="${uiLabelMap.ProductShipmentPlanToOrderItems}" target="AddItemsFromOrder">
+                                    <parameter param-name="shipmentId"/>
+                                    <parameter 
param-name="selectFromShipmentPlan" value="true"/>
+                                </link>
+                            </widgets>
+                        </section>
                     </decorator-section>
                 </decorator-screen>
             </widgets>


Reply via email to