From b2a40a0be5cbffd54fe19c8d4074ea7ba433bc3f Mon Sep 17 00:00:00 2001 From: Vikas Mayur Date: Mon, 14 Jul 2008 13:52:20 +0000 Subject: [PATCH] In shopping cart and summary, Discount is calculated as Sum of Order Adjustments. Patch from Brajesh Patel git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@676589 13f79535-47bb-0310-9956-ffa450edef68 --- .../ecommerce/images/checkoutProcess.js | 8 ++-- .../order/OnePageCheckoutProcess.ftl | 40 +++++++++++-------- .../order/servicedef/services_cart.xml | 2 +- .../shoppingcart/ShoppingCartServices.java | 4 +- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js b/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js index d86b466e44..67122b6004 100644 --- a/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js +++ b/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js @@ -377,7 +377,7 @@ function addPromoCode() { } 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 @@ function addPromoCode() { $('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 @@ function updateCartData(elementId, formValues, itemQty, itemIndex) { } 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 @@ function updateCartData(elementId, formValues, itemQty, itemIndex) { $('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_'); diff --git a/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl b/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl index 2b4b50c019..55ab4c4c44 100644 --- a/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl +++ b/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl @@ -58,10 +58,10 @@ under the License.
${cartLine.getName()?if_exists}
-
@${cartLine.getDisplayPrice()}
+
${cartLine.getDisplayPrice()}
${cartLine.getQuantity()?string.number}
-
${cartLine.getOtherAdjustments()?string.number}
-
<@ofbizCurrency amount=cartLine.getDisplayItemSubTotalNoAdj() isoCode=shoppingCart.getCurrency()/>
+
<@ofbizCurrency amount=cartLine.getOtherAdjustments() isoCode=shoppingCart.getCurrency()/>
+
<@ofbizCurrency amount=cartLine.getDisplayItemSubTotal() isoCode=shoppingCart.getCurrency()/>

<#assign itemCount = itemCount + 1> @@ -69,14 +69,21 @@ under the License.
${uiLabelMap.CommonSubtotal}:
- <#assign initializedSubTotal = shoppingCart.getDisplaySubTotal() - shoppingCart.getProductPromoTotal()> -
<@ofbizCurrency amount=initializedSubTotal isoCode=shoppingCart.getCurrency()/>
+
<@ofbizCurrency amount=shoppingCart.getSubTotal() isoCode=shoppingCart.getCurrency()/>
+ <#assign orderAdjustmentsTotal = 0> + <#list shoppingCart.getAdjustments() as cartAdjustment> + <#assign orderAdjustmentsTotal = orderAdjustmentsTotal + Static["org.ofbiz.order.order.OrderReadHelper"].calcOrderAdjustment(cartAdjustment, shoppingCart.getSubTotal())> + - +
${uiLabelMap.ProductDiscount}:
-
<@ofbizCurrency amount=shoppingCart.getProductPromoTotal() isoCode=shoppingCart.getCurrency()/>
+ +
+ <@ofbizCurrency amount=orderAdjustmentsTotal isoCode=shoppingCart.getCurrency()/> +
+ @@ -150,7 +157,7 @@ under the License.
${cartLine.getName()?if_exists}
- <@ofbizCurrency amount=cartLine.getDisplayPrice() isoCode=shoppingCart.getCurrency() rounding=2/>
+ <@ofbizCurrency amount=cartLine.getDisplayPrice() isoCode=shoppingCart.getCurrency()/> <#if cartLine.getIsPromo()> @@ -172,11 +179,7 @@ under the License. <#else>
<@ofbizCurrency amount=cartLine.getOtherAdjustments() isoCode=shoppingCart.getCurrency()/>
- <#if cartLine.getIsPromo()> - FREE - <#else> -
<@ofbizCurrency amount=cartLine.getDisplayItemSubTotalNoAdj() isoCode=shoppingCart.getCurrency()/>
- +
<@ofbizCurrency amount=cartLine.getDisplayItemSubTotal() isoCode=shoppingCart.getCurrency()/>
<#if !cartLine.getIsPromo()> @@ -188,8 +191,7 @@ under the License.
${uiLabelMap.CommonSubtotal}:
- <#assign initializedSubTotal = shoppingCart.getDisplaySubTotal() - shoppingCart.getProductPromoTotal()> -
<@ofbizCurrency amount=initializedSubTotal isoCode=shoppingCart.getCurrency()/>
+
<@ofbizCurrency amount=shoppingCart.getSubTotal() isoCode=shoppingCart.getCurrency()/>
@@ -199,7 +201,13 @@ under the License.
${uiLabelMap.ProductDiscount}:
-
<@ofbizCurrency amount=shoppingCart.getProductPromoTotal() isoCode=shoppingCart.getCurrency()/>
+
+ <#assign orderAdjustmentsTotal = 0> + <#list shoppingCart.getAdjustments() as cartAdjustment> + <#assign orderAdjustmentsTotal = orderAdjustmentsTotal + Static["org.ofbiz.order.order.OrderReadHelper"].calcOrderAdjustment(cartAdjustment, shoppingCart.getSubTotal())> + + <@ofbizCurrency amount=orderAdjustmentsTotal isoCode=shoppingCart.getCurrency()/> +
diff --git a/applications/order/servicedef/services_cart.xml b/applications/order/servicedef/services_cart.xml index d9a98303f8..31d48d475a 100644 --- a/applications/order/servicedef/services_cart.xml +++ b/applications/order/servicedef/services_cart.xml @@ -132,7 +132,7 @@ under the License. - +