js-money
js-money copied to clipboard
Documentation fails to mention that unit is sometimes cents
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
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 ;)