From b5b0570233c02bf9f1bec18d35dac54dbaa0d113 Mon Sep 17 00:00:00 2001 From: Ramiro Morales Date: Thu, 2 Aug 2018 07:25:50 -0300 Subject: [PATCH] Add 34 prefix value (ar localflavor ARCUITField). (#342) --- docs/changelog.rst | 4 +++- localflavor/ar/forms.py | 17 +++++++++++------ tests/test_ar.py | 3 ++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index a16c23873..8293a1055 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,10 +22,12 @@ Modifications to existing flavors: Other changes: -- Added VAT identifcation number validator for all EU locales. +- Added VAT identification number validator for all EU locales. - Fix EAN validation when intermediate checksum is 10 (`gh-331 `_). - Confirmed support for Django 2.1. +- Added 34 as a valid CUIT prefix value for `ARCUITField` + (`gh-342 `_). 2.0 (2017-12-30) diff --git a/localflavor/ar/forms.py b/localflavor/ar/forms.py index ada40d598..acf46b2b0 100644 --- a/localflavor/ar/forms.py +++ b/localflavor/ar/forms.py @@ -22,8 +22,9 @@ class ARPostalCodeField(RegexField): A field that accepts a 'classic' NNNN Postal Code or a CPA. See: - http://www.correoargentino.com.ar/cpa/que_es - http://www.correoargentino.com.ar/cpa/como_escribirlo + + * http://www.correoargentino.com.ar/cpa/que_es + * http://www.correoargentino.com.ar/cpa/como_escribirlo """ default_error_messages = { @@ -77,19 +78,23 @@ class ARCUITField(RegexField): """ This field validates a CUIT (Código Único de Identificación Tributaria). - ACUIT is of the form XX-XXXXXXXX-V. The last digit is a check digit. + A CUIT is of the form XX-XXXXXXXX-V. The last digit is a check digit. More info: http://es.wikipedia.org/wiki/Clave_%C3%9Anica_de_Identificaci%C3%B3n_Tributaria - English info: + Info in English: http://www.justlanded.com/english/Argentina/Argentina-Guide/Visas-Permits/Other-Legal-Documents + + .. versionchanged:: 2.1 + + ``ARCUITField`` now also accepts CUIT with prefix 34. """ default_error_messages = { 'invalid': _('Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'), 'checksum': _("Invalid CUIT."), - 'legal_type': _('Invalid legal type. Type must be 27, 20, 30, 23, 24 or 33.'), + 'legal_type': _('Invalid legal type. Type must be 27, 20, 30, 23, 24, 33 or 34.'), } def __init__(self, *args, **kwargs): @@ -101,7 +106,7 @@ def clean(self, value): if value in self.empty_values: return self.empty_value value, cd = self._canon(value) - if not value[:2] in ['27', '20', '30', '23', '24', '33']: + if not value[:2] in ['27', '20', '30', '23', '24', '33', '34']: raise ValidationError(self.error_messages['legal_type']) if self._calc_cd(value) != cd: raise ValidationError(self.error_messages['checksum']) diff --git a/tests/test_ar.py b/tests/test_ar.py index 663cf93bb..7e48cff55 100644 --- a/tests/test_ar.py +++ b/tests/test_ar.py @@ -77,7 +77,7 @@ def test_ARDNIField(self): def test_ARCUITField(self): error_format = ['Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] error_invalid = ['Invalid CUIT.'] - error_legal_type = ['Invalid legal type. Type must be 27, 20, 30, 23, 24 or 33.'] + error_legal_type = ['Invalid legal type. Type must be 27, 20, 30, 23, 24, 33 or 34.'] valid = { '20-10123456-9': '20-10123456-9', '27-10345678-4': '27-10345678-4', @@ -87,6 +87,7 @@ def test_ARCUITField(self): '24117166062': '24-11716606-2', '33500001599': '33-50000159-9', '23000052264': '23-00005226-4', + '34546198105': '34-54619810-5', } invalid = { '2-10123456-9': error_format,