refs #6143 refactor: ibanValidation with countryCode param
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
5690d9bd72
commit
4657bf4e43
|
@ -1,6 +1,7 @@
|
|||
module.exports = function(iban) {
|
||||
module.exports = function(iban, countryCode) {
|
||||
if (iban == null) return true;
|
||||
if (typeof iban != 'string') return false;
|
||||
if (countryCode?.toLowerCase() != 'es') return true;
|
||||
|
||||
iban = iban.toUpperCase();
|
||||
iban = trim(iban);
|
||||
|
|
|
@ -90,16 +90,14 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
async function ibanNeedsValidation(err, done) {
|
||||
const bankEntity = await Self.app.models.BankEntity.findById(this.bankEntityFk);
|
||||
const filter = {
|
||||
fields: ['code'],
|
||||
where: {id: this.countryFk}
|
||||
where: {id: bankEntity.countryFk}
|
||||
};
|
||||
const country = await Self.app.models.Country.findOne(filter);
|
||||
const code = country ? country.code.toLowerCase() : null;
|
||||
if (code != 'es')
|
||||
return done();
|
||||
|
||||
if (!validateIban(this.iban))
|
||||
if (!validateIban(this.iban, country?.code))
|
||||
err();
|
||||
done();
|
||||
}
|
||||
|
|
|
@ -7,18 +7,15 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
async function ibanValidation(err, done) {
|
||||
const supplier = await Self.app.models.Supplier.findById(this.supplierFk);
|
||||
const bankEntity = await Self.app.models.BankEntity.findById(this.bankEntityFk);
|
||||
const filter = {
|
||||
fields: ['code'],
|
||||
where: {id: supplier.countryFk}
|
||||
where: {id: bankEntity.countryFk}
|
||||
};
|
||||
|
||||
const country = await Self.app.models.Country.findOne(filter);
|
||||
const code = country ? country.code.toLowerCase() : null;
|
||||
if (code != 'es')
|
||||
return done();
|
||||
|
||||
if (!validateIban(this.iban))
|
||||
if (!validateIban(this.iban, country?.code))
|
||||
err();
|
||||
done();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue