refs #5540 arreglo en supplier
This commit is contained in:
parent
38142c121d
commit
c0deb745d6
|
@ -24,18 +24,18 @@ module.exports = Self => {
|
|||
message: 'TIN must be unique'
|
||||
});
|
||||
|
||||
// async function fiInvalid(err, done) {
|
||||
// const filter = {
|
||||
// fields: ['code'],
|
||||
// where: {id: this.countryFk}
|
||||
// };
|
||||
// const countryCode = this.fi.toUpperCase().substring(0, 2);
|
||||
// const country = await Self.app.models.Country.findOne(filter);
|
||||
// const code = country ? country.code : null;
|
||||
// if (this.isVies && countryCode == code)
|
||||
// err();
|
||||
// done();
|
||||
// }
|
||||
async function fiInvalid(err, done) {
|
||||
const filter = {
|
||||
fields: ['code'],
|
||||
where: {id: this.countryFk}
|
||||
};
|
||||
const countryCode = this.fi.toUpperCase().substring(0, 2);
|
||||
const country = await Self.app.models.Country.findOne(filter);
|
||||
const code = country ? country.code : null;
|
||||
if (this.isVies && countryCode == code)
|
||||
err();
|
||||
done();
|
||||
}
|
||||
|
||||
Self.validatesFormatOf('email', {
|
||||
message: 'Invalid email',
|
||||
|
|
|
@ -32,10 +32,6 @@ module.exports = Self => {
|
|||
message: 'TIN must be unique'
|
||||
});
|
||||
|
||||
Self.validateAsync('nif', nifInvalid, {
|
||||
message: 'Invalid NIF for VIES'
|
||||
});
|
||||
|
||||
Self.validateAsync('nif', tinIsValid, {
|
||||
message: 'Invalid TIN'
|
||||
});
|
||||
|
@ -71,22 +67,9 @@ module.exports = Self => {
|
|||
};
|
||||
const country = await Self.app.models.Country.findOne(filter);
|
||||
const code = country ? country.code.toLowerCase() : null;
|
||||
const countryCode = this.nif.toLowerCase().substring(0, 2);
|
||||
|
||||
if (!this.nif || !validateTin(this.nif, code))
|
||||
err();
|
||||
done();
|
||||
}
|
||||
|
||||
Self.validateAsync('nif', nifInvalid);
|
||||
async function nifInvalid(err, done) {
|
||||
const filter = {
|
||||
fields: ['code'],
|
||||
where: {id: this.countryFk}
|
||||
};
|
||||
const countryCode = this.nif.toUpperCase().substring(0, 2);
|
||||
const country = await Self.app.models.Country.findOne(filter);
|
||||
const code = country ? country.code : null;
|
||||
if (this.isVies && countryCode == code)
|
||||
if (!this.nif || !validateTin(this.nif, code) || (this.isVies && countryCode == code))
|
||||
err();
|
||||
done();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue