You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by as...@apache.org on 2014/10/18 13:46:25 UTC

svn commit: r1632772 - in /ofbiz/trunk/applications/product: servicedef/ src/org/ofbiz/shipment/packing/ webapp/facility/WEB-INF/actions/shipment/ webapp/facility/shipment/

Author: ashish
Date: Sat Oct 18 11:46:24 2014
New Revision: 1632772

URL: http://svn.apache.org/r1632772
Log:
Applied patch from jira issue - OFBIZ-5783 - Shipment Box Type selection should be at package level instead of item level on Pack Order Screen.\
=======================================================================
The Shipment Box Type selection is at line item level on Pack Order screen where the package selection for each order item is made. It should instead be at package level next to the package weight input box.

Also, ShipmentBoxType values are supported only for USPS, which is hard coded in PackOrder.groovy.

There is a bug reported in OFBIZ-4606 for Release 11.04 but exists in Trunk as well. It should be fixed if we make the above change.
=======================================================================
Thanks Mridul for creating the issue and providing the patch for the same. 

Modified:
    ofbiz/trunk/applications/product/servicedef/services_shipment.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java
    ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.groovy
    ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl

Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=1632772&r1=1632771&r2=1632772&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Sat Oct 18 11:46:24 2014
@@ -627,7 +627,6 @@ under the License.
         <attribute name="selInfo" type="Map" string-map-prefix="sel_" mode="IN" optional="true"/>
         <attribute name="iteInfo" type="Map" string-map-prefix="ite_" mode="IN" optional="true"/>
         <attribute name="wgtInfo" type="Map" string-map-prefix="wgt_" mode="IN" optional="true"/>
-        <attribute name="boxTypeInfo" type="Map" string-map-prefix="boxType_" mode="IN" optional="true"/>
         <attribute name="numPackagesInfo" type="Map" string-map-prefix="numPackages_" mode="IN" optional="true"/>
     </service>
 
@@ -690,6 +689,7 @@ under the License.
         <attribute name="dimensionUomId" type="String" mode="IN" optional="true"/>
         <attribute name="weightUomId" type="String" mode="IN" optional="true"/>
         <attribute name="shipmentId" type="String" mode="OUT" optional="false"/>
+        <attribute name="boxTypes" type="Map" string-map-prefix="boxType_" mode="IN" optional="true"/>
     </service>
 
     <!-- Shipment Plan Services -->

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java?rev=1632772&r1=1632771&r2=1632772&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java Sat Oct 18 11:46:24 2014
@@ -116,7 +116,6 @@ public class PackingServices {
         Map<String, String> pkgInfo = UtilGenerics.checkMap(context.get("pkgInfo"));
         Map<String, String> wgtInfo = UtilGenerics.checkMap(context.get("wgtInfo"));
         Map<String, String> numPackagesInfo = UtilGenerics.checkMap(context.get("numPackagesInfo"));
-        Map<String, String> boxTypeInfo = UtilGenerics.checkMap(context.get("boxTypeInfo"));
 
         if (selInfo != null) {
             for (String rowKey: selInfo.keySet()) {
@@ -131,8 +130,6 @@ public class PackingServices {
                 String pkgStr = pkgInfo.get(rowKey);
                 String qtyStr = qtyInfo.get(rowKey);
                 String wgtStr = wgtInfo.get(rowKey);
-                String boxType = boxTypeInfo.get(rowKey);
-                session.setShipmentBoxTypeId(boxType);
 
                 Debug.logInfo("Item: " + orderItemSeqId + " / Product: " + prdStr + " / Quantity: " + qtyStr + " /  Package: " + pkgStr + " / Weight: " + wgtStr, module);
 
@@ -288,12 +285,14 @@ public class PackingServices {
         String pickerPartyId = (String) context.get("pickerPartyId");
         BigDecimal additionalShippingCharge = (BigDecimal) context.get("additionalShippingCharge");
         Map<String, String> packageWeights = UtilGenerics.checkMap(context.get("packageWeights"));
+        Map<String, String> boxTypes = UtilGenerics.checkMap(context.get("boxTypes"));
         String weightUomId = (String) context.get("weightUomId");
         session.setHandlingInstructions(instructions);
         session.setPickerPartyId(pickerPartyId);
         session.setAdditionalShippingCharge(additionalShippingCharge);
         session.setWeightUomId(weightUomId);
         setSessionPackageWeights(session, packageWeights);
+        setSessionShipmentBoxTypes(session, boxTypes);
 
         Boolean force = (Boolean) context.get("forceComplete");
         if (force == null) {
@@ -338,4 +337,18 @@ public class PackingServices {
         }
         return shippableWeight;
     }
+
+    public static void setSessionShipmentBoxTypes(PackingSession session, Map<String, String> boxTypes) {
+        if (UtilValidate.isNotEmpty(boxTypes)) {
+            for (Map.Entry<String, String> entry: boxTypes.entrySet()) {
+                String packageSeqId = entry.getKey();
+                String boxTypeStr = entry.getValue();
+                if (UtilValidate.isNotEmpty(boxTypeStr)) {
+                    session.setShipmentBoxType(Integer.parseInt(packageSeqId), boxTypeStr);
+                } else {
+                    session.setShipmentBoxType(Integer.parseInt(packageSeqId), null);
+                }
+            }
+        }
+    }
 }

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=1632772&r1=1632771&r2=1632772&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java Sat Oct 18 11:46:24 2014
@@ -70,6 +70,7 @@ public class PackingSession implements j
     protected List<ItemDisplay> itemInfos = null;
     protected int packageSeq = -1;
     protected int status = 1;
+    protected Map<Integer, String> shipmentBoxTypes = null;
 
     private transient Delegator _delegator = null;
     private transient LocalDispatcher _dispatcher = null;
@@ -91,6 +92,7 @@ public class PackingSession implements j
         this.itemInfos = FastList.newInstance();
         this.packageSeq = 1;
         this.packageWeights = FastMap.newInstance();
+        this.shipmentBoxTypes = FastMap.newInstance();
     }
 
     public PackingSession(LocalDispatcher dispatcher, GenericValue userLogin, String facilityId) {
@@ -598,6 +600,7 @@ public class PackingSession implements j
     public void clearAllLines() {
         this.packLines.clear();
         this.packageWeights.clear();
+        this.shipmentBoxTypes.clear();
         this.packageSeq = 1;
     }
 
@@ -610,6 +613,7 @@ public class PackingSession implements j
         this.primaryShipGrp = null;
         this.additionalShippingCharge = null;
         if (this.packageWeights != null) this.packageWeights.clear();
+        if (this.shipmentBoxTypes != null) this.shipmentBoxTypes.clear();
         this.weightUomId = null;
         this.packageSeq = 1;
         this.status = 1;
@@ -795,7 +799,7 @@ public class PackingSession implements j
             Map<String, Object> pkgCtx = FastMap.newInstance();
             pkgCtx.put("shipmentId", shipmentId);
             pkgCtx.put("shipmentPackageSeqId", shipmentPackageSeqId);
-            pkgCtx.put("shipmentBoxTypeId", this.shipmentBoxTypeId);
+            pkgCtx.put("shipmentBoxTypeId", getShipmentBoxType(i+1));
             pkgCtx.put("weight", getPackageWeight(i+1));
             pkgCtx.put("weightUomId", getWeightUomId());
             pkgCtx.put("userLogin", userLogin);
@@ -989,6 +993,25 @@ public class PackingSession implements j
         setPackageWeight(packageSeqId, newPackageWeight);
     }
 
+    // These methods (setShipmentBoxType and getShipmentBoxType) are added so that each package will have different box type.
+    public void setShipmentBoxType(int packageSeqId, String shipmentBoxType) {
+        if (UtilValidate.isEmpty(shipmentBoxType)) {
+            shipmentBoxTypes.remove(Integer.valueOf(packageSeqId));
+        } else {
+            shipmentBoxTypes.put(Integer.valueOf(packageSeqId), shipmentBoxType);
+        }
+    }
+
+    public String getShipmentBoxType(int packageSeqId) {
+        if (this.shipmentBoxTypes == null) return null;
+        String shipmentBoxType = null;
+        Object p = shipmentBoxTypes.get(packageSeqId);
+        if (p != null) {
+            shipmentBoxType = (String) p;
+        }
+        return shipmentBoxType;
+    }
+
     class ItemDisplay extends AbstractMap<Object, Object> {
 
         public GenericValue orderItem;

Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.groovy?rev=1632772&r1=1632771&r2=1632772&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.groovy Sat Oct 18 11:46:24 2014
@@ -133,10 +133,10 @@ if (orderId) {
         orderItemShipGroup = orh.getOrderItemShipGroup(shipGroupSeqId);
         context.orderItemShipGroup = orderItemShipGroup;
         carrierPartyId = orderItemShipGroup.carrierPartyId;
-        if ("USPS".equals(carrierPartyId)) {
             carrierShipmentBoxTypes = delegator.findList("CarrierShipmentBoxType", EntityCondition.makeCondition([partyId : carrierPartyId]), null, null, null, false);
+            if (carrierShipmentBoxTypes) {
             context.carrierShipmentBoxTypes = carrierShipmentBoxTypes;
-        }
+            }
 
         if ("ORDER_APPROVED".equals(orderHeader.statusId)) {
             if (shipGroupSeqId) {

Modified: ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl?rev=1632772&r1=1632771&r2=1632772&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl Sat Oct 18 11:46:24 2014
@@ -266,9 +266,6 @@ under the License.
                       <td>&nbsp;</td>
                       <td align="center">${uiLabelMap.ProductPackQty}</td>
                       <td align="center">${uiLabelMap.ProductPackedWeight}&nbsp;(${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultWeightUomId)?eval})</td>
-                      <#if carrierShipmentBoxTypes?has_content>
-                        <td align="center">${uiLabelMap.ProductShipmentBoxType}</td>
-                      </#if>
                       <td align="center">${uiLabelMap.ProductPackage}</td>
                       <td align="right">&nbsp;<b>*</b>&nbsp;${uiLabelMap.ProductPackages}</td>
                     </tr>
@@ -315,17 +312,6 @@ under the License.
                           <td align="center">
                             <input type="text" size="7" name="wgt_${rowKey}" value="" />
                           </td>
-                          <#if carrierShipmentBoxTypes?has_content>
-                            <td align="center">
-                              <select name="boxType_${rowKey}">
-                                <option value=""></option>
-                                <#list carrierShipmentBoxTypes as carrierShipmentBoxType>
-                                  <#assign shipmentBoxType = carrierShipmentBoxType.getRelatedOne("ShipmentBoxType", false) />
-                                  <option value="${shipmentBoxType.shipmentBoxTypeId}">${shipmentBoxType.description?default(shipmentBoxType.shipmentBoxTypeId)}</option>
-                                </#list>
-                              </select>
-                            </td>
-                          </#if>
                           <td align="center">
                             <select name="pkg_${rowKey}">
                               <#if packingSession.getPackageSeqIds()?exists>
@@ -395,6 +381,22 @@ under the License.
                                     <input type="hidden" name="productStoreId" value="${productStoreId!}"/>
                                 </#if>
                             </td>
+                            <#if carrierShipmentBoxTypes?has_content>
+                              <td>
+                                <span class="label">${uiLabelMap.ProductShipmentBoxType}</span>
+                                <br/>
+                                <#list packageSeqIds as packageSeqId>
+                                  <select name="boxType_${packageSeqId}">
+                                    <option value=""></option>
+                                    <#list carrierShipmentBoxTypes as carrierShipmentBoxType>
+                                      <#assign shipmentBoxType = carrierShipmentBoxType.getRelatedOne("ShipmentBoxType", false) />
+                                      <option value="${shipmentBoxType.shipmentBoxTypeId}">${shipmentBoxType.description?default(shipmentBoxType.shipmentBoxTypeId)}</option>
+                                    </#list>
+                                  </select>
+                                  <br/>
+                                </#list>
+                              </td>
+                            </#if>
                         </#if>
                         <td nowrap="nowrap">
                             <span class="label">${uiLabelMap.ProductAdditionalShippingCharge}:</span>