akeneo / pim-community-dev

[Community Development Repository] The open source Product Information Management (PIM)
http://www.akeneo.com
Other
954 stars 516 forks source link

Negative values are not "normalized" from the ui #5962

Closed mathewrapid closed 4 years ago

mathewrapid commented 7 years ago

I'm reporting a Bug

Exists in 1.6, tested even in 1.7

Use case:

As we can see the -4 and −4 are not the same.

The transformation happens in https://github.com/akeneo/pim-community-dev/blob/v1.7.0/src/Akeneo/Component/Localization/Localizer/NumberLocalizer.php#L45-L72

Why then is there not a "normalization" phase in the product update action in https://github.com/akeneo/pim-community-dev/blob/v1.7.0/src/Pim/Bundle/EnrichBundle/Controller/Rest/ProductController.php#L257-L298 ?

mathewrapid commented 7 years ago

Is there a reason to not utilize the $numberFormatter->parse($number, \NumberFormatter::TYPE_DOUBLE); in NumberLocalizer::delocalize?

mickaelandrieu commented 7 years ago

Hello @mathewrapid,

I could reproduce the issue, I agree this is probably not the expected behavior.

Can you contribute a pull request with your proposal? I think it's the right thing to do, but this need to be reviewed by a core team member.

Thanks for your help!

mickaelandrieu commented 7 years ago

Hello @mathewrapid,

I've added your issue to our board of "Wanna contribute". Feel free to contribute a patch, if you don't maybe someone from the community will take it.

Thanks for your help :)

ghost commented 7 years ago

Hi, this is not only on product value. The problem appear on the attribute too. If you try to edit an numeric attribute which allow negative value and got a negative value, the negative values are display with − and not a -

ghost commented 7 years ago

I tried to fix the problem with the solution given by @mathewrapid, but it's make some bord effect for decimal numbers :