Closed breakline87 closed 3 years ago
Yeap, I think, you are right.
Looking into the structure for HU, we'll find the following definition:
structures.put(CountryCode.HU,
new BbanStructure(
BbanStructureEntry.bankCode(3, 'n'),
BbanStructureEntry.branchCode(4, 'n'),
BbanStructureEntry.accountNumber(16, 'n'),
BbanStructureEntry.nationalCheckDigit(1, 'n')));
I think, the national check digit should be located before the account number.
I have updated my clone and published a new SNAPSHOT.
@breakline87 Would be nice, if you could test the fix. To use the lib, please add the following dependency:
<dependency>
<groupId>com.github.nalukit</groupId>
<artifactId>iban4g</artifactId>
<version>HEAD-SNAPSHOT</version>
</dependency>
Thanks
Hey, so I also did a hotfix to the jar itself, so basically had to move the national check digit forward, that worked.
Correct, that was the problem.
I did the fix and will release a new version of iban4g (2.0.1) at the weekend.
Thank you, very nice, I'm gonna update to yours. I'll close this.
Done ... should land in Maven Central in a few hours ...
I'm trying with Hungarian bank accounts. This is a Hungarian bank account format:
11600006-00000000-34953226
This is how it looks:
116 is the bank code 0000 is the branch code 6 is the national digit 0000000034953226 is the account number (16 long)
According to the converter here: https://www.iban.com/calculate-iban
This is the IBAN number for that account: HU74116000060000000034953226
So putting this into code:
Iban iban = Iban.valueOf("HU74116000060000000034953226"); Iban.Builder builder = new Iban.Builder(); System.out.println(iban.getNationalCheckDigit()); //gives 6, correct builder.nationalCheckDigit(iban.getNationalCheckDigit()); System.out.println(iban.getCountryCode()); //gives HU, correct builder.countryCode(iban.getCountryCode()); System.out.println(iban.getAccountNumber()); //gives 6000000003495322, incorrect builder.accountNumber(iban.getAccountNumber()); System.out.println(iban.getBankCode()); builder.bankCode(iban.getBankCode()); //gives 116, correct System.out.println(iban.getBranchCode()); builder.branchCode(iban.getBranchCode()); //gives 0000, correct Iban iban2 = builder.build(true); System.out.println(iban2.toString()); //gives HU74116000060000000034953226, correct
So this gives me the same IBAN:
Iban iban = new Iban.Builder() .bankCode("116") .branchCode("0000") .nationalCheckDigit("6") .accountNumber("6000000003495322") .countryCode(CountryCode.HU) .build(true); System.out.println("IBAN: "+iban.toString());
However, with the correct account number:
Iban iban = new Iban.Builder() .bankCode("116") .branchCode("0000") .nationalCheckDigit("6") .accountNumber("0000000034953226") .countryCode(CountryCode.HU) .build(true); System.out.println("IBAN: "+iban.toString());
I get a totally different IBAN number: HU36116000000000000349532266
This is presented as "valid", but this is an incorrect number.
Looks like the numbers inside the account number are shifted in some way?