-
-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Don't calculate 100g nutriment if serving_quantity <=5 and value = '0', fixes #5848 #8403
Conversation
lib/ProductOpener/Numbers.pm
Outdated
@@ -130,7 +130,12 @@ sub convert_string_to_number ($value) { | |||
} | |||
# Remove remaining commas that can be used as separators | |||
$value =~ s/,//g; | |||
$value += 0; | |||
|
|||
# If number has been recorded as 0.0 without decimals then want to preserve this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today we don't have a way to store "4.0" or "0.0", they are converted to 4 and 0. The API expects numbers for both reading and writing (even though we do support strings for writing).
Do you anticipate [problem,s with what I am doing here then? |
Codecov Report
@@ Coverage Diff @@
## main #8403 +/- ##
=======================================
Coverage 48.47% 48.47%
=======================================
Files 114 114
Lines 21277 21286 +9
Branches 4770 4772 +2
=======================================
+ Hits 10314 10319 +5
- Misses 9679 9682 +3
- Partials 1284 1285 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
The number of digits might imply an accuracy of the value. So 0.5 implies an error of 0.05. And 0.00 an error of 0.005. A kind of implied accuracy. |
I tried to run it and edit products, but somehow "0.0" is not kept for me. I probably made a mistake somewhere, but I haven't found it yet. I don't think we should have a field that is always of type number, unless it's "0.0". I think it would be very worthwhile to find a way to keep the extra 0s, but it should be in all numbers (e.g. "4.00"). The function convert_string_to_number() is intended to return a number type, it's used in other functions, so we should be careful if we change its behaviour (probably a new function would be better). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you!
The PR is still marked as "draft", can we merge it?
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
What
Screenshot
Related issue(s) and discussion