1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.plausj.bank.german.strategy.util;
18
19 import net.sf.plausj.bank.german.CheckDigit;
20
21 /**
22 * @author ninan
23 *
24 */
25 public class Strategy52AlikeHelper {
26
27 public static int calculateSum(int[] legacyAccountNumber,
28 int[] multiplicators) {
29 int sum = 0;
30 for (int i = 11; i >= 0; --i) {
31 sum += legacyAccountNumber[i] * multiplicators[i];
32 }
33 int mod = sum % 11;
34 return mod;
35 }
36
37 public static CheckDigit getCheckSumFromMod(int mod, int weight, int pos) {
38 CheckDigit cd = null;
39 for (int i = 0; i < 10; ++i) {
40 if ((mod + i * weight) % 11 == 10) {
41 cd = new CheckDigit(pos, i);
42 }
43 }
44 if (null == cd) {
45 cd = new CheckDigit(CheckDigit.ALWAYS_INVALID, 0);
46 }
47
48 return cd;
49 }
50
51 }