diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-07-09 13:58:07 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-07-09 14:10:54 +0200 |
| commit | 1d2982362df1dbd9b08ffcc1d2506b2e3789250e (patch) | |
| tree | f96f26a973a53aca970aecd1e64ec69edaf03d56 | |
| parent | 590de18add78945344de049c2d3e7021fd46ce53 (diff) | |
Fixed #18537 -- Fixed CUIT calculation in ar localflavor
Thanks mmoya at 8ksoft.com.ar for the report and Kevin Shaul for the
initial patch.
| -rw-r--r-- | django/contrib/localflavor/ar/forms.py | 9 | ||||
| -rw-r--r-- | tests/regressiontests/localflavor/ar/tests.py | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/django/contrib/localflavor/ar/forms.py b/django/contrib/localflavor/ar/forms.py index 8e252beec9..ffc2d177c0 100644 --- a/django/contrib/localflavor/ar/forms.py +++ b/django/contrib/localflavor/ar/forms.py @@ -105,9 +105,16 @@ class ARCUITField(RegexField): return cuit[:-1], cuit[-1] def _calc_cd(self, cuit): + # Calculation code based on: + # http://es.wikipedia.org/wiki/C%C3%B3digo_%C3%9Anico_de_Identificaci%C3%B3n_Tributaria mults = (5, 4, 3, 2, 7, 6, 5, 4, 3, 2) tmp = sum([m * int(cuit[idx]) for idx, m in enumerate(mults)]) - return str(11 - tmp % 11) + result = 11 - (tmp % 11) + if result == 11: + result = 0 + elif result == 10: + result = 9 + return str(result) def _format(self, cuit, check_digit=None): if check_digit == None: diff --git a/tests/regressiontests/localflavor/ar/tests.py b/tests/regressiontests/localflavor/ar/tests.py index 0731c3ce9b..efc2025fd2 100644 --- a/tests/regressiontests/localflavor/ar/tests.py +++ b/tests/regressiontests/localflavor/ar/tests.py @@ -87,6 +87,7 @@ class ARLocalFlavorTests(SimpleTestCase): '27-10345678-4': '27-10345678-4', '20101234569': '20-10123456-9', '27103456784': '27-10345678-4', + '30011111110': '30-01111111-0', } invalid = { '2-10123456-9': error_format, |
