Skip to content

[Intl] Add methods to filter currencies more precisely #61431

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

Open
wants to merge 16 commits into
base: 7.4
Choose a base branch
from

Conversation

Crovitche-1623
Copy link

@Crovitche-1623 Crovitche-1623 commented Aug 15, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues Close #61365
License MIT

Description

In the ICU dataset, there are values that are no longer relevant / no longer used today (e.g. the BEF currency). This PR add a method that check the metadata in the ICU metadata to check if the currency is active in at least 1 country.

Limitations

  1. There are currencies that do not have legal tender and therefore no available date ranges. That can cause problem when we check if the currency is active (within the date range).
  2. If we have a case in the future where a currency is no longer valid for a given date range but becomes valid again in the future, this will not work with the current date check (parameter $active).

@carsonbot
Copy link

Hey!

To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done?

Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review.

Cheers!

Carsonbot

@Crovitche-1623 Crovitche-1623 changed the title [DRAFT] feat: Add Currencies::isActive() to ensure the currency is active in at least 1 country [Intl] Add Currencies::isActive() to ensure the currency is active in at least 1 country Aug 15, 2025
@Crovitche-1623 Crovitche-1623 marked this pull request as ready for review August 15, 2025 09:33
@carsonbot carsonbot added this to the 7.4 milestone Aug 15, 2025
@Crovitche-1623
Copy link
Author

I think it's pretty much ready for a first review @javiereguiluz.

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps an alternative API could be getCurrencyCodesForCountry(string $country, ?bool $active = null) + existsForCountry(string $country, ?bool $active = null)
?

@Crovitche-1623
Copy link
Author

perhaps an alternative API could be getCurrencyCodesForCountry(string $country, ?bool $active = null) + existsForCountry(string $country, ?bool $active = null)

?

I will add this ASAP 👍🏻

@Crovitche-1623
Copy link
Author

I added the requested methods + tender filter but I need to add fews tests to ensure all uses cases are covered. I also need to update the CHANGELOG. I'll continue this ASAP.

@Crovitche-1623 Crovitche-1623 changed the title [Intl] Add Currencies::isActive() to ensure the currency is active in at least 1 country [Intl] Add methods to filter currencies more precisely Aug 15, 2025
@Crovitche-1623
Copy link
Author

I’ve applied the requested changes, this should be ready for a second review.

Comment on lines +196 to +198
$regions = iterator_to_array($supplementalDataBundle['CurrencyMap']);

foreach ($regions as $regionId => $region) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just foreach ($supplementalDataBundle['CurrencyMap']?

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

Successfully merging this pull request may close these issues.

[Intl] Methods to check if a given currency is obsolete/active
3 participants