From 569d7f2cc492e074ccb2878eeda61848ae274a42 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Sun, 16 Apr 2023 21:42:40 +0200 Subject: [PATCH] Implement Betriebsnummer check --- Elwig/Helpers/Validator.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Elwig/Helpers/Validator.cs b/Elwig/Helpers/Validator.cs index 1ea8042..599e7e9 100644 --- a/Elwig/Helpers/Validator.cs +++ b/Elwig/Helpers/Validator.cs @@ -246,9 +246,16 @@ namespace Elwig.Helpers { return new(false, "Betriebsnummer zu kurz"); } - // TODO + // https://statistik.at/fileadmin/shared/QM/Standarddokumentationen/RW/std_r_land-forstw_register.pdf#page=41 + int s = 0; + for (int i = 0; i < 6; i++) + s += (input.Text[i] - '0') * (7 - i); + s = (11 - (s % 11)) % 10; - return new(true, "Not implemented yet"); + if (s != (input.Text[6] - '0')) + return new(false, "Prüfsumme der Betriebsnummer ist falsch"); + + return new(true, null); } public static ValidationResult CheckUstId(TextBox input, bool required) {