From 2cc39ea459dcd712462113e12ceb5eda27de9ecb Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Fri, 8 Sep 2017 10:48:45 +0200 Subject: Fix Czech DIČ check digit calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- stdnum/cz/dic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'stdnum/cz') 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): -- cgit v1.2.3