Author: mor
Date: Mon Jul 14 06:52:20 2008 New Revision: 676589 URL: http://svn.apache.org/viewvc?rev=676589&view=rev Log: In shopping cart and summary, Discount is calculated as Sum of Order Adjustments. Patch from Brajesh Patel Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl ofbiz/trunk/applications/order/servicedef/services_cart.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js?rev=676589&r1=676588&r2=676589&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js Mon Jul 14 06:52:20 2008 @@ -377,7 +377,7 @@ } else if (data._ERROR_MESSAGE_ != undefined) { $('cartFormServerError').update(data._ERROR_MESSAGE_); } else { - $('cartDiscountValue').update(data.displayDiscountTotalCurrencyFormatted); + $('cartDiscountValue').update(data.displayOrderAdjustmentsTotalCurrencyFormatted); $('cartSubTotal').update(data.subTotalCurrencyFormatted); $('cartTotalShipping').update(data.totalShippingCurrencyFormatted); $('cartTotalSalesTax').update(data.totalSalesTaxCurrencyFormatted); @@ -387,7 +387,7 @@ $('completedCartTotalShipping').update(data.totalShippingCurrencyFormatted); $('completedCartTotalSalesTax').update(data.totalSalesTaxCurrencyFormatted); $('completedCartDisplayGrandTotal').update(data.displayGrandTotalCurrencyFormatted); - $('completedCartDiscount').update(data.displayDiscountTotalCurrencyFormatted); + $('completedCartDiscount').update(data.displayOrderAdjustmentsTotalCurrencyFormatted); if (data.displayDiscountTotal < 0) { $('completedCartDiscountRow').show(); } else { @@ -458,7 +458,7 @@ } else { // Used for edit cart $('cartSubTotal').update(data.subTotalCurrencyFormatted); - $('cartDiscountValue').update(data.displayDiscountTotalCurrencyFormatted); + $('cartDiscountValue').update(data.displayOrderAdjustmentsTotalCurrencyFormatted); $('cartTotalShipping').update(data.totalShippingCurrencyFormatted); $('cartTotalSalesTax').update(data.totalSalesTaxCurrencyFormatted); $('cartDisplayGrandTotal').update(data.displayGrandTotalCurrencyFormatted); @@ -467,7 +467,7 @@ $('completedCartTotalShipping').update(data.totalShippingCurrencyFormatted); $('completedCartTotalSalesTax').update(data.totalSalesTaxCurrencyFormatted); $('completedCartDisplayGrandTotal').update(data.displayGrandTotalCurrencyFormatted); - $('completedCartDiscount').update(data.displayDiscountTotalCurrencyFormatted); + $('completedCartDiscount').update(data.displayOrderAdjustmentsTotalCurrencyFormatted); if (elementId != undefined && $(elementId).value != "") { if (itemQty == 0) { var cartItemRowId = elementId.sub('qty_','cartItemRow_'); Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl?rev=676589&r1=676588&r2=676589&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl Mon Jul 14 06:52:20 2008 @@ -58,10 +58,10 @@ <tr id="cartItemDisplayRow_${cartLineIndex}"> <td align="left"><div><img src="<@ofbizContentUrl>${requestAttributes.contentPathPrefix?if_exists}${smallImageUrl}</@ofbizContentUrl>" align="center" height="20" hspace="0" vspace="0" width="20"></div></td> <td align="left"><div>${cartLine.getName()?if_exists}</div> - <td align="center"><div>@${cartLine.getDisplayPrice()}</div></td> + <td align="center"><div>${cartLine.getDisplayPrice()}</div></td> <td align="center"><div><span id="completedCartItemQty_${cartLineIndex}">${cartLine.getQuantity()?string.number}</span></div></td> - <td align="center"><div><span id="completedCartItemAdjustment_${cartLineIndex}">${cartLine.getOtherAdjustments()?string.number}</span></div></td> - <td align="right"><div id="completedCartItemSubTotal_${cartLineIndex}"><@ofbizCurrency amount=cartLine.getDisplayItemSubTotalNoAdj() isoCode=shoppingCart.getCurrency()/></div></td> + <td align="center"><div><span id="completedCartItemAdjustment_${cartLineIndex}"><@ofbizCurrency amount=cartLine.getOtherAdjustments() isoCode=shoppingCart.getCurrency()/></span></div></td> + <td align="right"><div id="completedCartItemSubTotal_${cartLineIndex}"><@ofbizCurrency amount=cartLine.getDisplayItemSubTotal() isoCode=shoppingCart.getCurrency()/></div></td> </tr> <tr><td colspan="6"><hr class="sepbar"/></td></tr> <#assign itemCount = itemCount + 1> @@ -69,14 +69,21 @@ <tr id="completedCartSubtotalRow"> <td colspan="4"></td> <td><div align="right"><b>${uiLabelMap.CommonSubtotal}:</b></div></td> - <#assign initializedSubTotal = shoppingCart.getDisplaySubTotal() - shoppingCart.getProductPromoTotal()> - <td><div id="completedCartSubTotal" align="right"><@ofbizCurrency amount=initializedSubTotal isoCode=shoppingCart.getCurrency()/></div></td> + <td><div id="completedCartSubTotal" align="right"><@ofbizCurrency amount=shoppingCart.getSubTotal() isoCode=shoppingCart.getCurrency()/></div></td> </tr> + <#assign orderAdjustmentsTotal = 0> + <#list shoppingCart.getAdjustments() as cartAdjustment> + <#assign orderAdjustmentsTotal = orderAdjustmentsTotal + Static["org.ofbiz.order.order.OrderReadHelper"].calcOrderAdjustment(cartAdjustment, shoppingCart.getSubTotal())> + </#list> <tr id="completedCartDiscountRow"> - <input type="hidden" value="<b>${shoppingCart.getProductPromoTotal()}</b>" id="initializedCompletedCartDiscount"/> + <input type="hidden" value="${orderAdjustmentsTotal}" id="initializedCompletedCartDiscount"/> <td colspan="4"></td> <td><div align="right"><b>${uiLabelMap.ProductDiscount}:</b></div></td> - <td><div id="completedCartDiscount" align="right"><@ofbizCurrency amount=shoppingCart.getProductPromoTotal() isoCode=shoppingCart.getCurrency()/></div></td> + <td> + <div id="completedCartDiscount" align="right"> + <@ofbizCurrency amount=orderAdjustmentsTotal isoCode=shoppingCart.getCurrency()/> + </div> + </td> </tr> <tr> <td colspan="4"></td> @@ -150,7 +157,7 @@ </td> <td align="left"><div>${cartLine.getName()?if_exists}</div></td> <td align="center"><div id="itemUnitPrice_${cartLineIndex}"> - <@ofbizCurrency amount=cartLine.getDisplayPrice() isoCode=shoppingCart.getCurrency() rounding=2/></div> + <@ofbizCurrency amount=cartLine.getDisplayPrice() isoCode=shoppingCart.getCurrency()/></div> </td> <td align="center"> <#if cartLine.getIsPromo()> @@ -172,11 +179,7 @@ <#else> <td nowrap align="center"><div class="tabletext"><@ofbizCurrency amount=cartLine.getOtherAdjustments() isoCode=shoppingCart.getCurrency()/></div></td> </#if> - <#if cartLine.getIsPromo()> - <td align="center">FREE</td> - <#else> - <td align="center"><div id="displayItem_${cartLineIndex}"><@ofbizCurrency amount=cartLine.getDisplayItemSubTotalNoAdj() isoCode=shoppingCart.getCurrency()/></div></td> - </#if> + <td align="center"><div id="displayItem_${cartLineIndex}"><@ofbizCurrency amount=cartLine.getDisplayItemSubTotal() isoCode=shoppingCart.getCurrency()/></div></td> <#if !cartLine.getIsPromo()> <td align="right"><a href="javascript:void(0);"><img id="remove_${cartLineIndex?if_exists}" src="<@ofbizContentUrl>/ecommerce/images/remove.png</@ofbizContentUrl>" border="0" height="30" hspace="0" vspace="0" width="40"></a></td> </#if> @@ -188,8 +191,7 @@ <tr> <td colspan="4"></td> <td><div align="right"><b>${uiLabelMap.CommonSubtotal}:</b></div></td> - <#assign initializedSubTotal = shoppingCart.getDisplaySubTotal() - shoppingCart.getProductPromoTotal()> - <td><div id="cartSubTotal" align="center"><@ofbizCurrency amount=initializedSubTotal isoCode=shoppingCart.getCurrency()/></div></td> + <td><div id="cartSubTotal" align="center"><@ofbizCurrency amount=shoppingCart.getSubTotal() isoCode=shoppingCart.getCurrency()/></div></td> </tr> <tr> <td colspan="4"> @@ -199,7 +201,13 @@ </td> <td><div id="cartDiscount" align="right"><b>${uiLabelMap.ProductDiscount}:</b></div></td> <td> - <div id="cartDiscountValue" align="center"><@ofbizCurrency amount=shoppingCart.getProductPromoTotal() isoCode=shoppingCart.getCurrency()/></div> + <div id="cartDiscountValue" align="center"> + <#assign orderAdjustmentsTotal = 0> + <#list shoppingCart.getAdjustments() as cartAdjustment> + <#assign orderAdjustmentsTotal = orderAdjustmentsTotal + Static["org.ofbiz.order.order.OrderReadHelper"].calcOrderAdjustment(cartAdjustment, shoppingCart.getSubTotal())> + </#list> + <@ofbizCurrency amount=orderAdjustmentsTotal isoCode=shoppingCart.getCurrency()/> + </div> </td> </tr> <tr> Modified: ofbiz/trunk/applications/order/servicedef/services_cart.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services_cart.xml?rev=676589&r1=676588&r2=676589&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services_cart.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services_cart.xml Mon Jul 14 06:52:20 2008 @@ -132,7 +132,7 @@ <attribute name="displayGrandTotal" type="Double" mode="OUT" optional="true"/> <attribute name="displayGrandTotalCurrencyFormatted" type="String" mode="OUT" optional="true"/> <attribute name="cartItemData" type="Map" mode="OUT"/> - <attribute name="displayDiscountTotalCurrencyFormatted" type="String" mode="OUT" optional="true"/> + <attribute name="displayOrderAdjustmentsTotalCurrencyFormatted" type="String" mode="OUT" optional="true"/> </service> <service name="getShoppingCartItemIndex" engine="java" auth="false" 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=676589&r1=676588&r2=676589&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 Mon Jul 14 06:52:20 2008 @@ -850,8 +850,8 @@ result.put("totalSalesTaxCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getTotalSalesTax(),isoCode,locale)); result.put("displayGrandTotal",new Double(shoppingCart.getDisplayGrandTotal())); result.put("displayGrandTotalCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getDisplayGrandTotal(),isoCode,locale)); - result.put("displayDiscountTotalCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getProductPromoTotal(),isoCode,locale)); - + double orderAdjustmentsTotal = OrderReadHelper.calcOrderAdjustments(OrderReadHelper.getOrderHeaderAdjustments(shoppingCart.getAdjustments(), null), BigDecimal.valueOf(shoppingCart.getSubTotal()), true, true, true).doubleValue(); + result.put("displayOrderAdjustmentsTotalCurrencyFormatted", org.ofbiz.base.util.UtilFormatOut.formatCurrency(orderAdjustmentsTotal, isoCode, locale)); Iterator i = shoppingCart.iterator(); Map cartItemData = FastMap.newInstance(); while (i.hasNext()) { |
Free forum by Nabble | Edit this page |