Announcement

Collapse
No announcement yet.

VAT Rounding Up on Add to Cart

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    VAT Rounding Up on Add to Cart

    Hi,

    I've nearly completed a site but seem to have a problem with a rounding up issue. The site is here:
    www.thebedsheduk.com

    There is only one product and when selecting the 'double' size at £104.99, when added to cart it shows at £105.00. Bizarrely when you increase the quantity to 2, it shows at £209.99. Has anyone any ideas why this would happen?

    I recently changed the permutation price code to show the VAT included price on screen as recommended here:
    http://community.actinic.com/showthr...clusive+of+VAT

    ...i've tried removing the '(round' part of this code but it throws up lots of errors.

    I just cant figure out why it works on products not ending .99p and why it displays fine until it adds to cart.

    FYI - i pull the price data through from sage but use Actinic to calculate the tax. Use simple tax @ 15%.

    Has anyone come across this before?

    Thanks in advance,
    Nikki.

    #2
    The price on the double is set to £91.30 plus 15% VAT which comes to £104.995 or £105.00 when rounded to nearest 1p.

    Two times £91.30 = £182.60 plus 15% VAT which equals £209.99 so the cart is showing the correct values.

    I can't say where the £104.99 is coming from. Is that manually entered?

    Mike
    -----------------------------------------

    First Tackle - Fly Fishing and Game Angling

    -----------------------------------------

    Comment


      #3
      Hi Mike,

      Thanks for the quick response! I seem to have got myself confused, the shopping cart is the correct figure, its the display of the permutation price that DOES NOT seem to be rounding up the figure. I changed the permutation price code (as per above post) to show the price including VAT as i believe this is not done as standard in Actinic. The code is now:

      <actinic:block if="%3cactinic%3avariable%20name%3d%22PermutationAssociatedPricesAreUsed%22%20%2f%3e%20%3d%3d%20FALSE" >
      <actinic:block PHP='true' SELECTABLE='false'>formattedcurrency(round(<actinic:variable name="PermutationPriceRaw" /> * 1.150, <actinic:variable name="CurrencyDigits" />), <actinic:variable name="CurrencyDigits" />, '<actinic:variable name="MoneyDecimalSeparator" />', '<actinic:variable name="MoneyThousandSeparator" />', '<actinic:variable name="DefaultCurrency" />');</actinic:block>
      </actinic:block>
      <actinic:block if="%3cactinic%3avariable%20name%3d%22PermutationAssociatedPricesAreUsed%22%20%2f%3e" />
      <actinic:block PHP='true' SELECTABLE='false'>formattedcurrency(round(<actinic:variable name="AssociatedProduct::ProductPriceRaw" /> * 1.150, <actinic:variable name="CurrencyDigits" />), <actinic:variable name="CurrencyDigits" />, '<actinic:variable name="MoneyDecimalSeparator" />', '<actinic:variable name="MoneyThousandSeparator" />', '<actinic:variable name="DefaultCurrency" />');</actinic:block>
      </actinic:block>

      So, the price should display as £105.00 on the radio button option, which would then match the shopping cart.

      Have you any ideas why this isn't rounding up?

      Sorry for the confusion....its been a long night/morning!

      Nikki

      Comment


        #4
        I've done a little more investigating and it appears there's an error with the round function:

        http://www.experts-exchange.com/Web_..._23201889.html

        Could this be the problem i wonder? If so, does that mean everyone who has used this workaround to get their permutations to display inclusive of VAT are displaying their prices incorrectly?

        I've looked for a workaround but i'm worried that changing the value will have an adverse affect on the other permutation prices....am i making this more difficult than it is? is it something simple that i'm missing?

        Comment


          #5
          from what I can see the most likely causes could be.

          1. A bug in the PHP round function early on meant that it didn't round correctly. I'd be surprised if this didn't work correctly now, but you could always try to specify the mode as PHP_ROUND_HALF_UP.

          2. When actinic multiplies by the VAT rate it probably uses floating numbers which can represent 104.995 as 104.99499999999999 (or there-abouts) which the round function would correctly round down to 104.99. You can get around this by first rounding to one extra place to get 104.995 and then rounding this to 1p to get 105.00.

          Mike
          -----------------------------------------

          First Tackle - Fly Fishing and Game Angling

          -----------------------------------------

          Comment


            #6
            I will admit that I haven't looked at your question in any real detail, but have you looked at all of the tax settings in the Business Settings | Tax area?

            In the default setup for "VAT", the choices against this can be set to "Tax Rounding Level": Line/Item/Order and "Tax Rounding Method": Standard/Truncate/Round Half Down/Round Up/Bankers Rounding.

            Apologies if this is a red herring.

            By the way, the web site calculates the tax using Perl, the desktop calculates the tax using an internal PHP routine.

            Chris

            Comment


              #7
              i really dont know a lot about php but i've been trying to find a workaround as it does seem to be a common problem. i'm assuming its because of using the 'round' function that doesn't work well with floating values (as mike said in point 2 above). however i have no idea how to implement the changes you said....do i need to do this in the php.ini file? or can i do this via actinic?

              thanks for your comments too chris - i tried switching from simple tax so i could test this but the problem is not with the way actinic is processing the rounding up....its the way the 'round' function that has been used to add VAT to the permutations is rounding up.

              There is a warning on the PHP site here about its use with floating numbers:
              http://uk3.php.net/float

              Apparently, the float function now uses the bankers method rather than the mathematical method of rounding up....the bankers method apparently round up or down depending whether odd or even to be fair to both them and the customer....you learn something new every day! although this doesn't help us as we use the mathematical approach where 104.995 would be rounded up to 105.00

              I've also tried to use the math.round function but actinic doesn't seem to like that...

              my head hurts!

              Comment

              Working...
              X