Skip to content

Releases: kipcole9/money

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

Money version 3.4.4

03 Jun 03:43
Compare
Choose a tag to compare

Enhancements

  • Supports passing an Cldr.Number.Formation.Options.t as alternative to a Keyword.t for options to Money.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

02 Jun 15:35
Compare
Choose a tag to compare

Bug Fixes

  • Ensure Money.to_string!/2 properly raises

  • Add specs for Money.to_string/2 and Money.to_string!/2

Thanks to @rodrigues for the report, tests and PR.

Money version 3.4.2

16 Apr 03:31
Compare
Choose a tag to compare

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

05 Apr 16:26
Compare
Choose a tag to compare

Bug Fixes

Money version 3.4.0

28 Mar 12:46
Compare
Choose a tag to compare

Enhancements