checkHungarianBBAN function
Hungarian (HU) BBAN check
@ignore
Implementation
bool checkHungarianBBAN(String bban) {
const List<int> weights = <int>[9, 7, 3, 1, 9, 7, 3, 1, 9, 7, 3, 1, 9, 7, 3];
final int controlDigitBankBranch = int.parse(bban[7], radix: 10);
final String toCheckBankBranch = bban.substring(0, 7);
int sum = 0;
for (int index = 0; index < toCheckBankBranch.length; index++) {
sum += int.parse(toCheckBankBranch[index], radix: 10) * weights[index];
}
int remainder = sum % 10;
if (controlDigitBankBranch != (remainder == 0 ? 0 : 10 - remainder)) {
return false;
}
sum = 0;
if (bban.endsWith('00000000')) {
final String toCheckAccount = bban.substring(8, 15);
final int controlDigitAccount = int.parse(bban[15], radix: 10);
for (int index = 0; index < toCheckAccount.length; index++) {
sum += int.parse(toCheckAccount[index], radix: 10) * weights[index];
}
int remainder = sum % 10;
return controlDigitAccount == (remainder == 0 ? 0 : 10 - remainder);
} else {
final String toCheckAccount = bban.substring(8, 23);
final int controlDigitAccount = int.parse(bban[23], radix: 10);
for (int index = 0; index < toCheckAccount.length; index++) {
sum += int.parse(toCheckAccount[index], radix: 10) * weights[index];
}
int remainder = sum % 10;
return controlDigitAccount == (remainder == 0 ? 0 : 10 - remainder);
}
}