openfoodnetwork icon indicating copy to clipboard operation
openfoodnetwork copied to clipboard

Avoid floating rounded errors when using imperial or metric system

Open jibees opened this issue 2 years ago • 1 comments

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 Capture d’écran 2022-08-01 à 16 17 50 Capture d’écran 2022-08-01 à 16 17 23

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

jibees avatar Aug 01 '22 14:08 jibees

Some problem in the dependencies.

I add issues with yarn.lock, I rebased onto master but then forgot to apply modifications!

jibees avatar Aug 11 '22 08:08 jibees

Thanks @jibees for this one as well!

Before this PR

All unit values are displayed properly in the product list: image

Editing the variant displays the incorrect numbers with many decimals: image

In the shopfront we can also see the incorrect numbers: image

After this PR

Refreshing the existing products

All unit values are displayed properly in the product list: image

Editing the variant now displays the correct numbers with no decimals: image

In the shopfront we can still see the incorrect numbers: image

Creating new products

All unit values are displayed properly in the product list: image

Editing the variant now displays the correct numbers with no decimals: image

In the shopfront we now see the correct numbers with no decimals: image

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:

drummer83 avatar Sep 08 '22 14:09 drummer83