-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
[14.0][FIX] delivery_schenker: round up package volume + weight #678
Conversation
36dcaa4
to
3fbd67b
Compare
3fbd67b
to
3b5226c
Compare
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.
Minor remarks
The Schenker API requires a volume to be non-zero, but also forces 2 decimal places. The 0.01 minimum was removed for avoiding fake volumes when incorrectly configured, but we must still round up cases where the volume is non-zero but rounds to 0.00. It is also logical to give an overestimate on the volume to the carrier, rather than an underestimate. round -> repr -> float to avoid Python floating decimals that error when validating with the Schema. float_round(2.086, precision_digits=2) = 2.0100000000000002 float_repr(float_round(2.086, precision_digits=2), 2) = '2.01' (string) float(float_repr(float_round(2.086, precision_digits=2), 2)) = 2.01
3b5226c
to
a516a34
Compare
@jbaudoux can you review and merge this one? |
round -> repr -> float to avoid extra decimals that error with the Schema. | ||
float_round(2.086, precision_digits=2) = 2.0100000000000002 | ||
""" | ||
return float( |
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.
Why reconvert back to float? You will get back extra decimals:
print('{0:.16f}'.format(float("2.09")))
2.0899999999999999
SOAP is transmitting in XML, so converting it all to text, so once you have the representation with 2 decimals, you better send that, you don't need a real float in your dict.
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.
I think this was just to maintain the same type as before, but I see what you mean with it being pointless
The schenker api requires 2 decimal points. | ||
Round up to avoid 0 if <0.005. | ||
round -> repr -> float to avoid extra decimals that error with the Schema. | ||
float_round(2.086, precision_digits=2) = 2.0100000000000002 |
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.
Your example doesn't look right
float_round(2.086, precision_digits=2) = 2.0100000000000002 | |
float_round(2.086, precision_digits=2) = 2.0899999999999999 |
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.
round -> repr -> float to avoid extra decimals that error with the Schema. | ||
float_round(2.086, precision_digits=2) = 2.0100000000000002 |
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.
round -> repr -> float to avoid extra decimals that error with the Schema. | |
float_round(2.086, precision_digits=2) = 2.0100000000000002 | |
Returns the string representation with the given precision |
@jbaudoux we can reopen this of course. |
@hildickethan-S73 can we close this PR in favor of #710 as it solves it properly ? |
If we can merge it yes, I need the change suggested in #710 (comment) though since it was in this PR |
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
closed in favor of #710 |
float(float_repr())
to thefloat_round
to avoid trailing decimals that can happen sometimes, in my case it was rounding 2.0086 to 2.01 would result in 2.0100000000000002 which errored