2455 - Validate socialname when isDataChecked is changed #395

Merged
carlosjr merged 3 commits from 2455-socialname_validation into dev 2020-10-05 07:24:12 +00:00
1 changed files with 9 additions and 3 deletions

View File

@ -186,10 +186,16 @@ module.exports = Self => {
let payMethodWithIban = 4; let payMethodWithIban = 4;
// Validate socialName format // Validate socialName format
const socialNameChanged = orgData && changes const hasChanges = orgData && changes;
&& orgData.socialName != changes.socialName; 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'); throw new UserError('The socialName has an invalid format');
if (changes.salesPerson === null) { if (changes.salesPerson === null) {