From 503e1d0ed915fbafa536470e0632717db81b33ea Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 30 Sep 2020 09:31:01 +0200 Subject: [PATCH 1/2] 2455 - Validate socialname when isDataChecked is changed --- modules/client/back/models/client.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 636e32ffa..afdb011ee 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -186,10 +186,16 @@ module.exports = Self => { let payMethodWithIban = 4; // Validate socialName format - const socialNameChanged = orgData && changes - && orgData.socialName != changes.socialName; + const socialName = changes.socialName || orgData.socialName; + const isTaxDataChecked = changes.isTaxDataChecked || orgData.isTaxDataChecked; + const hasChanges = orgData && changes; - if (socialNameChanged && !isAlpha(changes.socialName)) + const socialNameChanged = hasChanges + && orgData.socialName != socialName; + const dataCheckedChanged = hasChanges + && orgData.isTaxDataChecked != isTaxDataChecked; + + if ((socialNameChanged || dataCheckedChanged) && !isAlpha(socialName)) throw new UserError('The socialName has an invalid format'); if (changes.salesPerson === null) { -- 2.40.1 From 9423216616159b6256b11652ae84dd841d49b529 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 30 Sep 2020 11:19:52 +0200 Subject: [PATCH 2/2] Fix --- modules/client/back/models/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index afdb011ee..36bc60dfa 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -186,9 +186,9 @@ module.exports = Self => { let payMethodWithIban = 4; // Validate socialName format - const socialName = changes.socialName || orgData.socialName; - const isTaxDataChecked = changes.isTaxDataChecked || orgData.isTaxDataChecked; const hasChanges = orgData && changes; + const socialName = changes.socialName || orgData.socialName; + const isTaxDataChecked = hasChanges && (changes.isTaxDataChecked || orgData.isTaxDataChecked); const socialNameChanged = hasChanges && orgData.socialName != socialName; -- 2.40.1