Data type IBAN

  • 135 Views
  • Last Post 07 September 2018
  • Topic Is Solved
Timo Neff posted this 12 August 2018

Hi, I could not find a standard data type which refers to the IBAN (International Bank Account Number). I am looking for a validation script which goes beyond checking the format (i.e. Regex for German IBAN: [DE][0-9]{20} ) and also consideres the checksum (with modulo etc.).

Order By: Standard | Newest | Votes
Ekaterina posted this 14 August 2018

Hello,

The IBAN format is described here “ABBYY FlexiCapture for Invoices > Specifications > Data Sets > Columns in the Vendors Data Set” (Text, normalization: Alphanumeric code) in the Administrator Help.

Timo Neff posted this 14 August 2018

Hello Ekaterina, thank you for your message.

 

I could find the description of an IBAN within the Administrator Help of ABBYY FlexiCapture for Invoices (http://help.abbyy.com/en-us/flexicapture/12/invoice_reader/ir_columnsvendors). It seems to me, that the data type described there only considers an IBAN as "Text, normalization: Alphanumeric code". However, I am looking for an actual validation (maybe via a script). The only “Special” content I can find for a “Code” data type is an “ISBN”.

This may be a feature request.

 

Timo Neff posted this 07 September 2018

Solution: I created a .DLL based on the Code from jhgbrt (GitHub), which can be used in a rule script.

//Copyright (C) 2013 DvdKhl

  //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),

  //to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,

  //and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

  //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

  //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

  //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,

  //WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

   

  static bool IsIbanChecksumValid(string iban) {

  if(iban.Length < 4 || iban[0] == ' ' || iban[1] == ' ' || iban[2] == ' ' || iban[3] == ' ') throw new InvalidOperationException();

   

  var checksum = 0;

  var shift = 4;

  var ibanLength = iban.Length;

  for (int i = 0; i + shift - 4 < ibanLength; i++) {

  int charindex = (i + shift) % ibanLength;

  while (iban[charindex] == ' ') {

  shift++;

  charindex = (i + shift) % ibanLength;

  }

   

  int value;

  var c = iban[(charIndex + shift) % ibanLength];

  if((c >= '0') && (c <= '9')) {

  value = c - '0';

  } else if((c >= 'A') && (c <= 'Z')) {

  value = c - 'A';

  checksum = (checksum * 10 + (value / 10 + 1)) % 97;

  value %= 10;

  } else if((c >= 'a') && (c <= 'z')) {

  value = c - 'a';

  checksum = (checksum * 10 + (value / 10 + 1)) % 97;

  value %= 10;

  } else throw new InvalidOperationException();

   

  checksum = (checksum * 10 + value) % 97;

  }

  return checksum == 1;

  }

Close