RubyMoney / money

A Ruby Library for dealing with money and currency conversion.
http://rubymoney.github.io/money
MIT License
2.73k stars 623 forks source link

Invalid ISO code USDC #1084

Closed bagp1 closed 6 months ago

bagp1 commented 6 months ago

I was just bumping this gem in my project with a minor version update and the test suite fell over. It turns out the issue is that we load every "ISO" currency codes to our 3 characters currency column in our DB. A currency column should be 3 digits, because an iso currency code can only be 3 digits.

However it turns out currency_non_iso.json now contains USDC. In my opinion this goes beyond the other entries which may be considered just codes that happen to not have been registered yet, and into a "code" that doesn't fit the ISO 4217 format this entire gem is built around. I think that: 1) USDC should be removed as it is not valid to the ISO format. 2) Non ISO currencies should be opt in; with something in the initializer required and/or a separate function to return ISO + non ISO currencies.

I tried to fix this issue by unregistering all currencies where iso? is false, but I found that there is a legacy version of JPY that is missing the numeric ISO (this is another data error), and when you try to unregister the iso code JPY you lose both the ISO and non ISO version. I would like to know what the intended way to get a list containing only valid ISO currencies is.

it's very surprising for the Gem that returns ISO currencies with ISO codes to be returning something that couldn't possibly be an ISO code so USDC is against the spirit of Ruby. Removing it is important because it's a breaking change in a minor version release.

semmons99 commented 6 months ago

welcome a PR to discuss/merge this.