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
Double to string for #44 #45
Conversation
Job #45 is now in scope, role is |
This pull request #45 is assigned to @g4s8/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @amihaiemil/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewer; there will be no monetary reward for this job |
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.
@ammaratef45 please see few comments
@@ -113,7 +114,7 @@ public double balance() throws IOException{ | |||
@Override | |||
public void pay( | |||
final String keygap, final String user, | |||
final double amount, final String details | |||
final String amount, final String details |
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.
@ammaratef45 this change will affect JSON payload format, type amount
changed from JSON-number
to JSON-string
:
before:
{
"amount": 1234.56
}
after:
{
"amount": "1234.56"
}
I'm not sure here (because I didn't find API docs for JSON payload), but most probably API won't accept such format.
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.
@g4s8 reverting it makes the issue meaningless, what do you think? we may need to rediscuss the issue, right?
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.
@ammaratef45 you can use json.add("amount", new BigDecimal(amount))
- that code adds amount as json number, but with arbitrary precision
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.
@g4s8 The problem is that this change meant to be used for avoiding any casting or precision problems and let the higher layers handle 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.
@ammaratef45 but BigDecimal
doesn't limit the precision, so I think it's safe to use here. In any case we should conform to wts API protocol, so if you have any doubts you can submit a ticket to wts repo, e.g. to expand documentation for JSON apis.
// cc @amihaiemil
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.
@ammaratef45 , @g4s8 , @amihaiemil , the following conversion is performed in wts.rb
here:
amount = Zold::Amount.new(zld: params[:amount].to_f)
I am not a Ruby expert but my guess, which is based on the documentation:
"123.45e1".to_f #=> 1234.5
"45.67 degrees".to_f #=> 45.67
"thx1138".to_f #=> 0.0
is that
"amount": "1234.56"
would be interpretted as 1234.56
(Float).
Hope, that would help us out here. By the way, there has been opened a related to accurate decimal operations issue #718 in Zold project.
@g4s8 I've merged the master and the irrelevant changes went away |
@ammaratef45 thanks |
@rultor merge |
@g4s8 Thanks for your request. @amihaiemil Please confirm this. |
@rultor merge it |
@amihaiemil OK, I'll try to merge now. You can check the progress of the merge here |
@amihaiemil Done! FYI, the full log is here (took me 2min) |
Job was finished in 24 hours, bonus for fast delivery is possible (see §36) |
The job #45 is now out of scope |
Payment to |
PR for #44
Changed double to string when referring to balance.