kipcole9 / money

Elixir implementation of Money with Currency
https://hex.pm/packages/ex_money
Other
572 stars 48 forks source link

Error: you attempted to apply a function named :symbol_count on 1 #162

Closed frahugo closed 10 months ago

frahugo commented 10 months ago

Hi Kip,

We are migrating our app to the latest version of ex_money and related dependencies:

  cldr_utils 2.17.2 => 2.24.2
  ex_cldr 2.32.1 => 2.37.5
  ex_cldr_currencies 2.14.1 => 2.15.1
  ex_cldr_numbers 2.27.2 => 2.32.3
  ex_money 5.12.0 => 5.15.3
  ex_money_sql 1.7.1 => 1.10.2

In version 5.12.0 of ex_money, we were able to pass a custom format to Money.to_string():

> money = Money.new!("1234.567", :CAD)
Money.new(:CAD, "1234.567")
> Money.to_string(money, format: "#,##0.###;-#,##0.###", locale: :en)
{:ok, "1,234.57"}

But in the latest version (5.15.3), we get this error:

> money = Money.new!("1234.567", :CAD)
Money.new(:CAD, "1234.567")
> Money.to_string(money, format: "#,##0.###;-#,##0.###", locale: :en)

** (ArgumentError) you attempted to apply a function named :symbol_count on 1. If you are using Kernel.apply/3, make sure the module is an atom. If you are using the dot syntax, such as map.field or module.function(), make sure the left side of the dot is an atom or a map
    :erlang.apply(1, :symbol_count, [])
    (ex_cldr_numbers 2.32.3) lib/cldr/number/format/options.ex:757: Cldr.Number.Format.Options.expand_currency_symbol/2
    (ex_cldr_numbers 2.32.3) lib/cldr/number/format/options.ex:131: Cldr.Number.Format.Options.validate_options/3
    (ex_cldr_numbers 2.32.3) lib/cldr/number.ex:442: Cldr.Number.to_string/3

This is our Cldr module:

defmodule MyApp.Cldr do
  @moduledoc false

  use Cldr,
    locales: ["en", "fr"],
    default_locale: "en",
    providers: [Cldr.Number]
end
kipcole9 commented 10 months ago

Fixed in ex_cldr_numbers version 2.32.4 with the following changelog entry. Thank you very much for report and sorry for the regression.

Bug Fixes

frahugo commented 9 months ago

@kipcole9 Thank you so much! solved our issue.