From c77715d865713bcc8aa77692e1813397b60738cf Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 26 Dec 2023 15:03:10 +0100 Subject: [PATCH] refs #6291 validation original --- db/dump/fixtures.sql | 2 +- modules/worker/back/models/worker.js | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index a63a7d314..2b339e191 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -3014,7 +3014,7 @@ UPDATE `vn`.`client` SET fi='65004204V' WHERE id=1; -UPDATE `vn`.`client` +UPDATE `vn`.`worker` SET fi='59328808D' WHERE id=1106; diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index 841b610ea..712f2b09d 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -34,17 +34,12 @@ module.exports = Self => { fields: ['code'], where: {id: this.countryFk} }; - const country = await Self.app.models.Country.findOne(filter); const code = country ? country.code.toLowerCase() : null; - const client = (await Self.findById(this.id, { - include: {relation: 'client'}}))?.client(); - if (client) { - const countryCode = client.fi?.toLowerCase().substring(0, 2); + const countryCode = this.fi?.toLowerCase().substring(0, 2); - if (!client.fi || !validateTin(client.fi, code) || countryCode == code) - err(); - } + if (!this.fi || !validateTin(this.fi, code) || countryCode == code) + err(); done(); } };