8000 Fix Ukrainian EDRPOU check digit calculation · jmak-odoo/python-stdnum@bb20121 · GitHub
[go: up one dir, main page]

Skip to content

Commit bb20121

Browse files
committed
Fix Ukrainian EDRPOU check digit calculation
This fixes the case where the weighted sum woud be 10 which should result in a check digit of 0. Closes arthurdejong#429
1 parent 9c7c669 commit bb20121

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

stdnum/ua/edrpou.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def calc_check_digit(number):
6464
# Calculate again with other weights
6565
weights = tuple(w + 2 for w in weights)
6666
total = sum(w * int(n) for w, n in zip(weights, number))
67-
return str(total % 11)
67+
return str(total % 11 % 10)
6868

6969

7070
def validate(number):

tests/test_ua_edrpou.doctest

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ These have been found online and should all be valid numbers.
190190
... 22800735
191191
... 22815333
192192
... 23226362
193+
... 23246880
193194
... 23293513
194195
... 23505151
195196
... 23541342
@@ -198,6 +199,7 @@ These have been found online and should all be valid numbers.
198199
... 24976272
199200
... 24978555
200201
... 25042882
202+
... 25083040
201203
... 25836018
202204
... 26112972
203205
... 26255795
@@ -279,10 +281,12 @@ These have been found online and should all be valid numbers.
279281
... 40108625
280282
... 40108866
281283
... 40109173
284+
... 40599600
282285
... 41399586
283286
... 41436842
284287
... 41475043
285288
... 41617928
289+
... 41761770
286290
... 41800368
287291
... 41810109
288292
... 42258617
@@ -292,12 +296,15 @@ These have been found online and should all be valid numbers.
292296
... 42588390
293297
... 42598807
294298
... 43178370
299+
... 43328020
295300
... 43476227
296301
... 43518172
297302
... 43529818
303+
... 43573920
298304
... 43586656
299305
... 43618792
300306
... 43629317
307+
... 43808820
301308
...
302309
... '''
303310
>>> [x for x in numbers.splitlines() if x and not edrpou.is_valid(x)]

0 commit comments

Comments
 (0)
0