Jump to content

PDF Invoice Total (tax excl.) incorrect


Recommended Posts

will be todo with rounding.

Look at preferences in your back office and you can select the different types of rounding. either superior, inferior or classical.

Unfortunately rounding of numbers has always been problematic and needs careful consideration in software development. If its any consolation the financial industry probably spends millions every year on this very same problem when testing and implementing bespoke software, and many a developer has cursed the outcomes of rounding up and down on decimal places.

Link to comment
Share on other sites

BTW, I'm using PS v1.3.1.1

With superior rounding:

Total products (tax excl.) : $10.00
Total products (tax incl.) : $10.82
Total (tax excl.) : $9.99
Total (tax incl.) : $10.82



With classical rounding:

Total products (tax excl.) : $9.99
Total products (tax incl.) : $10.81
Total (tax excl.) : $9.98
Total (tax incl.) : $10.81 



With inferior rounding:

Total products (tax excl.) : $9.98
Total products (tax incl.) : $10.81
Total (tax excl.) : $9.98
Total (tax incl.) : $10.81



I just don't see how it can be so difficult to get this correct when there is only ONE product in the cart.

I can understand if there are many items in the cart but not when there is only one and the price is 9.99000.
It should not round at all if there is only one item in the cart, for sure.

I also don't see how it can get two different totals with either superior or classical if there is only one item.

The "Total products (tax excl.)" should be the EXACT same as "Total (tax excl.)"

While inferior rounding produces the same values, it does NOT reflect the actual price of the product.

I see this as a BUG...

Link to comment
Share on other sites

it is a bug.

Personally not delved much into the actual code of pretashop.

But going by your initial testing my first assumption would be that the rounding of the variables are not standardized. i.e. looks like calculations and rounding from including tax price whereas elswhere in code it rounding from excluding tax

PS the below is all purely speculation as i have not looked closely at undelying code and only based on experience for normal reasons this happens.

eg looking at your prices and tax the tax rate is 8.25% so 9.99 +8.25% tax = 10.814175 so rounding depending where it down will be different when working out total excluding tax depending how it is done. eg working out price before tax will work out different from 10.814175 than would with 10.81. These should be done as too seperate calculations from the initial pre-tax prices but im assuming they are all worked out from the initial rounded up and down figure totals then rounding conducted again on them.


As said in previous post though finding the right balance so works out perfect 100% of the time is a developers nightmare are times

Link to comment
Share on other sites

It is my understanding that the Tools:displayPrice() function is what is being used. If they are feeding in an already rounded price to that, it will be rounded again.

Me thinks that they should always use raw amounts for calculations, including calculating the totals to 6 decimal places like it is set in the shop, and round only for display. It looks like they may be doing something different.

Link to comment
Share on other sites

  • 3 years later...
×
×
  • Create New...