Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate currency entry with the same ISO code #227

Open
ttjiaa opened this issue Feb 19, 2021 · 0 comments
Open

Duplicate currency entry with the same ISO code #227

ttjiaa opened this issue Feb 19, 2021 · 0 comments

Comments

@ttjiaa
Copy link

ttjiaa commented Feb 19, 2021

A recent graphql gem bump PR in Billing which introduced additional checks to ensured a field isn't defined more than once revealed an issue with Money::Currency.currencies as there is a pair of currency entries with the same ISO code.

The error is raised on https://github.com/Shopify/billing/blob/dependabot/bundler/graphql-1.12.4/app/graphql/types/currency_code.rb#L8, when the iso_code is used to create the fields. There are 2 that are the same with GHS, which results in the error ArgumentError: GHS is already defined for CurrencyCode, please remove one of the definitions.:

[19] pry(main)> (::Money::Currency.currencies.values.map{|x| x["iso_code"]}).count
=> 190
[20] pry(main)> (::Money::Currency.currencies.values.map{|x| x["iso_code"]}).uniq.count
=> 189
{
   "priority":100,
   "iso_code":"GHS",
   "name":"Ghanaian Cedi",
   "symbol":"₵",
   "disambiguate_symbol":"GH₵",
   "alternate_symbols":[
      "GH₵"
   ],
   "subunit":"Pesewa",
   "subunit_to_unit":100,
   "symbol_first":true,
   "html_entity":"₵",
   "decimal_mark":".",
   "thousands_separator":",",
   "iso_numeric":"288",
   "smallest_denomination":1
}
{
   "priority":100,
   "iso_code":"GHS",
   "name":"Ghanaian Cedi",
   "symbol":"₵",
   "alternate_symbols":[
      "GH¢",
      "GH₵"
   ],
   "subunit":"Pesewa",
   "subunit_to_unit":100,
   "symbol_first":true,
   "html_entity":"₵",
   "decimal_mark":".",
   "thousands_separator":",",
   "iso_numeric":"936",
   "smallest_denomination":1
}

Based on https://en.wikipedia.org/wiki/ISO_4217#Numeric_codes, it looks like the "iso_numeric":"288" one is historic while "iso_numeric":"936" is current.

I'm unsure how long this has been going on. The relevant ymls haven't been recently changed and they seem to look correct: 288, 936.

Is this indeed an issue? Should we make sure that Money::Currency.currencies doesn't return two currency entries for GHS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant