Author: ashish
Date: Sat Jun 6 13:15:14 2009 New Revision: 782258 URL: http://svn.apache.org/viewvc?rev=782258&view=rev Log: Applied patch from jira issue OFBIZ-2407 (Functionality for "Weight Packages Only" option on pack order screen). I have cursory reviewed the code and did the functional testing. And found functionality working fine. Thanks Akash Jain for your contribution. Specially thanks to other members involved in this work are Divesh, Pranay & Vikas. Added: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageServices.java (with props) ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java (with props) ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java (with props) ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/WeightPackage.groovy (with props) ofbiz/trunk/applications/product/webapp/facility/shipment/WeightPackage.ftl (with props) Modified: ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml ofbiz/trunk/applications/product/servicedef/services_shipment.xml ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.groovy ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml Modified: ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml?rev=782258&r1=782257&r2=782258&view=diff ============================================================================== --- ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml (original) +++ ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml Sat Jun 6 13:15:14 2009 @@ -654,6 +654,9 @@ <value xml:lang="th">ERROR : à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸ ! à¹à¸¡à¹à¸à¸à¸à¹à¸²à¸«à¸±à¸§à¸à¹à¸à¸£à¸²à¸¢à¸à¸²à¸£à¸ªà¸±à¹à¸à¸à¸·à¹à¸à¸ªà¸³à¸«à¸£à¸±à¸à¸£à¸«à¸±à¸ªà¸£à¸²à¸¢à¸à¸²à¸£à¸ªà¸±à¹à¸à¸à¸·à¹à¸ : ${orderId}</value> <value xml:lang="zh">é误ï¼æ²¡æ为订åæ è¯ï¼${orderId} æ¾å°ææç订å头 </value> </property> + <property key="OrderErrorOrderHasBeenAlreadyVerified"> + <value xml:lang="en">ERROR: Order #${orderId} has been already verified, go to Weight Package Only screen for further processing</value> + </property> <property key="OrderErrorOrderIdNotFound"> <value xml:lang="en">ERROR: Order with ID [${orderId}] not found</value> <value xml:lang="fr">Erreur : la commande avec la réf. [${orderId}] n'a pas été trouvé</value> @@ -702,6 +705,9 @@ <value xml:lang="ru">Ðаказ ${orderId} не ÑвлÑеÑÑÑ Ð·Ð°ÐºÑпоÑнÑм заказом</value> <value xml:lang="th">à¹à¸à¸ªà¸±à¹à¸à¸à¸·à¹à¸à¸ªà¸´à¸à¸à¹à¸² ${orderId} à¹à¸¡à¹à¹à¸à¹à¸à¸£à¸²à¸¢à¸à¸²à¸£à¸ªà¸±à¹à¸à¸à¸·à¹à¸</value> </property> + <property key="OrderErrorOrderNotVerified"> + <value xml:lang="en">ERROR: Order #${orderId} is not verified, click Pack Order button instead of Weight Package Only button for further processing</value> + </property> <property key="OrderErrorOrderNotVerifiedForPacking"> <value xml:lang="en">ERROR: Order #${orderId} is not verified for packing</value> </property> Modified: ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml?rev=782258&r1=782257&r2=782258&view=diff ============================================================================== --- ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml (original) +++ ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml Sat Jun 6 13:15:14 2009 @@ -85,6 +85,12 @@ <property key="ProductErrorNoValidOrderItemFoundForProductWithEnteredQuantity"> <value xml:lang="en">ERROR: No valid order item found for product [${productId}] with quantity [${quantity}]</value> </property> + <property key="ProductErrorNumberOfPackageCannotBeGreaterThanTheNumberOfOrderedQuantity"> + <value xml:lang="en">ERROR: Number of package cannot be greater than the number of ordered quantity</value> + </property> + <property key="ProductErrorPackageWeightCannotBeNullOrZero"> + <value xml:lang="en">ERROR: Package weight cannot be null/zero, it should be greater than zero</value> + </property> <property key="ProductFeatureTypeIdMustContainsLettersAndDigits"> <value xml:lang="de">Die Produktmerkmal Typ ID darf nur Buchstaben, Zahlen und _ enthalten. Bitte erneut eingeben.</value> <value xml:lang="en">The Product Feature TypeId must contains only letters, underscore and digits. Please re-enter</value> Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=782258&r1=782257&r2=782258&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Sat Jun 6 13:15:14 2009 @@ -482,6 +482,57 @@ <attribute name="shipmentId" type="String" mode="INOUT" optional="true"/> </service> + <!-- Weight Package Only Services --> + <service name="weightPackageOnly" engine="java" + location="org.ofbiz.shipment.weightPackage.WeightPackageServices" invoke="weightPackageOnly" auth="true"> + <description>Check order is verified or not, if veified than shown weight package only screen otherwise shown packing screen</description> + <attribute name="orderId" type="String" mode="IN" optional="false"/> + </service> + + <service name="setPackageInfo" engine="java" + location="org.ofbiz.shipment.weightPackage.WeightPackageServices" invoke="setPackageInfo" auth="true"> + <description>Set the weight, dimensions/shipmentBoxType of package in SESSION</description> + <attribute name="weightPackageSession" type="org.ofbiz.shipment.weightPackage.WeightPackageSession" mode="IN" optional="false"/> + <attribute name="orderId" type="String" mode="IN" optional="false"/> + <attribute name="packageWeight" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="packageLength" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="packageWidth" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="packageHeight" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="shipmentBoxTypeId" type="String" mode="IN" optional="true"/> + </service> + + <service name="updatePackedLine" engine="java" + location="org.ofbiz.shipment.weightPackage.WeightPackageServices" invoke="updatePackedLine" auth="true"> + <description>Update the weight, dimensions/shipmentBoxType of package</description> + <attribute name="weightPackageSession" type="org.ofbiz.shipment.weightPackage.WeightPackageSession" mode="IN" optional="false"/> + <attribute name="packageWeight" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="packageLength" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="packageWidth" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="packageHeight" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="shipmentBoxTypeId" type="String" mode="IN" optional="true"/> + <attribute name="weightPackageSeqId" type="Integer" mode="IN" optional="false"/> + </service> + + <service name="deletePackedLine" engine="java" + location="org.ofbiz.shipment.weightPackage.WeightPackageServices" invoke="deletePackedLine" auth="true"> + <description>Delete the weight, dimensions/shipmentBoxType of package</description> + <attribute name="weightPackageSession" type="org.ofbiz.shipment.weightPackage.WeightPackageSession" mode="IN" optional="false"/> + <attribute name="weightPackageSeqId" type="Integer" mode="IN" optional="false"/> + </service> + + <service name="completePackage" engine="java" + location="org.ofbiz.shipment.weightPackage.WeightPackageServices" invoke="completePackage" auth="true"> + <description>Complete the packging and set the shipment to packed</description> + <attribute name="weightPackageSession" type="org.ofbiz.shipment.weightPackage.WeightPackageSession" mode="IN" optional="false"/> + <attribute name="orderId" type="String" mode="IN" optional="true"/> + <attribute name="invoiceId" type="String" mode="IN" optional="true"/> + <attribute name="facilityId" type="String" mode="IN" optional="true"/> + <attribute name="dimensionUomId" type="String" mode="IN" optional="true"/> + <attribute name="weightUomId" type="String" mode="IN" optional="true"/> + <attribute name="estimatedShippingCost" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="shipmentId" type="String" mode="INOUT" optional="true"/> + </service> + <!-- Pack Order Services --> <service name="packSingleItem" engine="java" location="org.ofbiz.shipment.packing.PackingServices" invoke="addPackLine" auth="true"> @@ -572,27 +623,6 @@ <attribute name="dimensionSavedInSession" type="Boolean" mode="OUT" optional="true"/> </service> - <service name="completePackage" engine="java" - location="org.ofbiz.shipment.packing.PackingServices" invoke="completePackage" auth="true"> - <description>Complete the packging and set the shipment to packed</description> - <attribute name="packingSession" type="org.ofbiz.shipment.packing.PackingSession" mode="IN" optional="false"/> - <attribute name="packageWeights" type="Map" string-map-prefix="packageWeight_" mode="IN" optional="true"/> - <attribute name="orderId" type="String" mode="IN" optional="true"/> - <attribute name="invoiceId" type="String" mode="IN" optional="true"/> - <attribute name="dimensionUomId" type="String" mode="IN" optional="true"/> - <attribute name="weightUomId" type="String" mode="IN" optional="true"/> - <attribute name="shippingContactMechId" type="String" mode="IN" optional="false"/> - <attribute name="shipmentMethodTypeId" type="String" mode="IN" optional="false"/> - <attribute name="carrierPartyId" type="String" mode="IN" optional="false"/> - <attribute name="carrierRoleTypeId" type="String" mode="IN" optional="false"/> - <attribute name="productStoreId" type="String" mode="IN" optional="false"/> - <attribute name="shipmentCostEstimateForShipGroup" type="String" mode="IN" optional="true"/> - <attribute name="pickerPartyId" type="String" mode="IN" optional="true"/> - <attribute name="forceComplete" type="Boolean" mode="IN" optional="true"/> - <attribute name="shipmentId" type="String" mode="INOUT" optional="true"/> - <attribute name="showWarningForm" type="Boolean" mode="OUT" optional="true"/> - </service> - <service name="holdShipment" engine="java" location="org.ofbiz.shipment.packing.PackingServices" invoke="holdShipment" auth="true"> <description>Shipment will remains in PICKED sataus and dimension and weight will save in the ShipmentPackage entity</description> Added: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageServices.java?rev=782258&view=auto ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageServices.java (added) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageServices.java Sat Jun 6 13:15:14 2009 @@ -0,0 +1,176 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.shipment.weightPackage; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javolution.util.FastMap; + +import org.ofbiz.base.util.GeneralException; +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.GenericValue; +import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ServiceUtil; + +public class WeightPackageServices { + + private static BigDecimal ZERO = BigDecimal.ZERO; + + public static Map<String, Object> weightPackageOnly(DispatchContext dctx, Map<String, ? extends Object> context) { + GenericDelegator delegator = dctx.getDelegator(); + Locale locale = (Locale) context.get("locale"); + WeightPackageSession weightPackageSession = (WeightPackageSession) context.get("weightPackageSession"); + String orderId = (String) context.get("orderId"); + try { + GenericValue shipment = EntityUtil.getFirst(delegator.findByAnd("Shipment", UtilMisc.toMap("primaryOrderId", orderId, "statusId", "SHIPMENT_PICKED"))); + if (UtilValidate.isEmpty(shipment)) { + return ServiceUtil.returnError(UtilProperties.getMessage("OrderErrorUiLabels", "OrderErrorOrderNotVerified", UtilMisc.toMap("orderId", orderId), locale)); + } + } catch (GeneralException e) { + ServiceUtil.returnError(e.getMessage()); + } + return ServiceUtil.returnSuccess(); + } + + public static Map<String, Object> setPackageInfo(DispatchContext dctx, Map<String, ? extends Object> context) { + GenericDelegator delegator = dctx.getDelegator(); + WeightPackageSession weightPackageSession = (WeightPackageSession) context.get("weightPackageSession"); + Locale locale = (Locale) context.get("locale"); + + String orderId = (String) context.get("orderId"); + BigDecimal packageWeight = (BigDecimal) context.get("packageWeight"); + BigDecimal packageLength = (BigDecimal) context.get("packageLength"); + BigDecimal packageWidth = (BigDecimal) context.get("packageWidth"); + BigDecimal packageHeight = (BigDecimal) context.get("packageHeight"); + String shipmentBoxTypeId = (String) context.get("shipmentBoxTypeId"); + + // 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 + 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 + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNotEnteredAllFieldsInDimension", locale)); + } + } + // Check package weight, it must be greater than ZERO + if (UtilValidate.isEmpty(packageWeight) || packageWeight.compareTo(ZERO) <= 0) { + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorPackageWeightCannotBeNullOrZero", locale)); + } + try { + // Checked no of packages, it should not be greater than ordered quantity + List<GenericValue> orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId)); + BigDecimal orderedItemQty = ZERO; + for (GenericValue orderItem : orderItems) { + orderedItemQty = orderedItemQty.add(orderItem.getBigDecimal("quantity")); + } + int packageQuantity = weightPackageSession.getPackedLines(orderId).size(); + if ((orderedItemQty.intValue() - packageQuantity) > 0) { + weightPackageSession.createWeightPackageLine(orderId, packageWeight, packageLength, packageWidth, packageHeight, shipmentBoxTypeId); + } else { + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNumberOfPackageCannotBeGreaterThanTheNumberOfOrderedQuantity", locale)); + } + } catch (GeneralException e) { + return ServiceUtil.returnError(e.getMessage()); + } + return ServiceUtil.returnSuccess(); + } + + public static Map<String, Object> updatePackedLine(DispatchContext dctx, Map<String, ? extends Object> context) { + WeightPackageSession weightPackageSession = (WeightPackageSession) context.get("weightPackageSession"); + Locale locale = (Locale) context.get("locale"); + + BigDecimal packageWeight = (BigDecimal) context.get("packageWeight"); + BigDecimal packageLength = (BigDecimal) context.get("packageLength"); + BigDecimal packageWidth = (BigDecimal) context.get("packageWidth"); + BigDecimal packageHeight = (BigDecimal) context.get("packageHeight"); + String shipmentBoxTypeId = (String) context.get("shipmentBoxTypeId"); + Integer weightPackageSeqId = (Integer) 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 + weightPackageSession.setDimensionAndShipmentBoxType(weightPackageSeqId); + 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 + weightPackageSession.setDimensionAndShipmentBoxType(weightPackageSeqId); + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNotEnteredAllFieldsInDimension", locale)); + } + } + + // Check package weight, it must be greater than ZERO + if (UtilValidate.isEmpty(packageWeight) || packageWeight.compareTo(ZERO) <= 0) { + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorPackageWeightCannotBeNullOrZero", locale)); + } + + weightPackageSession.setPackageWeight(packageWeight, weightPackageSeqId); + weightPackageSession.setPackageLength(packageLength, weightPackageSeqId); + weightPackageSession.setPackageWidth(packageWidth, weightPackageSeqId); + weightPackageSession.setPackageHeight(packageHeight, weightPackageSeqId); + weightPackageSession.setShipmentBoxTypeId(shipmentBoxTypeId, weightPackageSeqId); + + return ServiceUtil.returnSuccess(); + } + + public static Map<String, Object> deletePackedLine(DispatchContext dctx, Map<String, ? extends Object> context) { + WeightPackageSession weightPackageSession = (WeightPackageSession) context.get("weightPackageSession"); + Integer weightPackageSeqId = (Integer) context.get("weightPackageSeqId"); + + weightPackageSession.deletePackedLine(weightPackageSeqId); + return ServiceUtil.returnSuccess(); + } + + public static Map<String, Object> completePackage(DispatchContext dctx, Map<String, ? extends Object> context) { + GenericDelegator delegator = dctx.getDelegator(); + WeightPackageSession weightPackageSession = (WeightPackageSession) context.get("weightPackageSession"); + Locale locale = (Locale) context.get("locale"); + + String orderId = (String) context.get("orderId"); + String shipmentId = (String) context.get("shipmentId"); + String invoiceId = (String) context.get("invoiceId"); + String dimensionUomId = (String) context.get("dimensionUomId"); + String weightUomId = (String) context.get("weightUomId"); + BigDecimal estimatedShipCost = (BigDecimal) context.get("shipmentEstimateCost"); + + weightPackageSession.setDimensionUomId(dimensionUomId); + weightPackageSession.setWeightUomId(weightUomId); + weightPackageSession.setShipmentId(shipmentId); + weightPackageSession.setInvoiceId(invoiceId); + weightPackageSession.setEstimatedShipCost(estimatedShipCost); + + Map<String, Object> response = FastMap.newInstance(); + try { + if (weightPackageSession.complete(orderId, locale)) { + response.put("shipmentId", shipmentId); + } else { + response = ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoItemsCurrentlySetToBeShippedCannotComplete", locale)); + } + } catch (GeneralException e) { + return ServiceUtil.returnError(e.getMessage(), e.getMessageList()); + } + return response; + } + +} \ No newline at end of file Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageServices.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageServices.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageServices.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=782258&view=auto ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java (added) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java Sat Jun 6 13:15:14 2009 @@ -0,0 +1,413 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.shipment.weightPackage; + +import java.io.Serializable; +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.UtilFormatOut; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.service.GenericDispatcher; +import org.ofbiz.service.LocalDispatcher; +import org.ofbiz.service.ServiceUtil; +import org.ofbiz.shipment.weightPackage.WeightPackageSession; +import org.ofbiz.shipment.weightPackage.WeightPackageSessionLine; + +public class WeightPackageSession implements Serializable { + + public static final String module = WeightPackageSession.class.getName(); + + protected GenericValue userLogin = null; + protected String dispatcherName = null; + protected String delegatorName = null; + protected String primaryOrderId = null; + protected String primaryShipGrpSeqId = null; + protected String picklistBinId = null; + protected String shipmentId = null; + protected String invoiceId = null; + protected String facilityId = null; + protected String dimensionUomId = null; + protected String weightUomId = null; + protected BigDecimal estimatedShipCost = null; + protected int weightPackageSeqId = 1; + protected List<WeightPackageSessionLine> weightPackageLines = null; + + private transient GenericDelegator _delegator = null; + private transient LocalDispatcher _dispatcher = null; + private static BigDecimal ZERO = BigDecimal.ZERO; + + public WeightPackageSession() { + } + + public WeightPackageSession(LocalDispatcher dispatcher, GenericValue userLogin, String facilityId, String picklistBinId, String orderId, String shipGrpSeqId) { + this._dispatcher = dispatcher; + this.dispatcherName = dispatcher.getName(); + + this._delegator = _dispatcher.getDelegator(); + this.delegatorName = _delegator.getDelegatorName(); + + this.primaryOrderId = orderId; + this.primaryShipGrpSeqId = shipGrpSeqId; + this.picklistBinId = picklistBinId; + this.userLogin = userLogin; + this.facilityId = facilityId; + this.weightPackageLines = FastList.newInstance(); + } + + public WeightPackageSession(LocalDispatcher dispatcher, GenericValue userLogin, String facilityId) { + this(dispatcher, userLogin, facilityId, null, null, null); + } + + public WeightPackageSession(LocalDispatcher dispatcher, GenericValue userLogin) { + this(dispatcher, userLogin, null, null, null, null); + } + + public LocalDispatcher getDispatcher() { + if (_dispatcher == null) { + _dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherName, this.getDelegator()); + } + return _dispatcher; + } + + public GenericDelegator getDelegator() { + if (_delegator == null) { + _delegator = GenericDelegator.getGenericDelegator(delegatorName); + } + return _delegator; + } + + public void createWeightPackageLine(String orderId, BigDecimal packageWeight, BigDecimal packageLength, BigDecimal packageWidth, BigDecimal packageHeight, String shipmentBoxTypeId) throws GeneralException { + weightPackageLines.add(new WeightPackageSessionLine(orderId, packageWeight, packageLength, packageWidth, packageHeight, shipmentBoxTypeId, this.weightPackageSeqId)); + this.weightPackageSeqId++; + } + + public int getWeightPackageSeqId() { + return this.weightPackageSeqId; + } + + public String getFacilityId() { + return this.facilityId; + } + + public void setFacilityId(String facilityId) { + this.facilityId = facilityId; + } + + public String getPrimaryOrderId() { + return this.primaryOrderId; + } + + public void setPrimaryOrderId(String primaryOrderId) { + this.primaryOrderId = primaryOrderId; + } + + public String getPrimaryShipGroupSeqId() { + return this.primaryShipGrpSeqId; + } + + public void setPrimaryShipGroupSeqId(String primaryShipGrpSeqId) { + this.primaryShipGrpSeqId = primaryShipGrpSeqId; + } + + public void setPicklistBinId(String picklistBinId) { + this.picklistBinId = picklistBinId; + } + + public String getPicklistBinId() { + return this.picklistBinId; + } + + public void setEstimatedShipCost(BigDecimal estimatedShipCost) { + this.estimatedShipCost = estimatedShipCost; + } + + public BigDecimal getEstimatedShipCost() { + return this.estimatedShipCost; + } + + public String getShipmentId() { + 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 String getWeightUomId() { + return weightUomId; + } + + public void setWeightUomId(String weightUomId) { + this.weightUomId = weightUomId; + } + + public String getDimensionUomId() { + return dimensionUomId; + } + + public void setDimensionUomId(String dimensionUomId) { + this.dimensionUomId = dimensionUomId; + } + + public BigDecimal getShippableWeight(String orderId) { + BigDecimal shippableWeight = ZERO; + for (WeightPackageSessionLine packedLine : this.getPackedLines(orderId)) { + shippableWeight = shippableWeight.add(packedLine.getPackageWeight()); + } + return shippableWeight; + } + + public List<WeightPackageSessionLine> getPackedLines() { + return this.weightPackageLines; + } + + public List<WeightPackageSessionLine> getPackedLines(String orderId) { + List<WeightPackageSessionLine> packedLines = FastList.newInstance(); + if (UtilValidate.isNotEmpty(orderId)) { + for (WeightPackageSessionLine packedLine: this.getPackedLines()) { + if (orderId.equals(packedLine.getOrderId())) + packedLines.add(packedLine); + } + } + return packedLines; + } + + public WeightPackageSessionLine getPackedLine(int weightPackageSeqId) { + WeightPackageSessionLine packedLine = null; + if (weightPackageSeqId > 0) { + for (WeightPackageSessionLine line : this.getPackedLines()) { + if ((line.getWeightPackageSeqId()) == weightPackageSeqId) + packedLine = line; + } + } + return packedLine; + } + + public void setPackageWeight(BigDecimal packageWeight, int weightPackageSeqId) { + if (weightPackageSeqId > 0) { + WeightPackageSessionLine packedLine = this.getPackedLine(weightPackageSeqId); + if (UtilValidate.isNotEmpty(packedLine)) + packedLine.setPackageWeight(packageWeight); + } + } + + public void setPackageLength(BigDecimal packageLength, int weightPackageSeqId) { + if (weightPackageSeqId > 0) { + WeightPackageSessionLine packedLine = this.getPackedLine(weightPackageSeqId); + if (UtilValidate.isNotEmpty(packedLine)) + packedLine.setPackageLength(packageLength); + } + } + + public void setPackageWidth(BigDecimal packageWidth, int weightPackageSeqId) { + if (weightPackageSeqId > 0) { + WeightPackageSessionLine packedLine = this.getPackedLine(weightPackageSeqId); + if (UtilValidate.isNotEmpty(packedLine)) + packedLine.setPackageWidth(packageWidth); + } + } + + public void setPackageHeight(BigDecimal packageHeight, int weightPackageSeqId) { + if (weightPackageSeqId > 0) { + WeightPackageSessionLine packedLine = this.getPackedLine(weightPackageSeqId); + if (UtilValidate.isNotEmpty(packedLine)) + packedLine.setPackageHeight(packageHeight); + } + } + + public void setShipmentBoxTypeId(String shipmentBoxTypeId, int weightPackageSeqId) { + if (weightPackageSeqId > 0) { + WeightPackageSessionLine packedLine = this.getPackedLine(weightPackageSeqId); + if (UtilValidate.isNotEmpty(packedLine)) + packedLine.setShipmentBoxTypeId(shipmentBoxTypeId); + } + } + + public void deletePackedLine(int weightPackageSeqId) { + if (weightPackageSeqId > 0) { + WeightPackageSessionLine packedLine = this.getPackedLine(weightPackageSeqId); + this.weightPackageLines.remove(packedLine); + } + } + + public void setDimensionAndShipmentBoxType(int weightPackageSeqId) { + if (weightPackageSeqId > 0) { + WeightPackageSessionLine packedLine = this.getPackedLine(weightPackageSeqId); + packedLine.setPackageLength(null); + packedLine.setPackageWidth(null); + packedLine.setPackageHeight(null); + packedLine.setShipmentBoxTypeId(null); + } + } + + public void clearPackedLines(String orderId) { + for (WeightPackageSessionLine packedLine : this.getPackedLines(orderId)) { + this.weightPackageLines.remove(packedLine); + } + } + + public boolean complete(String orderId, Locale locale) throws GeneralException { + + this.createPackages(orderId); + this.changeOrderItemStatus(orderId, shipmentId); + this.applyItemsToPackages(orderId); + this.updateShipmentRouteSegments(orderId); + this.setShipmentToPacked(); + + return true; + } + + protected void createPackages(String orderId) throws GeneralException { + int shipPackSeqId = 0; + for (WeightPackageSessionLine packedLine : this.getPackedLines(orderId)) { + String shipmentPackageSeqId = UtilFormatOut.formatPaddedNumber(++shipPackSeqId, 5); + + Map<String, Object> shipmentPackageMap = FastMap.newInstance(); + shipmentPackageMap.put("shipmentId", shipmentId); + shipmentPackageMap.put("shipmentPackageSeqId", shipmentPackageSeqId); + shipmentPackageMap.put("weight", packedLine.getPackageWeight()); + shipmentPackageMap.put("boxLength", packedLine.getPackageLength()); + shipmentPackageMap.put("boxWidth", packedLine.getPackageWidth()); + shipmentPackageMap.put("boxHeight", packedLine.getPackageHeight()); + shipmentPackageMap.put("dimensionUomId", getDimensionUomId()); + shipmentPackageMap.put("shipmentBoxTypeId", packedLine.getShipmentBoxTypeId()); + shipmentPackageMap.put("weightUomId", getWeightUomId()); + shipmentPackageMap.put("userLogin", userLogin); + + Map<String, Object> shipmentPackageResult = this.getDispatcher().runSync("createShipmentPackage", shipmentPackageMap); + if (ServiceUtil.isError(shipmentPackageResult)) { + throw new GeneralException(ServiceUtil.getErrorMessage(shipmentPackageResult)); + } + } + } + + 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 (WeightPackageSessionLine packedLine : this.getPackedLines(orderId)) { + packedLine.setShipmentItemSeqId(shipmentItem.getString("shipmentItemSeqId")); + } + } + List<GenericValue> orderItems = this.getDelegator().findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId)); + for (GenericValue orderItem : orderItems) { + List<GenericValue> 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> orderItemStatusResult = this.getDispatcher().runSync("changeOrderItemStatus", orderItemStatusMap); + if (ServiceUtil.isError(orderItemStatusResult)) { + throw new GeneralException(ServiceUtil.getErrorMessage(orderItemStatusResult)); + } + } + } + } + + protected void applyItemsToPackages(String orderId) throws GeneralException { + if (UtilValidate.isNotEmpty(orderId) && UtilValidate.isNotEmpty(this.getPackedLines(orderId))) { + int shipPackSeqId = 0; + for (WeightPackageSessionLine line: this.getPackedLines(orderId)) { + line.applyLineToPackage(shipmentId, userLogin, getDispatcher(), ++shipPackSeqId); + } + } + } + + protected void updateShipmentRouteSegments(String orderId) throws GeneralException { + if (UtilValidate.isNotEmpty(orderId)) { + BigDecimal shipmentWeight = getShippableWeight(orderId); + if (UtilValidate.isNotEmpty(shipmentWeight) && shipmentWeight.compareTo(BigDecimal.ZERO) <= 0) return; + List<GenericValue> shipmentRouteSegments = getDelegator().findByAnd("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", this.getShipmentId())); + if (UtilValidate.isNotEmpty(shipmentRouteSegments)) { + for (GenericValue shipmentRouteSegment : shipmentRouteSegments) { + shipmentRouteSegment.set("billingWeight", shipmentWeight); + shipmentRouteSegment.set("billingWeightUomId", getWeightUomId()); + } + getDelegator().storeAll(shipmentRouteSegments); + } + } + } + + protected void setShipmentToPacked() throws GeneralException { + Map<String, Object> shipmentMap = FastMap.newInstance(); + shipmentMap.put("shipmentId", shipmentId); + shipmentMap.put("statusId", "SHIPMENT_PACKED"); + shipmentMap.put("userLogin", userLogin); + Map<String, Object> shipmentResult = this.getDispatcher().runSync("updateShipment", shipmentMap); + if (UtilValidate.isNotEmpty(shipmentResult) && ServiceUtil.isError(shipmentResult)) { + throw new GeneralException(ServiceUtil.getErrorMessage(shipmentResult)); + } + } + + public BigDecimal getShipmentCostEstimate(GenericValue orderItemShipGroup, String orderId, String productStoreId, List<GenericValue> shippableItemInfo, BigDecimal shippableTotal, BigDecimal shippableWeight, BigDecimal shippableQuantity) { + return getShipmentCostEstimate(orderItemShipGroup.getString("contactMechId"), orderItemShipGroup.getString("shipmentMethodTypeId"), + orderItemShipGroup.getString("carrierPartyId"), orderItemShipGroup.getString("carrierRoleTypeId"), + orderId, productStoreId, shippableItemInfo, shippableTotal, shippableWeight, shippableQuantity); + } + + public BigDecimal getShipmentCostEstimate(String shippingContactMechId, String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String orderId, String productStoreId, List<GenericValue> shippableItemInfo, BigDecimal shippableTotal, BigDecimal shippableWeight, BigDecimal shippableQuantity) { + BigDecimal shipmentCostEstimate = ZERO; + Map<String, Object> shipCostEstimateResult = null; + try { + Map<String, Object> shipCostEstimateMap = FastMap.newInstance(); + shipCostEstimateMap.put("shippingContactMechId", shippingContactMechId); + shipCostEstimateMap.put("shipmentMethodTypeId", shipmentMethodTypeId); + shipCostEstimateMap.put("carrierPartyId", carrierPartyId); + shipCostEstimateMap.put("carrierRoleTypeId", carrierRoleTypeId); + shipCostEstimateMap.put("productStoreId", productStoreId); + shipCostEstimateMap.put("shippableItemInfo", shippableItemInfo); + if (UtilValidate.isEmpty(shippableWeight) && UtilValidate.isNotEmpty(orderId)) { + shippableWeight = this.getShippableWeight(orderId); + } + shipCostEstimateMap.put("shippableWeight", shippableWeight); + shipCostEstimateMap.put("shippableQuantity", shippableQuantity); + if (UtilValidate.isEmpty(shippableTotal)) { + shippableTotal = BigDecimal.ZERO; + } + shipCostEstimateMap.put("shippableTotal", shippableTotal); + shipCostEstimateResult = getDispatcher().runSync("calcShipmentCostEstimate", shipCostEstimateMap); + } catch ( GeneralException e ) { + Debug.logError(e, module); + } + if (UtilValidate.isNotEmpty(shipCostEstimateResult.get("shippingEstimateAmount"))) { + shipmentCostEstimate = (BigDecimal) shipCostEstimateResult.get("shippingEstimateAmount"); + } + return shipmentCostEstimate; + } +} \ No newline at end of file Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java?rev=782258&view=auto ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java (added) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java Sat Jun 6 13:15:14 2009 @@ -0,0 +1,134 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.shipment.weightPackage; + +import java.math.BigDecimal; +import java.util.Map; +import java.io.Serializable; + +import javolution.util.FastMap; + +import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilFormatOut; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.service.LocalDispatcher; +import org.ofbiz.service.ServiceUtil; + +public class WeightPackageSessionLine implements java.io.Serializable { + + protected String orderId = null; + protected BigDecimal packageWeight = BigDecimal.ZERO; + protected BigDecimal packageLength = null; + protected BigDecimal packageWidth = null; + protected BigDecimal packageHeight = null; + protected String shipmentBoxTypeId = null; + protected String shipmentItemSeqId = null; + protected int weightPackageSeqId = 0; + + public WeightPackageSessionLine(String orderId, BigDecimal packageWeight, BigDecimal packageLength, BigDecimal packageWidth, BigDecimal packageHeight, String shipmentBoxTypeId, int weightPackageSeqId) throws GeneralException { + this.orderId = orderId; + this.packageWeight = packageWeight; + this.packageLength = packageLength; + this.packageWidth = packageWidth; + this.packageHeight = packageHeight; + this.shipmentBoxTypeId = shipmentBoxTypeId; + this.weightPackageSeqId = weightPackageSeqId; + } + + public String getOrderId() { + return this.orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public BigDecimal getPackageWeight() { + return this.packageWeight; + } + + public void setPackageWeight(BigDecimal packageWeight) { + this.packageWeight = packageWeight; + } + + public BigDecimal getPackageLength() { + return this.packageLength; + } + + public void setPackageLength(BigDecimal packageLength) { + this.packageLength = packageLength; + } + + public BigDecimal getPackageWidth() { + return this.packageWidth; + } + + public void setPackageWidth(BigDecimal packageWidth) { + this.packageWidth = packageWidth; + } + + public BigDecimal getPackageHeight() { + return this.packageHeight; + } + + public void setPackageHeight(BigDecimal packageHeight) { + this.packageHeight = packageHeight; + } + + public String getShipmentBoxTypeId() { + return this.shipmentBoxTypeId; + } + + public void setShipmentBoxTypeId(String shipmentBoxTypeId) { + this.shipmentBoxTypeId = shipmentBoxTypeId; + } + + public int getWeightPackageSeqId() { + return this.weightPackageSeqId; + } + + public void setWeightPackageSeqId(int weightPackageSeqId) { + this.weightPackageSeqId = weightPackageSeqId; + } + + public String getShipmentItemSeqId() { + return this.shipmentItemSeqId; + } + + public void setShipmentItemSeqId(String shipmentItemSeqId) { + this.shipmentItemSeqId = shipmentItemSeqId; + } + + protected void applyLineToPackage(String shipmentId, GenericValue userLogin, LocalDispatcher dispatcher, int shipPackSeqId) throws GeneralException { + String shipmentPackageSeqId = UtilFormatOut.formatPaddedNumber(shipPackSeqId, 5); + + Map<String, Object> packageMap = FastMap.newInstance(); + packageMap.put("shipmentId", shipmentId); + packageMap.put("shipmentItemSeqId", this.getShipmentItemSeqId()); + // quanity given, by defult one because it is a required field + packageMap.put("quantity", BigDecimal.ONE); + packageMap.put("shipmentPackageSeqId", shipmentPackageSeqId); + packageMap.put("userLogin", userLogin); + Map<String, Object> packageResp = dispatcher.runSync("addShipmentContentToPackage", packageMap); + + if (ServiceUtil.isError(packageResp)) { + throw new GeneralException(ServiceUtil.getErrorMessage(packageResp)); + } + } +} \ No newline at end of file Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java ------------------------------------------------------------------------------ svn:mime-type = text/plain 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=782258&r1=782257&r2=782258&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 Jun 6 13:15:14 2009 @@ -40,6 +40,7 @@ context.shipmentId = shipmentId; // If a shipment exists, provide the IDs of any related invoices +invoiceIds = null; if (shipmentId) { // Get the primaryOrderId from the shipment shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false); @@ -110,6 +111,12 @@ packSession.setPicklistBinId(picklistBinId); packSession.setFacilityId(facilityId); +if (invoiceIds) { + orderId = null; +} +shipment = EntityUtil.getFirst(delegator.findByAnd("Shipment", [primaryOrderId : orderId, statusId : "SHIPMENT_PICKED"])); +context.shipment = shipment; + context.packingSession = packSession; context.orderId = orderId; context.shipGroupSeqId = shipGroupSeqId; @@ -128,6 +135,7 @@ if ("ORDER_APPROVED".equals(orderHeader.statusId)) { if (shipGroupSeqId) { + if (!shipment) { // Generate the shipment cost estimate for the ship group productStoreId = orh.getProductStoreId(); @@ -145,6 +153,9 @@ //context.put("itemInfos", shippableItemInfo); } } else { + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage("OrderErrorUiLabels", "OrderErrorOrderHasBeenAlreadyVerified", [orderId : orderId], locale)); + } + } else { request.setAttribute("errorMessageList", ['No ship group sequence ID. Cannot process.']); } } else { Added: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/WeightPackage.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/WeightPackage.groovy?rev=782258&view=auto ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/WeightPackage.groovy (added) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/WeightPackage.groovy Sat Jun 6 13:15:14 2009 @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.order.order.OrderReadHelper; +import org.ofbiz.shipment.weightPackage.WeightPackageSession; + +weightPackageSession = session.getAttribute("weightPackageSession"); +if (!weightPackageSession) { + weightPackageSession = new WeightPackageSession(dispatcher, userLogin); + session.setAttribute("weightPackageSession", weightPackageSession); +} +context.weightPackageSession = weightPackageSession; + +orderId = parameters.orderId; +shipGroupSeqId = parameters.shipGroupSeqId; + +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; +} + +facilityId = parameters.facilityId; +if (facilityId) { + facility = delegator.findOne("Facility", [facilityId : facilityId], false); + context.facility = facility; +} + +if (orderId && !shipGroupSeqId && orderId.indexOf("/") > -1) { + idSplit = orderId.split("\\/"); + orderId = idSplit[0]; + shipGroupSeqId = idSplit[1]; +} else if (orderId && !shipGroupSeqId) { + shipGroupSeqId = "00001"; +} + +picklistBinId = parameters.picklistBinId; +if (picklistBinId) { + picklistBin = delegator.findOne("PicklistBin", [picklistBinId : picklistBinId], false); + if (picklistBin) { + orderId = picklistBin.primaryOrderId; + shipGroupSeqId = picklistBin.primaryShipGroupSeqId; + } else { + picklistBinId = null; + } +} + +weightPackageSession.setPrimaryShipGroupSeqId(shipGroupSeqId); +weightPackageSession.setPrimaryOrderId(orderId); +weightPackageSession.setPicklistBinId(picklistBinId); +weightPackageSession.setFacilityId(facilityId); + +if (orderId) { + orderHeader = delegator.findOne("OrderHeader", [orderId : orderId], false); + if (orderHeader) { + OrderReadHelper orderReadHelper = new OrderReadHelper(orderHeader); + GenericValue orderItemShipGroup = orderReadHelper.getOrderItemShipGroup(shipGroupSeqId); + if ("ORDER_APPROVED".equals(orderHeader.statusId)) { + if (shipGroupSeqId) { + productStoreId = orderReadHelper.getProductStoreId(); + shippableItemInfo = orderReadHelper.getOrderItemAndShipGroupAssoc(shipGroupSeqId); + shippableItems = delegator.findList("OrderItemAndShipGrpInvResAndItemSum", EntityCondition.makeCondition([orderId : orderId, shipGroupSeqId : shipGroupSeqId]), null, null, null, false); + shippableTotal = orderReadHelper.getShippableTotal(shipGroupSeqId); + shippableWeight = orderReadHelper.getShippableWeight(shipGroupSeqId); + shippableQuantity = orderReadHelper.getShippableQuantity(shipGroupSeqId); + estimatedShippingCost = weightPackageSession.getShipmentCostEstimate(orderItemShipGroup, orderId, productStoreId, shippableItemInfo, shippableTotal, shippableWeight, shippableQuantity); + if (weightPackageSession.getPackedLines(orderId)) { + shipWeight = weightPackageSession.getShippableWeight(orderId); + newEstimatedShippingCost = weightPackageSession.getShipmentCostEstimate(orderItemShipGroup, orderId, productStoreId, shippableItemInfo, shippableTotal, shipWeight, shippableQuantity); + context.newEstimatedShippingCost = newEstimatedShippingCost; + } + context.productStoreId = productStoreId; + context.estimatedShippingCost = estimatedShippingCost; + } else { + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoShipGroupSequenceIdFoundCannotProcess", locale)); + } + } else { + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage("OrderErrorUiLabels", "OrderErrorOrderNotApprovedForPacking", [orderId : orderId], locale)); + } + } else { + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage("OrderErrorUiLabels", "OrderErrorOrderIdNotFound", [orderId : orderId], locale)); + } +} + +context.orderId = orderId; +context.shipGroupSeqId = shipGroupSeqId; +context.picklistBinId = picklistBinId; + +shipmentBoxTypes = delegator.findList("ShipmentBoxType", null, null, ["description"], null, true); +context.shipmentBoxTypes = shipmentBoxTypes; + +defaultDimensionUomId = null; +if (facility) { + defaultDimensionUomId = facility.defaultDimensionUomId; +} +if (!defaultDimensionUomId) { + defaultDimensionUomId = UtilProperties.getPropertyValue("shipment.properties", "shipment.default.dimension.uom", "LEN_in"); +} +context.defaultDimensionUomId = defaultDimensionUomId; + +defaultWeightUomId = null; +if (facility) { + defaultWeightUomId = facility.defaultWeightUomId; +} +if (!defaultWeightUomId) { + defaultWeightUomId = UtilProperties.getPropertyValue("shipment.properties", "shipment.default.weight.uom", "WT_kg"); +} +context.defaultWeightUomId = defaultWeightUomId; \ No newline at end of file Propchange: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/WeightPackage.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/WeightPackage.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/WeightPackage.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain 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?rev=782258&r1=782257&r2=782258&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml Sat Jun 6 13:15:14 2009 @@ -692,6 +692,38 @@ <response name="error" type="view" value="VerifyPick"/> </request-map> + <!-- ============= Weight Package Only Requests ============== --> + <request-map uri="weightPackageOnly"> + <security https="true" auth="true"/> + <event type="service" invoke="weightPackageOnly"/> + <response name="success" type="view" value="WeightPackageOnly"/> + <response name="error" type="view" value="PackOrder"/> + </request-map> + <request-map uri="setPackageInfo"> + <security https="true" auth="true"/> + <event type="service" invoke="setPackageInfo"/> + <response name="success" type="view" value="WeightPackageOnly"/> + <response name="error" type="view" value="WeightPackageOnly"/> + </request-map> + <request-map uri="updatePackedLine"> + <security https="true" auth="true"/> + <event type="service" invoke="updatePackedLine"/> + <response name="success" type="view" value="WeightPackageOnly"/> + <response name="error" type="view" value="WeightPackageOnly"/> + </request-map> + <request-map uri="deletePackedLine"> + <security https="true" auth="true"/> + <event type="service" invoke="deletePackedLine"/> + <response name="success" type="view" value="WeightPackageOnly"/> + <response name="error" type="view" value="WeightPackageOnly"/> + </request-map> + <request-map uri="completePackage"> + <security https="true" auth="true"/> + <event type="service" invoke="completePackage"/> + <response name="success" type="view" value="PackOrder"/> + <response name="error" type="view" value="WeightPackageOnly"/> + </request-map> + <!-- ============= Packing Wizard Requests ============== --> <request-map uri="PackOrder"> <security https="true" auth="true"/> @@ -743,12 +775,6 @@ <response name="success" type="view" value="PackOrder"/> <response name="error" type="view" value="PackOrder"/> </request-map> - <request-map uri="completePackage"> - <security https="true" auth="true"/> - <event type="service" invoke="completePackage"/> - <response name="success" type="view" value="PackOrder"/> - <response name="error" type="view" value="PackOrder"/> - </request-map> <request-map uri="shipNow"> <security https="true" auth="true"/> <event type="service" invoke="completePack"/> @@ -1267,6 +1293,7 @@ <view-map name="ShipmentManifest.pdf" type="screenfop" page="component://product/widget/facility/ShipmentScreens.xml#ShipmentManifest.fo" content-type="application/pdf" encoding="none"/> <view-map name="VerifyPick" type="screen" page="component://product/widget/facility/ShipmentScreens.xml#VerifyPick"/> + <view-map name="WeightPackageOnly" type="screen" page="component://product/widget/facility/ShipmentScreens.xml#WeightPackageOnly"/> <view-map name="ScheduleShipmentRouteSegment" type="screen" page="component://product/widget/facility/FacilityScreens.xml#ScheduleShipmentRouteSegment"/> <view-map name="Labels" type="screen" page="component://product/widget/facility/FacilityScreens.xml#Labels"/> 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=782258&r1=782257&r2=782258&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl (original) +++ ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl Sat Jun 6 13:15:14 2009 @@ -21,10 +21,11 @@ <#assign showInput = requestParameters.showInput?default("Y")> <#assign hideGrid = requestParameters.hideGrid?default("N")> - <#if (requestParameters.forceComplete?has_content && !shipmentId?has_content)> + <#if (requestParameters.forceComplete?has_content && !invoiceIds?has_content)> <#assign forceComplete = "true"> <#assign showInput = "Y"> </#if> + <div class="screenlet"> <div class="screenlet-title-bar"> <ul> @@ -33,7 +34,7 @@ <br class="clear"/> </div> <div class="screenlet-body"> - <#if shipmentId?has_content> + <#if invoiceIds?has_content> <div> ${uiLabelMap.CommonView} <a href="<@ofbizUrl>/PackingSlip.pdf?shipmentId=${shipmentId}</@ofbizUrl>" target="_blank" class="buttontext">${uiLabelMap.ProductPackingSlip}</a> ${uiLabelMap.CommonOr} ${uiLabelMap.CommonView} <a href="<@ofbizUrl>/ShipmentBarCode.pdf?shipmentId=${shipmentId}</@ofbizUrl>" target="_blank" class="buttontext">${uiLabelMap.ProductBarcode}</a> ${uiLabelMap.CommonFor} ${uiLabelMap.ProductShipmentId} <a href="<@ofbizUrl>/ViewShipment?shipmentId=${shipmentId}</@ofbizUrl>" class="buttontext">${shipmentId}</a> @@ -74,6 +75,7 @@ <td colspan="2"> <input type="image" src="<@ofbizContentUrl>/images/spacer.gif</@ofbizContentUrl>" onClick="javascript:document.selectOrderForm.submit();"> <a href="javascript:document.selectOrderForm.submit();" class="buttontext">${uiLabelMap.ProductPackOrder}</a> + <a href="javascript:document.selectOrderForm.action='<@ofbizUrl>weightPackageOnly</@ofbizUrl>';document.selectOrderForm.submit();" class="buttontext">${uiLabelMap.ProductWeightPackageOnly}</a> </td> </tr> </table> @@ -98,6 +100,7 @@ <td colspan="1"> <input type="image" src="<@ofbizContentUrl>/images/spacer.gif</@ofbizContentUrl>" onClick="javascript:document.selectPicklistBinForm.submit();"> <a href="javascript:document.selectPicklistBinForm.submit();" class="buttontext">${uiLabelMap.ProductPackOrder}</a> + <a href="javascript:document.selectPicklistBinForm.action='<@ofbizUrl>weightPackageOnly</@ofbizUrl>';document.selectPicklistBinForm.submit();" class="buttontext">${uiLabelMap.ProductWeightPackageOnly}</a> </td> </tr> </table> Added: ofbiz/trunk/applications/product/webapp/facility/shipment/WeightPackage.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/shipment/WeightPackage.ftl?rev=782258&view=auto ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/shipment/WeightPackage.ftl (added) +++ ofbiz/trunk/applications/product/webapp/facility/shipment/WeightPackage.ftl Sat Jun 6 13:15:14 2009 @@ -0,0 +1,138 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<#if security.hasEntityPermission("FACILITY", "_VIEW", session)> + <div class="screenlet"> + <div class="screenlet-title-bar"> + <ul> + <li class="h3">${uiLabelMap.ProductWeightPackageOnly} in ${facility.facilityName?if_exists} [${(facility.facilityId)?if_exists}]</li> + </ul> + <br class="clear"/> + </div> + <div class="screenlet-body"> + <#assign packedLines = weightPackageSession.getPackedLines(orderId)/> + <#if packedLines?has_content> + <table class="basic-table" cellpadding="2" cellspacing='0'> + <tr> + <th> + ${uiLabelMap.ProductPackedWeight} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultWeightUomId)?eval}): + </th> + <th> + ${uiLabelMap.CommonDimension} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultDimensionUomId)?eval}): + </th> + <th> + ${uiLabelMap.ProductPackageInputBox}: + </th> + </tr> + <#list packedLines as packedLine> + <form name="updateWeightPackageForm_${packedLine.getWeightPackageSeqId()}" method="post" action="<@ofbizUrl>updatePackedLine</@ofbizUrl>"> + <input type="hidden" name="orderId" value ="${orderId?if_exists}"/> + <input type="hidden" name = "facilityId" value = "${(facility.facilityId)?if_exists}"/> + <input type="hidden" name="weightPackageSeqId" value ="${packedLine.getWeightPackageSeqId()}"/> + <tr> + <td> + <span class="label"> + ${uiLabelMap.ProductPackage} ${packedLine.getWeightPackageSeqId()} + <input type="text" size="7" name="packageWeight" value="${(packedLine.getPackageWeight())?if_exists}"> + </span> + </td> + <td> + <span class="label">${uiLabelMap.CommonLength}<input type="text" name="packageLength" value="${(packedLine.getPackageLength())?if_exists}" size="5"/></span> + <span class="label">${uiLabelMap.ProductWidth}<input type="text" name="packageWidth" value="${(packedLine.getPackageWidth())?if_exists}" size="5"/></span> + <span class="label">${uiLabelMap.PartyHeight}<input type="text" name="packageHeight" value="${(packedLine.getPackageHeight())?if_exists}" size="5"/></span> + </td> + <td> + <select name="shipmentBoxTypeId"> + <#if shipmentBoxTypes?has_content> + <#assign shipmentBoxTypeId = "${(packedLine.getShipmentBoxTypeId())?if_exists}"/> + <#list shipmentBoxTypes as shipmentBoxType> + <#if shipmentBoxTypeId == "${shipmentBoxType.shipmentBoxTypeId}"> + <option value="${shipmentBoxType.shipmentBoxTypeId}">${shipmentBoxType.description}</option> + </#if> + </#list> + <option value=""></option> + <#list shipmentBoxTypes as shipmentBoxType> + <option value="${shipmentBoxType.shipmentBoxTypeId}">${shipmentBoxType.description}</option> + </#list> + </#if> + </select> + </td> + <td align="right"><a href="javascript:document.updateWeightPackageForm_${packedLine.getWeightPackageSeqId()}.submit()" class="buttontext">${uiLabelMap.CommonUpdate}</a></td> + <td align="right"><a href="javascript:document.updateWeightPackageForm_${packedLine.getWeightPackageSeqId()}.action='<@ofbizUrl>deletePackedLine</@ofbizUrl>';document.updateWeightPackageForm_${packedLine.getWeightPackageSeqId()}.submit();" class="buttontext">${uiLabelMap.CommonDelete}</a></div> + </tr> + </form> + </#list> + </table> + <div align="right"> + <a href="javascript:document.completePackageForm.submit()" class="buttontext">${uiLabelMap.ProductComplete}</a> + </div> + <form name="completePackageForm" method ="post" action="<@ofbizUrl>completePackage</@ofbizUrl>"> + <input type="hidden" name="orderId" value="${orderId?if_exists}"/> + <input type="hidden" name="shipGroupSeqId" value="${shipGroupSeqId?if_exists}"/> + <input type="hidden" name="facilityId" value="${(facility.facilityId)?if_exists}"/> + <input type="hidden" name="weightUomId" value="${defaultWeightUomId}"/> + <input type="hidden" name="dimensionUomId" value="${defaultDimensionUomId}"/> + <input type="hidden" name="shipmentId" value="${(shipment.shipmentId)?default("")}"/> + <input type="hidden" name="invoiceId" value="${(invoice.invoiceId)?default("")}"/> + <input type="hidden" name="estimatedShippingCost" value="${estimatedShippingCost?if_exists}"/> + </form> + </#if> + <table class="basic-table" cellpadding="2" cellspacing='0'> + <form name="weightPackageForm" method ="post" action="<@ofbizUrl>setPackageInfo</@ofbizUrl>"> + <input type="hidden" name = "shipGroupSeqId" value = "${shipGroupSeqId?if_exists}"/> + <input type="hidden" name = "facilityId" value = "${(facility.facilityId)?if_exists}"/> + <input type="hidden" name = "orderId" value = "${orderId?if_exists}"/> + <#assign packedLines = weightPackageSession.getPackedLines(orderId)/> + <#if packedLines?has_content> + <hr> + </#if> + <tr> + <td> + <span class="label">${uiLabelMap.ProductPackedWeight} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultWeightUomId)?eval}): + <br/> + ${uiLabelMap.ProductPackage} + <input type="text" size="7" name="packageWeight" value=""/> + </span> + </td> + <td> + <span class="label">${uiLabelMap.CommonDimension} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultDimensionUomId)?eval}):</span> + <br/> + <span class="label">${uiLabelMap.CommonLength}<input type="text" name="packageLength" value="" size="5"/></span> + <span class="label">${uiLabelMap.ProductWidth}<input type="text" name="packageWidth" value="" size="5"/></span> + <span class="label">${uiLabelMap.PartyHeight}<input type="text" name="packageHeight" value="" size="5"/></span> + </td> + <td> + <span class="label">${uiLabelMap.ProductPackageInputBox}:</span> + <br/> + <select name="shipmentBoxTypeId"> + <#if shipmentBoxTypes?has_content> + <option value=""></option> + <#list shipmentBoxTypes as shipmentBoxType> + <option value="${shipmentBoxType.shipmentBoxTypeId}">${shipmentBoxType.description}</option> + </#list> + </#if> + </select> + </td> + <td align="right"><a href="javascript:document.weightPackageForm.submit()" class="buttontext">${uiLabelMap.ProductNextPackage}</a></td> + </form> + </table> + </div> + </div> + </div> +</#if> \ No newline at end of file Propchange: ofbiz/trunk/applications/product/webapp/facility/shipment/WeightPackage.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/product/webapp/facility/shipment/WeightPackage.ftl ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/product/webapp/facility/shipment/WeightPackage.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml?rev=782258&r1=782257&r2=782258&view=diff ============================================================================== --- ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml (original) +++ ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml Sat Jun 6 13:15:14 2009 @@ -298,6 +298,25 @@ </section> </screen> + <screen name="WeightPackageOnly"> + <section> + <actions> + <set field="titleProperty" value="ProductWeightPackageOnly"/> + <set field="headerItem" value="shipment"/> + <script location="component://product/webapp/facility/WEB-INF/actions/shipment/WeightPackage.groovy"/> + </actions> + <widgets> + <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> + <decorator-section name="body"> + <platform-specific> + <html><html-template location="component://product/webapp/facility/shipment/WeightPackage.ftl"/></html> + </platform-specific> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> + <screen name="PackingSlip.fo"> <section> <actions> |
Free forum by Nabble | Edit this page |