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/05/09 08:55:24 UTC
svn commit: r773172 - in /ofbiz/trunk/applications/product: config/
script/org/ofbiz/shipment/issuance/ servicedef/
src/org/ofbiz/shipment/packing/ src/org/ofbiz/shipment/verify/
webapp/facility/WEB-INF/actions/shipment/ webapp/facility/shipment/
Author: mor
Date: Sat May 9 06:55:23 2009
New Revision: 773172
URL: http://svn.apache.org/viewvc?rev=773172&view=rev
Log:
Improvement in Verify Pick screen to issue items as well when shipment is created.
Patch from Akash Jain (reviewed and tested by Pranay Pandey), part of OFBIZ-2436 (https://issues.apache.org/jira/browse/OFBIZ-2436)
Modified:
ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml
ofbiz/trunk/applications/product/servicedef/services_shipment.xml
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickServices.java
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSessionRow.java
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.groovy
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/VerifyPick.groovy
ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl
ofbiz/trunk/applications/product/webapp/facility/shipment/VerifyPick.ftl
Modified: ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml?rev=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml (original)
+++ ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml Sat May 9 06:55:23 2009
@@ -51,13 +51,31 @@
<value xml:lang="en">Create Communication Event Product Permission Error</value>
<value xml:lang="it">Errore di permesso durante la creazione evento comunicazione prodotto</value>
</property>
+ <property key="ProductErrorAllOrderItemsAreNotPacked">
+ <value xml:lang="en">ERROR: All order items are not packed</value>
+ </property>
+ <property key="ProductErrorAllOrderItemsAreNotVerified">
+ <value xml:lang="en">ERROR: All order items are not verified</value>
+ </property>
<property key="ProductErrorInventoryItemLabelIdNotFound">
<value xml:lang="en">Error Inventory Item Label Id Not Found</value>
<value xml:lang="it">Errore riga etichetta inventario non trovata</value>
</property>
+ <property key="ProductErrorIssueItemDidNotReturnAValidShipmentItemSeqId">
+ <value xml:lang="en">ERROR: Issue item did not return a valid shipmentItemSeqId</value>
+ </property>
+ <property key="ProductErrorNoInventoryReservationsAvailableCannotVerifyThisItem">
+ <value xml:lang="en">ERROR: No inventory reservations available; cannot pick this item</value>
+ </property>
<property key="ProductErrorNoShipGroupSequenceIdFoundCannotProcess">
<value xml:lang="en">ERROR: No ship group sequence Id found cannot process</value>
</property>
+ <property key="ProductErrorNotEnoughInventoryReservationAvailableCannotVerifyTheItem">
+ <value xml:lang="en">ERROR: Not enough inventory reservation available; cannot verify the item</value>
+ </property>
+ <property key="ProductErrorNoValidOrderItemFoundForProductWithEnteredQuantity">
+ <value xml:lang="en">ERROR: No valid order item found for product [${productId}] with quantity [${quantity}]</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/script/org/ofbiz/shipment/issuance/IssuanceServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml?rev=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml Sat May 9 06:55:23 2009
@@ -241,14 +241,6 @@
<if-compare value="0" operator="equals" field="orderItemShipGrpInvRes.quantity" type="BigDecimal">
<!-- if none left reserved, remove OIIR -->
<remove-value value-field="orderItemShipGrpInvRes"/>
- <!-- if there are no more OIIRs for the orderItem, set the orderItem.statusId to ITEM_COMPLETED -->
- <get-related value-field="orderItem" relation-name="OrderItemShipGrpInvRes" list="otherOiirs"/>
- <if-empty field="otherOiirs">
- <set value="ITEM_COMPLETED" field="changeOrderItemStatusMap.statusId"/>
- <set from-field="orderItem.orderId" field="changeOrderItemStatusMap.orderId"/>
- <set from-field="orderItem.orderItemSeqId" field="changeOrderItemStatusMap.orderItemSeqId"/>
- <call-service service-name="changeOrderItemStatus" in-map-name="changeOrderItemStatusMap"/>
- </if-empty>
<else>
<store-value value-field="orderItemShipGrpInvRes"/>
</else>
Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Sat May 9 06:55:23 2009
@@ -487,7 +487,7 @@
location="org.ofbiz.shipment.packing.PackingServices" invoke="addPackLine" auth="true">
<description>Pack Single Item</description>
<attribute name="packingSession" type="org.ofbiz.shipment.packing.PackingSession" mode="IN" optional="false"/>
- <attribute name="productId" type="String" mode="IN" optional="false"/>
+ <attribute name="productId" type="String" mode="IN" optional="true"/>
<attribute name="orderId" type="String" mode="IN" optional="true"/>
<attribute name="shipGroupSeqId" type="String" mode="IN" optional="true"/>
<attribute name="quantity" type="BigDecimal" mode="IN" optional="true"/>
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=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java Sat May 9 06:55:23 2009
@@ -19,20 +19,33 @@
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 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.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;
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");
@@ -50,23 +63,61 @@
session.setPickerPartyId(pickerPartyId);
if (quantity == null) {
- quantity = BigDecimal.ONE;
+ quantity = ZERO;
}
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 = BigDecimal.ZERO;
+ weight = ZERO;
}
+ List<String> orderItemSeqIds = FastList.newInstance();
+ BigDecimal qtyToPack = ZERO;
+ BigDecimal qtyToPacked = ZERO;
+ BigDecimal packedQuantity = ZERO;
+ BigDecimal readyToPackQty = ZERO;
+ int counter = 0;
try {
- session.addOrIncreaseLine(orderId, null, shipGroupSeqId, productId, quantity, packageSeq.intValue(), weight, false);
- } catch (GeneralException e) {
- Debug.logError(e, module);
- return ServiceUtil.returnError(e.getMessage());
+ // 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());
}
-
return ServiceUtil.returnSuccess();
}
@@ -269,6 +320,7 @@
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");
@@ -293,7 +345,7 @@
}
try {
- shipmentId = session.complete(force, orderId);
+ shipmentId = session.complete(force, orderId, locale);
} 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=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java Sat May 9 06:55:23 2009
@@ -22,6 +22,7 @@
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;
@@ -34,6 +35,7 @@
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;
@@ -71,6 +73,7 @@
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;
@@ -129,7 +132,7 @@
invLookup.put("orderId", orderId);
invLookup.put("orderItemSeqId", orderItemSeqId);
invLookup.put("shipGroupSeqId", shipGroupSeqId);
- List<GenericValue> reservations = this.getDelegator().findByAnd("OrderItemShipGrpInvRes", invLookup, UtilMisc.toList("quantity DESC"));
+ List<GenericValue> reservations = this.getDelegator().findByAnd("ItemIssuance", invLookup, UtilMisc.toList("quantity DESC"));
// no reservations we cannot add this item
if (UtilValidate.isEmpty(reservations)) {
@@ -626,7 +629,7 @@
this.runEvents(PackingEvent.EVENT_CODE_CLEAR);
}
- public String complete(boolean force, String orderId) throws GeneralException {
+ public String complete(boolean force, String orderId, Locale locale) throws GeneralException {
// clear out empty lines
// this.checkEmptyLines(); // removing, this seems to be causeing issues - mja
@@ -635,9 +638,7 @@
return "EMPTY";
}
- this.checkPackedQty(orderId);
- // check for errors
- this.checkReservations(force);
+ this.checkPackedQty(orderId, locale);
// set the status to 0
this.status = 0;
// create the shipment
@@ -648,7 +649,7 @@
// create the packages
this.createPackages();
// issue the items
- this.issueItemsToShipment();
+ this.changeOrderItemStatus(orderId, shipmentId);
// assign items to packages
this.applyItemsToPackages();
// update ShipmentRouteSegments with total weight and weightUomId
@@ -663,24 +664,22 @@
return this.shipmentId;
}
- protected void checkPackedQty(String orderId) throws GeneralException {
- int counter = 0;
- List<GenericValue> orderItems = null;
+ 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()) {
- orderItems = this.getDelegator().findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId));
- for (GenericValue orderItem : orderItems) {
- if (orderId.equals(line.getOrderId())) {
- if ((orderItem.get("orderItemSeqId")).equals(line.getOrderItemSeqId())) {
- BigDecimal packedQty = this.getPackedQuantity(line.getOrderId(), line.getOrderItemSeqId(), line.getShipGroupSeqId(), line.getProductId());
- if ((packedQty.compareTo(orderItem.getBigDecimal("quantity"))) == 0 ) {
- counter++;
- }
- }
- }
- }
+ packedQty = packedQty.add(line.getQuantity());
}
- if (((this.getLines().size()) != (orderItems.size())) || (counter != (orderItems.size()))) {
- throw new GeneralException("All order items are not packed");
+
+ if (orderedQty.compareTo(packedQty) != 0 ) {
+ throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorAllOrderItemsAreNotPacked", locale));
}
}
@@ -779,6 +778,32 @@
}
}
+ 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)) {
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickServices.java?rev=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickServices.java Sat May 9 06:55:23 2009
@@ -21,6 +21,7 @@
import java.math.BigDecimal;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import javolution.util.FastList;
import javolution.util.FastMap;
@@ -41,61 +42,18 @@
public static Map<String, Object> verifySingleItem(DispatchContext dctx, Map<String, ? extends Object> context) {
GenericDelegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
+ Locale locale = (Locale) context.get("locale");
VerifyPickSession pickSession = (VerifyPickSession) context.get("verifyPickSession");
String orderId = (String) context.get("orderId");
- String facilityId = (String) context.get("facilityId");
String shipGroupSeqId = (String) context.get("shipGroupSeqId");
String productId = (String) context.get("productId");
BigDecimal quantity = (BigDecimal) context.get("quantity");
- List<String> orderItemSeqIds = FastList.newInstance();
- boolean isProductId = false;
- BigDecimal qtyToVerify = ZERO;
- BigDecimal qtyToVerified = ZERO;
- BigDecimal verifiedQuantity = ZERO;
- BigDecimal readyToVerifyQty = ZERO;
- int counter = 0;
- try {
- List<GenericValue> orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId));
- for (GenericValue orderItem : orderItems) {
- if (productId.equals(orderItem.getString("productId"))) {
- orderItemSeqIds.add(orderItem.getString("orderItemSeqId"));
- isProductId = true;
- }
+ if (quantity != null) {
+ try {
+ pickSession.createRow(orderId, null, shipGroupSeqId, productId, quantity, locale);
+ } catch (GeneralException e) {
+ return ServiceUtil.returnError(e.getMessage());
}
- if (isProductId) {
- for (String orderItemSeqId : orderItemSeqIds) {
- counter++;
- if (quantity.compareTo(ZERO) > 0) {
- GenericValue orderItem = delegator.findOne("OrderItem", UtilMisc.toMap("orderId", orderId , "orderItemSeqId", orderItemSeqId), false);
- BigDecimal orderedQuantity = orderItem.getBigDecimal("quantity");
- List<GenericValue> shipments = delegator.findByAnd("Shipment", UtilMisc.toMap("primaryOrderId", orderId , "statusId", "SHIPMENT_PICKED"));
- for(GenericValue shipment : shipments) {
- List<GenericValue> orderShipments = shipment.getRelatedByAnd("OrderShipment" , UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId));
- for(GenericValue orderShipment : orderShipments) {
- verifiedQuantity = verifiedQuantity.add(orderShipment.getBigDecimal("quantity"));
- }
- }
- qtyToVerify = orderedQuantity.subtract(verifiedQuantity);
- if (qtyToVerify.compareTo(quantity) > -1) {
- readyToVerifyQty = pickSession.getReadyToVerifyQuantity(orderId, orderItemSeqId);
- qtyToVerified = orderedQuantity.subtract(readyToVerifyQty);
- if (qtyToVerified.compareTo(quantity) > -1) {
- pickSession.createRow(orderId, orderItemSeqId, shipGroupSeqId, productId, quantity, facilityId, orderItem);
- counter--;
- break;
- } else if (orderItems.size() == counter) {
- throw new GeneralException("No valid order item found for product ["+productId+"] with quantity: "+quantity);
- }
- } else if (orderItemSeqIds.size() == counter) {
- throw new GeneralException("No valid order item found for product ["+productId+"] with quantity: "+quantity);
- }
- }
- }
- } else {
- throw new GeneralException("No valid order item found for product ["+productId+"] with quantity: "+quantity);
- }
- } catch (Exception ex) {
- return ServiceUtil.returnError(ex.getMessage());
}
return ServiceUtil.returnSuccess();
}
@@ -103,9 +61,9 @@
public static Map<String, Object> verifyBulkItem(DispatchContext dctx, Map<String, ? extends Object> context) {
GenericDelegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
+ Locale locale = (Locale) context.get("locale");
VerifyPickSession pickSession = (VerifyPickSession) context.get("verifyPickSession");
String orderId = (String) context.get("orderId");
- String facilityId = (String) context.get("facilityId");
String shipGroupSeqId = (String) context.get("shipGroupSeqId");
GenericValue userLogin = (GenericValue) context.get("userLogin");
Map<String, ?> selectedMap = UtilGenerics.checkMap(context.get("selectedMap"));
@@ -116,34 +74,10 @@
for (String rowKey : selectedMap.keySet()) {
String orderItemSeqId = itemMap.get(rowKey);
String productId = productMap.get(rowKey);
- BigDecimal qtyToVerify = ZERO;
- BigDecimal qtyToVerified = ZERO;
- BigDecimal verifiedQuantity = ZERO;
- BigDecimal readyToVerifyQty = ZERO;
BigDecimal quantity = new BigDecimal(quantityMap.get(rowKey));
if (quantity.compareTo(ZERO) > 0) {
try {
- GenericValue orderItem = delegator.findOne("OrderItem", UtilMisc.toMap("orderId", orderId , "orderItemSeqId", orderItemSeqId), false);
- BigDecimal orderedQuantity = orderItem.getBigDecimal("quantity");
- List<GenericValue> shipments = delegator.findByAnd("Shipment", UtilMisc.toMap("primaryOrderId", orderId , "statusId", "SHIPMENT_PICKED"));
- for(GenericValue shipment : shipments) {
- List<GenericValue> orderShipments = shipment.getRelatedByAnd("OrderShipment" , UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId));
- for(GenericValue orderShipment : orderShipments) {
- verifiedQuantity = verifiedQuantity.add(orderShipment.getBigDecimal("quantity"));
- }
- }
- qtyToVerify = orderedQuantity.subtract(verifiedQuantity);
- if (qtyToVerify.compareTo(quantity) > -1) {
- readyToVerifyQty = pickSession.getReadyToVerifyQuantity(orderId,orderItemSeqId);
- qtyToVerified = orderedQuantity.subtract(readyToVerifyQty);
- if (qtyToVerified.compareTo(quantity) > -1) {
- pickSession.createRow(orderId, orderItemSeqId, shipGroupSeqId, productId, quantity, facilityId, orderItem);
- } else {
- throw new GeneralException("Quantity to Verify is more than the Quantity left to Verify (orderedQuantity - readyToVerifiedQty)");
- }
- } else {
- throw new GeneralException("Quantity to Verify is more than the Quantity left to Verify (orderedQuantity - verifiedQuantity)");
- }
+ pickSession.createRow(orderId, orderItemSeqId, shipGroupSeqId, productId, quantity, locale);
} catch (Exception ex) {
return ServiceUtil.returnError(ex.getMessage());
}
@@ -156,14 +90,12 @@
public static Map<String, Object> completeVerifiedPick(DispatchContext dctx, Map<String, ? extends Object> context) {
GenericDelegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
+ Locale locale = (Locale) context.get("locale");
String shipmentId = null;
VerifyPickSession pickSession = (VerifyPickSession) context.get("verifyPickSession");
String orderId = (String) context.get("orderId");
- String facilityId = (String) context.get("facilityId");
- String shipGroupSeqId = (String) context.get("shipGroupSeqId");
- GenericValue userLogin = (GenericValue) context.get("userLogin");
try {
- shipmentId = pickSession.complete(orderId);
+ shipmentId = pickSession.complete(orderId, locale);
Map<String, Object> shipment = FastMap.newInstance();
shipment.put("shipmentId", shipmentId);
pickSession.clearAllRows();
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java Sat May 9 06:55:23 2009
@@ -22,12 +22,15 @@
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.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;
@@ -40,11 +43,13 @@
protected GenericValue userLogin = null;
protected String dispatcherName = null;
protected String delegatorName = null;
- protected int rowItems = 1;
+ protected String picklistBinId = null;
+ protected String facilityId = null;
protected List<VerifyPickSessionRow> pickRows = null;
private transient GenericDelegator _delegator = null;
private transient LocalDispatcher _dispatcher = null;
+ private static BigDecimal ZERO = BigDecimal.ZERO;
public VerifyPickSession() {
}
@@ -72,42 +77,169 @@
return _delegator;
}
- public void createRow(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity, String facilityId, GenericValue orderItem) {
- int rowItem = this.getRowNo();
- int counter = 1;
- BigDecimal readyToVerify = null;
- if (rowItem > 1) {
- List<VerifyPickSessionRow> rows = this.getPickRows();
- for (VerifyPickSessionRow row : rows) {
- counter++;
- if ((orderId.equals(row.getOrderId())) && (orderItemSeqId.equals(row.getOrderSeqId()))) {
- readyToVerify = quantity.add(row.getReadyToVerifyQty());
- row.setReadyToVerifyQty(readyToVerify);
- break;
- } else if (counter == rowItem) {
- this.createRow(orderId, orderItemSeqId, shipGroupSeqId, productId, quantity, facilityId, orderItem, rowItem);
+ public void createRow(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity, Locale locale) throws GeneralException {
+
+ if (orderItemSeqId == null && productId != null) {
+ orderItemSeqId = this.findOrderItemSeqId(productId, orderId, shipGroupSeqId, quantity, locale);
+ }
+
+ // get the reservations for the item
+ Map<String, Object> inventoryLookupMap = FastMap.newInstance();
+ inventoryLookupMap.put("orderId", orderId);
+ inventoryLookupMap.put("orderItemSeqId", orderItemSeqId);
+ inventoryLookupMap.put("shipGroupSeqId", shipGroupSeqId);
+ List<GenericValue> reservations = this.getDelegator().findByAnd("OrderItemShipGrpInvRes", inventoryLookupMap, UtilMisc.toList("quantity DESC"));
+
+ // no reservations we cannot add this item
+ if (UtilValidate.isEmpty(reservations)) {
+ throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoInventoryReservationsAvailableCannotVerifyThisItem", locale));
+ }
+
+ if (reservations.size() == 1) {
+ GenericValue reservation = EntityUtil.getFirst(reservations);
+ int checkCode = this.checkRowForAdd(reservation, orderId, orderItemSeqId, shipGroupSeqId, productId, quantity);
+ this.createVerifyPickRow(checkCode, reservation, orderId, orderItemSeqId, shipGroupSeqId, productId, quantity, locale);
+ } else {
+ // more than one reservation found
+ Map<GenericValue, BigDecimal> reserveQtyMap = FastMap.newInstance();
+ BigDecimal qtyRemain = quantity;
+
+ for (GenericValue reservation : reservations) {
+ if (qtyRemain.compareTo(ZERO) > 0) {
+ if (!productId.equals(reservation.getRelatedOne("InventoryItem").getString("productId"))) {
+ continue;
+ }
+ BigDecimal reservedQty = reservation.getBigDecimal("quantity");
+ BigDecimal resVerifiedQty = this.getVerifiedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId, reservation.getString("inventoryItemId"));
+ if (resVerifiedQty.compareTo(reservedQty) >= 0) {
+ continue;
+ } else {
+ reservedQty = reservedQty.subtract(resVerifiedQty);
+ }
+ BigDecimal thisQty = reservedQty.compareTo(qtyRemain) > 0 ? qtyRemain : reservedQty;
+ int thisCheck = this.checkRowForAdd(reservation, orderId, orderItemSeqId, shipGroupSeqId, productId, thisQty);
+ switch (thisCheck) {
+ case 2:
+ // new verify pick row will be created
+ reserveQtyMap.put(reservation, thisQty);
+ qtyRemain = qtyRemain.subtract(thisQty);
+ break;
+ case 1:
+ // existing verify pick row has been updated
+ qtyRemain = qtyRemain.subtract(thisQty);
+ break;
+ case 0:
+ //doing nothing
+ break;
+ }
+ }
+ }
+ if (qtyRemain.compareTo(ZERO) == 0) {
+ for (Map.Entry<GenericValue, BigDecimal> entry : reserveQtyMap.entrySet()) {
+ GenericValue reservation = entry.getKey();
+ BigDecimal qty = entry.getValue();
+ this.createVerifyPickRow(2, reservation, orderId, orderItemSeqId, shipGroupSeqId, productId, qty, locale);
+ }
+ } else {
+ throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNotEnoughInventoryReservationAvailableCannotVerifyTheItem", locale));
+ }
+ }
+ }
+
+ protected String findOrderItemSeqId(String productId, String orderId, String shipGroupSeqId, BigDecimal quantity, Locale locale) throws GeneralException {
+
+ Map<String, Object> orderItemLookupMap = FastMap.newInstance();
+ orderItemLookupMap.put("orderId", orderId);
+ orderItemLookupMap.put("productId", productId);
+ orderItemLookupMap.put("statusId", "ITEM_APPROVED");
+ orderItemLookupMap.put("shipGroupSeqId", shipGroupSeqId);
+
+ List<GenericValue> orderItems = this.getDelegator().findByAnd("OrderItemAndShipGroupAssoc", orderItemLookupMap);
+
+ String orderItemSeqId = null;
+ if (orderItems != null) {
+ for (GenericValue orderItem : orderItems) {
+ // get the reservations for the item
+ Map<String, Object> inventoryLookupMap = FastMap.newInstance();
+ inventoryLookupMap.put("orderId", orderId);
+ inventoryLookupMap.put("orderItemSeqId", orderItem.getString("orderItemSeqId"));
+ inventoryLookupMap.put("shipGroupSeqId", shipGroupSeqId);
+ List<GenericValue> reservations = this.getDelegator().findByAnd("OrderItemShipGrpInvRes", inventoryLookupMap);
+ for (GenericValue reservation : reservations) {
+ BigDecimal qty = reservation.getBigDecimal("quantity");
+ if (quantity.compareTo(qty) <= 0) {
+ orderItemSeqId = orderItem.getString("orderItemSeqId");
+ break;
+ }
}
}
+ }
+
+ if (orderItemSeqId != null) {
+ return orderItemSeqId;
} else {
- this.createRow(orderId, orderItemSeqId, shipGroupSeqId, productId, quantity, facilityId, orderItem, rowItem);
+ throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoValidOrderItemFoundForProductWithEnteredQuantity", UtilMisc.toMap("productId", productId, "quantity", quantity), locale));
}
}
- public void createRow(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity, String facilityId, GenericValue orderItem, int rowItem) {
- pickRows.add(new VerifyPickSessionRow(orderId, orderItemSeqId, shipGroupSeqId, productId, quantity, facilityId, orderItem, rowItem));
- this.setRowNo();
+ protected int checkRowForAdd(GenericValue reservation, String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity) {
+ // check to see if the reservation can hold the requested quantity amount
+ String inventoryItemId = reservation.getString("inventoryItemId");
+ BigDecimal resQty = reservation.getBigDecimal("quantity");
+ VerifyPickSessionRow pickRow = this.getPickRow(orderId, orderItemSeqId, shipGroupSeqId, productId, inventoryItemId);
+
+ if (pickRow == null) {
+ if (resQty.compareTo(quantity) < 0) {
+ return 0;
+ } else {
+ return 2;
+ }
+ } else {
+ BigDecimal newQty = pickRow.getReadyToVerifyQty().add(quantity);
+ if (resQty.compareTo(newQty) < 0) {
+ return 0;
+ } else {
+ pickRow.setReadyToVerifyQty(newQty);
+ return 1;
+ }
+ }
}
- public int getRowNo() {
- return this.rowItems;
+ protected void createVerifyPickRow(int checkCode, GenericValue res, String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity, Locale locale) throws GeneralException {
+ // process the result; add new item if necessary
+ switch (checkCode) {
+ case 0:
+ // not enough reserved
+ throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNotEnoughInventoryReservationAvailableCannotVerifyTheItem", locale));
+ case 1:
+ // we're all good to go; quantity already updated
+ break;
+ case 2:
+ // need to create a new item
+ String inventoryItemId = res.getString("inventoryItemId");
+ pickRows.add(new VerifyPickSessionRow(orderId, orderItemSeqId, shipGroupSeqId, productId, inventoryItemId, quantity));
+ break;
+ }
}
public GenericValue getUserLogin() {
return this.userLogin;
}
- public void setRowNo() {
- this.rowItems = (this.getRowNo()) + 1;
+ public void setFacilityId(String facilityId) {
+ this.facilityId = facilityId;
+ }
+
+ public String getFacilityId() {
+ return this.facilityId;
+ }
+
+ public void setPicklistBinId(String setPicklistBinId) {
+ this.picklistBinId = setPicklistBinId;
+ }
+
+ public String getPicklistBinId() {
+ return this.picklistBinId;
}
public List<VerifyPickSessionRow> getPickRows() {
@@ -127,28 +259,45 @@
public BigDecimal getReadyToVerifyQuantity(String orderId, String orderSeqId) throws GeneralException {
BigDecimal readyToVerifyQty = BigDecimal.ZERO;
for (VerifyPickSessionRow line: this.getPickRows()) {
- if ((orderId.equals(line.getOrderId())) && (orderSeqId.equals(line.getOrderSeqId()))) {
+ if ((orderId.equals(line.getOrderId())) && (orderSeqId.equals(line.getOrderItemSeqId()))) {
readyToVerifyQty = readyToVerifyQty.add(line.getReadyToVerifyQty());
}
}
return readyToVerifyQty;
}
+ public VerifyPickSessionRow getPickRow(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId) {
+ for (VerifyPickSessionRow line : this.getPickRows(orderId)) {
+ if (orderItemSeqId.equals(line.getOrderItemSeqId()) && shipGroupSeqId.equals(line.getShipGroupSeqId())
+ && productId.equals(line.getProductId()) && inventoryItemId.equals(line.getInventoryItemId())) {
+ return line;
+ }
+ }
+ return null;
+ }
+
+ public BigDecimal getVerifiedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId) {
+ BigDecimal total = ZERO;
+ for (VerifyPickSessionRow pickRow : this.getPickRows(orderId)) {
+ if (orderItemSeqId.equals(pickRow.getOrderItemSeqId()) && shipGroupSeqId.equals(pickRow.getShipGroupSeqId()) && productId.equals(pickRow.getProductId())) {
+ if (inventoryItemId == null || inventoryItemId.equals(pickRow.getInventoryItemId())) {
+ total = total.add(pickRow.getReadyToVerifyQty());
+ }
+ }
+ }
+ return total;
+ }
+
public void clearAllRows() {
this.pickRows.clear();
- this.rowItems = 1;
}
- public String complete(String orderId) throws GeneralException {
- String shipmentItemSeqId = null;
+ public String complete(String orderId, Locale locale) throws GeneralException {
String invoiceId = null;
String invoiceItemSeqId = null;
- this.checkVerifiedQty(orderId);
+ this.checkVerifiedQty(orderId, locale);
String shipmentId = this.createShipment((this.getPickRows(orderId)).get(0));
- for (VerifyPickSessionRow line: this.getPickRows(orderId)) {
- shipmentItemSeqId = this.createShipmentItem(line,shipmentId);
- line.setShipmentItemSeqId(shipmentItemSeqId);
- }
+ this.issueItemsToShipment(shipmentId, locale);
invoiceId = this.createInvoice(orderId);
for (VerifyPickSessionRow line: this.getPickRows(orderId)) {
invoiceItemSeqId = this.createInvoiceItem(line, invoiceId, shipmentId);
@@ -157,27 +306,49 @@
return shipmentId;
}
- protected void checkVerifiedQty(String orderId) throws GeneralException {
- int counter = 0;
- List<GenericValue> orderItems = null;
- for (VerifyPickSessionRow line : this.getPickRows(orderId)) {
- orderItems = this.getDelegator().findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId));
- for (GenericValue orderItem : orderItems) {
- if ((orderItem.get("orderItemSeqId")).equals(line.getOrderSeqId())) {
- if (((line.getReadyToVerifyQty()).compareTo(orderItem.getBigDecimal("quantity"))) == 0 ) {
- counter++;
- }
- }
+ protected void checkVerifiedQty(String orderId, Locale locale) throws GeneralException {
+
+ BigDecimal verifiedQty = 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 (VerifyPickSessionRow pickRow : this.getPickRows(orderId)) {
+ verifiedQty = verifiedQty.add(pickRow.getReadyToVerifyQty());
+ }
+
+ if (orderedQty.compareTo(verifiedQty) != 0 ) {
+ throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorAllOrderItemsAreNotVerified", locale));
+ }
+ }
+
+ protected void issueItemsToShipment(String shipmentId, Locale locale) throws GeneralException {
+ List<VerifyPickSessionRow> processedRows = FastList.newInstance();
+ for (VerifyPickSessionRow pickRow : this.getPickRows()) {
+ if (this.checkLine(processedRows, pickRow)) {
+ BigDecimal totalVerifiedQty = this.getVerifiedQuantity(pickRow.getOrderId(), pickRow.getOrderItemSeqId(), pickRow.getShipGroupSeqId(), pickRow.getProductId(), pickRow.getInventoryItemId());
+ pickRow.issueItemToShipment(shipmentId, picklistBinId, userLogin, totalVerifiedQty, getDispatcher(), locale);
+ processedRows.add(pickRow);
}
}
- if (counter != (orderItems.size())) {
- throw new GeneralException("All order items are not verified");
+ }
+
+ protected boolean checkLine(List<VerifyPickSessionRow> processedRows, VerifyPickSessionRow pickrow) {
+ for (VerifyPickSessionRow processedRow : processedRows) {
+ if (pickrow.isSameItem(processedRow)) {
+ pickrow.setShipmentItemSeqId(processedRow.getShipmentItemSeqId());
+ return false;
+ }
}
+ return true;
}
protected String createShipment(VerifyPickSessionRow line) throws GeneralException {
Map<String, Object> newShipment = FastMap.newInstance();
- newShipment.put("originFacilityId", line.getFacilityId());
+ newShipment.put("originFacilityId", facilityId);
newShipment.put("primaryShipGroupSeqId", line.getShipGroupSeqId());
newShipment.put("primaryOrderId", line.getOrderId());
newShipment.put("shipmentTypeId", "OUTGOING_SHIPMENT");
@@ -191,31 +362,6 @@
return shipmentId;
}
- protected String createShipmentItem(VerifyPickSessionRow line,String shipmentId) throws GeneralException {
- Map<String, Object> newShipmentItem = FastMap.newInstance();
- newShipmentItem.put("shipmentId", shipmentId);
- newShipmentItem.put("productId", line.getProductId());
- newShipmentItem.put("userLogin", this.getUserLogin());
- newShipmentItem.put("quantity", line.getReadyToVerifyQty());
- Map<String, Object> newShipItem = this.getDispatcher().runSync("createShipmentItem", newShipmentItem);
- if (ServiceUtil.isError(newShipItem)) {
- throw new GeneralException(ServiceUtil.getErrorMessage(newShipItem));
- }
- String shipmentItemSeqId = (String) newShipItem.get("shipmentItemSeqId");
- Map<String, Object> newOrderShipment = FastMap.newInstance();
- newOrderShipment.put("shipmentId", shipmentId);
- newOrderShipment.put("shipmentItemSeqId", shipmentItemSeqId);
- newOrderShipment.put("orderId", line.getOrderId());
- newOrderShipment.put("orderItemSeqId", line.getOrderSeqId());
- newOrderShipment.put("quantity", line.getReadyToVerifyQty());
- newOrderShipment.put("userLogin", this.getUserLogin());
- Map<String, Object> newOrderShip = this.getDispatcher().runSync("createOrderShipment", newOrderShipment);
- if (ServiceUtil.isError(newOrderShip)) {
- throw new GeneralException(ServiceUtil.getErrorMessage(newOrderShip));
- }
- return shipmentItemSeqId;
- }
-
protected String createInvoice(String orderId) throws GeneralException {
GenericDelegator delegator = this.getDelegator();
Map createInvoiceContext = FastMap.newInstance();
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSessionRow.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSessionRow.java?rev=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSessionRow.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSessionRow.java Sat May 9 06:55:23 2009
@@ -21,8 +21,17 @@
import java.io.Serializable;
import java.math.BigDecimal;
-
+import java.util.Locale;
+import java.util.Map;
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.GeneralException;
+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.LocalDispatcher;
+import org.ofbiz.service.ServiceUtil;
public class VerifyPickSessionRow implements Serializable {
@@ -30,25 +39,22 @@
protected String orderItemSeqId = null;
protected String shipGroupSeqId = null;
protected String productId = null;
- protected String facilityId = null;
+ protected String inventoryItemId = null;
protected BigDecimal readyToVerifyQty = BigDecimal.ZERO;
protected GenericValue orderItem = null;
- protected int rowItem = 0;
protected String shipmentItemSeqId = null;
protected String invoiceItemSeqId = null;
public VerifyPickSessionRow() {
}
- public VerifyPickSessionRow(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity, String facilityId, GenericValue orderItem, int rowItem) {
+ public VerifyPickSessionRow(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, BigDecimal quantity) {
this.orderId = orderId;
this.orderItemSeqId = orderItemSeqId;
this.shipGroupSeqId = shipGroupSeqId;
this.productId = productId;
this.readyToVerifyQty = quantity;
- this.facilityId = facilityId;
- this.orderItem = orderItem;
- this.rowItem = rowItem;
+ this.inventoryItemId = inventoryItemId;
this.shipmentItemSeqId = null;
this.invoiceItemSeqId = null;
}
@@ -57,7 +63,7 @@
return this.orderId;
}
- public String getOrderSeqId() {
+ public String getOrderItemSeqId() {
return this.orderItemSeqId;
}
@@ -69,8 +75,8 @@
return this.productId;
}
- public String getFacilityId() {
- return this.facilityId;
+ public String getInventoryItemId() {
+ return this.inventoryItemId;
}
public BigDecimal getReadyToVerifyQty() {
@@ -100,4 +106,68 @@
public GenericValue getOrderItem() {
return this.orderItem;
}
+
+ public boolean isSameItem(VerifyPickSessionRow line) {
+ if (this.getInventoryItemId().equals(line.getInventoryItemId()) && this.getOrderItemSeqId().equals(line.getOrderItemSeqId())
+ && this.getOrderId().equals(line.getOrderId()) && this.getShipGroupSeqId().equals(line.getShipGroupSeqId())) {
+ return true;
+ }
+ return false;
+ }
+
+ protected void issueItemToShipment(String shipmentId, String picklistBinId, GenericValue userLogin, BigDecimal quantity, LocalDispatcher dispatcher, Locale locale) throws GeneralException {
+
+ if (quantity == null) {
+ quantity = this.getReadyToVerifyQty();
+ }
+
+ Map<String, Object> issueOrderItemMap = FastMap.newInstance();
+ issueOrderItemMap.put("shipmentId", shipmentId);
+ issueOrderItemMap.put("orderId", this.getOrderId());
+ issueOrderItemMap.put("orderItemSeqId", this.getOrderItemSeqId());
+ issueOrderItemMap.put("shipGroupSeqId", this.getShipGroupSeqId());
+ issueOrderItemMap.put("inventoryItemId", this.getInventoryItemId());
+ issueOrderItemMap.put("quantity", quantity);
+ issueOrderItemMap.put("userLogin", userLogin);
+
+ Map<String, Object> issueOrderItemResp = dispatcher.runSync("issueOrderItemShipGrpInvResToShipment", issueOrderItemMap);
+ if (ServiceUtil.isError(issueOrderItemResp)) {
+ throw new GeneralException(ServiceUtil.getErrorMessage(issueOrderItemResp));
+ }
+
+ String shipmentItemSeqId = (String) issueOrderItemResp.get("shipmentItemSeqId");
+ if (shipmentItemSeqId == null) {
+ throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorIssueItemDidNotReturnAValidShipmentItemSeqId", locale));
+ } else {
+ this.setShipmentItemSeqId(shipmentItemSeqId);
+ }
+
+ if (picklistBinId != null) {
+ // find the pick list item
+ GenericDelegator delegator = dispatcher.getDelegator();
+ Map<String, Object> picklistItemMap = FastMap.newInstance();
+ picklistItemMap.put("picklistBinId", picklistBinId);
+ picklistItemMap.put("orderId", this.getOrderId());
+ picklistItemMap.put("orderItemSeqId", this.getOrderItemSeqId());
+ picklistItemMap.put("shipGroupSeqId", this.getShipGroupSeqId());
+ picklistItemMap.put("inventoryItemId", this.getInventoryItemId());
+
+ GenericValue picklistItem = delegator.findOne("PicklistItem", picklistItemMap, true);
+ if (UtilValidate.isNotEmpty(picklistItem)) {
+ BigDecimal itemQty = picklistItem.getBigDecimal("quantity");
+ if (itemQty.compareTo(quantity) == 0) {
+ // set to complete
+ picklistItemMap.put("itemStatusId", "PICKITEM_COMPLETED");
+ } else {
+ picklistItemMap.put("itemStatusId", "PICKITEM_CANCELLED");
+ }
+ picklistItemMap.put("userLogin", userLogin);
+ Map<String, Object> picklistItemResp = dispatcher.runSync("updatePicklistItem", picklistItemMap);
+ if (ServiceUtil.isError(picklistItemResp)) {
+ throw new GeneralException(ServiceUtil.getErrorMessage(picklistItemResp));
+ }
+ }
+ }
+ }
+
}
\ No newline at end of file
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=773172&r1=773171&r2=773172&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 May 9 06:55:23 2009
@@ -135,6 +135,8 @@
context.orderReadHelper = orh;
orderItemShipGroup = orh.getOrderItemShipGroup(shipGroupSeqId);
context.orderItemShipGroup = orderItemShipGroup;
+ orderItems = orh.getOrderItems();
+ context.orderItems = orderItems;
if ("ORDER_APPROVED".equals(orderHeader.statusId)) {
if (shipGroupSeqId) {
Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/VerifyPick.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/VerifyPick.groovy?rev=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/VerifyPick.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/VerifyPick.groovy Sat May 9 06:55:23 2009
@@ -53,6 +53,7 @@
facility = delegator.findOne("Facility", [facilityId : facilityId], false);
context.facility = facility;
}
+verifyPickSession.setFacilityId(facilityId);
orderId = parameters.orderId;
shipGroupSeqId = parameters.shipGroupSeqId;
@@ -70,6 +71,7 @@
if (picklistBin) {
orderId = picklistBin.primaryOrderId;
shipGroupSeqId = picklistBin.primaryShipGroupSeqId;
+ verifyPickSession.setPicklistBinId(picklistBinId);
}
}
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=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl Sat May 9 06:55:23 2009
@@ -235,8 +235,7 @@
</#if>
<!-- auto grid form -->
- <#assign itemInfos = packingSession.getItemInfos()?if_exists>
- <#if showInput != "N" && hideGrid != "Y" && itemInfos?has_content>
+ <#if showInput != "N" && hideGrid != "Y" && orderItems?has_content>
<br/>
<form name="multiPackForm" method="post" action="<@o...@ofbizUrl>">
<input type="hidden" name="facilityId" value="${facilityId?if_exists}">
@@ -259,15 +258,26 @@
<td align="center">${uiLabelMap.ProductPackage}</td>
<td align="right"> <b>*</b> ${uiLabelMap.ProductPackages}</td>
</tr>
- <#if (itemInfos?has_content)>
+ <#if orderItems?has_content>
<#assign rowKey = 1>
- <#list itemInfos as itemInfo>
+ <#list orderItems as orderItem>
<#-- <#list itemInfos as orderItem> -->
- <#assign orderItem = itemInfo.orderItem/>
- <#assign shippedQuantity = orderReadHelper.getItemShippedQuantity(orderItem)?if_exists>
- <#assign orderItemQuantity = itemInfo.quantity/>
+ <#assign shippedQuantity = 0.000000>
+ <#assign orderItemQuantity = orderItem.getBigDecimal("quantity")/>
+ <#assign shipments = delegator.findByAnd("Shipment", Static["org.ofbiz.base.util.UtilMisc"].toMap("primaryOrderId", orderItem.getString("orderId"), "statusId", "SHIPMENT_PACKED"))>
+ <#if (shipments?has_content)>
+ <#list shipments as shipment>
+ <#assign itemIssuances = shipment.getRelatedByAnd("ItemIssuance", Static["org.ofbiz.base.util.UtilMisc"].toMap("orderId", "${orderId}", "orderItemSeqId", orderItemSeqId))>
+ <#if itemIssuances?has_content>
+ <#list itemIssuances as itemIssuance>
+ <#assign shippedQuantity = shippedQuantity + itemIssuance.getBigDecimal("quantity")>
+ </#list>
+ </#if>
+ </#list>
+ </#if>
+ <#assign orderItemQuantity = orderItemQuantity.subtract(shippedQuantity)>
<#assign orderProduct = orderItem.getRelatedOne("Product")?if_exists/>
- <#assign product = Static["org.ofbiz.product.product.ProductWorker"].findProduct(delegator, itemInfo.productId)?if_exists/>
+ <#assign product = Static["org.ofbiz.product.product.ProductWorker"].findProduct(delegator, orderItem.productId)?if_exists/>
<#--
<#if orderItem.cancelQuantity?exists>
<#assign orderItemQuantity = orderItem.quantity - orderItem.cancelQuantity>
@@ -275,7 +285,7 @@
<#assign orderItemQuantity = orderItem.quantity>
</#if>
-->
- <#assign inputQty = orderItemQuantity - packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId, itemInfo.productId)>
+ <#assign inputQty = orderItemQuantity - packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId, orderItem.productId)>
<tr>
<td><input type="checkbox" name="sel_${rowKey}" value="Y" <#if (inputQty >0)>checked=""</#if>/></td>
<td>${orderItem.orderItemSeqId}</td>
@@ -292,8 +302,8 @@
</#if>
</td>
<td align="right">${orderItemQuantity}</td>
- <td align="right">${shippedQuantity?default(0)}</td>
- <td align="right">${packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId, itemInfo.productId)}</td>
+ <td align="right">${shippedQuantity}</td>
+ <td align="right">${packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId, orderItem.productId)}</td>
<td> </td>
<td align="center">
<input type="text" size="7" name="qty_${rowKey}" value="${inputQty}">
@@ -321,7 +331,7 @@
<td align="right">
<input type="text" size="7" name="numPackages_${rowKey}" value="1">
</td>
- <input type="hidden" name="prd_${rowKey}" value="${itemInfo.productId?if_exists}"/>
+ <input type="hidden" name="prd_${rowKey}" value="${orderItem.productId?if_exists}"/>
<input type="hidden" name="ite_${rowKey}" value="${orderItem.orderItemSeqId}"/>
</tr>
<#assign rowKey = rowKey + 1>
Modified: ofbiz/trunk/applications/product/webapp/facility/shipment/VerifyPick.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/shipment/VerifyPick.ftl?rev=773172&r1=773171&r2=773172&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/shipment/VerifyPick.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/facility/shipment/VerifyPick.ftl Sat May 9 06:55:23 2009
@@ -209,13 +209,13 @@
<#assign readyToVerify = verifyPickSession.getReadyToVerifyQuantity(orderId,orderItemSeqId)>
<#assign orderItemQuantity = orderItem.getBigDecimal("quantity")>
<#assign verifiedQuantity = 0.000000>
- <#assign shipments = delegator.findByAnd("Shipment", Static["org.ofbiz.base.util.UtilMisc"].toMap("primaryOrderId", orderItem.getString("orderId"), "statusId", "SHIPMENT_PICKED"))>
+ <#assign shipments = delegator.findByAnd("Shipment", Static["org.ofbiz.base.util.UtilMisc"].toMap("primaryOrderId", orderItem.getString("orderId"), "statusId", "SHIPMENT_PICKED"))/>
<#if (shipments?has_content)>
<#list shipments as shipment>
- <#assign orderShipments = shipment.getRelatedByAnd("OrderShipment", Static["org.ofbiz.base.util.UtilMisc"].toMap("orderId", "${orderId}", "orderItemSeqId", orderItemSeqId))>
- <#if orderShipments?has_content>
- <#list orderShipments as orderShipment>
- <#assign verifiedQuantity = verifiedQuantity + orderShipment.getBigDecimal("quantity")>
+ <#assign itemIssuances = delegator.findByAnd("ItemIssuance", Static["org.ofbiz.base.util.UtilMisc"].toMap("shipmentId", shipment.getString("shipmentId"), "orderItemSeqId", orderItemSeqId))/>
+ <#if itemIssuances?has_content>
+ <#list itemIssuances as itemIssuance>
+ <#assign verifiedQuantity = verifiedQuantity + itemIssuance.getBigDecimal("quantity")>
</#list>
</#if>
</#list>
@@ -294,20 +294,24 @@
<tr class="header-row">
<td>${uiLabelMap.ProductItem} #</td>
<td>${uiLabelMap.ProductProductId}</td>
- <td align="right">${uiLabelMap.ProductVerify} ${uiLabelMap.CommonQty}</td>
+ <td>${uiLabelMap.ProductInventoryItem} #</td>
+ <td align="right">${uiLabelMap.ProductVerified} ${uiLabelMap.CommonQty}</td>
<td> </td>
</tr>
<#list pickRows as pickRow>
<#if (pickRow.getOrderId()?if_exists).equals(orderId)>
<tr>
- <td>${pickRow.getOrderSeqId()?if_exists}</td>
+ <td>${pickRow.getOrderItemSeqId()?if_exists}</td>
<td>${pickRow.getProductId()?if_exists}</td>
+ <td>${pickRow.getInventoryItemId()?if_exists}</td>
<td align="right">${pickRow.getReadyToVerifyQty()?if_exists}</td>
</tr>
</#if>
</#list>
</table>
- <input type="submit" value="${uiLabelMap.ProductComplete}"/>
+ <div align="right">
+ <a href="javascript:document.completePickForm.submit()" class="buttontext">${uiLabelMap.ProductComplete}</a>
+ </div>
</div>
</div>
</#if>