Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21
  1. #11
    Join Date
    Jan 2004
    Posts
    66,374
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Tax calculation in v1.5

    Exactly. Looks correct to me too.
    Since you're doing tax-included-pricing, when you give it 1.00000 it calculates the base pre-tax (20%) price to 0.8333. If you multiply it forward again, adding the 20% tax back onto it, it still works out correctly as 1.0000 (correctly rounded up from the 5-decimals 0.99996 to the 4-decimals 1.0000).

    I echo kuroi's comment: Why do you think it's wrong?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  2. #12
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Totals Off by a Penny!

    Indeed nothing wrong with the calculation. 1/1.2=0.83333333

    It is a common mistake a lot of people make when calculating their prices with and without taxes.

  3. #13
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,715
    Plugin Contributions
    123

    Default Re: Tax calculation in v1.5

    Quote Originally Posted by BillyBoyle View Post

    Tax Class: Taxable goods (20%)
    Products Price (Net): 0.8333
    Products Price (Gross): 1.00
    Consider a product whole price is 1.00 with an embedded tax of 20%.

    The tax component of this price is 1.00 - 1.0/(1+0.20) = 1 - 1/1.2 = 1 - 0.8333 = 0.1667.

    Therefore, the net price is 1 - 0.1667 = 0.8333.

    Remember the basic formula: VAT = $total - $total/(1+vat_percentage)
    Last edited by swguy; 13 Nov 2011 at 01:27 PM. Reason: more details
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  4. #14
    Join Date
    Jul 2011
    Location
    Glasgow, Scotland
    Posts
    113
    Plugin Contributions
    1

    Default Re: Totals Off by a Penny!

    Cause 20% of 100 is 80 not 83.

  5. #15
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Totals Off by a Penny!

    Quote Originally Posted by BillyBoyle View Post
    Cause 20% of 100 is 80 not 83.
    But in your case 100 is not 100% but 120%, so that causes 20% to be 83

  6. #16
    Join Date
    Jul 2011
    Location
    Glasgow, Scotland
    Posts
    113
    Plugin Contributions
    1

    Default Re: Totals Off by a Penny!

    OOPS timed out in editing > full reply below.

    Cause 20% of 100 is 80 not 83.
    But as I said if someone can explain it then I can understand it.
    What has the number of decimal places got to do with it?
    why is there a need to round down (to get the right answer)?
    why not just a straight calculation?

    I'm not a programer, but if I do the same calculation in excel and ask it to show 20 decimal places the answer is
    £0.80000000000000000000.

    I just want to understand what and how it's being caculated. Many cause I don't know and partly cause I want to reverse the calculation in Auto-facebook postings and show prices.

    Anyway thanks for all the explanations: man Have I Got Some To Learn.

    Thanks again guys.

  7. #17
    Join Date
    Jul 2011
    Location
    Glasgow, Scotland
    Posts
    113
    Plugin Contributions
    1

    Default Re: Tax calculation in v1.5

    Quote Originally Posted by DrByte View Post
    Exactly. Looks correct to me too.
    Since you're doing tax-included-pricing, when you give it 1.00000 it calculates the base pre-tax (20%) price to 0.8333. If you multiply it forward again, adding the 20% tax back onto it, it still works out correctly as 1.0000 (correctly rounded up from the 5-decimals 0.99996 to the 4-decimals 1.0000).

    I echo kuroi's comment: Why do you think it's wrong?
    There is a good reason you guys do the programming and we just spend a lot of time breaking it.

  8. #18
    Join Date
    Jan 2004
    Posts
    66,374
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Tax calculation in v1.5

    Haha! I gather you're starting to see the logic in how it all works. Taxes are complicated ... especially when they're handled completely differently on the other side of the pond!

    Cheers :)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #19
    Join Date
    Jul 2011
    Location
    Glasgow, Scotland
    Posts
    113
    Plugin Contributions
    1

    Default Re: Tax calculation in v1.5

    Quote Originally Posted by swguy View Post
    Consider a product whole price is 1.00 with an embedded tax of 20%.

    The tax component of this price is 1.00 - 1.0/(1+0.20) = 1 - 1/1.2 = 1 - 0.8333 = 0.1667.

    Therefore, the net price is 1 - 0.1667 = 0.8333.

    Remember the basic formula: VAT = $total - $total/(1+vat_percentage)
    Thanks Scot, I appreciate the math leason and explanation from DrByte.

    Seeing the formula written down makes it as clear as pea soup, but I do start to understand it now.


  10. #20
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Totals Off by a Penny!

    Don't get hung up on the idea that they're taxes. Just think of them as percentages and be grateful for the one benefit of working with 20% and not 17.5%.

    Taxes are added as a percentage to a net price. You were trying to calculate it from the gross price so starting in the wrong place.

    To work backwards from a gross price is more complex, which is where swguy's formula comes in.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. The dreaded penny problem returns
    By peteratdd in forum Bug Reports
    Replies: 1
    Last Post: 18 Jun 2013, 09:03 AM
  2. ZC Adding a Penny to the total
    By timhersh in forum General Questions
    Replies: 3
    Last Post: 21 May 2013, 03:43 PM
  3. Attributes. Over a penny off?
    By quixotic in forum General Questions
    Replies: 1
    Last Post: 28 Nov 2012, 11:47 AM
  4. Penny Shipping Not Registering
    By Tapper in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 5 Jul 2012, 06:31 PM
  5. Duplicate database sub-totals and totals
    By confused_aswell in forum General Questions
    Replies: 0
    Last Post: 28 Aug 2008, 08:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR