About two years ago I was working on a project and was asked to handle the tax setup. Normally this isn’t that big of a deal, however this was for a client who sells throughout Canada and has a retail presence in each province. Part of this requirement thus was to collect the correct taxes for each province, and because its required in certain provinces (ie. Quebec) display the breakdown of the collected taxes appropriately to the customers as well as on the back-end.
Setting up the taxes, wasn’t that difficult, and with a little research I was able to figure out that Magento has the ability to break-out and display the taxes built in.
Where To Start
Hidden in the back-end within System->Configuration->Tax there are settings labeled ‘Display Full Tax Summary‘, which when enabled allow you to display the individual taxes on both the front and back-end of your site.
After enabling these I went to the front-end and began testing the taxes I had set up only to realize something was amiss. The full tax break out was only displaying correctly for Quebec, and for other provinces it was only displaying the full tax value for the first rate and nothing for the second.
Being new to Magento back then, I took this challenge head on and tracked down and made changes to every template file which was responsible for displaying taxes in an attempt to correct the issue. This seemed like an acceptable solution at the time, however now I feel this was not the correct way to tackle this problem, and know that this may have caused some display issues as it was prone to a one cent rounding “error”.
The taxes are calculated to 4 decimals places and rounded, thus $9.48 at 5% GST and 5% PST could be calculated separately as $0.47 each (exactly 0.4740) but when combined would display as $0.95 (0.9480) due to rounding up.
Digging a Little Deeper
Now jump to 2 weeks ago when I was tasked with doing a similar setup, with similar requirements. Imagine my surpise when I realized that almost 2 years later, and several versions down the road (Enterprise 18.104.22.168 specifically) Magento still seems to suffer from the exact same issue. This time with some experience under my belt, I dug deeper than the template level, and discovered that Magento was only breaking out the taxes properly when the taxes were compounded (when one tax has a higher priority than another).
I tracked the issue back to the file
Mage_Tax_Model_Resource_Calculation and specifically the
getCalculationProcess function, which is responsible for collecting, grouping and return the applicable tax rates. Within this function it compares the “priority” and combines all rates with the same priority level which in turn is the cause of the tax rates grouping and not displaying separately. After a little experimenting I found that adding logic to not group the rates that had different “tax codes” seemed to be trick.
Download the Demac TaxFix Module
As with many things in Magento, its always amazing how hours or research and work tend to lead us to so few lines of code. Never the less, hopefully others can benefit and might find this information useful. To make it even easier I have made and attached a small module called
Demac_Taxfix, which includes the adjustments I mentioned above.