svn commit: r1306729 - /ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1306729 - /ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java

sascharodekamp
Author: sascharodekamp
Date: Thu Mar 29 07:24:27 2012
New Revision: 1306729

URL: http://svn.apache.org/viewvc?rev=1306729&view=rev
Log:
runSubscriptionAutoReorders places duplicate orderIds (https://issues.apache.org/jira/browse/OFBIZ-4762) A patch from Sebastian Leitner: The services "runSubscriptionAutoReorders" runs every midnight by default. It checks for expired subscriptions and places a new order to extend them. It fills up a cart from the previous order and places the order.
It also sets the orderId of the old order at the cart, which is used during creation of the new order. According to this, no new order can be placed because of duplicate-entry exceptions from the database.

Modified:
    ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java

Modified: ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1306729&r1=1306728&r2=1306729&view=diff
==============================================================================
--- ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java Thu Mar 29 07:24:27 2012
@@ -1963,7 +1963,7 @@ public class OrderServices {
                             return ServiceUtil.returnError((String)resp.get(ModelService.ERROR_MESSAGE));
                         }
                     }
-                    
+
                     // log an order note
                     try {
                         BigDecimal quantity = thisCancelQty.setScale(1, orderRounding);
@@ -5215,6 +5215,10 @@ public class OrderServices {
                     result = dispatcher.runSync("loadCartFromOrder", UtilMisc.toMap("orderId", subscription.get("orderId"), "userLogin", userLogin));
                     ShoppingCart cart = (ShoppingCart) result.get("shoppingCart");
 
+                    // remove former orderId from cart (would cause duplicate entry).
+                    // orderId is set by order-creation services (including store-specific prefixes, e.g.)
+                    cart.setOrderId(null);
+
                     // only keep the orderitem with the related product.
                     List cartItems = cart.items();
                     Iterator ci = cartItems.iterator();