Author: doogie
Date: Tue Nov 30 22:04:04 2010
New Revision: 1040802
URL: http://svn.apache.org/viewvc?rev=1040802&view=rev
Log:
If the last item of an approved order is cancelled, and a new item is
then added, the orderItemSeqId would be reused. This is because
OrderReadHelper.getValidOrderItems() does not return cancelled/rejected
items, so the loop to find the highest orderItemSeqId wouldn't consider
them. This means we have to loop over all items, to find the highest
value, then skip the invalid ones locally.
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1040802&r1=1040801&r2=1040802&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
Tue Nov 30 22:04:04 2010
@@ -337,7 +337,7 @@ public class ShoppingCartServices {
cartShipInfo.shipTaxAdj.addAll(orh.getOrderHeaderAdjustmentsTax(orderItemShipGroup.getString("shipGroupSeqId")));
}
- List<GenericValue> orderItems = orh.getValidOrderItems();
+ List<GenericValue> orderItems = orh.getOrderItems();
long nextItemSeq = 0;
if (UtilValidate.isNotEmpty(orderItems)) {
for (GenericValue item : orderItems) {
@@ -350,6 +350,16 @@ public class ShoppingCartServices {
// creates survey responses for Gift cards same as last Order
created
Map surveyResponseResult = null;
try {
+ long seq = Long.parseLong(orderItemSeqId);
+ if (seq > nextItemSeq) {
+ nextItemSeq = seq;
+ }
+ } catch (NumberFormatException e) {
+ Debug.logError(e, module);
+ return ServiceUtil.returnError(e.getMessage());
+ }
+ if ("ITEM_REJECTED".equals(item.getString("statusId")) ||
"ITEM_CANCELLED".equals(item.getString("statusId"))) continue;
+ try {
product = delegator.findOne("Product",
UtilMisc.toMap("productId", productId), false);
if
("DIGITAL_GOOD".equals(product.getString("productTypeId"))) {
Map<String, Object> surveyResponseMap =
FastMap.newInstance();
@@ -372,15 +382,6 @@ public class ShoppingCartServices {
Debug.logError(e.toString(), module);
return ServiceUtil.returnError(e.toString());
}
- try {
- long seq = Long.parseLong(orderItemSeqId);
- if (seq > nextItemSeq) {
- nextItemSeq = seq;
- }
- } catch (NumberFormatException e) {
- Debug.logError(e, module);
- return ServiceUtil.returnError(e.getMessage());
- }
// do not include PROMO items
if (!includePromoItems && item.get("isPromo") != null &&
"Y".equals(item.getString("isPromo"))) {