Author: jleroux
Date: Fri Jun 20 05:32:34 2008 New Revision: 669874 URL: http://svn.apache.org/viewvc?rev=669874&view=rev Log: A patch from Rashko Rejmer "Edit order - promotion calculation problem" (https://issues.apache.org/jira/browse/OFBIZ-1833) - OFBIZ-1833 Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.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=669874&r1=669873&r2=669874&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 Fri Jun 20 05:32:34 2008 @@ -48,6 +48,7 @@ import org.ofbiz.order.shoppingcart.ItemNotFoundException; import org.ofbiz.order.shoppingcart.ShoppingCart; import org.ofbiz.order.shoppingcart.ShoppingCartItem; +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; import org.ofbiz.order.shoppingcart.shipping.ShippingEvents; import org.ofbiz.party.contact.ContactHelper; import org.ofbiz.party.party.PartyWorker; @@ -3278,7 +3279,7 @@ // set quantity try { - cartItem.setQuantity(qty.doubleValue(), dispatcher, cart, true, false); // trigger external ops, don't reset ship groups (and update prices for both PO and SO items) + cartItem.setQuantity(qty.doubleValue(), dispatcher, cart, false, false); // trigger external ops, don't reset ship groups (and update prices for both PO and SO items) } catch (CartItemModifyException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -3359,6 +3360,9 @@ } } + // run promotions to handle all changes in the cart + ProductPromoWorker.doPromotions(cart, dispatcher); + // save all the updated information try { saveUpdatedCartToOrder(dispatcher, delegator, cart, locale, userLogin, orderId, UtilMisc.toMap("itemReasonMap", itemReasonMap, "itemCommentMap", itemCommentMap)); 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=669874&r1=669873&r2=669874&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 Fri Jun 20 05:32:34 2008 @@ -303,6 +303,12 @@ if (quantity != null) { quantityDbl = quantity.doubleValue(); } + + Double unitPrice = null; + if ("Y".equals(item.getString("isModifiedPrice"))) { + unitPrice = item.getDouble("unitPrice"); + } + int itemIndex = -1; if (item.get("productId") == null) { // non-product item @@ -310,7 +316,7 @@ String desc = item.getString("itemDescription"); try { // TODO: passing in null now for itemGroupNumber, but should reproduce from OrderItemGroup records - itemIndex = cart.addNonProductItem(itemType, desc, null, null, quantity.doubleValue(), null, null, null, dispatcher); + itemIndex = cart.addNonProductItem(itemType, desc, null, unitPrice, quantity.doubleValue(), null, null, null, dispatcher); } catch (CartItemModifyException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -366,9 +372,7 @@ configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, productId, productStoreId, prodCatalogId, website, currency, locale, userLogin); } try { - - itemIndex = cart.addItemToEnd(productId, amount, quantityDbl, null, reservStart, reservLength, reservPersons,accommodationMapId,accommodationSpotId, null, null, prodCatalogId, configWrapper, item.getString("orderItemTypeId"), dispatcher, null, null, skipInventoryChecks, skipProductChecks); - + itemIndex = cart.addItemToEnd(productId, amount, quantityDbl, unitPrice, reservStart, reservLength, reservPersons,accommodationMapId,accommodationSpotId, null, null, prodCatalogId, configWrapper, item.getString("orderItemTypeId"), dispatcher, null, unitPrice == null ? null : false, skipInventoryChecks, skipProductChecks); } catch (ItemNotFoundException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -394,8 +398,6 @@ cartItem.setShipAfterDate(item.getTimestamp("shipAfterDate")); cartItem.setShoppingList(item.getString("shoppingListId"), item.getString("shoppingListItemSeqId")); cartItem.setIsModifiedPrice("Y".equals(item.getString("isModifiedPrice"))); - if(cartItem.getIsModifiedPrice()) - cartItem.setBasePrice(item.getDouble("unitPrice").doubleValue()); // set the PO number on the cart cart.setPoNumber(item.getString("correspondingPoId")); |
Free forum by Nabble | Edit this page |