python-stdnum branch master updated. 1.12-9-g0b30c4b
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.12-9-g0b30c4b
- From: Commits of the python-stdnum project <python-stdnum-commits [at] lists.arthurdejong.org>
- To: python-stdnum-commits [at] lists.arthurdejong.org
- Reply-to: python-stdnum-users [at] lists.arthurdejong.org, python-stdnum-commits [at] lists.arthurdejong.org
- Subject: python-stdnum branch master updated. 1.12-9-g0b30c4b
- Date: Sat, 11 Jan 2020 23:41:32 +0100 (CET)
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 0b30c4b86150e055a87dff21285a40c9d06df4ff (commit)
from a9b3e90b781e3fa9058589311a8991337244f0f1 (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=0b30c4b86150e055a87dff21285a40c9d06df4ff
commit 0b30c4b86150e055a87dff21285a40c9d06df4ff
Author: Emmanuel Arias <eamanu@yaerobi.com>
Date: Thu Jan 9 19:17:37 2020 -0300
Test Argentinian CUIT type
The first two digits of the CUIT indicate the type of CUIT (personal,
company or international) and can only have certain values.
Closes https://github.com/arthurdejong/python-stdnum/issues/179
Closes https://github.com/arthurdejong/python-stdnum/pull/181
diff --git a/stdnum/ar/cuit.py b/stdnum/ar/cuit.py
index 6325dce..89522b2 100644
--- a/stdnum/ar/cuit.py
+++ b/stdnum/ar/cuit.py
@@ -27,16 +27,12 @@
The CUIT is a taxpayer identification number used for VAT (IVA, Impuesto al
Valor Agregado) and other taxes.
->>> validate('200-5536168-2')
+More information:
+
+* https://es.wikipedia.org/wiki/Clave_Única_de_Identificación_Tributaria
+
+>>> validate('20-05536168-2')
'20055361682'
->>> validate('2026756539')
-Traceback (most recent call last):
- ...
-InvalidLength: ...
->>> validate('2026756A393')
-Traceback (most recent call last):
- ...
-InvalidFormat: ...
>>> validate('20267565392')
Traceback (most recent call last):
...
@@ -62,6 +58,14 @@ def calc_check_digit(number):
return '012345678990'[11 - check]
+# The different types of CUIT that are known
+_cuit_tpes = (
+ '20', '23', '24', '27', # individuals
+ '30', '33', '34', # companies
+ '50', '51', '55', # international purposes
+)
+
+
def validate(number):
"""Check if the number is a valid CUIT."""
number = compact(number)
@@ -69,6 +73,8 @@ def validate(number):
raise InvalidLength()
if not isdigits(number):
raise InvalidFormat()
+ if number[:2] not in _cuit_tpes:
+ raise InvalidComponent()
if calc_check_digit(number[:-1]) != number[-1]:
raise InvalidChecksum()
return number
diff --git a/tests/test_ar_cuit.doctest b/tests/test_ar_cuit.doctest
index f015374..511634e 100644
--- a/tests/test_ar_cuit.doctest
+++ b/tests/test_ar_cuit.doctest
@@ -25,6 +25,24 @@ tries to validate a number of numbers that have been found
online.
>>> from stdnum.exceptions import *
+Test some corner cases.
+
+>>> cuit.validate('20-05536168-2')
+'20055361682'
+>>> cuit.validate('2026756539')
+Traceback (most recent call last):
+ ...
+InvalidLength: ...
+>>> cuit.validate('2026756A393')
+Traceback (most recent call last):
+ ...
+InvalidFormat: ...
+>>> cuit.validate('99-05536168-8')
+Traceback (most recent call last):
+ ...
+InvalidComponent: ...
+
+
These have been found online and should all be valid numbers.
>>> numbers = '''
-----------------------------------------------------------------------
Summary of changes:
stdnum/ar/cuit.py | 24 +++++++++++++++---------
tests/test_ar_cuit.doctest | 18 ++++++++++++++++++
2 files changed, 33 insertions(+), 9 deletions(-)
hooks/post-receive
--
python-stdnum
- python-stdnum branch master updated. 1.12-9-g0b30c4b,
Commits of the python-stdnum project