Author: ashish
Date: Wed Jun 10 14:43:32 2009 New Revision: 783374 URL: http://svn.apache.org/viewvc?rev=783374&view=rev Log: Applied fix from trunk revision: 783369 Applied patch from jira issue OFBIZ-2527 (When editing items, Promotion Codes are getting deleted when we click Update Items.) Thanks Ratnesh and Chirag for your contribution. Modified: ofbiz/branches/release09.04/applications/order/script/org/ofbiz/order/order/OrderSimpleMethods.xml ofbiz/branches/release09.04/applications/order/servicedef/services.xml ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java ofbiz/branches/release09.04/applications/order/webapp/ordermgr/order/editorderitems.ftl Modified: ofbiz/branches/release09.04/applications/order/script/org/ofbiz/order/order/OrderSimpleMethods.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/order/script/org/ofbiz/order/order/OrderSimpleMethods.xml?rev=783374&r1=783373&r2=783374&view=diff ============================================================================== --- ofbiz/branches/release09.04/applications/order/script/org/ofbiz/order/order/OrderSimpleMethods.xml (original) +++ ofbiz/branches/release09.04/applications/order/script/org/ofbiz/order/order/OrderSimpleMethods.xml Wed Jun 10 14:43:32 2009 @@ -50,6 +50,13 @@ <check-errors/> <entity-one entity-name="OrderAdjustment" value-field="lookedUpValue"/> <remove-value value-field="lookedUpValue"/> + + <if-not-empty field="parameters.productPromoCodeId"> + <entity-one entity-name="OrderProductPromoCode" value-field="lookedUpValue"/> + <if-not-empty field="lookedUpValue"> + <remove-value value-field="lookedUpValue"/> + </if-not-empty> + </if-not-empty> </simple-method> <simple-method method-name="createOrderAdjustmentBilling" short-description="Create an OrderAdjustmentBilling"> Modified: ofbiz/branches/release09.04/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/order/servicedef/services.xml?rev=783374&r1=783373&r2=783374&view=diff ============================================================================== --- ofbiz/branches/release09.04/applications/order/servicedef/services.xml (original) +++ ofbiz/branches/release09.04/applications/order/servicedef/services.xml Wed Jun 10 14:43:32 2009 @@ -132,6 +132,7 @@ <attribute name="orderItemContactMechs" type="List" mode="IN" optional="true"/> <attribute name="orderItemPriceInfos" type="List" mode="IN" optional="true"/> <attribute name="orderProductPromoUses" type="List" mode="IN" optional="true"/> + <attribute name="orderProductPromoCodes" type="Set" mode="IN" optional="true"/> <attribute name="orderItemSurveyResponses" type="List" mode="IN" optional="true"/> <attribute name="trackingCodeOrders" type="List" mode="IN" optional="true"/> <attribute name="orderAdditionalPartyRoleMap" type="Map" mode="IN" optional="true"/> @@ -196,6 +197,7 @@ <description>Delete an order adjustment record</description> <auto-attributes mode="IN" include="pk" optional="false"/> <attribute name="orderId" type="String" mode="IN" optional="false"/> <!-- needed for resetGrandTotal seca --> + <attribute name="productPromoCodeId" type="String" mode="IN" optional="true"/> </service> <service name="createOrderAdjustmentBilling" engine="simple" Modified: ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=783374&r1=783373&r2=783374&view=diff ============================================================================== --- ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/order/OrderServices.java Wed Jun 10 14:43:32 2009 @@ -930,6 +930,19 @@ toBeStored.add(productPromoUse); } } + + // store the orderProductPromoCodes + Set orderProductPromoCodes = (Set) context.get("orderProductPromoCodes"); + if (UtilValidate.isNotEmpty(orderProductPromoCodes)) { + GenericValue orderProductPromoCode = delegator.makeValue("OrderProductPromoCode"); + Iterator orderProductPromoCodeIter = orderProductPromoCodes.iterator(); + while (orderProductPromoCodeIter.hasNext()) { + orderProductPromoCode.clear(); + orderProductPromoCode.set("orderId", orderId); + orderProductPromoCode.set("productPromoCodeId", orderProductPromoCodeIter.next()); + toBeStored.add(orderProductPromoCode); + } + } /* DEJ20050529 the OLD way, where a single party had all roles... no longer doing things this way... // define the roles for the order @@ -3556,9 +3569,6 @@ } } - // 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)); @@ -3566,6 +3576,9 @@ return ServiceUtil.returnError(e.getMessage()); } + // run promotions to handle all changes in the cart + ProductPromoWorker.doPromotions(cart, dispatcher); + // log an order note try { dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", "Updated order.", "internalNote", "Y", "userLogin", userLogin)); Modified: ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=783374&r1=783373&r2=783374&view=diff ============================================================================== --- ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Wed Jun 10 14:43:32 2009 @@ -3947,6 +3947,7 @@ result.put("orderTerms", this.getOrderTerms()); result.put("orderItemPriceInfos", this.makeAllOrderItemPriceInfos()); result.put("orderProductPromoUses", this.makeProductPromoUses()); + result.put("orderProductPromoCodes", this.getProductPromoCodesEntered()); result.put("orderAttributes", this.makeAllOrderAttributes()); result.put("orderItemAttributes", this.makeAllOrderItemAttributes()); Modified: ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=783374&r1=783373&r2=783374&view=diff ============================================================================== --- ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original) +++ ofbiz/branches/release09.04/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Wed Jun 10 14:43:32 2009 @@ -379,6 +379,15 @@ // check if promo code required if (requireCode) { Set enteredCodes = cart.getProductPromoCodesEntered(); + // Check whether any promotion code is applied on order. + if (cart.getOrderId() != null) { + List orderproductPromoCodes = delegator.findList("OrderProductPromoCode", EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, cart.getOrderId()), null, null, null, false); + Iterator orderproductPromoCodesItr = UtilMisc.toIterator(orderproductPromoCodes); + while (orderproductPromoCodesItr != null && orderproductPromoCodesItr.hasNext()) { + GenericValue orderproductPromoCode = (GenericValue) orderproductPromoCodesItr.next(); + enteredCodes.add(orderproductPromoCode.getString("productPromoCodeId")); + } + } if (enteredCodes.size() > 0) { // get all promo codes entered, do a query with an IN condition to see if any of those are related EntityCondition codeCondition = EntityCondition.makeCondition(EntityCondition.makeCondition("productPromoId", EntityOperator.EQUALS, productPromoId), EntityOperator.AND, EntityCondition.makeCondition("productPromoCodeId", EntityOperator.IN, enteredCodes)); Modified: ofbiz/branches/release09.04/applications/order/webapp/ordermgr/order/editorderitems.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/order/webapp/ordermgr/order/editorderitems.ftl?rev=783374&r1=783373&r2=783374&view=diff ============================================================================== --- ofbiz/branches/release09.04/applications/order/webapp/ordermgr/order/editorderitems.ftl (original) +++ ofbiz/branches/release09.04/applications/order/webapp/ordermgr/order/editorderitems.ftl Wed Jun 10 14:43:32 2009 @@ -275,6 +275,20 @@ <#assign adjustmentType = orderHeaderAdjustment.getRelatedOne("OrderAdjustmentType")> <#assign adjustmentAmount = Static["org.ofbiz.order.order.OrderReadHelper"].calcOrderAdjustment(orderHeaderAdjustment, orderSubTotal)> <#assign orderAdjustmentId = orderHeaderAdjustment.get("orderAdjustmentId")> + <#assign productPromoCodeId = ''> + <#if adjustmentType.get("orderAdjustmentTypeId") == "PROMOTION_ADJUSTMENT" && orderHeaderAdjustment.get("productPromoId")?has_content> + <#assign productPromo = orderHeaderAdjustment.getRelatedOne("ProductPromo")> + <#assign productPromoCodes = delegator.findByAnd("ProductPromoCode", {"productPromoId":productPromo.productPromoId})> + <#assign orderProductPromoCode = ''> + <#list productPromoCodes as productPromoCode> + <#if !(orderProductPromoCode?has_content)> + <#assign orderProductPromoCode = delegator.findOne("OrderProductPromoCode", {"productPromoCodeId":productPromoCode.productPromoCodeId, "orderId":orderHeaderAdjustment.orderId}, false)?if_exists> + </#if> + </#list> + <#if orderProductPromoCode?has_content> + <#assign productPromoCodeId = orderProductPromoCode.get("productPromoCodeId")> + </#if> + </#if> <#if adjustmentAmount != 0> <form name="updateOrderAdjustmentForm${orderAdjustmentId}" method="post" action="<@ofbizUrl>updateOrderAdjustment</@ofbizUrl>"> <input type="hidden" name="orderAdjustmentId" value="${orderAdjustmentId?if_exists}"/> @@ -306,6 +320,9 @@ <form name="deleteOrderAdjustment${orderAdjustmentId}" method="post" action="<@ofbizUrl>deleteOrderAdjustment</@ofbizUrl>"> <input type="hidden" name="orderAdjustmentId" value="${orderAdjustmentId?if_exists}"/> <input type="hidden" name="orderId" value="${orderId?if_exists}"/> + <#if adjustmentType.get("orderAdjustmentTypeId") == "PROMOTION_ADJUSTMENT"> + <input type="hidden" name="productPromoCodeId" value="${productPromoCodeId?if_exists}"/> + </#if> </form> </#if> </#list> |
Free forum by Nabble | Edit this page |