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

The countryMatches assertion is wrong when country code includes other countries/territories #137

Open
7hibault opened this issue Feb 20, 2025 · 0 comments

Comments

@7hibault
Copy link

7hibault commented Feb 20, 2025

Expected Behavior

It should be possible to generate a file with

  • IBAN FR3930003000306936293381A23 (randomly generated)
  • BIC AGRIMQMX (valid BIC from this list)

This should be valid, as specified in the IBAN registry, some country codes include other countries / territories

Current Behavior

The countryMatches assertion fails and displays the following error:

country mismatch in BIC/IBA

Possible Solution and Implementation

This assertion happens in two places

We could extend this assertion to check for country codes that may include other countries/territories

var includedTerritoryCodes = {
  'FI': ['AX'],
  'FR': [ 'GF', 'GP', 'MQ', 'RE', 'PF', 'TF', 'YT', 'NC', 'BL', 'MF', 'PM', 'WF'],
  'GB': ['IM', 'JE', 'GG']
}
var countryIncludesOtherTerritory = Object.keys(includedTerritoryCodes).includes(this[pullFrom + 'IBAN'].substr(0, 2))
countryMatches = countryMatches || countryIncludesOtherTerritory && includedTerritoryCodes[this[pullFrom + 'IBAN'].substr(0, 2)].includes(this[pullFrom + 'BIC'].substr(4, 2))

Maybe we could also refactor IBAN and BIC into their own variables to make the code more readable.

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