joonis Logo

Python kontocheck library

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

Install it with easy_install:

easy_install -U kontocheck

Or use pip:

pip install -U kontocheck

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_name('37040044')
iban = kontocheck.create_iban('37040044', '532013000')
kontocheck.check_iban(iban)
bic = kontocheck.get_bic(iban)
kontocheck.get_version()

Get the version of the compiled konto_check library.

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

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 to a given IBAN.

kontocheck.get_name(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_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_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.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.

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

Can I
  help you?


Just drop me a line at
giraffe@joonis.de