Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 34 prefix value (ar localflavor ARCUITField). #342

Merged
merged 3 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/django/django-localflavor/issues/331>`_).
- Confirmed support for Django 2.1.
- Added 34 as a valid CUIT prefix value for `ARCUITField`
(`gh-342 <https://github.com/django/django-localflavor/pull/342>`_).


2.0 (2017-12-30)
Expand Down
16 changes: 9 additions & 7 deletions localflavor/ar/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@


class ARProvinceSelect(Select):
"""A Select widget that uses a list of Argentinean provinces/autonomous cities as its choices."""
"""A Select widget that uses a list of Argentinean provinces/autonomous
cities as its choices."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we generally go to next line after """ when it takes more than one line, but that's nit-picking...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. We're using 120 character lines so you can also just not include this change. Either way is fine.


def __init__(self, attrs=None):
super(ARProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
Expand All @@ -22,8 +23,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 = {
Expand Down Expand Up @@ -77,19 +79,19 @@ 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
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if you could add .. versionchanged:: 2.1 here.


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):
Expand All @@ -101,7 +103,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'])
Expand Down
3 changes: 2 additions & 1 deletion tests/test_ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down