Skip to content

Duplicate currency entry with the same ISO code  #227

Description

@ttjiaa

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions