arturmkrtchyan / iban4j

A Java library for generation and validation of the International Bank Account Numbers (IBAN ISO_13616) and Business Identifier Codes (BIC ISO_9362).
http://iban4j.org
Apache License 2.0
271 stars 124 forks source link

CountryCode.Ru #86

Closed kamyshev1993-admin closed 8 months ago

kamyshev1993-admin commented 2 years ago

Hello. I have some problems with generate ru iban.

Iban.random(CountryCode.RU);

org.iban4j.UnsupportedCountryException: Country code is not supported.

    at org.iban4j.Iban$Builder.fillMissingFieldsRandomly(Iban.java:464)
    at org.iban4j.Iban$Builder.buildRandom(Iban.java:385)
    at org.iban4j.Iban.random(Iban.java:201)
    at TestTestasd.testMethod(TestTestasd.java:47)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
    at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:584)
    at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172)
    at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
    at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804)
    at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.testng.TestRunner.privateRun(TestRunner.java:770)
    at org.testng.TestRunner.run(TestRunner.java:591)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
    at org.testng.SuiteRunner.run(SuiteRunner.java:304)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
    at org.testng.TestNG.runSuites(TestNG.java:1032)
    at org.testng.TestNG.run(TestNG.java:1000)
    at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
    at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)

Could you add it in structures EnumMap please?)

kamyshev1993-admin commented 2 years ago

ContryCode doesnt have RUS value, just RU. RU("Russian Federation", "RUS"), it is from CountryCode enum.

FrankHossfeld commented 2 years ago

Oh Yes, I see, It's missing in BbanStructure.

FrankHossfeld commented 2 years ago

I think, it is because Russia is not in the list of countries using the IBAN standard.

See: https://bank-code.net/iban/country-list?__cf_chl_captcha_tk__=pmd_m0hQcnz.9rcCcCXAIz3L5.R6VMXd4kEQL2eNg.ECVBQ-1632218069-0-gqNtZGzNAvujcnBszQil

kamyshev1993-admin commented 2 years ago

Oh yes, i see. Thank you for help)

tdltdl commented 1 year ago

RU has been added to the IBAN structure - see https://www.swift.com/standards/data-standards/iban-international-bank-account-number An option could be to generate the supported countries from the SWIFT source as it is authoritative. That would also solve issues like all supported territories and the info if they are part of the SEPA area. We even have samples to generate the unit tests. What is missing though is the check digit into the BBAN (that should be stored separately) To support new countries we would just need to update the SWIFT file and regenerate - other option is to parse the file at startup, so that would allow easier maintenance and flexibility if some wants to update the structure (either because new release of the library is lagging behind or to add "experimental countries" as per https://www.iban.com/structure or the bottom of the wikipedia page: https://en.wikipedia.org/wiki/International_Bank_Account_Number ).