#18537: Error in calculation of check digit in ARCUITField
----------------------------+-----------------------------------------
Reporter: mmoya@… | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Keywords: ARCUITField, localflavor.ar
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-----------------------------------------
There is a bug in the calculation of check digit on forms.py from
django.contrib.localflavor.ar.
When using ARCUITField and enter a valid CUIT terminated (that is, check
digit) in 0 or 9, the clean method raise a Validation error message.
To replicate the bug, just enter a valid cuit number with the format XX-
XXXXXXXX-0, and you will see the error "Invalid CUIT".
The problem is in the _calc_cd(self, cuit) method, that not take care of
this two special cases. More info in
[http://es.wikipedia.org/wiki/C%C3%B3digo_%C3%9Anico_de_Identificaci%C3%B3n_Tributaria]
A quick fix for this could be:
{{{
def _calc_cd(self, cuit):
mults = (5, 4, 3, 2, 7, 6, 5, 4, 3, 2)
tmp = sum([m * int(cuit[idx]) for idx, m in enumerate(mults)])
aux_cd = 11 - tmp % 11
if aux_cd == 11:
aux_cd = 0
elif aux_cd == 10:
aux_cd = 9
return str(aux_cd)
}}}
Thanks,
--
Ticket URL: <https://code.djangoproject.com/ticket/18537>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.