OFBiz
  1. OFBiz
  2. OFBIZ-113

Showing VAT/Sales tax in Shopping cart before checkout

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Trunk
    • Fix Version/s: Trunk
    • Labels:
      None

      Description

      VAT/Sales tax is currently calculated only after initiating Checkout. Even if the price in ecommerce catalog includes tax, shopping cart shows price without tax. It would be nice if Shopping cart showed the same price as in ecommerce catalog and instantly calculated total tax when a new product is added to Shopping cart.

      I tried to look into source code and seems this has to be changed in ShoppingCart.java, but it also seems quite complex issue.

      1. cart.diff
        2 kB
        Eriks Dobelis

        Issue Links

          Activity

          Hide
          Jacques Le Roux added a comment -

          It's not perfect, but in trunk at r813136, I have commited something which solves this issue.

          Show
          Jacques Le Roux added a comment - It's not perfect, but in trunk at r813136, I have commited something which solves this issue.
          Hide
          Jacques Le Roux added a comment -

          Mmm, after reading David's 1st comment maybe it has not been changed (I thought the issue title was right). But I guess it should. For instance if we decide to show price tax included we get inconsistent sub-total in cart. With Tiny Chrome Widget I get

          .                                                    Quantity     Unit Price    Adjustments Item Total
              
               
                
          WG-5569 - Tiny Chrome Widget : Tiny Chrome Widget    1           US$48.48    US$0.00      US$48.48
              
               
          Sub Total:                                                                                US$48.00
               
          Adjustment - Promotion Details:                                                           -US$4.80
               
          Cart Total:                                                                               US$43.68
           

          and we should have something like that

          .                                                    Quantity     Unit Price    Adjustments Item Total
              
               
                
          WG-5569 - Tiny Chrome Widget : Tiny Chrome Widget    1           US$48.48    US$0.00      US$48.00
              
               
          Sub Total:                                                                                US$48.00
          Included Sales tax                                                                         US$0.48  
               
          Adjustment - Promotion Details:                                                           -US$4.80
               
          Cart Total:                                                                               US$43.68
           

          I have no time to work on this now, but hopefully I will in some days.

          Show
          Jacques Le Roux added a comment - Mmm, after reading David's 1st comment maybe it has not been changed (I thought the issue title was right). But I guess it should. For instance if we decide to show price tax included we get inconsistent sub-total in cart. With Tiny Chrome Widget I get . Quantity Unit Price Adjustments Item Total WG-5569 - Tiny Chrome Widget : Tiny Chrome Widget 1 US$48.48 US$0.00 US$48.48 Sub Total: US$48.00 Adjustment - Promotion Details: -US$4.80 Cart Total: US$43.68 and we should have something like that . Quantity Unit Price Adjustments Item Total WG-5569 - Tiny Chrome Widget : Tiny Chrome Widget 1 US$48.48 US$0.00 US$48.00 Sub Total: US$48.00 Included Sales tax US$0.48 Adjustment - Promotion Details: -US$4.80 Cart Total: US$43.68 I have no time to work on this now, but hopefully I will in some days.
          Hide
          Jacques Le Roux added a comment -

          This problem has reappeared . You only see VAT/sale tax in cart when you come back to the cart page after having set the shipping method

          Show
          Jacques Le Roux added a comment - This problem has reappeared . You only see VAT/sale tax in cart when you come back to the cart page after having set the shipping method
          Hide
          Eriks Dobelis added a comment -

          There is a problem when checkout is started (shipping address is entered), but not finished, then VAT is not calculated. Suggestions? Should normal VAT calculation be forced as soon as shipping address is entered or display price be used until the checkout is finalized?

          Show
          Eriks Dobelis added a comment - There is a problem when checkout is started (shipping address is entered), but not finished, then VAT is not calculated. Suggestions? Should normal VAT calculation be forced as soon as shipping address is entered or display price be used until the checkout is finalized?
          Hide
          David E. Jones added a comment -

          Thanks for your work on this Eriks. The changes for OFBIZ-113 and OFBIZ-164 plus a couple of small changes are in SVN rev 437453. You can see the commit log for details.

          Show
          David E. Jones added a comment - Thanks for your work on this Eriks. The changes for OFBIZ-113 and OFBIZ-164 plus a couple of small changes are in SVN rev 437453. You can see the commit log for details.
          Hide
          Eriks Dobelis added a comment -

          Just a note that this should be applied together with patch from OFBIZ-164 as otherwise VAT calculation is incorrect.

          Show
          Eriks Dobelis added a comment - Just a note that this should be applied together with patch from OFBIZ-164 as otherwise VAT calculation is incorrect.
          Hide
          Eriks Dobelis added a comment -

          Attached diff fixes totals in shopping cart by including VAT even if shipping is not supplied. Looks somewhat strange because depending on existence of shipping VAT is either shown separately or not. Probably would be better if it was shown all the time.

          Is it correct way to check existence of shipping?

          I am not sure whether it works correctly in case there are adjustments, but in simple cases it works.

          Show
          Eriks Dobelis added a comment - Attached diff fixes totals in shopping cart by including VAT even if shipping is not supplied. Looks somewhat strange because depending on existence of shipping VAT is either shown separately or not. Probably would be better if it was shown all the time. Is it correct way to check existence of shipping? I am not sure whether it works correctly in case there are adjustments, but in simple cases it works.
          Hide
          David E. Jones added a comment -

          Interesting... It looks like this part of ShoppingCartItem was updated to use the new displayPrice and such, but didn't go the last step to setting the flag to get the VAT added into the display price (and left out of the base price so that in the final order it will be split appropriately).

          The big trick with this, related to what you're saying about the shipping address and such, is that the actualy tax adjustment is added in once we know the address and not before, just in case it will go outside of the VAT jurisdiction or other taxes might be involved or whatever.

          It should be possible though to make a change to the shopping cart page to show the total with tax included, ie have it be based on the display price and not on the base price. Of course, then we need to make sure that when the tax adjustment is put in place that it is not added in twice.

          Okay, this ShoppingCartItem change is now in SVN, rev 432121.

          Show
          David E. Jones added a comment - Interesting... It looks like this part of ShoppingCartItem was updated to use the new displayPrice and such, but didn't go the last step to setting the flag to get the VAT added into the display price (and left out of the base price so that in the final order it will be split appropriately). The big trick with this, related to what you're saying about the shipping address and such, is that the actualy tax adjustment is added in once we know the address and not before, just in case it will go outside of the VAT jurisdiction or other taxes might be involved or whatever. It should be possible though to make a change to the shopping cart page to show the total with tax included, ie have it be based on the display price and not on the base price. Of course, then we need to make sure that when the tax adjustment is put in place that it is not added in twice. Okay, this ShoppingCartItem change is now in SVN, rev 432121.
          Hide
          Eriks Dobelis added a comment -

          This patch shows line items in Cart with VAT, but the total is still without VAT before shipping address is assigned.

          Index: applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
          ===================================================================
          — applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (revision 431541)
          +++ applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (working copy)
          @@ -877,6 +877,7 @@
          priceContext.put("webSiteId", cart.getWebSiteId());
          priceContext.put("productStoreId", cart.getProductStoreId());
          priceContext.put("agreementId", cart.getAgreementId());
          + priceContext.put("checkIncludeVat", "Y");
          Map priceResult = dispatcher.runSync("calculateProductPrice", priceContext);
          if (ServiceUtil.isError(priceResult)) {
          throw new CartItemModifyException("There was an error while calculating the price: " + ServiceUtil.getErrorMessage(priceResult));

          Show
          Eriks Dobelis added a comment - This patch shows line items in Cart with VAT, but the total is still without VAT before shipping address is assigned. Index: applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java =================================================================== — applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (revision 431541) +++ applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (working copy) @@ -877,6 +877,7 @@ priceContext.put("webSiteId", cart.getWebSiteId()); priceContext.put("productStoreId", cart.getProductStoreId()); priceContext.put("agreementId", cart.getAgreementId()); + priceContext.put("checkIncludeVat", "Y"); Map priceResult = dispatcher.runSync("calculateProductPrice", priceContext); if (ServiceUtil.isError(priceResult)) { throw new CartItemModifyException("There was an error while calculating the price: " + ServiceUtil.getErrorMessage(priceResult));
          Hide
          Jacques Le Roux added a comment -

          I agree and I vote for

          Show
          Jacques Le Roux added a comment - I agree and I vote for

            People

            • Assignee:
              Jacques Le Roux
              Reporter:
              Eriks Dobelis
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development