Releases: kipcole9/money
Money version 4.2.2
Bug Fixes
- Use
Keyword.get_lazy
when the default isCldr.default_backend/0
to avoid exceptions when no default backend is configured. Thanks to @LostKobrakai.
Money version 4.2.1
Money version 4.2.0
Bug Fixes
- Move the
Money.Migration
module to ex_money_sql where it belongs
Enhancements
Money.default_backend/0
will now either use the backend configured under the:default_cldr_backend
key ofex_money
orCldr.default_locale/0
. In either case an exeption will be raised if no default backend is configured.
Money version 4.1.0
Enhancements
-
Adds
Money.abs/1
. Thanks to @jeremyjh. -
Improve
@doc
consistency using## Arguments
not## Options
.
Money version 4.0.0
Breaking Changes
-
Functions related to the serialization of money types have been extracted to the library ex_money_sql. For applications using the dependency
ex_money
that do not require serialization no changes are required. For applications using serialization, the dependency should be changed toex_money_sql
(which in turn depends onex_money
). -
Supports Elixir 1.6 and later only
Money version 3.4.4
Enhancements
- Supports passing an
Cldr.Number.Formation.Options.t
as alternative to aKeyword.t
for options toMoney.to_string/2
. Performance is doubled when using pre-validated options which is useful if formatting is being executed in a tight loop.
An example of this usage is:
iex> money = Money.new(:USD, 100)
# Apply any options required as a keyword list
# Money will take care of managing the `:currency` option
iex> options = []
iex> {:ok, options} = Cldr.Number.Format.Options.validate_options(0, backend, options)
iex> Money.to_string(money, options)
The 0
in validate_options
is used to determine the sign of the amount because that can influence formatting - for example the accounting format often uses (1234)
as its format. If you know your amounts are always positive, just use 0
.
If the use case may have both positive and negative amounts, generate two option sets (one with the positive number and one with the negative). Then use the appropriate option set. For example:
iex> money = Money.new(:USD, 1234)
# Add options as required
# Money will take care of managing the `:currency` option
iex> options = []
iex> {:ok, positive_options} = Cldr.Number.Format.Options.validate_options(0, backend, options)
iex> {:ok, negative_options} = Cldr.Number.Format.Options.validate_options(-1, backend, options)
iex> if Money.cmp(money, Money.zero(:USD)) == :gt do
...> Money.to_string(money, positive_options)
...> else
...> Money.to_string(money, negative_options)
...> end
Money version 3.4.3
Bug Fixes
-
Ensure
Money.to_string!/2
properly raises -
Add specs for
Money.to_string/2
andMoney.to_string!/2
Thanks to @rodrigues for the report, tests and PR.
Money version 3.4.2
Bug Fixes
Money.put_fraction/2
now correctly allows setting the fraction to 0.
Enhancements
-
Money.round/2
allows setting:currency_digits
to an integer number of digits in addition to the options:iso
,:cash
and:accounting
. The default remains:iso
. -
Improves the documentation for
Money.to_string/2
.
Money version 3.4.1
Bug Fixes
- Fix
README.md
markdown formatting error. Thanks to @fireproofsocks for the report and @LostKobrakai for the fix. Closes #99.
Money version 3.4.0
Enhancements
- Updates to CLDR version 35.0.0 released on March 27th 2019 through
ex_cldr
version 2.6.0.