Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/stdnum/cz
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2017-09-08 10:48:45 +0200
committerArthur de Jong <arthur@arthurdejong.org>2017-09-08 10:54:15 +0200
commit2cc39ea459dcd712462113e12ceb5eda27de9ecb (patch)
tree01ed1860696d8dcf433ae9c417b56280585a14ab /stdnum/cz
parentd24a439d2a7c5ce3ed1628e3393f67cae45b67e2 (diff)
Fix Czech DIČ check digit calculation
This fixes a bug in the check digit calculation for the 9-digit numbers that start with a 6 for individuals without a RČ. This also adds a few tests for Czech VAT numbers. See https://github.com/arthurdejong/python-stdnum/issues/51
Diffstat (limited to 'stdnum/cz')
-rw-r--r--stdnum/cz/dic.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/stdnum/cz/dic.py b/stdnum/cz/dic.py
index fc24b24..df507ac 100644
--- a/stdnum/cz/dic.py
+++ b/stdnum/cz/dic.py
@@ -1,7 +1,7 @@
# dic.py - functions for handling Czech VAT numbers
# coding: utf-8
#
-# Copyright (C) 2012, 2013 Arthur de Jong
+# Copyright (C) 2012-2017 Arthur de Jong
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -64,8 +64,8 @@ def calc_check_digit_legal(number):
def calc_check_digit_special(number):
"""Calculate the check digit for special cases. The number passed
should not have the first and last digits included."""
- check = (11 - sum((8 - i) * int(n) for i, n in enumerate(number))) % 11
- return str(9 - check % 10)
+ check = sum((8 - i) * int(n) for i, n in enumerate(number)) % 11
+ return str((8 - (10 - check) % 11 ) % 10)
def validate(number):