Phase 2 commits - common approach for number checks

Ralf Habacker ralf.habacker at freenet.de
Wed Aug 19 13:16:51 BST 2020


Am 11.08.20 um 19:21 schrieb Prasun Kumar:
> Hi Ralf,
> 
>     ktoblzcheck help screen shows these error conditions
> 
>              1: Validation algorithm is unknown/unimplemented
>               2: Account and bank do not match
>               3: No bank with given bank-id found
> 
>     which are not checked by the currently present "invalid" test checks.
> 
>     The present 'ktoblzcheck_invalid' checks only result (2) for german
>     databases:
> 
>          7: Bank: 'Hamburger Sparkasse' at 'Hamburg
>        ' (20050550)
>          7: Account: 1262693333
>          7: Result is: (2) ERROR: account and bank do not match
> 
>     which should be extended to cover all error conditions and languages.
> 
> 
> Yeah, I agree with you. Although, since there are no validation 
> algorithms for NL and CH checkers,

At https://mail.kde.org/pipermail/kde-finance-apps/2020-July/000908.html 
related informations were provided to the list:

The bank identifier '4!a' can be checked that it has 4 upper case 
letters and the account number '10!n' must have 10 digits.

For swiss data the bank identifier must have 5 digits and the account 
must have 12 upper and lower case characters.


In AccountNumberCheck::check() there is already a rudimentary length check:

     // Check account-id length
     if (accountId.size() > 10 || bankId.size() > 8) {
         return ERROR;
     }

which you already used for NL and CH.

For a common approach I suggest to add additional functions to

const struct method_funcLong_s cb_funcs_long[] = {

e.g.
      ...
     { "4!a10!n", method_4ea_10en},
     { "5!n12!c", method_5en_12ec},

in the mentioned example 'e' stands for exactly

or if full pronounced is prefered:

     { "4!a10!n", method_4_exactly_ascii_10_exactly_numbers},
     { "5!n12!c", method_5_exactly_numbers_12_exactly_alpha_numeric_chars},


and run that for the related checks e.g.

     if(country == "NL"){
         try{
             Record rec = findBank(bankId);
         } catch (int){
             return BANK_NOT_KNOWN;
         }

	return method_4ea_10en(0, 0, accountId, bankId);
      }

The same for swiss

     if(country == "CH"){
         try{
             Record rec = findBank(bankId);
         } catch (int){
             return BANK_NOT_KNOWN;
         }

	return method_5ea_12ec(0, 0, accountId, bankId);
      }

Regards
Ralf


More information about the Kde-finance-apps mailing list