You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mo...@apache.org on 2009/06/02 13:35:50 UTC

svn commit: r781008 [1/2] - in /ofbiz/trunk/applications/product: src/org/ofbiz/shipment/packing/ webapp/facility/WEB-INF/actions/shipment/ webapp/facility/shipment/

Author: mor
Date: Tue Jun  2 11:35:49 2009
New Revision: 781008

URL: http://svn.apache.org/viewvc?rev=781008&view=rev
Log:
Reverting all the changes to these files that were done just after rev. 767392. All these changes break the normal packing process as to pack an order, it should be verified 
first through "Verify Pick" screen in facility (new feature). This issue has also been reported by Jacques on mailing list. With this revert packing will work as normal i.e. 
No verify pick required. Please report back any error if you see any just because of these changes and we will try to fix them asap. Also sorry for this big revert.
Note: I will be adding back the securing URLs in FTL changes which are also being reverted because of this commit.

Modified:
    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/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=781008&r1=781007&r2=781008&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 Tue Jun  2 11:35:49 2009
@@ -19,36 +19,20 @@
 package org.ofbiz.shipment.packing;
 
 import java.math.BigDecimal;
-import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 
-import javolution.util.FastList;
-import javolution.util.FastMap;
-
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilGenerics;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilNumber;
-import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.entity.GenericDelegator;
-import org.ofbiz.entity.GenericValue;
 import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
 
 public class PackingServices {
 
     public static final String module = PackingServices.class.getName();
-    private static BigDecimal ZERO = BigDecimal.ZERO;
-    private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
 
     public static Map<String, Object> addPackLine(DispatchContext dctx, Map<String, ? extends Object> context) {
-        GenericDelegator delegator = dctx.getDelegator();
-        LocalDispatcher dispatcher = dctx.getDispatcher();
-        Locale locale = (Locale) context.get("locale");
         PackingSession session = (PackingSession) context.get("packingSession");
         String shipGroupSeqId = (String) context.get("shipGroupSeqId");
         String orderId = (String) context.get("orderId");
@@ -66,61 +50,23 @@
         session.setPickerPartyId(pickerPartyId);
 
         if (quantity == null) {
-            quantity = ZERO;
+            quantity = BigDecimal.ONE;
         }
 
         Debug.log("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] Pack input [" + productId + "] @ [" + quantity + "] packageSeq [" + packageSeq + "] weight [" + weight +"]", module);
 
         if (weight == null) {
             Debug.logWarning("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] product [" + productId + "] being packed without a weight, assuming 0", module);
-            weight = ZERO;
+            weight = BigDecimal.ZERO;
         }
 
-        List<String> orderItemSeqIds = FastList.newInstance();
-        BigDecimal qtyToPack = ZERO;
-        BigDecimal qtyToPacked = ZERO;
-        BigDecimal packedQuantity = ZERO;
-        BigDecimal readyToPackQty = ZERO;
-        int counter = 0;
         try {
-            // check if entered product is ordered product or not
-            if (UtilValidate.isNotEmpty(productId)) {
-                List<GenericValue> orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId, "productId", productId));
-                if (UtilValidate.isNotEmpty(orderItems)) {
-                    for (GenericValue orderItem : orderItems) {
-                        counter++;
-                        if (quantity.compareTo(ZERO) > 0) {
-                            BigDecimal orderedQuantity = orderItem.getBigDecimal("quantity");
-                            List<GenericValue> shipments = delegator.findByAnd("Shipment", UtilMisc.toMap("primaryOrderId", orderId , "statusId", "SHIPMENT_PACKED"));
-                            for(GenericValue shipment : shipments) {
-                                List<GenericValue> itemIssuances = shipment.getRelatedByAnd("ItemIssuance" , UtilMisc.toMap("shipmentId", shipment.getString("shipmentId"), "orderItemSeqId", orderItem.getString("orderItemSeqId")));
-                                for(GenericValue itemIssuance : itemIssuances) {
-                                    packedQuantity = packedQuantity.add(itemIssuance.getBigDecimal("quantity"));
-                                }
-                            }
-                            qtyToPack = orderedQuantity.subtract(packedQuantity);
-                            if (qtyToPack.compareTo(quantity) > -1) {
-                                readyToPackQty = session.getPackedQuantity(orderId, orderItem.getString("orderItemSeqId"), shipGroupSeqId, productId);
-                                qtyToPacked =  orderedQuantity.subtract(readyToPackQty);
-                                if (qtyToPacked.compareTo(quantity) > -1) {
-                                    session.addOrIncreaseLine(orderId, orderItem.getString("orderItemSeqId"), shipGroupSeqId, productId, quantity, packageSeq.intValue(), weight, false);
-                                    counter--;
-                                    break;
-                                } else if (orderItems.size() == counter) {
-                                    throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoValidOrderItemFoundForProductWithEnteredQuantity", UtilMisc.toMap("productId", productId, "quantity", quantity), locale));
-                                }
-                            } else if (orderItems.size() == counter) {
-                                throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoValidOrderItemFoundForProductWithEnteredQuantity", UtilMisc.toMap("productId", productId, "quantity", quantity), locale));
-                            }
-                        }
-                    }
-                } else {
-                    throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoValidOrderItemFoundForProductWithEnteredQuantity", UtilMisc.toMap("productId", productId, "quantity", quantity), locale));
-                }
-            }
-        } catch (Exception ex) {
-            return ServiceUtil.returnError(ex.getMessage());
+            session.addOrIncreaseLine(orderId, null, shipGroupSeqId, productId, quantity, packageSeq.intValue(), weight, false);
+        } catch (GeneralException e) {
+            Debug.logError(e, module);
+            return ServiceUtil.returnError(e.getMessage());
         }
+
         return ServiceUtil.returnSuccess();
     }
 
@@ -320,160 +266,19 @@
         return result;
     }
 
-    public static Map<String, Object> weightPackage(DispatchContext dctx, Map<String, ? extends Object> context) {
-        PackingSession session = (PackingSession) context.get("packingSession");
-        Locale locale = (Locale) context.get("locale");
-        String packageLength = (String) context.get("packageLength");
-        String packageWidth = (String) context.get("packageWidth");
-        String packageHeight = (String) context.get("packageHeight");
-        String packageSeqId = (String) context.get("packageSeqId");
-        String packageWeight = (String) context.get("packageWeight");
-        String shipmentBoxTypeId = (String) context.get("shipmentBoxTypeId");
-        String weightPackageSeqId = (String) context.get("weightPackageSeqId");
-
-        // User can either enter all the dimensions or shipment box type, but not both
-        if (UtilValidate.isNotEmpty(packageLength) || UtilValidate.isNotEmpty(packageWidth) || UtilValidate.isNotEmpty(packageHeight)) { // Check if user entered any dimensions
-            if (UtilValidate.isNotEmpty(shipmentBoxTypeId)) { // check also if user entered shipment box type
-                session.setDimensionAndShipmentBoxType(packageSeqId);
-                return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorEnteredBothDimensionAndPackageInputBoxField", locale));
-            } else if (!(UtilValidate.isNotEmpty(packageLength) && UtilValidate.isNotEmpty(packageWidth) && UtilValidate.isNotEmpty(packageHeight))) { // check if user does not enter all the dimensions
-                session.setDimensionAndShipmentBoxType(packageSeqId);
-                return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNotEnteredAllFieldsInDimension", locale));
-            }
-        }
-
-        BigDecimal shippableWeight = ZERO;
-        Map<String, Object> response = FastMap.newInstance();
-
-        session.setPackageLength(packageSeqId, packageLength);
-        session.setPackageWidth(packageSeqId, packageWidth);
-        session.setPackageHeight(packageSeqId, packageHeight);
-        session.setShipmentBoxTypeId(packageSeqId, shipmentBoxTypeId);
-
-        if (UtilValidate.isNotEmpty(packageWeight)) {
-            BigDecimal packWeight = new BigDecimal(packageWeight);
-            session.setPackageWeight(Integer.parseInt(packageSeqId), packWeight);
-            shippableWeight = shippableWeight.add(packWeight);
-        } else {
-            session.setPackageWeight(Integer.parseInt(packageSeqId), null);
-        }
-        session.setWeightPackageSeqId(packageSeqId, weightPackageSeqId);
-        response.put("dimensionSavedInSession", true);
-        return response;
-    }
-
-    public static Map<String, Object> holdShipment(DispatchContext dctx, Map<String, ? extends Object> context) {
-        PackingSession session = (PackingSession) context.get("packingSession");
-        String shipmentId = (String) context.get("shipmentId");
-        String dimensionUomId = (String) context.get("dimensionUomId");
-        String weightUomId = (String) context.get("weightUomId");
-        try {
-            session.setDimensionUomId(dimensionUomId);
-            session.setWeightUomId(weightUomId);
-            session.createPackages(shipmentId);
-            session.clearAllLines();
-        } catch (GeneralException e) {
-            return ServiceUtil.returnError(e.getMessage(), e.getMessageList());
-        }
-        return ServiceUtil.returnSuccess();
-    }
-
-    public static Map<String, Object> completePackage(DispatchContext dctx, Map<String, ? extends Object> context) {
-        GenericDelegator delegator = dctx.getDelegator();
-        PackingSession session = (PackingSession) context.get("packingSession");
-        Locale locale = (Locale) context.get("locale");
-        Map<String, String> packageWeights = UtilGenerics.checkMap(context.get("packageWeights"));
-
-        String orderId = (String) context.get("orderId");
-        String shipmentId = (String) context.get("shipmentId");
-        String invoiceId = (String) context.get("invoiceId");
-        String productStoreId = (String) context.get("productStoreId");
-        String pickerPartyId = (String) context.get("pickerPartyId");
-        String carrierPartyId = (String) context.get("carrierPartyId");
-        String carrierRoleTypeId = (String) context.get("carrierRoleTypeId");
-        String shippingContactMechId = (String) context.get("shippingContactMechId");
-        String shipmentMethodTypeId = (String) context.get("shipmentMethodTypeId");
-        String dimensionUomId = (String) context.get("dimensionUomId");
-        String weightUomId = (String) context.get("weightUomId");
-        Boolean forceComplete = (Boolean) context.get("forceComplete");
-
-        String shipmentCostEstimateForShipGroup = (String) context.get("shipmentCostEstimateForShipGroup");
-        BigDecimal estimatedShipCost = new BigDecimal(shipmentCostEstimateForShipGroup);
-
-        BigDecimal doEstimates = new BigDecimal(UtilProperties.getPropertyValue("shipment.properties", "shipment.default.cost_actual_over_estimated_percent_allowed", "10"));
-
-        Map<String, Object> response = FastMap.newInstance();
-        BigDecimal diffInShipCostInPerc = ZERO;
-
-        BigDecimal shippableWeight = setSessionPackageWeights(session, packageWeights);
-        BigDecimal newEstimatedShipCost = session.getShipmentCostEstimate(shippingContactMechId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId, productStoreId, null, null, shippableWeight, null);
-
-        session.setAdditionalShippingCharge(newEstimatedShipCost);
-        session.setDimensionUomId(dimensionUomId);
-        session.setWeightUomId(weightUomId);
-        session.setPickerPartyId(pickerPartyId);
-        session.setShipmentId(shipmentId);
-        session.setInvoiceId(invoiceId);
-
-        try {
-            session.checkPackedQty(orderId, locale);
-            FastList<GenericValue> shipments = (FastList) delegator.findByAnd("Shipment", UtilMisc.toMap("primaryOrderId", orderId, "statusId", "SHIPMENT_PACKED"));
-            for (GenericValue shipment : shipments) {
-                BigDecimal additionalShippingCharge = shipment.getBigDecimal("additionalShippingCharge");
-                if (UtilValidate.isNotEmpty(additionalShippingCharge)) {
-                    newEstimatedShipCost = newEstimatedShipCost.add(shipment.getBigDecimal("additionalShippingCharge"));
-                }
-            }
-            if (estimatedShipCost.compareTo(ZERO) == 0) {
-                diffInShipCostInPerc = newEstimatedShipCost;
-            } else {
-                diffInShipCostInPerc = (((newEstimatedShipCost.subtract(estimatedShipCost)).divide(estimatedShipCost, 2, rounding)).multiply(new BigDecimal(100))).abs();
-            }
-            if (doEstimates.compareTo(diffInShipCostInPerc) == -1) {
-                response.put("showWarningForm", true);
-            } else {
-                if (forceComplete == null) {
-                    forceComplete = Boolean.FALSE;
-                }
-                try {
-                    shipmentId = session.complete(forceComplete, orderId, locale);
-                } catch (GeneralException e) {
-                    return ServiceUtil.returnError(e.getMessage(), e.getMessageList());
-                }
-                if (UtilValidate.isEmpty(shipmentId)) {
-                    response = ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoItemsCurrentlySetToBeShippedCannotComplete", locale));
-                } else {
-                    response = ServiceUtil.returnSuccess(UtilProperties.getMessage("ProductUiLabels", "FacilityShipmentCreatedAndMarkedAsPacked", UtilMisc.toMap("shipmentId", shipmentId), locale));
-                }
-                response.put("shipmentId", shipmentId);
-                response.put("showWarningForm", false);
-            }
-        } catch (GeneralException e) {
-            return ServiceUtil.returnError(e.getMessage(), e.getMessageList());
-        }
-        return response;
-    }
 
     public static Map<String, Object> completePack(DispatchContext dctx, Map<String, ? extends Object> context) {
         PackingSession session = (PackingSession) context.get("packingSession");
-        Locale locale = (Locale) context.get("locale");
 
         // set the instructions -- will clear out previous if now null
-        String orderId = (String) context.get("orderId");
-        String shipmentId = (String) context.get("shipmentId");
-        String invoiceId = (String) context.get("invoiceId");
         String instructions = (String) context.get("handlingInstructions");
         String pickerPartyId = (String) context.get("pickerPartyId");
         BigDecimal additionalShippingCharge = (BigDecimal) context.get("additionalShippingCharge");
         Map<String, String> packageWeights = UtilGenerics.checkMap(context.get("packageWeights"));
-        String dimensionUomId = (String) context.get("dimensionUomId");
         String weightUomId = (String) context.get("weightUomId");
-        session.setShipmentId(shipmentId);
-        session.setInvoiceId(invoiceId);
         session.setHandlingInstructions(instructions);
         session.setPickerPartyId(pickerPartyId);
         session.setAdditionalShippingCharge(additionalShippingCharge);
-        session.setDimensionUomId(dimensionUomId);
         session.setWeightUomId(weightUomId);
         setSessionPackageWeights(session, packageWeights);
 
@@ -482,8 +287,9 @@
             force = Boolean.FALSE;
         }
 
+        String shipmentId = null;
         try {
-            shipmentId = session.complete(force, orderId, locale);
+            shipmentId = session.complete(force);
         } catch (GeneralException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage(), e.getMessageList());

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=781008&r1=781007&r2=781008&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 Tue Jun  2 11:35:49 2009
@@ -22,7 +22,6 @@
 import java.util.AbstractMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
@@ -35,7 +34,6 @@
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
@@ -61,9 +59,7 @@
     protected String facilityId = null;
     protected String shipmentId = null;
     protected String instructions = null;
-    protected String dimensionUomId = null;
     protected String weightUomId = null;
-    protected String invoiceId = null;
     protected BigDecimal additionalShippingCharge = null;
     protected Map<Integer, BigDecimal> packageWeights = null;
     protected List<PackingEvent> packEvents = null;
@@ -74,7 +70,6 @@
 
     private transient GenericDelegator _delegator = null;
     private transient LocalDispatcher _dispatcher = null;
-    private static BigDecimal ZERO = BigDecimal.ZERO;
 
     public PackingSession(LocalDispatcher dispatcher, GenericValue userLogin, String facilityId, String binId, String orderId, String shipGrp) {
         this._dispatcher = dispatcher;
@@ -133,7 +128,7 @@
         invLookup.put("orderId", orderId);
         invLookup.put("orderItemSeqId", orderItemSeqId);
         invLookup.put("shipGroupSeqId", shipGroupSeqId);
-        List<GenericValue> reservations = this.getDelegator().findByAnd("ItemIssuance", invLookup, UtilMisc.toList("quantity DESC"));
+        List<GenericValue> reservations = this.getDelegator().findByAnd("OrderItemShipGrpInvRes", invLookup, UtilMisc.toList("quantity DESC"));
 
         // no reservations we cannot add this item
         if (UtilValidate.isEmpty(reservations)) {
@@ -372,32 +367,10 @@
         return this.shipmentId;
     }
 
-    public void setShipmentId(String shipmentId) {
-        this.shipmentId = shipmentId;
-    }
-
-    public String getInvoiceId() {
-        return this.invoiceId;
-    }
-
-    public void setInvoiceId(String invoiceId) {
-        this.invoiceId = invoiceId;
-    }
-
     public List<PackingSessionLine> getLines() {
         return this.packLines;
     }
 
-    public PackingSessionLine getLine(int packageSeqId) {
-        PackingSessionLine packLine = null;
-        for (PackingSessionLine line : this.getLines()) {
-            if ((line.getPackageSeq()) == packageSeqId) {
-                packLine = line;
-            }
-        }
-        return packLine;
-    }
-
     public int nextPackageSeq() {
         return ++packageSeq;
     }
@@ -634,14 +607,13 @@
         this.primaryShipGrp = null;
         this.additionalShippingCharge = null;
         if (this.packageWeights != null) this.packageWeights.clear();
-        this.dimensionUomId = null;
         this.weightUomId = null;
         this.packageSeq = 1;
         this.status = 1;
         this.runEvents(PackingEvent.EVENT_CODE_CLEAR);
     }
 
-    public String complete(boolean force, String orderId, Locale locale) throws GeneralException {
+    public String complete(boolean force) throws GeneralException {
         // clear out empty lines
         // this.checkEmptyLines(); // removing, this seems to be causeing issues -  mja
 
@@ -650,18 +622,16 @@
             return "EMPTY";
         }
 
-        this.checkPackedQty(orderId, locale);
+        // check for errors
+        this.checkReservations(force);
         // set the status to 0
         this.status = 0;
         // create the shipment
-        String shipmentId = this.getShipmentId();
-        if (UtilValidate.isEmpty(shipmentId)) {
-            this.createShipment();
-        }
+        this.createShipment();
         // create the packages
         this.createPackages();
         // issue the items
-        this.changeOrderItemStatus(orderId, shipmentId);
+        this.issueItemsToShipment();
         // assign items to packages
         this.applyItemsToPackages();
         // update ShipmentRouteSegments with total weight and weightUomId
@@ -676,25 +646,6 @@
         return this.shipmentId;
     }
 
-    protected void checkPackedQty(String orderId, Locale locale) throws GeneralException {
-
-        BigDecimal packedQty = ZERO;
-        BigDecimal orderedQty = ZERO;
-
-        List<GenericValue> orderItems = this.getDelegator().findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId));
-        for (GenericValue orderItem : orderItems) {
-            orderedQty = orderedQty.add(orderItem.getBigDecimal("quantity"));
-        }
-
-        for (PackingSessionLine line : this.getLines()) {
-            packedQty = packedQty.add(line.getQuantity());
-        }
-
-        if (orderedQty.compareTo(packedQty) != 0 ) {
-            throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorAllOrderItemsAreNotPacked", locale));
-        }
-    }
-
     protected void checkReservations(boolean ignore) throws GeneralException {
         List<String> errors = FastList.newInstance();
         for (PackingSessionLine line: this.getLines()) {
@@ -790,32 +741,6 @@
         }
     }
 
-    protected void changeOrderItemStatus(String orderId, String shipmentId) throws GeneralException {
-        List<GenericValue> shipmentItems = this.getDelegator().findByAnd("ShipmentItem", UtilMisc.toMap("shipmentId", shipmentId));
-        for (GenericValue shipmentItem : shipmentItems) {
-            for (PackingSessionLine line : this.getLines()) {
-                if (orderId.equals(line.getOrderId()) && shipmentItem.getString("productId").equals(line.getProductId())) {
-                    line.setShipmentItemSeqId(shipmentItem.getString("shipmentItemSeqId"));
-                }
-            }
-        }
-        List<GenericValue> orderItems = this.getDelegator().findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId));
-        for (GenericValue orderItem : orderItems) {
-            List orderItemShipGrpInvReserves = orderItem.getRelated("OrderItemShipGrpInvRes");
-            if (UtilValidate.isEmpty(orderItemShipGrpInvReserves)) {
-                Map<String, Object> orderItemStatusMap = FastMap.newInstance();
-                orderItemStatusMap.put("orderId", orderId);
-                orderItemStatusMap.put("orderItemSeqId", orderItem.getString("orderItemSeqId"));
-                orderItemStatusMap.put("userLogin", userLogin);
-                orderItemStatusMap.put("statusId", "ITEM_COMPLETED");
-                Map<String, Object> orderItemStatusResp = this.getDispatcher().runSync("changeOrderItemStatus", orderItemStatusMap);
-                if (ServiceUtil.isError(orderItemStatusResp)) {
-                    throw new GeneralException(ServiceUtil.getErrorMessage(orderItemStatusResp));
-                }
-            }
-        }
-    }
-
     protected boolean checkLine(List<PackingSessionLine> processedLines, PackingSessionLine line) {
         for (PackingSessionLine l: processedLines) {
             if (line.isSameItem(l)) {
@@ -829,17 +754,12 @@
 
     protected void createPackages() throws GeneralException {
         for (int i = 0; i < packageSeq; i++) {
-            PackingSessionLine line = this.getLine(i+1);
             String shipmentPackageSeqId = UtilFormatOut.formatPaddedNumber(i+1, 5);
 
             Map<String, Object> pkgCtx = FastMap.newInstance();
             pkgCtx.put("shipmentId", shipmentId);
             pkgCtx.put("shipmentPackageSeqId", shipmentPackageSeqId);
-            pkgCtx.put("boxLength", line.getLength());
-            pkgCtx.put("boxWidth", line.getWidth());
-            pkgCtx.put("boxHeight", line.getHeight());
-            pkgCtx.put("dimensionUomId", getDimensionUomId());
-            pkgCtx.put("shipmentBoxTypeId", line.getShipmentBoxTypeId());
+            //pkgCtx.put("shipmentBoxTypeId", "");
             pkgCtx.put("weight", getPackageWeight(i+1));
             pkgCtx.put("weightUomId", getWeightUomId());
             pkgCtx.put("userLogin", userLogin);
@@ -994,14 +914,6 @@
         this.weightUomId = weightUomId;
     }
 
-    public String getDimensionUomId() {
-        return dimensionUomId;
-    }
-
-    public void setDimensionUomId(String dimensionUomId) {
-        this.dimensionUomId = dimensionUomId;
-    }
-
     public List<Integer> getPackageSeqIds() {
         Set<Integer> packageSeqIds = new TreeSet<Integer>();
         if (! UtilValidate.isEmpty(this.getLines())) {
@@ -1023,7 +935,7 @@
     public BigDecimal getPackageWeight(int packageSeqId) {
         if (this.packageWeights == null) return null;
         BigDecimal packageWeight = null;
-        Object p = packageWeights.get(Integer.valueOf(packageSeqId));
+        Object p = packageWeights.get(new Integer(packageSeqId));
         if (p != null) {
             packageWeight = (BigDecimal) p;
         }
@@ -1037,140 +949,6 @@
         setPackageWeight(packageSeqId, newPackageWeight);
     }
 
-    public void setPackageLength(String packageSeqId, String packageLength) {
-        if (UtilValidate.isNotEmpty(packageSeqId)) {
-            PackingSessionLine packLine = this.getLine(Integer.parseInt(packageSeqId));
-            if (UtilValidate.isNotEmpty(packageLength)) {
-                packLine.setLength(new BigDecimal(packageLength));
-            }
-        }
-    }
-
-    public BigDecimal getPackageLength(int packageSeqId) {
-        BigDecimal packageLength = null;
-        PackingSessionLine packLine = this.getLine(packageSeqId);
-        if (UtilValidate.isNotEmpty(packLine)) {
-            packageLength = packLine.getLength();
-        }
-        return packageLength;
-    }
-
-    public void setPackageWidth(String packageSeqId, String packageWidth) {
-        if (UtilValidate.isNotEmpty(packageSeqId)) {
-            PackingSessionLine packLine = this.getLine(Integer.parseInt(packageSeqId));
-            if (UtilValidate.isNotEmpty(packageWidth)) {
-                packLine.setWidth(new BigDecimal(packageWidth));
-            }
-        }
-    }
-
-    public BigDecimal getPackageWidth(int packageSeqId) {
-        BigDecimal packageWidth = null;
-        PackingSessionLine packLine = this.getLine(packageSeqId);
-        if (UtilValidate.isNotEmpty(packLine)) {
-            packageWidth = packLine.getWidth();
-        }
-        return packageWidth;
-    }
-
-    public void setPackageHeight(String packageSeqId, String packageHeight) {
-        if (UtilValidate.isNotEmpty(packageSeqId)) {
-            PackingSessionLine packLine = this.getLine(Integer.parseInt(packageSeqId));
-            if (UtilValidate.isNotEmpty(packageHeight)) {
-                packLine.setHeight(new BigDecimal(packageHeight));
-            }
-        }
-    }
-
-    public BigDecimal getPackageHeight(int packageSeqId) {
-        BigDecimal packageHeight = null;
-        PackingSessionLine packLine = this.getLine(packageSeqId);
-        if (UtilValidate.isNotEmpty(packLine)) {
-            packageHeight = packLine.getHeight();
-        }
-        return packageHeight;
-    }
-
-    public void setShipmentBoxTypeId(String packageSeqId, String shipmentBoxTypeId) {
-        if (UtilValidate.isNotEmpty(packageSeqId)) {
-            PackingSessionLine packLine = this.getLine(Integer.parseInt(packageSeqId));
-            if (UtilValidate.isNotEmpty(shipmentBoxTypeId)) {
-                packLine.setShipmentBoxTypeId(shipmentBoxTypeId);
-            }
-        }
-    }
-
-    public String getShipmentBoxTypeId(int packageSeqId) {
-        String shipmentBoxTypeId = null;
-        PackingSessionLine packLine = this.getLine(packageSeqId);
-        if (UtilValidate.isNotEmpty(packLine)) {
-            shipmentBoxTypeId = packLine.getShipmentBoxTypeId();
-        }
-        return shipmentBoxTypeId;
-    }
-
-    public void setWeightPackageSeqId(String packageSeqId, String weightPackageSeqId) {
-        if (UtilValidate.isNotEmpty(packageSeqId)) {
-            PackingSessionLine packLine = this.getLine(Integer.parseInt(packageSeqId));
-            if (UtilValidate.isNotEmpty(weightPackageSeqId)) {
-                packLine.setWeightPackageSeqId(weightPackageSeqId);
-            }
-        }
-    }
-
-    public int getWeightPackageSeqId(int packageSeqId) {
-        int weightPackageSeqId = -1;
-        if (UtilValidate.isNotEmpty(this.getLine(packageSeqId))) {
-            if (UtilValidate.isNotEmpty(this.getLine(packageSeqId).getWeightPackageSeqId()))
-                weightPackageSeqId = Integer.parseInt(this.getLine(packageSeqId).getWeightPackageSeqId());
-        }
-        return weightPackageSeqId;
-    }
-
-    protected void createPackages(String shipmentId) throws GeneralException {
-        List<GenericValue> shipmentPackageRouteSegs = this.getDelegator().findByAnd("ShipmentPackageRouteSeg", UtilMisc.toMap("shipmentId", shipmentId));
-        if (UtilValidate.isNotEmpty(shipmentPackageRouteSegs)) {
-            for (GenericValue shipmentPackageRouteSeg : shipmentPackageRouteSegs) {
-                shipmentPackageRouteSeg.remove();
-            }
-        }
-        List<GenericValue> shipmentPackages = this.getDelegator().findByAnd("ShipmentPackage", UtilMisc.toMap("shipmentId", shipmentId));
-        if (UtilValidate.isNotEmpty(shipmentPackages)) {
-            for (GenericValue shipmentPackage : shipmentPackages) {
-                shipmentPackage.remove();
-            }
-        }
-        for (int i = 0; i < packageSeq; i++) {
-            PackingSessionLine line = this.getLine(i+1);
-            String shipmentPackageSeqId = UtilFormatOut.formatPaddedNumber(i+1, 5);
-            Map<String, Object> shipmentPackageCtx = FastMap.newInstance();
-            shipmentPackageCtx.put("shipmentId", shipmentId);
-            shipmentPackageCtx.put("shipmentPackageSeqId", shipmentPackageSeqId);
-            shipmentPackageCtx.put("boxLength", line.getLength());
-            shipmentPackageCtx.put("boxWidth", line.getWidth());
-            shipmentPackageCtx.put("boxHeight", line.getHeight());
-            shipmentPackageCtx.put("dimensionUomId", getDimensionUomId());
-            shipmentPackageCtx.put("shipmentBoxTypeId", line.getShipmentBoxTypeId());
-            shipmentPackageCtx.put("weight", getPackageWeight(i+1));
-            shipmentPackageCtx.put("weightUomId", getWeightUomId());
-            shipmentPackageCtx.put("userLogin", userLogin);
-            Map<String, Object> shipmentPackageResult = this.getDispatcher().runSync("createShipmentPackage", shipmentPackageCtx);
-            if (ServiceUtil.isError(shipmentPackageResult)) {
-                throw new GeneralException(ServiceUtil.getErrorMessage(shipmentPackageResult));
-            }
-        }
-    }
-
-    public void setDimensionAndShipmentBoxType(String packageSeqId) {
-        if (UtilValidate.isNotEmpty(packageSeqId)) {
-            PackingSessionLine packLine = this.getLine(Integer.parseInt(packageSeqId));
-            packLine.setLength(null);
-            packLine.setWidth(null);
-            packLine.setHeight(null);
-            packLine.setShipmentBoxTypeId(null);
-        }
-    }
-
     class ItemDisplay extends AbstractMap {
 
         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=781008&r1=781007&r2=781008&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 Tue Jun  2 11:35:49 2009
@@ -86,50 +86,6 @@
 }
 packSession.clearItemInfos();
 
-showWarningForm = parameters.showWarningForm;
-if (!showWarningForm) {
-    showWarningForm = false;
-}
-context.showWarningForm = showWarningForm;
-
-currentIndex = parameters.currentIndex;
-if (!currentIndex) {
-    currentIndex = "0";
-}
-dimensionSavedInSession = parameters.dimensionSavedInSession;
-if (!dimensionSavedInSession) {
-    if ("0" != currentIndex) {
-        currentIndex = Integer.toString((Integer.parseInt(currentIndex) - 1));
-    }
-}
-context.currentIndex = currentIndex;
-
-if (packSession) {
-    packageSeqIds = packSession.getPackageSeqIds();
-    index = Integer.parseInt(currentIndex);
-    if (packageSeqIds && (packageSeqIds.size() > index)) {
-        packageSequenceId = packageSeqIds.get(index);
-        context.packageSequenceId = packageSequenceId;
-    } else {
-        context.packageSequenceId = "0";
-    }
-}
-
-packageSeqIds = packSession.getPackageSeqIds();
-if (packageSeqIds) {
-    weightPackageSeqIds = [];
-    packageSeqIds.each { packageSeqId ->
-        weightPackageSeqId = packSession.getWeightPackageSeqId(packageSeqId);
-        if (weightPackageSeqId > -1) {
-            weightPackageSeqIds.add(weightPackageSeqId);
-        }
-    }
-    context.weightPackageSeqIds = weightPackageSeqIds;
-}
-
-shipmentBoxTypes = delegator.findList("ShipmentBoxType", null, null, ["description"], null, true);
-context.shipmentBoxTypes = shipmentBoxTypes;
-
 // picklist based packing information
 picklistBinId = parameters.picklistBinId;
 // see if the bin ID is already set
@@ -159,16 +115,6 @@
 context.shipGroupSeqId = shipGroupSeqId;
 context.picklistBinId = picklistBinId;
 
-shipment = EntityUtil.getFirst(delegator.findByAnd("Shipment", [primaryOrderId : orderId, statusId : "SHIPMENT_PICKED"]));
-context.shipment = shipment;
-
-if (shipment) {
-    invoice = EntityUtil.getFirst(delegator.findByAnd("ShipmentItemBilling", [shipmentId : shipment.shipmentId]));
-    context.invoice = invoice;
-} else {
-    context.invoice = null;
-}
-
 // grab the order information
 if (orderId) {
     orderHeader = delegator.findOne("OrderHeader", [orderId : orderId], false);
@@ -179,51 +125,36 @@
         context.orderReadHelper = orh;
         orderItemShipGroup = orh.getOrderItemShipGroup(shipGroupSeqId);
         context.orderItemShipGroup = orderItemShipGroup;
-        orderItems = orh.getOrderItems();
-        context.orderItems = orderItems;
 
         if ("ORDER_APPROVED".equals(orderHeader.statusId)) {
             if (shipGroupSeqId) {
-                if (shipment) {
 
-                    // Generate the shipment cost estimate for the ship group
-                    productStoreId = orh.getProductStoreId();
-                    shippableItemInfo = orh.getOrderItemAndShipGroupAssoc(shipGroupSeqId);
-                    shippableItems = delegator.findList("OrderItemAndShipGrpInvResAndItemSum", EntityCondition.makeCondition([orderId : orderId, shipGroupSeqId : shipGroupSeqId]), null, null, null, false);
-                    shippableTotal = new Double(orh.getShippableTotal(shipGroupSeqId).doubleValue());
-                    shippableWeight = new Double(orh.getShippableWeight(shipGroupSeqId).doubleValue());
-                    shippableQuantity = new Double(orh.getShippableQuantity(shipGroupSeqId).doubleValue());
-                    shipmentCostEstimate = packSession.getShipmentCostEstimate(orderItemShipGroup, productStoreId, shippableItemInfo, shippableTotal, shippableWeight, shippableQuantity);
-                    context.shipmentCostEstimateForShipGroup = shipmentCostEstimate;
-                    context.productStoreId = productStoreId;
-
-                    if (!picklistBinId) {
-                        packSession.addItemInfo(shippableItems);
-                        //context.put("itemInfos", shippableItemInfo);
-                    }
-                } else {
-                    request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage("OrderErrorUiLabels", "OrderErrorOrderNotVerifiedForPacking", [orderId : orderId], locale));
+                // Generate the shipment cost estimate for the ship group
+                productStoreId = orh.getProductStoreId();
+                shippableItemInfo = orh.getOrderItemAndShipGroupAssoc(shipGroupSeqId);
+                shippableItems = delegator.findList("OrderItemAndShipGrpInvResAndItemSum", EntityCondition.makeCondition([orderId : orderId, shipGroupSeqId : shipGroupSeqId]), null, null, null, false);
+                shippableTotal = new Double(orh.getShippableTotal(shipGroupSeqId).doubleValue());
+                shippableWeight = new Double(orh.getShippableWeight(shipGroupSeqId).doubleValue());
+                shippableQuantity = new Double(orh.getShippableQuantity(shipGroupSeqId).doubleValue());
+                shipmentCostEstimate = packSession.getShipmentCostEstimate(orderItemShipGroup, productStoreId, shippableItemInfo, shippableTotal, shippableWeight, shippableQuantity);
+                context.shipmentCostEstimateForShipGroup = shipmentCostEstimate;
+                context.productStoreId = productStoreId;
+
+                if (!picklistBinId) {
+                    packSession.addItemInfo(shippableItems);
+                    //context.put("itemInfos", shippableItemInfo);
                 }
             } else {
-                request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoShipGroupSequenceIdFoundCannotProcess", locale));
+                request.setAttribute("errorMessageList", ['No ship group sequence ID. Cannot process.']);
             }
         } else {
-            request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage("OrderErrorUiLabels", "OrderErrorOrderNotApprovedForPacking", [orderId : orderId], locale));
+            request.setAttribute("errorMessageList", ["Order #" + orderId + " is not approved for packing."]);
         }
     } else {
-        request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage("OrderErrorUiLabels", "OrderErrorOrderIdNotFound", [orderId : orderId], locale));
+        request.setAttribute("errorMessageList", ["Order #" + orderId + " cannot be found."]);
     }
 }
 
-defaultDimensionUomId = null;
-if (facility) {
-    defaultDimensionUomId = facility.defaultDimensionUomId;
-}
-if (!defaultDimensionUomId) {
-    defaultDimensionUomId = UtilProperties.getPropertyValue("shipment.properties", "shipment.default.dimension.uom", "LEN_in");
-}
-context.defaultDimensionUomId = defaultDimensionUomId;
-
 // Try to get the defaultWeightUomId first from the facility, then from the shipment properties, and finally defaulting to kilos
 defaultWeightUomId = null;
 if (facility) {