clojurewerkz / money

A Clojure library that deals with monetary values and currencies. Built on top of Joda Money.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with multiplication o money by decimal amount

The-Q opened this issue · comments

Hi, there. I've found strange behaviour with multiplication by decimal amount. For examlple the following code :

(ma/multiply (ma/amount-of mc/USD 45) 10.1)

results in

#<Money USD 450.00>

where are result as I think should be

#<Money USD 454.50>

Is there any bug in multiplication?

multiply is missing another arity that lets you specify rounding mode. Feel free to submit a pull request that adds it, it should be identical to divide.

In fact, the only multiplyBy version that accepts doubles [1] requires specifying a rounding mode. In your case, multiplier is implicitly coerced to a long.

  1. http://www.joda.org/joda-money/apidocs/org/joda/money/Money.html#multipliedBy(java.math.BigDecimal, java.math.RoundingMode)

Fixed in 1.4.0 which is already up on Clojars.

Thanks.