diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 636e32ffa..36bc60dfa 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 hasChanges = orgData && changes; + const socialName = changes.socialName || orgData.socialName; + const isTaxDataChecked = hasChanges && (changes.isTaxDataChecked || orgData.isTaxDataChecked); - 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) {