From eb54ae1d22eae1e22814dfad87ddbca76c7bb147 Mon Sep 17 00:00:00 2001 From: Faustin Date: Fri, 28 Oct 2022 17:41:09 +0200 Subject: [PATCH] Added checking when thirdparty is created/updated --- htdocs/societe/class/societe.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c01f83401cf..d0012e78e3a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1171,7 +1171,7 @@ class Societe extends CommonObject } // Check for duplicate or mandatory fields defined into setup - $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'TVA_INTRA'); foreach ($array_to_check as $key) { $keymin = strtolower($key); $i = (int) preg_replace('/[^0-9]/', '', $key); @@ -1216,6 +1216,14 @@ class Societe extends CommonObject $error++; $this->errors[] = $langs->trans('Email')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; } } + } elseif ($key == 'TVA_INTRA') { + // Check for unicity + if ($vallabel && !empty($conf->global->SOCIETE_VAT_INTRA_UNIQUE)) { + if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { + $langs->load("errors"); + $error++; $this->errors[] = $langs->trans('VATIntra')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; + } + } } } }