From d1c7dea218caeb4d3c7ca62e268320a6244239de Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 23 Dec 2021 08:09:48 +0100 Subject: [PATCH] fix(supplier_account): get countryFk in model.js --- modules/supplier/back/models/supplier-account.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/supplier/back/models/supplier-account.js b/modules/supplier/back/models/supplier-account.js index 2eecab8b3..c8b2f0595 100644 --- a/modules/supplier/back/models/supplier-account.js +++ b/modules/supplier/back/models/supplier-account.js @@ -7,12 +7,14 @@ module.exports = Self => { }); async function ibanValidation(err, done) { - let filter = { + const supplier = await Self.app.models.Supplier.findById(this.supplierFk); + const filter = { fields: ['code'], - where: {id: this.countryFk} + where: {id: supplier.countryFk} }; - let country = await Self.app.models.Country.findOne(filter); - let code = country ? country.code.toLowerCase() : null; + + const country = await Self.app.models.Country.findOne(filter); + const code = country ? country.code.toLowerCase() : null; if (code != 'es') return done();