English Deutsch

Python kontocheck library

The kontocheck library is available on PyPI. Licensed under the GNU/LGPL.

Installation

pip install kontocheck

The LUT data file is already shipped with the kontocheck package. However, the latest version can be downloaded separately:

LUT-Datei generiert am 6.8.2021 [1.1 MB]

Try it

Documentation

Python ctypes wrapper of the konto_check library.

This module is based on konto_check, a small library to check German bank accounts. It implements all check methods and IBAN generation rules, published by the German Central Bank.

In addition it provides access to the SCL Directory and the possibility to verify VAT-IDs by the German Federal Central Tax Office.

Example:

import kontocheck
kontocheck.lut_load()
bankname = kontocheck.get_bankname('37040044')
iban = kontocheck.create_iban('37040044', '532013000')
kontocheck.check_iban(iban)
bic = kontocheck.get_bic(iban)
bankname = kontocheck.scl_get_bankname('VBOEATWW')
kontocheck.get_version()

Get the version of the compiled konto_check library.

kontocheck.lut_load(field_set=5, path=None, load_scl=True)

Load the given field set from a LUT file specified by path.

If path is omitted or None the shipped LUT file is used.

Available field sets (default is 5):

Value

Fields to load

0

BLZ, Prüfziffer und Filialen (always loaded)

1

Kurzname

2

Kurzname, BIC

3

Name, PLZ, Ort

4

Name, PLZ, Ort, BIC

5

Name+Kurzname, PLZ, Ort, BIC

6

Name+Kurzname, PLZ, Ort, BIC, Nachfolge-BLZ

7

Name+Kurzname, PLZ, Ort, BIC, Nachfolge-BLZ, Änderungsdatum

8

Name+Kurzname, PLZ, Ort, BIC, Nachfolge-BLZ, Änderungsdatum, Löschdatum

9

Name+Kurzname, PLZ, Ort, BIC, Nachfolge-BLZ, Änderungsdatum, Löschdatum, PAN, Laufende Nr. des Datensatzes (kompletter Datensatz)

kontocheck.lut_is_valid()

Check if the current LUT file is valid.

If this function returns False, you should update the LUT file and/or the whole kontocheck library.

Raises an exception if no LUT file was loaded.

kontocheck.cleanup()

Reset and free all loaded LUT data.

It is called by default when the program exits.

kontocheck.check_iban(iban, error=False)

Check an IBAN for validity.

For German IBANs also the check digit of the account number is verified. If error is set to True, an exception is raised on failure.

kontocheck.create_iban(bankcode, account, get_bic=False)

Create a valid IBAN by given bank code and account.

If get_bic evaluates to True, a 2-tupel of (IBAN, BIC) is returned.

kontocheck.get_bic(iban)

Get the corresponding BIC for a German IBAN or bankcode.

kontocheck.get_bankname(bankcode, short_form=False)

Get the name of a bank by a given bankcode (or German IBAN).

Returns the short or long version of the name.

kontocheck.get_name(bankcode, short_form=False)

Deprecated since version 6.13.1. Use get_bankname() instead.

kontocheck.get_postalcode(bankcode)

Get the postalcode of a bank by a given bankcode (or German IBAN).

kontocheck.get_city(bankcode)

Get the city of a bank by a given bankcode (or German IBAN).

kontocheck.scl_load(path=None, encoding='latin1')

Deprecated since version 6.13.1. The SCL data is now loaded by calling lut_load().

kontocheck.scl_get_routing(bic)

Returns a dictionary with the SEPA routing information for the given BIC from the SCL directory, published by the German Central Bank.

kontocheck.scl_get_bankname(bic)

Returns the bank name for the given BIC from the SCL directory, published by the German Central Bank.

kontocheck.eu_check_vatid(vatid)

Checks a VAT-ID for validity using the webservice provided by the European Commission. For further information see https://ec.europa.eu/taxation_customs/vies/technicalInformation.html

Performs a basic check and returns the result as True or False.

kontocheck.bff_check_vatid(local_vatid, remote_vatid, company='', city='', postalcode='', street='', request_mail=False)

Checks a VAT-ID for validity using the webservice provided by the German Federal Central Tax Office. For further information see https://evatr.bff-online.de/eVatR/xmlrpc/

Performs a basic or qualified check depending on the given parameters as described on the following website: https://evatr.bff-online.de/eVatR/xmlrpc/schnittstelle

Returns a dictionary with keys as described on the following website: https://evatr.bff-online.de/eVatR/xmlrpc/aufbau

The webservice is available daily between 5:00 and 23:00 (CET).

exception kontocheck.KontoCheckError(code)

The konto_check library returned an error.

NO_SCL_BLOCKS_LOADED = -158
NO_SCL_INFO_BLOCK = -157
SCL_BIC_NOT_FOUND = -156
INVALID_SCL_INFO_BLOCK = -155
NO_SCL_BLOCKS = -154
SCL_INPUT_FORMAT_ERROR = -153
INVALID_REGULAR_EXPRESSION_CNT = -152
INVALID_REGULAR_EXPRESSION = -151
INVALID_HANDLE = -150
INVALID_BIQ_INDEX = -149
ARRAY_INDEX_OUT_OF_RANGE = -148
IBAN_ONLY_GERMAN = -147
INVALID_PARAMETER_TYPE = -146
BIC_ONLY_GERMAN = -145
INVALID_BIC_LENGTH = -144
IBAN_CHKSUM_OK_RULE_IGNORED_BLZ = -143
IBAN_CHKSUM_OK_KC_NOT_INITIALIZED = -142
IBAN_CHKSUM_OK_BLZ_INVALID = -141
IBAN_CHKSUM_OK_NACHFOLGE_BLZ_DEFINED = -140
LUT2_NOT_ALL_IBAN_BLOCKS_LOADED = -139
LUT2_NOT_YET_VALID_PARTIAL_OK = -138
LUT2_NO_LONGER_VALID_PARTIAL_OK = -137
LUT2_BLOCKS_MISSING = -136
FALSE_UNTERKONTO_ATTACHED = -135
BLZ_BLACKLISTED = -134
BLZ_MARKED_AS_DELETED = -133
IBAN_CHKSUM_OK_SOMETHING_WRONG = -132
IBAN_CHKSUM_OK_NO_IBAN_CALCULATION = -131
IBAN_CHKSUM_OK_RULE_IGNORED = -130
IBAN_CHKSUM_OK_UNTERKTO_MISSING = -129
IBAN_INVALID_RULE = -128
IBAN_AMBIGUOUS_KTO = -127
IBAN_RULE_NOT_IMPLEMENTED = -126
IBAN_RULE_UNKNOWN = -125
NO_IBAN_CALCULATION = -124
OLD_BLZ_OK_NEW_NOT = -123
LUT2_IBAN_REGEL_NOT_INITIALIZED = -122
INVALID_IBAN_LENGTH = -121
LUT2_NO_ACCOUNT_GIVEN = -120
LUT2_VOLLTEXT_INVALID_CHAR = -119
LUT2_VOLLTEXT_SINGLE_WORD_ONLY = -118
LUT_SUCHE_INVALID_RSC = -117
LUT_SUCHE_INVALID_CMD = -116
LUT_SUCHE_INVALID_CNT = -115
LUT2_VOLLTEXT_NOT_INITIALIZED = -114
NO_OWN_IBAN_CALCULATION = -113
KTO_CHECK_UNSUPPORTED_COMPRESSION = -112
KTO_CHECK_INVALID_COMPRESSION_LIB = -111
OK_UNTERKONTO_ATTACHED_OLD = -110
KTO_CHECK_DEFAULT_BLOCK_INVALID = -109
KTO_CHECK_DEFAULT_BLOCK_FULL = -108
KTO_CHECK_NO_DEFAULT_BLOCK = -107
KTO_CHECK_KEY_NOT_FOUND = -106
LUT2_NO_LONGER_VALID_BETTER = -105
DTA_SRC_KTO_DIFFERENT = -104
DTA_SRC_BLZ_DIFFERENT = -103
DTA_CR_LF_IN_FILE = -102
DTA_INVALID_C_EXTENSION = -101
DTA_FOUND_SET_A_NOT_C = -100
DTA_FOUND_SET_E_NOT_C = -99
DTA_FOUND_SET_C_NOT_EXTENSION = -98
DTA_FOUND_SET_E_NOT_EXTENSION = -97
DTA_INVALID_EXTENSION_COUNT = -96
DTA_INVALID_NUM = -95
DTA_INVALID_CHARS = -94
DTA_CURRENCY_NOT_EURO = -93
DTA_EMPTY_AMOUNT = -92
DTA_INVALID_TEXT_KEY = -91
DTA_EMPTY_STRING = -90
DTA_MARKER_A_NOT_FOUND = -89
DTA_MARKER_C_NOT_FOUND = -88
DTA_MARKER_E_NOT_FOUND = -87
DTA_INVALID_SET_C_LEN = -86
DTA_INVALID_SET_LEN = -85
DTA_WAERUNG_NOT_EURO = -84
DTA_INVALID_ISSUE_DATE = -83
DTA_INVALID_DATE = -82
DTA_FORMAT_ERROR = -81
DTA_FILE_WITH_ERRORS = -80
INVALID_SEARCH_RANGE = -79
KEY_NOT_FOUND = -78
BAV_FALSE = -77
LUT2_NO_USER_BLOCK = -76
INVALID_SET = -75
NO_GERMAN_BIC = -74
IPI_CHECK_INVALID_LENGTH = -73
IPI_INVALID_CHARACTER = -72
IPI_INVALID_LENGTH = -71
LUT1_FILE_USED = -70
MISSING_PARAMETER = -69
IBAN2BIC_ONLY_GERMAN = -68
IBAN_OK_KTO_NOT = -67
KTO_OK_IBAN_NOT = -66
TOO_MANY_SLOTS = -65
INIT_FATAL_ERROR = -64
INCREMENTAL_INIT_NEEDS_INFO = -63
INCREMENTAL_INIT_FROM_DIFFERENT_FILE = -62
DEBUG_ONLY_FUNCTION = -61
LUT2_INVALID = -60
LUT2_NOT_YET_VALID = -59
LUT2_NO_LONGER_VALID = -58
LUT2_GUELTIGKEIT_SWAPPED = -57
LUT2_INVALID_GUELTIGKEIT = -56
LUT2_INDEX_OUT_OF_RANGE = -55
LUT2_INIT_IN_PROGRESS = -54
LUT2_BLZ_NOT_INITIALIZED = -53
LUT2_FILIALEN_NOT_INITIALIZED = -52
LUT2_NAME_NOT_INITIALIZED = -51
LUT2_PLZ_NOT_INITIALIZED = -50
LUT2_ORT_NOT_INITIALIZED = -49
LUT2_NAME_KURZ_NOT_INITIALIZED = -48
LUT2_PAN_NOT_INITIALIZED = -47
LUT2_BIC_NOT_INITIALIZED = -46
LUT2_PZ_NOT_INITIALIZED = -45
LUT2_NR_NOT_INITIALIZED = -44
LUT2_AENDERUNG_NOT_INITIALIZED = -43
LUT2_LOESCHUNG_NOT_INITIALIZED = -42
LUT2_NACHFOLGE_BLZ_NOT_INITIALIZED = -41
LUT2_NOT_INITIALIZED = -40
LUT2_FILIALEN_MISSING = -39
LUT2_PARTIAL_OK = -38
LUT2_Z_BUF_ERROR = -37
LUT2_Z_MEM_ERROR = -36
LUT2_Z_DATA_ERROR = -35
LUT2_BLOCK_NOT_IN_FILE = -34
LUT2_DECOMPRESS_ERROR = -33
LUT2_COMPRESS_ERROR = -32
LUT2_FILE_CORRUPTED = -31
LUT2_NO_SLOT_FREE = -30
UNDEFINED_SUBMETHOD = -29
EXCLUDED_AT_COMPILETIME = -28
INVALID_LUT_VERSION = -27
INVALID_PARAMETER_STELLE1 = -26
INVALID_PARAMETER_COUNT = -25
INVALID_PARAMETER_PRUEFZIFFER = -24
INVALID_PARAMETER_WICHTUNG = -23
INVALID_PARAMETER_METHODE = -22
LIBRARY_INIT_ERROR = -21
LUT_CRC_ERROR = -20
FALSE_GELOESCHT = -19
OK_NO_CHK_GELOESCHT = -18
OK_GELOESCHT = -17
BLZ_GELOESCHT = -16
INVALID_BLZ_FILE = -15
LIBRARY_IS_NOT_THREAD_SAFE = -14
FATAL_ERROR = -13
INVALID_KTO_LENGTH = -12
FILE_WRITE_ERROR = -11
FILE_READ_ERROR = -10
ERROR_MALLOC = -9
NO_BLZ_FILE = -8
INVALID_LUT_FILE = -7
NO_LUT_FILE = -6
INVALID_BLZ_LENGTH = -5
INVALID_BLZ = -4
INVALID_KTO = -3
NOT_IMPLEMENTED = -2
NOT_DEFINED = -1
FALSE = 0
OK = 1
OK_NO_CHK = 2
OK_TEST_BLZ_USED = 3
LUT2_VALID = 4
LUT2_NO_VALID_DATE = 5
LUT1_SET_LOADED = 6
LUT1_FILE_GENERATED = 7
DTA_FILE_WITH_WARNINGS = 8
LUT_V2_FILE_GENERATED = 9
KTO_CHECK_VALUE_REPLACED = 10
OK_UNTERKONTO_POSSIBLE = 11
OK_UNTERKONTO_GIVEN = 12
OK_SLOT_CNT_MIN_USED = 13
SOME_KEYS_NOT_FOUND = 14
LUT2_KTO_NOT_CHECKED = 15
LUT2_OK_WITHOUT_IBAN_RULES = 16
OK_NACHFOLGE_BLZ_USED = 17
OK_KTO_REPLACED = 18
OK_BLZ_REPLACED = 19
OK_BLZ_KTO_REPLACED = 20
OK_IBAN_WITHOUT_KC_TEST = 21
OK_INVALID_FOR_IBAN = 22
OK_HYPO_REQUIRES_KTO = 23
OK_KTO_REPLACED_NO_PZ = 24
OK_UNTERKONTO_ATTACHED = 25
OK_SHORT_BIC_USED = 26
OK_SCL_EXTENSION_BIC_USED = 27
OK_SCL_WILDCARD_BIC_USED = 28