Revision ddd531b6
Added by Mikaël Ates over 13 years ago
| calebasse/dossiers/models.py | ||
|---|---|---|
|
|
||
|
def get_control_key(self):
|
||
|
if self.social_security_id:
|
||
|
return (97 - (int(self.social_security_id) % 97))
|
||
|
nir = self.social_security_id
|
||
|
try:
|
||
|
# Corse dpt 2A et 2B
|
||
|
minus = 0
|
||
|
if nir[6] in ('A', 'a'):
|
||
|
nir = [c for c in nir]
|
||
|
nir[6] = '0'
|
||
|
nir = ''.join(nir)
|
||
|
minus = 1000000
|
||
|
elif nir[6] in ('B', 'b'):
|
||
|
nir = [c for c in nir]
|
||
|
nir[6] = '0'
|
||
|
nir = ''.join(nir)
|
||
|
minus = 2000000
|
||
|
nir = int(nir) - minus
|
||
|
return (97 - (nir % 97))
|
||
|
except Exception, e:
|
||
|
print str(e)
|
||
|
return None
|
||
|
return None
|
||
|
|
||
|
|
||
| calebasse/static/js/calebasse.dossiers.js | ||
|---|---|---|
|
$('p#nir-key span').text('-');
|
||
|
} else {
|
||
|
$('p#nir-key span').attr('id', 'highlight')
|
||
|
var key = 97 - ($(this).val() % 97)
|
||
|
var nir = $(this).val();
|
||
|
var minus = 0;
|
||
|
if (nir.charAt(6) == 'A'){
|
||
|
nir = nir.replace('A', '0');
|
||
|
minus = 1000000;
|
||
|
}
|
||
|
if (nir.charAt(6) == 'B'){
|
||
|
nir = nir.replace('B', '0');
|
||
|
minus = 2000000;
|
||
|
}
|
||
|
nir = parseInt(nir, 10);
|
||
|
nir = nir - minus;
|
||
|
var key = 97 - (nir % 97);
|
||
|
if (isNaN(key)) {
|
||
|
$('p#nir-key span').text('NIR invalide');
|
||
|
} else {
|
||
Also available in: Unified diff
dossiers/js: fix NIR key computation for corsica.