python-stdnum branch master updated. 1.6-18-g2cc39ea
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.6-18-g2cc39ea
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".
The branch, master has been updated
via 2cc39ea459dcd712462113e12ceb5eda27de9ecb (commit)
from d24a439d2a7c5ce3ed1628e3393f67cae45b67e2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=2cc39ea459dcd712462113e12ceb5eda27de9ecb
commit 2cc39ea459dcd712462113e12ceb5eda27de9ecb
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Fri Sep 8 10:48:45 2017 +0200
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
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):
diff --git a/tests/test_eu_vat.doctest b/tests/test_eu_vat.doctest
index a578d67..4ea4cb2 100644
--- a/tests/test_eu_vat.doctest
+++ b/tests/test_eu_vat.doctest
@@ -103,16 +103,28 @@ These have been found online and should all be valid
numbers.
... CZ 25123891
... CZ 25577581
... CZ 26852357
+... CZ 60 72 77 72
... CZ 61467839
... CZ 640229/4448
... CZ 640903926
+... CZ 64628060
+... CZ 654123789
+... CZ 682127228
... CZ 6956220612
... CZ 736028/5163
... CZ 8058012314
+... CZ00023205
+... CZ24158313
... CZ26780259
+... CZ450 33 145
... CZ48207926
... CZ49620819
+... CZ6011270177
+... CZ6109220348
+... CZ61989100
... CZ6306150004
+... CZ7205151536
+... CZ7652046248
...
... DE - 113866163
... DE - 231969187
-----------------------------------------------------------------------
Summary of changes:
stdnum/cz/dic.py | 6 +++---
tests/test_eu_vat.doctest | 12 ++++++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
hooks/post-receive
--
python-stdnum
--
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
https://lists.arthurdejong.org/python-stdnum-commits/
- python-stdnum branch master updated. 1.6-18-g2cc39ea,
Commits of the python-stdnum project