openfoodnetwork
openfoodnetwork copied to clipboard
Avoid floating rounded errors when using imperial or metric system
What? Why?
Closes #9493
What should we test?
In imperial system
- create or edit a product with weight in oz
- Enter 12 (or 24)
- Save
- See that the weight is well saved with 12 (or 24) and not something with rounded error
In metric system
Create a new product with 700 as value and mL
as unit_value via /admin/products/new
. See that it is correctly rounded right after the creation, when redirected to /admin/products
list.
Release notes
Changelog Category: User facing changes
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates
Some problem in the dependencies.
I add issues with yarn.lock
, I rebased onto master but then forgot to apply modifications!
Thanks @jibees for this one as well!
Before this PR
All unit values are displayed properly in the product list:
Editing the variant displays the incorrect numbers with many decimals:
In the shopfront we can also see the incorrect numbers:
After this PR
Refreshing the existing products
All unit values are displayed properly in the product list:
Editing the variant now displays the correct numbers with no decimals:
In the shopfront we can still see the incorrect numbers:
Creating new products
All unit values are displayed properly in the product list:
Editing the variant now displays the correct numbers with no decimals:
In the shopfront we now see the correct numbers with no decimals:
So, existing products will still show the strange numbers with many decimals in the shopfront. Not sure if we can do something about that. But we have great improvement for new products and on the product variant page.
This is ready to go! :tada: