Author: jaz
Date: Thu May 17 17:54:22 2007
New Revision: 539199
URL: http://svn.apache.org/viewvc?view=rev&rev=539199
Log:
added new code to help with grouping product for display on packing (and custom
packing screens); this now groups all items by product so a running total can
be packed.
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh
ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl
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?view=diff&rev=539199&r1=539198&r2=539199
==============================================================================
---
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
(original)
+++
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
Thu May 17 17:54:22 2007
@@ -19,6 +19,7 @@
package org.ofbiz.shipment.packing;
import java.util.*;
+import java.math.BigDecimal;
import javolution.util.FastMap;
import javolution.util.FastList;
@@ -58,6 +59,7 @@
protected Map packageWeights = null;
protected List packEvents = null;
protected List packLines = null;
+ protected List itemInfos = null;
protected int packageSeq = -1;
protected int status = 1;
@@ -76,10 +78,11 @@
this.picklistBinId = binId;
this.userLogin = userLogin;
this.facilityId = facilityId;
- this.packLines = new ArrayList();
- this.packEvents = new ArrayList();
+ this.packLines = FastList.newInstance();
+ this.packEvents = FastList.newInstance();
+ this.itemInfos = FastList.newInstance();
this.packageSeq = 1;
- this.packageWeights = new HashMap();
+ this.packageWeights = FastMap.newInstance();
}
public PackingSession(LocalDispatcher dispatcher, GenericValue userLogin,
String facilityId) {
@@ -300,6 +303,29 @@
}
}
+ public void addItemInfo(List infos) {
+ Iterator i = infos.iterator();
+ while (i.hasNext()) {
+ GenericValue v = (GenericValue) i.next();
+ ItemDisplay newItem = new ItemDisplay(v);
+ int currentIdx = itemInfos.indexOf(newItem);
+ if (currentIdx != -1) {
+ ItemDisplay existingItem = (ItemDisplay)
itemInfos.get(currentIdx);
+ existingItem.quantity =
existingItem.quantity.add(newItem.quantity);
+ } else {
+ itemInfos.add(newItem);
+ }
+ }
+ }
+
+ public List getItemInfos() {
+ return itemInfos;
+ }
+
+ public void clearItemInfos() {
+ itemInfos.clear();
+ }
+
public String getShipmentId() {
return this.shipmentId;
}
@@ -917,5 +943,61 @@
Double newPackageWeight = UtilValidate.isEmpty(packageWeight) ? weight
: new Double(weight.doubleValue() + packageWeight.doubleValue());
setPackageWeight(packageSeqId, newPackageWeight);
}
-
+
+ class ItemDisplay extends AbstractMap {
+
+ public GenericValue orderItem;
+ public BigDecimal quantity;
+ public String productId;
+
+ public ItemDisplay(GenericValue v) {
+ if ("PicklistItem".equals(v.getEntityName())) {
+ quantity = v.getBigDecimal("quantity").setScale(2,
BigDecimal.ROUND_HALF_UP);
+ try {
+ orderItem = v.getRelatedOne("OrderItem");
+ productId = orderItem.getString("productId");
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ }
+ } else {
+ orderItem = v;
+ productId = v.getString("productId");
+ double reserved =
getCurrentReservedQuantity(orderItem.getString("orderId"),
orderItem.getString("orderItemSeqId"), primaryShipGrp);
+ quantity = new BigDecimal(reserved).setScale(2,
BigDecimal.ROUND_HALF_UP);
+ }
+ Debug.log("created item display object quanttiy: " + quantity + "
(" + productId + ")", module);
+ }
+
+ public GenericValue getOrderItem() {
+ return orderItem;
+ }
+
+ public BigDecimal getQuantity() {
+ return quantity;
+ }
+
+ public Set entrySet() {
+ return null;
+ }
+
+ public Object get(Object name) {
+ if ("orderItem".equals(name.toString())) {
+ return orderItem;
+ } else if ("quantity".equals(name.toString())) {
+ return quantity;
+ } else if ("productId".equals(name.toString())) {
+ return productId;
+ }
+ return null;
+ }
+
+ public boolean equals(Object o) {
+ if (o instanceof ItemDisplay) {
+ ItemDisplay d = (ItemDisplay) o;
+ return (d.productId.equals(productId));
+ } else {
+ return false;
+ }
+ }
+ }
}
Modified:
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh?view=diff&rev=539199&r1=539198&r2=539199
==============================================================================
---
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh
(original)
+++
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh
Thu May 17 17:54:22 2007
@@ -84,6 +84,7 @@
packSession.clear();
}
}
+packSession.clearItemInfos();
// picklist based packing information
picklistBinId = parameters.get("picklistBinId");
@@ -96,7 +97,8 @@
if (bin != null) {
orderId = bin.getString("primaryOrderId");
shipGroupSeqId = bin.getString("primaryShipGroupSeqId");
- context.put("picklistItemInfos", bin.getRelatedByAnd("PicklistItem",
UtilMisc.toMap("itemStatusId", "PICKITEM_PENDING")));
+ packSession.addItemInfo(bin.getRelatedByAnd("PicklistItem",
UtilMisc.toMap("itemStatusId", "PICKITEM_PENDING")));
+ //context.put("picklistItemInfos", bin.getRelatedByAnd("PicklistItem",
UtilMisc.toMap("itemStatusId", "PICKITEM_PENDING")));
}
} else {
picklistBinId = null;
@@ -137,7 +139,10 @@
context.put("shipmentCostEstimateForShipGroup",
shipmentCostEstimate);
context.put("productStoreId", productStoreId);
- context.put("itemInfos", shippableItemInfo);
+ if (picklistBinId == null) {
+ packSession.addItemInfo(shippableItemInfo);
+ //context.put("itemInfos", shippableItemInfo);
+ }
} else {
request.setAttribute("errorMessageList", UtilMisc.toList("No
ship group sequence ID. Cannot process."));
}
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?view=diff&rev=539199&r1=539198&r2=539199
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl
(original)
+++ ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl Thu
May 17 17:54:22 2007
@@ -109,7 +109,7 @@
<input type="hidden" name="facilityId" value="${facilityId?if_exists}"/>
</form>
- <#if showInput != "N" && ((orderHeader?exists && orderHeader?has_content)
|| picklistItemInfos?has_content)>
+ <#if showInput != "N" && ((orderHeader?exists && orderHeader?has_content))>
<hr class="sepbar"/>
<div class='head2'>${uiLabelMap.ProductOrderId} #<a
href="/ordermgr/control/orderview?orderId=${orderId}"
class="buttontext">${orderId}</a> / ${uiLabelMap.ProductOrderShipGroupId}
#${shipGroupSeqId}</div>
<div> </div>
@@ -207,6 +207,7 @@
</#if>
<!-- auto grid form -->
+ <#assign itemInfos = packingSession.getItemInfos()?if_exists>
<#if showInput != "N" && hideGrid != "Y" && itemInfos?has_content>
<hr class="sepbar"/>
<div> </div>
@@ -236,52 +237,21 @@
<hr class="sepbar"/>
</td>
</tr>
-
- <#if (picklistItemInfos?has_content)>
- <#list picklistItemInfos as pickItem>
- <#assign orderItem = pickItem.getRelatedOne("OrderItem")/>
- <#assign shippedQuantity =
orderReadHelper.getItemShippedQuantityBd(orderItem)?if_exists>
- <#if orderItem.cancelQuantity?exists>
- <#assign orderItemQuantity = orderItem.quantity -
orderItem.cancelQuantity>
- <#else>
- <#assign orderItemQuantity = orderItem.quantity>
- </#if>
- <#assign inputQty = (orderItemQuantity - shippedQuantity -
packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId,
shipGroupSeqId))>
- <tr>
- <td><input type="checkbox"
name="sel_${orderItem.orderItemSeqId}" value="Y" <#if (inputQty
>0)>checked=""</#if>/></td>
- <td><div class="tabletext">${orderItem.orderItemSeqId}</td>
- <td><div
class="tabletext">${orderItem.productId?default("N/A")}</td>
- <td><div
class="tabletext">${orderItem.itemDescription?if_exists}</td>
- <td align="right"><div
class="tabletext">${orderItemQuantity}</td>
- <td align="right"><div
class="tabletext">${shippedQuantity?default(0)}</td>
- <td align="right"><div
class="tabletext">${packingSession.getPackedQuantity(orderId,
orderItem.orderItemSeqId, shipGroupSeqId)}</td>
- <td> </td>
- <td align="center">
- <input type="text" class="inputBox" size="7"
name="qty_${orderItem.orderItemSeqId}" value="${inputQty}">
- </td>
- <#--td align="center">
- <input type="text" class="inputBox" size="7"
name="wgt_${orderItem.orderItemSeqId}" value="">
- </td-->
- <td align="center">
- <select name="pkg_${orderItem.orderItemSeqId}">
- <option value="1">${uiLabelMap.ProductPackage} 1</option>
- <option value="2">${uiLabelMap.ProductPackage} 2</option>
- <option value="3">${uiLabelMap.ProductPackage} 3</option>
- <option value="4">${uiLabelMap.ProductPackage} 4</option>
- <option value="5">${uiLabelMap.ProductPackage} 5</option>
- </select>
- </td>
- <input type="hidden" name="prd_${orderItem.orderItemSeqId}"
value="${orderItem.productId?if_exists}">
- </tr>
- </#list>
- <#else>
- <#list itemInfos as orderItem>
+
+ <#if (itemInfos?has_content)>
+ <#list itemInfos as itemInfo>
+ <#-- <#list itemInfos as orderItem> -->
+ <#assign orderItem = itemInfo.orderItem/>
<#assign shippedQuantity =
orderReadHelper.getItemShippedQuantityBd(orderItem)?if_exists>
+ <#assign orderItemQuantity = itemInfo.quantity/>
+ <#--
<#if orderItem.cancelQuantity?exists>
<#assign orderItemQuantity = orderItem.quantity -
orderItem.cancelQuantity>
<#else>
<#assign orderItemQuantity = orderItem.quantity>
</#if>
+ -->
+
<#assign inputQty = (orderItemQuantity - shippedQuantity -
packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId,
shipGroupSeqId))>
<tr>
<td><input type="checkbox"
name="sel_${orderItem.orderItemSeqId}" value="Y" <#if (inputQty
>0)>checked=""</#if>/></td>