#222 - DNI validation bug solved

This commit is contained in:
Juan 2018-04-03 16:54:41 +02:00
parent ffde937022
commit fd324df1c9
2 changed files with 4 additions and 3 deletions

View File

@ -7,5 +7,6 @@
"El método de pago seleccionado requiere que se especifique el IBAN": "El método de pago seleccionado requiere que se especifique el IBAN",
"Ya existe un usuario con ese nombre": "Ya existe un usuario con ese nombre",
"Quantity cannot be zero": "Quantity cannot be zero",
"can't be blank": "can't be blank"
"can't be blank": "can't be blank",
"DNI Incorrecto": "DNI Incorrecto"
}

View File

@ -37,8 +37,8 @@ module.exports = function(tin, country) {
let sum = (pairSum + oddSum).toString();
let units = parseInt(sum.charAt(sum.length - 1));
let control = units == 0 ? 0 : 10 - units;
let index = 'JABCDEFGHI'.indexOf(lastDigit);
computedDigit = index == -1 ? control.toString() : index;
let isLetter = /^[A-Z]$/.test(lastDigit);
computedDigit = isLetter ? 'JABCDEFGHI'.charAt(control) : control.toString();
} else {
// Foreign NIF
let index = 'XYZ'.indexOf(tin.charAt(0));