js-money icon indicating copy to clipboard operation
js-money copied to clipboard

Documentation fails to mention that unit is sometimes cents

Open cbrunnkvist opened this issue 8 years ago • 1 comments

I can see the need to internally store the amount in a different format than a floating point Number, but I think it would make total sense to hide that implementation detail from the rest outside world. Otherwise, you easily end up with situations where suddenly, $100 has grown into $10000 for no apparent reason, aside from the joy it might bring to your accounting department. :)

Look at these examples:

> (new Money(1, Money.USD)).compare( new Money(1, Money.USD) )
0 // true
> Money.fromDecimal(1.0, Money.USD).compare( new Money(1, Money.USD) )
1 // uh oh

cbrunnkvist avatar Jun 14 '16 15:06 cbrunnkvist

I think this is clear from the documentation how various construction methods work. If you feel it's confusing feel free to address that with a PR ;)

davidkalosi avatar Sep 02 '16 10:09 davidkalosi