Skip to content

Releases: kipcole9/money

Money version 5.0.0

21 Jan 06:12
Compare
Choose a tag to compare

Breaking changes

  • Elixir 1.10 introduces semantic sorting for stucts that depends on the availability of a compare/2 function that returns :lt, :eq or :gt. Therefore in this release of ex_money the functions compare/2 and compare!/2 are swapped with cmp/2 and cmp!/2 in order to conform with this expectation. Now compare/2 will return :eq, :lt or :gt. And cmp/2 return -1, 0 or 1.

  • Deprecate Money.reduce/1 in favour of Money.normalize/1 to be consistent with Decimal versions 1.9 and later.

It is believed and tested that Money version 5.0.0 is compatible with all versions of Decimal from 1.6 up to the as-yet-unreleased 2.0.

Support of Elixir 1.10 Enum sorting

From Elixir verison 1.10.0, several functions in the Enum module can use the Money.compare/2 function to simplify sorting. For example:

iex> list = [Money.new(:USD, 100), Money.new(:USD, 200)]
[#Money<:USD, 100>, #Money<:USD, 200>]
iex> Enum.sort list, Money
[#Money<:USD, 100>, #Money<:USD, 200>]
iex> Enum.sort list, {:asc, Money}
[#Money<:USD, 100>, #Money<:USD, 200>]
iex> Enum.sort list, {:desc, Money}
[#Money<:USD, 200>, #Money<:USD, 100>]

Note that Enum.sort/2 will sort money amounts even when the currencies are incompatible. In this case the order of the result is not predictable. It is the developers responsibility to filter the list to compatible currencies prior to sorting. This is a limitation of the Enum.sort/2 implementation.

Notes on Decimal version support

  • ex_money version 5.0.0 is compatible with Decimal versions from 1.6 onwards. In Decimal version 2.0 the same changes to compare/2 and cmp/2 will occur and in Decimal version 1.9, Decimal.cmp/2 is deprecated. ex_money version 5.0.0 detects these different versions of Decimal and therefore remains compatability with Decimal back to version 1.6.

Money version 4.4.2

02 Jan 09:06
Compare
Choose a tag to compare

Bug Fixes

  • Remove calls to Code.ensure_compiled?/1 since it is deprecated in Elixir 1.10. Use instead Cldr.Config.ensure_compiled?/1 which is added as a private API in Cldr version 2.12.0. This version of Cldr now becomes the minimum version required.

  • Remove spurious entries in .dialyzer_ignore_warnings - no entries are required and dialyzer is happy.

Money version 4.4.1

11 Nov 01:46
Compare
Choose a tag to compare

Bug Fixes

  • Fixes money parsing error. Thanks to @Doerge. Closes #112.

Money version 4.4.0

08 Nov 06:53
Compare
Choose a tag to compare

Breaking Change

  • Money.parse/2 until this release supported the :currency_filter option. It allowed for currencies to be filtered based upon their attributes (:all, :current, :historic, :tender, :annotated). When multiple attributes were passed in a list, a currency had to meet all of these attributes. From this release onwards, multiple attributes items are ored, not anded. It is expected this option is used extremely rarely and therefore of limited impact.

Enhancements

  • Money.parse/2 now includes the option :default_currency which allows for parsing a number only (without a currency code) and it will be tagged with the :default_currency.
  iex> Money.parse("100")
  {:error,
   {Money.Invalid,
    "A currency code, symbol or description must be specified but was not found in \"100\""}}
  iex> Money.parse("100", default_currency: :USD)
  #Money<:USD, 100>
  • Add :only and :except options to Money.parse/2 to specify which currency codes or currency attributes are permitted. :only and :except replace the option :currency_filter which is now deprecated. If provided, :currency_filter is interpreted as :only. An example:
  iex> Money.parse("100 usd", only: :current, except: :USD)
  {:error,
   {Money.UnknownCurrencyError,
    "The currency \"usd\" is unknown or not supported"}}
  • Money.parse/2 now supports negative money amounts.
  iex> Money.parse("chf -100")
  #Money<:CHF, -100>

  iex> Money.parse("(chf 100)")
  #Money<:CHF, -100>

Money version 4.3.0

08 Sep 16:24
Compare
Choose a tag to compare

Enhancements

  • Adds a Money backend in the same spirit as other libraries that leverge ex_cldr. Thanks to @LostKobrakai. Closes #108. All of the functions in the Money module may also be called on a backend module <backend>.Money.fun without having to specify a backend module since this is implicit.

Bug Fixes

  • Money.new!/3 replaces Money.new!/2 to accept options. Thanks to @LostKobrakai. Closes #109.

Money version 4.2.2

06 Sep 21:51
Compare
Choose a tag to compare

Bug Fixes

  • Use Keyword.get_lazy when the default is Cldr.default_backend/0 to avoid exceptions when no default backend is configured. Thanks to @LostKobrakai.

Money version 4.2.1

02 Sep 08:06
Compare
Choose a tag to compare

Bug Fixes

  • Fixes parsing of money amount that have a single digit amount. Closes #107. Thanks to @njwest

Money version 4.2.0

21 Aug 04:06
Compare
Choose a tag to compare

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 of ex_money or Cldr.default_locale/0. In either case an exeption will be raised if no default backend is configured.

Money version 4.1.0

12 Jul 22:22
Compare
Choose a tag to compare

Enhancements

  • Adds Money.abs/1. Thanks to @jeremyjh.

  • Improve @doc consistency using ## Arguments not ## Options.

Money version 4.0.0

07 Jul 23:32
Compare
Choose a tag to compare

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 to ex_money_sql (which in turn depends on ex_money).

  • Supports Elixir 1.6 and later only