diff options
author | Emmanuel Arias <eamanu@yaerobi.com> | 2020-01-09 23:17:37 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2020-01-11 23:40:33 +0100 |
commit | 0b30c4b86150e055a87dff21285a40c9d06df4ff (patch) | |
tree | d83d88a8821b9c370bc2297d14c83c0f2e273faf /stdnum | |
parent | a9b3e90b781e3fa9058589311a8991337244f0f1 (diff) |
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
Diffstat (limited to 'stdnum')
-rw-r--r-- | stdnum/ar/cuit.py | 24 |
1 files changed, 15 insertions, 9 deletions
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 |