Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8384775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:29:37+00:00 2026-06-09T17:29:37+00:00

Today I was studying how Magento tax calculation works to understand the difference between

  • 0

Today I was studying how Magento tax calculation works to understand the difference between the behaviors for “Tax Calculation Method Based On“.

I traced deep into Mage_Tax_Model_Sales_Total_Quote_Tax which implements all methods in the _unitBaseCalculation, _rowBaseCalculation, _totalBaseCalculation.

I discovered that they produce exactly the same results. So why did they go through the trouble of implementing them ?

For example, unit-price calculation goes to the trouble of calculating the tax for the single unit and then dividing the discount amount by the qty (if tax applied after discount), then subtracting both, and then multiplying again by the quantity… which just introduces rounding errors.

Whereas Row Total calculation is the most intuitive one (which takes the price from the row “subtotal”) minus discount amount (if tax applied after discount).

While the third one is just an aggregation of the second, calculated at once.

This just introduces confusion and obfuscation to the tax calculation logic. Can anyone shed a light onto why this was done ?

(Rounding errors ? Backward compatibility ? Candidate for TheDailyWTF prize ?)

EDIT: For the record this is true as of Magento 1.6 and 1.7, don’t know about older versions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:29:38+00:00Added an answer on June 9, 2026 at 5:29 pm

    I found this from: https://gist.github.com/2572772 (by Alan Storm it seems)

    This feature was probably motivated by individual local rules (or client requests) as to how taxes should be calculated, as fractional amounts could add up differently depending on when adding and rounding occurs. THat said, I haven’t run through the code to see if my guesses are right so YMMV. Other areas to consider for future research.

    How does each mode play with shopping cart price rules and store wide discounts

    For shopping cart price rules, it goes through painstaking trouble to divide the discount amount (which may not be divisible by the quote item quantity thus introducing a rounding error) so that the end result is the actually the same process, but only with different "when"s and "where"s as to rounding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today, I ran into this weird problem with a user using Mac OS X.
A friend and I are studying Java. We were looking at interfaces today and
I start studying ANT today in order to make Java compiling easier. I wrote
I'm new to using vectors...I just started studying them today. I'm trying to create
I am pretty new to Java and Maven and today was studying about maven,
today I had a very embarrassing experience. I just called Push.payload() method like this.
Today i was making a file upload for avatars, everything works great, it resizes
today i hit a really annoing problem with wpf. i just want to align
Today at work, I was given a task to fix a bug within our
Today I have had a problem with hiding text with text-indent: -9999px rule. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.