Skip to content

Move withdrawn ISO 4217 codes out of currency_iso.json - #1239

Open
yu2971512385-ui wants to merge 1 commit into
RubyMoney:mainfrom
yu2971512385-ui:fix/withdrawn-iso-codes
Open

yu2971512385-ui wants to merge 1 commit into
RubyMoney:mainfrom
yu2971512385-ui:fix/withdrawn-iso-codes

Conversation

@yu2971512385-ui

Copy link
Copy Markdown

config/currency_iso.json holds eight codes that ISO 4217 has withdrawn, while config/currency_backwards_compatible.json exists for exactly that. Checked against ISO 4217 list three (the historical list, published 2026-01-01):

code withdrawn successor, already present
SKK 2009-01 Slovak Koruna EUR
ZMK 2012-12 Zambian Kwacha ZMW
BYR 2017-01 Belarusian Ruble BYN
STD 2017-12 São Tomé and Príncipe Dobra STN
CUC 2021-06 Cuban Convertible Peso CUP
SLL 2023-12 Sierra Leonean Leone SLE
ANG 2025-03 Netherlands Antillean Guilder XCG
BGN 2026-01 Bulgarian Lev EUR

BGN is this January's — Bulgaria adopted the euro.

The part that is visible

BYR also carries "priority": 50. Only seven currencies in the file have a priority below 100, and the other six are the majors, so a currency withdrawn in 2017 comes seventh in Money::Currency.all, ahead of every currency still in use:

before:  USD(1) EUR(2) GBP(3) AUD(4) CAD(5) JPY(6) BYR(50) SLL(100)
after:   USD(1) EUR(2) GBP(3) AUD(4) CAD(5) JPY(6) TWD(100) TTD(100)

Anything that builds a currency picker from .all has been offering the pre-2016 Belarusian ruble in seventh place. Every entry already in currency_backwards_compatible.json sits at 100, so this drops BYR to match them.

Nothing stops resolving

Loader.load_currencies merges all three files, so moving an entry between them changes no lookup. Verified on the merged table:

before.size == after.size        # 196
before.keys - after.keys         # []        nothing lost
before.keys.select { |k| before[k] != after[k] }
                                 # ["byr"]   priority 50 -> 100, the fix itself

Money::Currency.new(:skk), .find("ANG") and find_by_iso_numeric all behave as before. The one thing that does shift is the iteration order of the merged hash, and with it the order of equal-priority entries in .all — but .all uses sort_by(&:priority), which is not a stable sort, so that order was never defined to begin with.

Testing

Added one case to the existing .all block, which fails on master and passes here:

bundle exec rspec spec/money/currency_spec.rb
  with the spec added and the data untouched:  56 examples, 1 failure
  with the data corrected:                     56 examples, 0 failures

bundle exec rspec
  503 examples, 0 failures

CHANGELOG and AUTHORS updated per CONTRIBUTING.

I left currency_iso.json alone otherwise. It also lacks VED and XAD, which are current in list one, but it deliberately omits the funds codes (BOV, CHE, CHW, COU, MXV, USN, UYI, UYW) and the units of account XSU and XUA, so where that boundary sits is your call rather than a bug.

Disclosure: written with AI assistance (Claude). The withdrawal dates come from ISO 4217 list three via SIX Group, and every figure above is real output from this branch.

🤖 Generated with Claude Code

ANG, BGN, BYR, CUC, SKK, SLL, STD and ZMK were withdrawn from ISO 4217
between 2009 and this January, and the repository already keeps a file
for retired codes. BYR also carried a priority of 50, which put a
currency withdrawn in 2017 seventh in Money::Currency.all, ahead of
every currency still in use; the other retired entries all sit at 100.

The loader merges the three files, so every code resolves exactly as
before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sunny

sunny commented Nov 2, 2026

Copy link
Copy Markdown
Member

Hi there. You have included way too much code in this patch by adding the vendor folder 😱

image

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants