Closed joiggama closed 9 years ago
What do you think about introducing a Money abstraction as in https://github.com/RubyMoney/money ?
@chischaschos we know we need one so if they do we should share thoughts because I've compiled a big list on the challenges. It depends on how deep they need to go :)
@chischaschos @jpfuentes2 I've already ported some of the very basic functionality, joiggama/money
It just deals with representation, so IT DOES NOT:
Yeah, the big problem with your money
is that it uses float
:
The initial concerns that we have about money are:
- http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
- https://groups.google.com/forum/#!topic/golang-nuts/q-vQS9cb9uI
- http://stackoverflow.com/questions/19238175/what-is-the-best-way-to-convert-a-currency-from-float-to-integer-in-go
- Let's use https://golang.org/pkg/math/big/ ?
I see, then we also have the problem from the spree database, right? I understand they use floats as well, we have all of our domain entities using floats from the db.
Is that an actual problem if we don't do any of the previously mentioned features?. As of now that library just handles the string representation, and don't intend to add any floating point arithmetic.
No, I think you're right that it's not a problem for gopher-spree-api but FoxComm couldn't re-use it :sob:. No worries, may be fork off your base and change to our needs. Ignore our static on this issue :)
Alright, I thought I might be missing something. I was aware that implementing something like arithmetics for currency would not be an easy thing. Thanks.
For now, we'll be using default spree currency read from spree config.
Right now:
@crowdint/gopher-spree-api We should remove the hardcoded currency, I wonder... how can we achieve this?