[#2] MemberAdminWindow: Update search filters
This commit is contained in:
@ -9,14 +9,14 @@ namespace Elwig.Helpers {
|
||||
|
||||
private static readonly Dictionary<string, string[][]> PHONE_NRS = new() {
|
||||
{ "43", new string[][] {
|
||||
Array.Empty<string>(),
|
||||
new string[] { "57", "59" },
|
||||
new string[] {
|
||||
[],
|
||||
["57", "59"],
|
||||
[
|
||||
"50", "517", "718", "804", "720", "780", "800", "802", "810",
|
||||
"820", "821", "828", "900", "901", "930", "931", "939",
|
||||
"650", "651", "652", "653", "655", "657", "659", "660", "661",
|
||||
"663", "664", "665", "666", "667", "668", "669", "67", "68", "69"
|
||||
}
|
||||
]
|
||||
} },
|
||||
{ "49", Array.Empty<string[]>() },
|
||||
{ "48", Array.Empty<string[]>() },
|
||||
@ -162,7 +162,7 @@ namespace Elwig.Helpers {
|
||||
if (text.StartsWith("+43 ")) {
|
||||
var nr = text[4..];
|
||||
var vws = PHONE_NRS["43"];
|
||||
if (!text.EndsWith(" ") && v >= 4 && v - 4 < vws.Length && vws[v - 4].Any(vw => nr.StartsWith(vw))) {
|
||||
if (!text.EndsWith(' ') && v >= 4 && v - 4 < vws.Length && vws[v - 4].Any(vw => nr.StartsWith(vw))) {
|
||||
text += ' ';
|
||||
} else if (nr == "1") {
|
||||
text += ' ';
|
||||
@ -320,18 +320,24 @@ namespace Elwig.Helpers {
|
||||
return new(true, null);
|
||||
} else if (input.Text.Length != 7) {
|
||||
return new(false, "Betriebsnummer zu kurz");
|
||||
} else if (!CheckLfbisNr(input.Text)) {
|
||||
return new(false, "Prüfsumme der Betriebsnummer ist falsch");
|
||||
} else {
|
||||
return new(true, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckLfbisNr(string nr) {
|
||||
if (nr.Length != 7 || !nr.All(char.IsAsciiDigit))
|
||||
return false;
|
||||
|
||||
// https://statistik.at/fileadmin/shared/QM/Standarddokumentationen/RW/std_r_land-forstw_register.pdf#page=41
|
||||
int s = 0, v;
|
||||
for (int i = 0; i < 6; i++)
|
||||
s += (input.Text[i] - '0') * (7 - i);
|
||||
s += (nr[i] - '0') * (7 - i);
|
||||
v = (11 - (s % 11)) % 10;
|
||||
|
||||
if (v != (input.Text[6] - '0'))
|
||||
return new(false, "Prüfsumme der Betriebsnummer ist falsch");
|
||||
|
||||
return new(true, null);
|
||||
return v == (nr[6] - '0');
|
||||
}
|
||||
|
||||
public static ValidationResult CheckUstIdNr(TextBox input, bool required) {
|
||||
@ -373,17 +379,11 @@ namespace Elwig.Helpers {
|
||||
return required ? new(false, "UID ist nicht optional") : new(true, null);
|
||||
|
||||
if (text.StartsWith("AT")) {
|
||||
if (text.Length != 11 || text[2] != 'U')
|
||||
if (text.Length != 11 || text[2] != 'U') {
|
||||
return new(false, "UID ist ungültig");
|
||||
|
||||
// http://www.pruefziffernberechnung.de/U/USt-IdNr.shtml
|
||||
int s = 0, v = 0;
|
||||
for (int i = 0; i < 7; i++)
|
||||
s += ((text[i + 3] - '0') * (i % 2 + 1)).ToString().Select(ch => ch - '0').Sum();
|
||||
v = (96 - s) % 10;
|
||||
|
||||
if (v != (text[10] - '0'))
|
||||
} else if (!CheckUstIdNr(text)) {
|
||||
return new(false, "Prüfsumme der UID ist falsch");
|
||||
}
|
||||
} else {
|
||||
return new(false, "Not implemented yet");
|
||||
}
|
||||
@ -391,6 +391,26 @@ namespace Elwig.Helpers {
|
||||
return new(true, null);
|
||||
}
|
||||
|
||||
public static bool CheckUstIdNr(string nr) {
|
||||
if (nr.Length < 4 || nr.Length > 14 || !nr.All(char.IsAsciiLetterOrDigit))
|
||||
return false;
|
||||
|
||||
if (nr.StartsWith("AT")) {
|
||||
if (nr.Length != 11 || nr[2] != 'U')
|
||||
return false;
|
||||
|
||||
// http://www.pruefziffernberechnung.de/U/USt-IdNr.shtml
|
||||
int s = 0, v = 0;
|
||||
for (int i = 0; i < 7; i++)
|
||||
s += ((nr[i + 3] - '0') * (i % 2 + 1)).ToString().Select(ch => ch - '0').Sum();
|
||||
v = (96 - s) % 10;
|
||||
|
||||
return v == (nr[10] - '0');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static ValidationResult CheckMgNr(TextBox input, bool required, AppDbContext ctx) {
|
||||
var res = CheckInteger(input, required);
|
||||
if (!res.IsValid) {
|
||||
|
Reference in New Issue
Block a user