Skip to content

Conversation

qrz-io
Copy link
Contributor

@qrz-io qrz-io commented Feb 20, 2013

...ice.php

Recently had an issue where the price of a product had 3 decimal points on the DB, 10.245 for example, but showed the rounded to 2 decimals price (10.25) on the admin panel product edit page.

When hitting save for that product from the admin panel, it would save the escaped value with 2 decimal points, replacing 10.245 with 10.25, which is completely undesirable and results in all kind of funny prices after taxes are applied.

Possible fixes:
(1) Allow more decimal points. 4 seems reasonable, but the issue might persist.
(2) Simply return $value as it comes from the database, since the method already checks that is a numeric value.

Note: the other reason why the number_format was being done is to remove the thousand comma separator, but is_numeric('1,235') is false, so price data coming from the DB with comma thousand separators won't be valid anyway.

…/Price.php

Recently had an issue where the price of a product had 3 decimal points on the DB, 10.245 for example, but showed the rounded to 2 decimals price (10.25) on the admin panel product edit page.

When hitting save for that product from the admin panel, it would save the escaped value with 2 decimal points, replacing 10.245 with 10.25, which is completely undesirable and results in all kind of funny prices after taxes are applied.

Possible fixes: 
(1) Allow more decimal points. 4 seems reasonable, but the issue might persist.
(2) Simply return $value as it comes from the database, since the method already checks that is a numeric value.

Note: the other reason why the number_format was being done is to remove the thousand comma separator, but is_numeric(1,230) is false, so price data coming from the DB with comma thousand separators won't be valid anyway.
@magento-team
Copy link
Contributor

Hello. In which currency/market you saw prices with 3 or 4 decimal places?

@witrin
Copy link

witrin commented Feb 21, 2013

Hi,

I had once a customer, who sold balloons. The unit prices were indeed with four decimal places. So at that time, I had to make sure that four decimal places could be entered through the backend.

Best regards,
Artus

@qrz-io
Copy link
Contributor Author

qrz-io commented Feb 21, 2013

The issue comes because prices for products are managed from a different system, and imported automatically into Magento with several decimal places.

For example, a price might be imported as 17.355, which on market with 21% tax, like the Netherlands, should result in 17.355_1.21 = 20.99955, rounded up to _21.00* on the product view page.
If the product is saved from the admin panel, the DB gets the rounded value 17.36, which would show up on the product view page as 17.36_1.21 =21.0056, rounded up to _21.01*

@magento-team
Copy link
Contributor

Hello. We will look into it but the solution requires reviewing all of the pricing logic. This is on our roadmap however no in the short term.

@choukalos
Copy link

Hi Artus - what country is the ballon example from? Did that merchant show customer prices with 4 decimal places?
Hi Christian - Is it common to use item level tax calculation with 3 digits in the Netherlands for B2C (business 2 consumer) or is this more of a B2B (business 2 business). Are the 3 decimal places prices shown to customers? Would you be free for a skype chat to go in more detail?

I'm the Magento product manager responsible for the tax module and would welcome any questions, comments, suggestions or help to improve our tax engine.

Regards,
Chuck

@qrz-io
Copy link
Contributor Author

qrz-io commented Feb 21, 2013

Hi Chuck,

I only used the Netherlands as an example. In the study case I described, the price is shown to the customer with 2 decimal points, but a rather minimal change in the amount saved in the DB, the price shown changes from 21.00 to 21.01, which is of course very undesirable.

The method in which I proposed the fix only seems to be used for the shown value in the admin panel, for styling purposes (correct me if I'm wrong) since I don't see a reason why the price of a product should be forcefully limited to 2 decimal points on the admin panel, specially when we are talking about prices before taxes.

(Please note that this issue means Magento is applying a round to 2 decimal values, and it's effectively and unintentionally enforcing the change on the DB without notification to the user.)

@witrin
Copy link

witrin commented Feb 21, 2013

Hi Chuck,

the example comes from Germany. The merchant showed their customers prices with two decimal places and have sold per hundred. But calculated was internal with four decimal places on a single balloon, the alternative was, to change the units from one to hundred. But there were reasons why we couldn't do this. I guess this had something to do with configurable products (balloon prints) and their price calculation.

Best Regards,
Artus

@choukalos
Copy link

I thought it was desirable for European merchant's to load their catalog prices including tax (I believe in all the countries mentioned prices are shown including tax)? Doesn't this most likely mean they had to do a fair bit of manual effort to load their prices without tax?

Allowing pricing to be loaded with more than 2 digits of precision, but only showing a customer 2 digits of precision will create cart abandonment scenarios with out some further logic/etc.

Example case (for abandonment): Buy 37 balloons
1 balloon on catalog page show a price of 21.00 inc tax
Cart:
ballon 37 qty 776.98 inc tax [ 17.355 * 1.21 * 37 = 776.98335 round to 776.98 ]

Customer expects 21.00 * 37 should be 777.00 - off by 0.02

-Chuck

@qrz-io
Copy link
Contributor Author

qrz-io commented Feb 23, 2013

Hi Chuck,

One can argue that happens with two decimal points as well:
41.32 * 1.21 = 49.9972, round to 50.00
31.32 * 1.21 * 2 = 99.9944, round to 99.99, of by 0.01

Mathematically, we can only get more precision by allowing more decimal points to be used. For example, if we allow the use of 4 decimal points.
41.3223 * 1.21 = 49.9999, round to 50.00
41.3223 * 1.21 *2 = 100.0000, with no precision error

and with the 37 balloons example:
17.3554 * 1.21 = 21.0000
17.3554 * 1.21 * 37 = 777.0013, round to 777.00

Since more decimal points allow much better precision in prices, and more flexibility in the use of the price calculation process, I don't see a reason to force the use of 2 decimal points. Specially when it's not really forced in the database or Magento itself, since it will allow users to save the price with as many decimal points as wanted, but will escape the value when showing it on the admin panel, and round it to 2 decimal points.

@witrin
Copy link

witrin commented Feb 23, 2013

Hi Chuck,

I thought it was desirable for European merchant's to load their catalog prices including tax [...]

Yes, for Germany (B2C) this is typically, and for the grand total the customer expects net and gross prices as well as the taxes separately.

Doesn't this most likely mean they had to do a fair bit of manual effort to load their prices without tax?

This is hard to be generalized. It depends on the merchant or producer, but mostly they use gross prices.

1 balloon on catalog page show a price of 21.00 inc tax [..]

Well here is the funny thing in this case, the price per ballon were e.g. 0.0604 €. The selling units were mostly 100 ballons, but if we had used this as a products base price (6.04 €), it had made the whole catalog more difficult to handle.

Best regards,
Artus

@verklov
Copy link
Contributor

verklov commented Dec 1, 2013

Hello cdquirozc,
Unfortunately we cannot accept your pull request. The proposed fix doesn't solve the problem described. It only reveals 4 decimal digits of price on the simple product page, but in all calculations rounded to 2 digits values are used.
We have to deeper analyze changes needed to resolve the issue in a correct way. We will create an internal story and place it into the product backlog to have this resolved according to the priorities of product development.

@verklov verklov closed this Dec 1, 2013
magento-team pushed a commit that referenced this pull request Dec 10, 2015
magento-engcom-team added a commit that referenced this pull request Nov 19, 2018
 - Merge Pull Request magento/graphql-ce#234 from magento/graphql-ce:graphql-189
 - Merged commits:
   1. a30654f
   2. 7664d93
   3. ac93407
   4. 645cdd2
   5. a54fed5
   6. 7f41544
magento-engcom-team pushed a commit that referenced this pull request Mar 27, 2020
MQE-1057: Update metadata filenames convention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants