fix: extracting logic gates to constants

This commit is contained in:
Vicent Llopis 2021-11-22 13:44:22 +01:00
parent 8f2e29787b
commit 709a300388
2 changed files with 4 additions and 2 deletions

View File

@ -138,7 +138,8 @@ module.exports = Self => {
function hasIban(err, done) { function hasIban(err, done) {
Self.app.models.PayMethod.findById(this.payMethodFk, (_, instance) => { Self.app.models.PayMethod.findById(this.payMethodFk, (_, instance) => {
if (instance && instance.isIbanRequiredForClients && !this.iban) const isMissingIban = instance && instance.isIbanRequiredForClients && !this.iban;
if (isMissingIban)
err(); err();
done(); done();
}); });

View File

@ -79,8 +79,9 @@ module.exports = Self => {
const payMethod = await Self.app.models.PayMethod.findById(this.payMethodFk); const payMethod = await Self.app.models.PayMethod.findById(this.payMethodFk);
const supplierAccount = await Self.app.models.SupplierAccount.findOne({where: {supplierFk: this.id}}); const supplierAccount = await Self.app.models.SupplierAccount.findOne({where: {supplierFk: this.id}});
const hasIban = supplierAccount && supplierAccount.iban; const hasIban = supplierAccount && supplierAccount.iban;
const isMissingIban = payMethod && payMethod.isIbanRequiredForSuppliers && !hasIban;
if (payMethod && payMethod.isIbanRequiredForSuppliers && !hasIban) if (isMissingIban)
err(); err();
done(); done();