Closed MuhistheHolvi closed 4 years ago
HI @MuhistheHolvi the compact()
function is missing (which is one of the causes of the test failures) and there are a few flake8 issues.
I need to learn using doctest locally. This constant pushing is not sustainable after every couple lines of change.
@arthurdejong Thank you for the pointer. I think I will close this PR when done and open new one with one commit. I think I am approaching one commit per line of code :) Unless you do a squat merge, in that case please go ahead and merge this branch.
HI @MuhistheHolvi,
Sorry for not responding sooner.
You should be able to run the tests locally with tox (e.g. use tox -e py36
to run it with a Python 3.6 interpreter, and use tox -e flake8
to run the style tests).
There are still a few issues:
A function to calculate a check digit based on the above would be (note that the check digit is the first digit, not the last one which is more common):
def calc_check_digit(number):
"""Calculate the check digit for the number. The passed number should not
have the check digit (the first one) included."""
weights = (6, 7, 8, 9, 10, 5, 4, 3, 2)
return '21987654321'[sum(int(n) * w for n, w in zip(number, weights)) % 11]
The above implementation also seems to match the one used on https://easydigitalfiling.com/kb/what-is-a-utr-number
These generated numbers are treated as correct on both implementations:
1234567895
1478641088
1955839661
2172858530
2234567890
4748949890
5179265754
5816619590
8258106771
9624088948
Introduce validator for GB UTR.