From 79f6ac6b767eec6c1fb5c0cc53385c9d3eb1d546 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 12 Jul 2024 11:41:31 +0200 Subject: [PATCH] hotfix fix createWorker business --- modules/client/front/postcode/index.html | 2 +- modules/worker/back/methods/worker/new.js | 2 +- modules/worker/back/models/worker.js | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/client/front/postcode/index.html b/modules/client/front/postcode/index.html index b3dbb74d8..fa0b7870f 100644 --- a/modules/client/front/postcode/index.html +++ b/modules/client/front/postcode/index.html @@ -53,7 +53,7 @@ diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index ba9dc3853..fddabcf43 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -202,7 +202,7 @@ module.exports = Self => { bossFk, fi, birth, - + provinceFk, }, myOptions); if (tx) await tx.commit(); diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index 0b0e043f2..3507cab8a 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -27,13 +27,17 @@ module.exports = Self => { }); async function tinIsValid(err, done) { + const countryFk = { + fields: ['countryFk'], + where: {id: this.provinceFk} + }; + const countryCode = await Self.app.models.Province.findOne(countryFk); const filter = { fields: ['code'], - where: {id: this.countryFk} + where: {id: countryCode.countryFk} }; const country = await Self.app.models.Country.findOne(filter); const code = country ? country.code.toLowerCase() : null; - if (!this.fi || !validateTin(this.fi, code)) err(); done();