Author: jaz
Date: Tue Nov  2 18:25:36 2010
New Revision: 1030158

URL: http://svn.apache.org/viewvc?rev=1030158&view=rev
Log:
saveUpdatedCartToOrder now stores promo codes and uses added/updated in the cart

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
    
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

Modified: 
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1030158&r1=1030157&r2=1030158&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java 
(original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java 
Tue Nov  2 18:25:36 2010
@@ -3908,12 +3908,35 @@ public class OrderServices {
         // Creating objects for New Shipping and Handling Charges Adjustment 
and Sales Tax Adjustment
         toStore.addAll(cart.makeAllShipGroupInfos());
         toStore.addAll(cart.makeAllOrderPaymentInfos(dispatcher));
-        toStore.addAll(cart.makeAllOrderItemAttributes(orderId, 
ShoppingCart.FILLED_ONLY));
+        toStore.addAll(cart.makeAllOrderItemAttributes(orderId, 
ShoppingCart.FILLED_ONLY));        
 
         // get the empty order item atrributes from the cart and remove them
         List toRemove = FastList.newInstance();
         toRemove.addAll(cart.makeAllOrderItemAttributes(orderId, 
ShoppingCart.EMPTY_ONLY));
 
+        // get the promo uses and codes
+        for (String promoCodeEntered : cart.getProductPromoCodesEntered()) {
+            GenericValue orderProductPromoCode = 
delegator.makeValue("OrderProductPromoCode");                                   
+            orderProductPromoCode.set("orderId", orderId);
+            orderProductPromoCode.set("productPromoCodeId", promoCodeEntered);
+            toStore.add(orderProductPromoCode);                                
    
+        }
+        for (GenericValue promoUse : cart.makeProductPromoUses()) {
+            promoUse.set("orderId", orderId);
+            toStore.add(promoUse);
+        }        
+        
+        List<GenericValue> existingPromoCodes = null;
+        List<GenericValue> existingPromoUses = null;
+        try {
+            existingPromoCodes = delegator.findByAnd("OrderProductPromoCode", 
UtilMisc.toMap("orderId", orderId));
+            existingPromoUses = delegator.findByAnd("ProductPromoUse", 
UtilMisc.toMap("orderId", orderId));
+        } catch (GenericEntityException e) {
+            Debug.logError(e, module);
+        }
+        toRemove.addAll(existingPromoCodes);
+        toRemove.addAll(existingPromoUses);
+        
         // set the orderId & other information on all new value objects
         List dropShipGroupIds = FastList.newInstance(); // this list will 
contain the ids of all the ship groups for drop shipments (no reservations)
         Iterator tsi = toStore.iterator();

Modified: 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1030158&r1=1030157&r2=1030158&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
 (original)
+++ 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
 Tue Nov  2 18:25:36 2010
@@ -130,7 +130,7 @@ public class ShoppingCart implements Ite
     /** Contains a List for each productPromoId (key) containing a 
productPromoCodeId (or empty string for no code) for each use of the 
productPromoId */
     private List<ProductPromoUseInfo> productPromoUseInfoList = 
FastList.newInstance();
     /** Contains the promo codes entered */
-    private Set productPromoCodes = new HashSet();
+    private Set<String> productPromoCodes = new HashSet<String>();
     private List freeShippingProductPromoActions = new ArrayList();
     /** Note that even though this is promotion info, it should NOT be cleared 
when the promos are cleared, it is a preference that will be used in the next 
promo calculation */
     private Map desiredAlternateGiftByAction = new HashMap();
@@ -3267,7 +3267,7 @@ public class ShoppingCart implements Ite
         }
     }
 
-    public Set getProductPromoCodesEntered() {
+    public Set<String> getProductPromoCodesEntered() {
         return this.productPromoCodes;
     }
 
@@ -3775,7 +3775,7 @@ public class ShoppingCart implements Ite
         return allInfos;
     }
 
-    public List makeProductPromoUses() {
+    public List<GenericValue> makeProductPromoUses() {
         List<GenericValue> productPromoUses = FastList.newInstance();
         String partyId = this.getPartyId();
         int sequenceValue = 0;


Reply via email to