Releases: kipcole9/money
Money version 2.0.2
Bug Fixes
Money.Sigil
was callingString.to_existing_atom/1
directly rather thanCldr.validate_currency/1
. Since currency codes are only loaded and therefore the atoms materialized whenCldr
is loaded this created a situation whereby a valid currency code may raise anagument error
.Money.Sigil
now correctly callsCldr.validate_currency/1
which ensures the currency atoms are loaded before validation. Closes #46.
Money version 2.0.1
Bug Fixes
Phoenix.HTML.Safe
protocol implementation correctly returns a formatted string, not an{:ok, string}
tuple. Closes #45.
Money version 2.0.0
Breaking Changes
-
The function
Money.new/2
no longer supports afloat
amount. The new functionMoney.from_float/2
is introduced. The factory functionMoney.new/2
previously supported afloat
amount as a parameter. There are many well-documented issues with float. Although a float with a precision of no more than 15 digits will convert (and round-trip) without loss of precision there is a real possibility that the upstream calculations that produced the float will have introduced rounding or precision errors. CallingMoney.new/2
with a float amount will return an error tuple:{:error, { Money.InvalidAmountError, "Float amounts are not supported in new/2 due to potenial rounding " <> "and precision issues. If absolutely required, use Money.from_float/2"}}
-
Remove support for
Money
tuples inMoney.Ecto.Composite.Type
andMoney.Ecto.Map.Type
. Previously there has been support for dumpingMoney
in a tuple format. This support has now been removed and allMoney
operations should be based on theMoney.t
struct.
Enhancements
-
Add
Money.from_float/2
to create aMoney
struct from a float and a currency code. This function is named to make it clear that we risk losing precision due to upstream rounding errors. According to the standard and experimentation, floats of up to 15 digits of precision will round trip without error. Thereforefrom_float/2
will check the precision of the number and return an error if the precision is greater than 15 since the correctness of the number cannot be verified beyond that. -
Add
Money.from_float!/2
which is likefrom_float/2
but raises on error -
Formatted the text the with the Elixir 1.6 code formatter
Money version 1.1.3
Enhancements
-
Improves the documentation that describes how to configure locales and how that relates to
Money.to_string/2
-
Add
Money.from_integer/2
as the effective inverse ofMoney.to_integer_exp/1
. This function converts an integer form of money (inluding any decimal digits) into aMoney
struct. This is useful for services that return money in an integer format.
iex> Money.from_integer(20000, :USD)
#Money<:USD, 200.00>
iex> Money.from_integer(200, :JPY)
#Money<:JPY, 200>
Money version 1.1.2
Bug fixes
- Fixes a bug in
Money.to_integer_exp/1
which was not correctly adjusting the exponent for money amounts that had no decimal places, or the number of decimal places was less than that required for the currency, Additional tests have been added.
Money version 1.1.1
Enhancements
- Add
Money.to_integer_exp
to convert theMoney
into a tuple of the currency_code, integer (coefficient), exponent and remainder. This is useful for services that require money to be presented in an integer format.
iex> m = Money.new(:USD, 200.012356)
#Money<:USD, 200.012356>
iex> Money.to_integer_exp(m)
{:USD, 20001, -2, Money.new(:USD, 0.002356)}
- Format the code using the Elixir code formatter
Money version 1.1.0
Money v1.1.0 released on December 22nd 2017
For older changelogs please consult the release tag on GitHub
Changes & Deprecations
-
The configuration option
:exchange_rate_service
is deprecated in favour of:auto_start_exchange_rate_service
to better reflect the intent of the option. The keyword:exchange_rate_service
will continue to be supported untilMoney
version 2.0. -
The configuration option
:delay_before_first_retrieval
is deprecated and is removed from the configuration struct. Since the option has had no effect since version 0.9 its removal should have no impact on existing code. -
Added Falsehoods programmers believe about prices topics which give a good summary of the challenges of managing money in an application and how
Money
manages each of them.
Money version 1.0 release
Money release candidate 1.0
Money version v1.0.0-rc.0 released on November 19th, 2017.
This version signals API stability and the first release candidate.
Enhancements
- Updated ex_cldr to version 1.0.0-rc.0