nationalIT function
Implementation
String nationalIT(String bban, BbanStructure structure) {
const List<int> even = [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
];
const List<int> odd = [
1,
0,
5,
7,
9,
13,
15,
17,
19,
21,
2,
4,
18,
20,
11,
3,
6,
8,
12,
14,
16,
10,
22,
25,
24,
23
];
final int V0 = "0".codeUnitAt(0);
final int V9 = "9".codeUnitAt(0);
final int VA = "A".codeUnitAt(0);
final List<int> listValues = [
PartType.BANK_CODE,
PartType.BRANCH_CODE,
PartType.ACCOUNT_NUMBER
]
.map((p) => structure.extractValueMust(bban, p))
.join("")
.split("")
.map((v) => v.toUpperCase().codeUnitAt(0))
.map((v) => v - (V0 <= v && v <= V9 ? V0 : VA))
.toList();
int value = 0;
for (int i = 0; i < listValues.length; ++i) {
value += (i % 2 == 0 ? odd[listValues[i]] : even[listValues[i]]);
}
value %= 26;
return String.fromCharCode(VA + value);
}